[Implemented] More Scintilla IDE shortcuts

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
kenmo
Addict
Addict
Posts: 1967
Joined: Tue Dec 23, 2003 3:54 am

[Implemented] More Scintilla IDE shortcuts

Post by kenmo »

Scintilla has a lot of useful shortcuts, such as Ctrl+D for Duplicate which the PB IDE supports but does not list in the Shortcuts preferences.

Now that Scintilla has been updated in PB recently, I would like to see a few more shortcuts supported that I like to use in other editors such as Notepad++:

- Move Selection Up (SCI_MOVESELECTEDLINESUP) Ctrl+Shift+Up
- Move Selection Down (SCI_MOVESELECTEDLINESDOWN) Ctrl+Shift+Down
- Delete Lines (SCI_LINEDELETE) maybe Ctrl+L although this key combo is set to "Recent Line" by default
- Find Previous (SCI_SEARCHPREV) Shift+F3 to complement the already-supported F3 Find Next

There may be other useful ones too.
Last edited by kenmo on Mon Feb 10, 2020 3:21 pm, edited 1 time in total.
User avatar
skywalk
Addict
Addict
Posts: 3972
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: More Scintilla IDE shortcuts

Post by skywalk »

The following code crashes my v5 IDE :(
IDE wrote: An error has been detected in the IDE!
Error: Invalid memory access

IDE build on 11/05/2012 [16:05] by Fred
Branch: v4.70 Revision: 1361

Code: Select all

; Compile & assign ct_sci_kybd_FindPrev.exe --> Shorcut = [Shift+F3]
; This becomes the opposite of Find Forward via Shorcut = [F3]
Define.i ri, hSci = Val(GetEnvironmentVariable("PB_TOOL_Scintilla"))
If hSci
  SendMessageTimeout_(hSci,#SCI_SEARCHPREV,0,0,#SMTO_ABORTIFHUNG,2000,@ri)
EndIf
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
kenmo
Addict
Addict
Posts: 1967
Joined: Tue Dec 23, 2003 3:54 am

Re: [Implemented] More Scintilla IDE shortcuts

Post by kenmo »

Marking my own post from 2012 as Implemented :)

Find Previous was added in PB 5.60

Move Lines Up/Down, and Delete Line, merged in Pull Request #54 for upcoming 5.72
https://github.com/fantaisie-software/purebasic/pull/54
User avatar
skywalk
Addict
Addict
Posts: 3972
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: [Implemented] More Scintilla IDE shortcuts

Post by skywalk »

Good deal.
Since [Crtl+D] = duplicate line, please enable or allow user hotkey choice for [Ctrl+Shift+D] = delete line.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
kenmo
Addict
Addict
Posts: 1967
Joined: Tue Dec 23, 2003 3:54 am

Re: [Implemented] More Scintilla IDE shortcuts

Post by kenmo »

They will be user configurable (assuming they make it into 5.72 Final)

I kept Ctrl+D as the default for Duplicate, but did not assign a default to Delete Line(s).

Ctrl+Shift+D is not currently used for anything..... but I think Fred and Timo get the final decision on default mappings.
User avatar
oreopa
Enthusiast
Enthusiast
Posts: 281
Joined: Sat Jun 24, 2006 3:29 am
Location: Edinburgh, Scotland.

Re: [Implemented] More Scintilla IDE shortcuts

Post by oreopa »

I don't know if this is in your remit - I'm not sure if Scintilla has this functionality built in, but...

1. Selection to uppercase
2. Selection to lowercase
3. Invert case of selection

...would be nice.

I have this already as a self built tool, but it would be nicer native.
Proud supporter of PB! * Musician * C64/6502 Freak
User avatar
kenmo
Addict
Addict
Posts: 1967
Joined: Tue Dec 23, 2003 3:54 am

Re: [Implemented] More Scintilla IDE shortcuts

Post by kenmo »

Scintilla has built-in UPPERCASE and LOWERCASE function:

Code: Select all

If OpenWindow(0, 0, 0, 330, 90, "ScintillaGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  If InitScintilla()
    ScintillaGadget(0, 10, 10, 320, 70, 0)
    
    *Text=UTF8("Hello World")
    ScintillaSendMessage(0, #SCI_SETTEXT, 0, *Text)
    FreeMemory(*Text)
    
    ScintillaSendMessage(0, #SCI_SETSEL, 0, 5)
    ScintillaSendMessage(0, #SCI_UPPERCASE)
    ScintillaSendMessage(0, #SCI_SETSEL, 6, 11)
    ScintillaSendMessage(0, #SCI_LOWERCASE)
    ScintillaSendMessage(0, #SCI_SETSEL, 0, 0)
    
    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf
EndIf
For invert case, you mean "Hello" --> "hELLO" ? That would be easy too:

Code: Select all

Procedure.s InvertCase(Text.s)
  Protected *C.CHARACTER = @Text
  While (*C\c)
    If (*C\c = Asc(LCase(Chr(*C\c))))
      *C\c = Asc(UCase(Chr(*C\c)))
    Else
      *C\c = Asc(LCase(Chr(*C\c)))
    EndIf
    *C + SizeOf(CHARACTER)
  Wend
  ProcedureReturn Text
EndProcedure

Debug InvertCase("123 Hello!")
Debug InvertCase(InvertCase("123 Hello!"))
User avatar
skywalk
Addict
Addict
Posts: 3972
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: [Implemented] More Scintilla IDE shortcuts

Post by skywalk »

Nice, where do we submit our IDE tool code to be converted to Native IDE?
Here on the forum or in the github?
I have several other functions I use.
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
oreopa
Enthusiast
Enthusiast
Posts: 281
Joined: Sat Jun 24, 2006 3:29 am
Location: Edinburgh, Scotland.

Re: [Implemented] More Scintilla IDE shortcuts

Post by oreopa »

kenmo wrote:Scintilla has built-in UPPERCASE and LOWERCASE function...
Actually I don't believe I forgot that, because its those functions I use in my usertool :)))
kenmo wrote:For invert case, you mean "Hello" --> "hELLO" ?
Exactly.

Anyway, IDE native would be great if possible ;)
Proud supporter of PB! * Musician * C64/6502 Freak
User avatar
kenmo
Addict
Addict
Posts: 1967
Joined: Tue Dec 23, 2003 3:54 am

Re: [Implemented] More Scintilla IDE shortcuts

Post by kenmo »

I think you can request IDE features on the forum or GitHub... I started a GitHub topic for new shortcuts / menu actions...
https://github.com/fantaisie-software/p ... /issues/46

I can't guarantee they'll get done... right now I'm converting my own IDE tools to native features... and starting with the easier ones like Scintilla shortcuts.

You are also free to download the IDE project and experiment yourself (it's fun and good practice!) :)


Funny, about UPPERCASE and LOWERCASE, I just tried them in the IDE thinking it would be simple.

It works on variables, comments, etc.
But because of the IDE's Very Aggressive CaseCorrection, it does not change keywords or built-in functions.

Case Correction is currently built into the highlighting, not just typing events.

So it goes UPPERCASE action --> rehighlight --> case correct --> instantly back to regular case!
User avatar
skywalk
Addict
Addict
Posts: 3972
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: [Implemented] More Scintilla IDE shortcuts

Post by skywalk »

Unfortunately, no time to load and review the IDE flow.
These are some of my goto tools.
I can PM you the source code if you think they are worthy of adding to the repo?
FINDDEF - is still a work in progress.

Code: Select all

; ToolName                Arguments               Shortcut          Description
; ----------------------  ----------------------  ----------------- -----------------------------------------------------------
; CLOSE_EXTRA_PB_WINDOWS  CLOSE_EXTRA_PB_WINDOWS  [Ctrl+0]          Close extra windows like debug,help,variable,etc.
; INDENTALL               INDENTALL               [Ctrl+Shift+i]    Select All characters, then trigger indent function.
; PASTECOMMENT            PASTECOMMENT            [Ctrl+Shift+v]    Paste text as comment to avoid syntax changes.
; COPYALL                 COPYALL                 [Ctrl+Shift+k]    Select All characters, then copy to clipboard.
; UCASE                   UCASE                   [Ctrl+u]
; LCASE                   LCASE                   [Ctrl+Shift+u]    Opposite of UCase line = [Ctrl+u]
; LINEDEL                 LINEDEL                 [Ctrl+Shift+d]    Opposite of duplicate line = [Ctrl+d]
; MVLINESUP               MVLINESUP               [Ctrl+Shift+Up]
; MVLINESDN               MVLINESDN               [Ctrl+Shift+Down]
; TRIM_LINES              NONE                    [Ctrl+t]          Trim whitespace only lines and trailing whitespace.
; ECHO                    ECHO                    [Ctrl+Shift+1]    Reports word under cursor
; HILITE                  HILITE                  [Ctrl+`]          Unhilite works by applying shortcut to white space.
; WORDCOUNT_THISLINE      WORDCOUNT_THISLINE      [Ctrl+1]          Count of specific character in current line.
; FINDDEF                 FINDDEF                 [Ctrl+2]          Jump to best guess at keyword(kw) definition/instantiation:
; GETASM-X86              GETASM-X86 %FILE        None              %FILE = full path + filename. Adds a datetime stamp to end to avoid overwrites.
; GETASM-X64              GETASM-X64 %FILE        None              %FILE = full path + filename. Adds a datetime stamp to end to avoid overwrites.
; GETENV                  GETENV                  None
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Post Reply