Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QB64 IDE Helper
#1
Forget about hotkeys, now thanks to Pete's handy dandy IDE Helper, we can use a HOT MOUSE, instead!

Folks, are you tired of typing in all those DO/LOOP, FOR/NEXT, and SELECT CASE statements? Are you tired of wishing that blankity-blank Steve would sell off some of his blankity-blank farm to provide us ALL with FREE mega-expensive multi-hot-key programmable keyboards? (Sorry, channeling that blankity-blank Clippy again). If so, here is a cheap-ascii solution for you!

Instructions:

1) Run program.
2) Left click a snippet from the list.
3) Right click in the QB64 IDE where you want the snippet placed then click the "Paste" selection in the QB64 IDE popup window.

Viola, you've got code!

Code: (Select All)
' Paste pre-made statements into the QB64 IDE.
' Use </> for page break. Place space(s) after the > symbol for empty lines between statements.
_Title "IDE Helper"
maxheight% = 50
wdth% = 30
Width wdth%, 2
_ScreenMove _DesktopWidth - wdth% * 8, 0
_Font 16
ReDim cbrd$(50), dsp$(50)
cc$ = "</>"
Do
    Read a$
    If a$ = "eof" Then Exit Do
    a1$ = a$: a2$ = a$: dsp$ = Space$(wdth%)
    cnt = cnt + 1
    q% = InStr(a$, cc$)
    Do
        q% = InStr(a1$, cc$)
        q_end% = InStr(a1$, cc$) + Len(cc$)
        If q% Then
            a1$ = Mid$(a1$, 1, q% - 1) + ": " + LTrim$(Mid$(a1$, q_end%))
        Else
            Exit Do
        End If
    Loop
    Mid$(dsp$, 2) = Mid$(a1$, 1, wdth% - 2)
    dsp$(cnt) = dsp$
    Do
        q% = InStr(a2$, cc$)
        If q% Then
            break$ = "": i% = 0
            Do
                i% = i% + 1
                break$ = break$ + Chr$(13) + Chr$(10)
            Loop Until Mid$(a2$, q% + 2 + i%, 1) <> " "
            a2$ = Mid$(a2$, 1, q% - 1) + break$ + LTrim$(Mid$(a2$, q% + Len(cc$)))
        Else
            Exit Do
        End If
    Loop
    cbrd$(cnt) = a2$ + Chr$(13) + Chr$(10)
Loop Until cnt = maxheight%
height% = cnt
Width wdth%, height%
palette_select = 0
Select Case palette_select
    Case 0
        Palette 3, 7 ' Odd rows.'62
        Palette 1, 56 ' Even rows. '20
        Palette 7, 63 ' Page background.
        Palette 6, 55 ' Odd row mouse click.
        Palette 4, 38 ' Even row mouse click
        Color 0, 7
    Case Else
        Palette 3, 62 ' Odd rows.
        Palette 1, 20 ' Even rows.
        Palette 7, 55 ' Page background.
        Palette 6, 38 ' Odd row mouse click.
        Palette 4, 36 ' Even row mouse click
        Color 0, 7
End Select
_Font 16
Cls
For i% = 1 To cnt
    If i% / 2 = i% \ 2 Then Color 15, 1 Else Color 0, 3
    Locate i%, 1: Print dsp$(i%);
Next
Do
    _Limit 30
    While _MouseInput: Wend
    x = _MouseX
    y = _MouseY
    If _MouseButton(1) Then
        _Clipboard$ = cbrd$(y)
        If y / 2 = y \ 2 Then Color 15, 4 Else Color 0, 6
        Locate y, 1: Print dsp$(y);: _Delay .1
        Locate y, 1
        If y / 2 = y \ 2 Then Color 15, 1 Else Color 0, 3
        Print dsp$(y);
    End If
Loop Until InKey$ = Chr$(27)
System

Data "_ScreenMove 0, 0"
Data "Width 180, 42"
Data + CHR$(34) + "
Data "If Then</> ELSE</> End IF"
Data "For i% = 1 to</> Next i%"
Data "Do</> Loop"
Data "While</> Wend"
Data "Select Case</> Case</> End Select"
Data "Do</>_Limit 30</>b$ = inkey$</>If Len(b$) Then</>Select Case b$</>Case Chr$(27)</>System</>Case</> Case</> End Select</>End If</>Loop"
Data "Open file$ for Input as #</> Close #"
Data "Open file$ for Output as #</> Close #"
Data "Open file$ for Binary as #</> Close #"
Data "Open dir$+ file$ for Input as #</> Close #"
Data "Open dir$+ file$ for Output as #</> Close #"
Data "Open dir$+ file$ for Binary as #</> Close #"
Data "Get #1, , a$"
Data "Put #1, , a$"
Data "While _MouseInput: Wend"
Data "x = _MouseX"
Data "y = _MouseY"
Data eof

Now if you act now, because we can't do this the whole day, you'll be able to get the one below, which allows you to easily write the code snippets into a database file with Notepad. A sample database is included. (See download below program.)

Code: (Select All)
' Paste pre-made statements into the QB64 IDE.
' Use </> for page break. Place space(s) after the > symbol for empty lines between statements.
_Title "IDE Helper"
maxheight% = 50
wdth% = 30
Width wdth%, 2
_ScreenMove _DesktopWidth - wdth% * 8, 0
_Font 16
ReDim cbrd$(50), dsp$(50)
cc$ = "</>"
file$ = "IDE-Helper.dat"
If Not _FileExists(file$) Then Print "Cannot find data file: "; file$: End
Open file$ For Binary As #1
Do
    Line Input #1, a$
    a1$ = a$: a2$ = a$: dsp$ = Space$(wdth%)
    cnt = cnt + 1
    q% = InStr(a$, cc$)
    Do
        q% = InStr(a1$, cc$)
        q_end% = InStr(a1$, cc$) + Len(cc$)
        If q% Then
            a1$ = Mid$(a1$, 1, q% - 1) + ": " + LTrim$(Mid$(a1$, q_end%))
        Else
            Exit Do
        End If
    Loop
    Mid$(dsp$, 2) = Mid$(a1$, 1, wdth% - 2)
    dsp$(cnt) = dsp$
    Do
        q% = InStr(a2$, cc$)
        If q% Then
            break$ = "": i% = 0
            Do
                i% = i% + 1
                break$ = break$ + Chr$(13) + Chr$(10)
            Loop Until Mid$(a2$, q% + 2 + i%, 1) <> " "
            a2$ = Mid$(a2$, 1, q% - 1) + break$ + LTrim$(Mid$(a2$, q% + Len(cc$)))
        Else
            Exit Do
        End If
    Loop
    cbrd$(cnt) = a2$ + Chr$(13) + Chr$(10)
Loop Until EOF(1) Or cnt = maxheight%
height% = cnt
Width wdth%, height%
palette_select = 0
Select Case palette_select
    Case 0
        Palette 3, 7 ' Odd rows.'62
        Palette 1, 56 ' Even rows. '20
        Palette 7, 63 ' Page background.
        Palette 6, 55 ' Odd row mouse click.
        Palette 4, 38 ' Even row mouse click
        Color 0, 7
    Case Else
        Palette 3, 62 ' Odd rows.
        Palette 1, 20 ' Even rows.
        Palette 7, 55 ' Page background.
        Palette 6, 38 ' Odd row mouse click.
        Palette 4, 36 ' Even row mouse click
        Color 0, 7
End Select
_Font 16
Cls
For i% = 1 To cnt
    If i% / 2 = i% \ 2 Then Color 15, 1 Else Color 0, 3
    Locate i%, 1: Print dsp$(i%);
Next
Do
    _Limit 30
    While _MouseInput: Wend
    x = _MouseX
    y = _MouseY
    If _MouseButton(1) Then
        _Clipboard$ = cbrd$(y)
        If y / 2 = y \ 2 Then Color 15, 4 Else Color 0, 6
        Locate y, 1: Print dsp$(y);: _Delay .1
        Locate y, 1
        If y / 2 = y \ 2 Then Color 15, 1 Else Color 0, 3
        Print dsp$(y);
    End If
Loop Until InKey$ = Chr$(27)
System


.7z   IDE-helper.7z (Size: 1.44 KB / Downloads: 25) Includes program and database IDE-Helper.dat file.

To add your own code snippets just write them out or paste them into the database or data statements (if using the first method posted). Now this is how the formatting works: 1) To add a line-break, use </>. To add multiple line breaks like 3, add spaces after the </> symbols...

Examples: 
DO: LOOP - Pastes as 
DO: LOOP

DO</>LOOP Pastes as:
DO
LOOP

DO</> LOOP Pastes as:
DO

LOOP

DO</>  LOOP Pastes as:
DO


LOOP

---------------------------

When you run the utility, it should open in the right upper corner of your screen. 

It only works with the mouse, no keys except Esc the quit. 

I run it so my QB64 IDE resides to the left at an adjusted width so the two windows don't overlap. That makes it easy to go to the right, copy a snippet, and get back into the IDE.

Note: It does not indent code. Let the IDE do that for you.

Note: There will by syntax errors because some areas of the code are intentionally left unfinished so you can type in your own variables, etc.

Let me know if you have any questions about use.

Pete
Reply
#2
Neat, Pete!  Works fine here in Linux.  I like the idea of having a code snippet place while in the IDE,  I added a note box for my IDE just for that, but had to seach/find/copy code to use anything.  You way makes it easier.

- Dav

Find my programs here in Dav's QB64 Corner
Reply
#3
Yea! It's about time I came up with something x-platform. Thanks for testing it on Linux!

I bet your IDE project is the type of endeavor that can make you go crazy from all the additions you can think up. I was thinking how cool it would be to have an AI feature that figures out typing Sel, at the start of a line, means to insert a full SELECT CASE BLOCK, etc. but if you keep typing, erase that block so it gets the the hell out of the way. I don't know why other AI routines don't follow that logic. Oh, and it would also be cool to have the GOSUBs or Subs an Functions appear in a popup coding window, so you could also stay focused on the calling routine. Hell, I'm going crazy just thinking these two things up. Big Grin 

Anyway, again, thanks for taking it for a spin, much appreciated!

Pete
Shoot first and shoot people who ask questions, later.
Reply




Users browsing this thread: 1 Guest(s)