- ALT+mouse selection : create rectangle selection
- CTRL+mouse selection : create multi ranges selection
- CTRL+mouse click : create additional cursor
- CTRL+D: extend current selection ** TODO **
- paste on multi selection
- cursor move in virtual space (beyond end of lines)
Code: Select all
EnableExplicit
InitScintilla()
#MENU_EXTEND_SELECTION=10
Define txt$, txtLen, marginWidth
Procedure MakeUTF8Text(text.s)
Static buffer.s
buffer=Space(StringByteLength(text, #PB_UTF8))
PokeS(@buffer, text, -1, #PB_UTF8)
ProcedureReturn @buffer
EndProcedure
Procedure ExtendScintillaSelection()
Protected mainSel, selStart, selEnd
mainSel=ScintillaSendMessage(0, #SCI_GETMAINSELECTION)
selStart=ScintillaSendMessage(0, #SCI_GETSELECTIONNSTART, mainSel)
selEnd=ScintillaSendMessage(0, #SCI_GETSELECTIONNEND, mainSel)
EndProcedure
txt$="Scintilla is a free source code editing component. It comes with "+#CR$+
"complete source code and a license that permits use in any project "+#CR$+
"or product personal or commercial. The license may be viewed here. "+#CR$+
"The source code, as well as the library documentation may be found "+#CR$+
"on the Scintilla Homepage. From the Scintilla Homepage : As well As "+#CR$+
"features found in standard text editing components, Scintilla includes "+#CR$+
"features especially useful when editing And debugging source code."+#CR$+
"These include support For syntax styling, error indicators, code "+#CR$+
"completion And call tips.The selection margin can contain markers "+#CR$+
"like those used in debuggers To indicate breakpoints and the current "+#CR$+
"line.Styling choices are more open than With many editors, allowing the"+#CR$+
" use of proportional fonts, bold And italics, multiple foreground "+#CR$+
"and background colors And multiple fonts."+#CR$
txtLen=StringByteLength(txt$, #PB_UTF8)
OpenWindow(100, 0, 0, 600, 400, "Editing with Multi cursor (like eclipse or sublimetext)", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ScintillaGadget(0, 0, 0, WindowWidth(100), WindowHeight(100), 0)
; Set Text Mode
ScintillaSendMessage(0, #SCI_SETWRAPMODE, #SC_WRAP_NONE)
ScintillaSendMessage(0, #SCI_SETCODEPAGE, #SC_CP_UTF8)
ScintillaSendMessage(0, #SCI_SETVIRTUALSPACEOPTIONS, #SCVS_RECTANGULARSELECTION | #SCVS_USERACCESSIBLE) ; allow cursor and rect selection to move beyond end of line
; Set Current Line Highlighting
ScintillaSendMessage(0, #SCI_SETCARETLINEVISIBLE, 1)
ScintillaSendMessage(0, #SCI_SETCARETLINEVISIBLEALWAYS, 1)
ScintillaSendMessage(0, #SCI_SETCARETLINEBACKALPHA, 50)
ScintillaSendMessage(0, #SCI_SETCARETLINEBACK, RGB(100, 252, 195))
; Set Text style
ScintillaSendMessage(0, #SCI_STYLESETFONT, #STYLE_DEFAULT, MakeUTF8Text("Courier New")) ; rectangle selection works better with mono-width font
ScintillaSendMessage(0, #SCI_STYLESETBACK, #STYLE_DEFAULT, RGB(70, 78, 85))
ScintillaSendMessage(0, #SCI_STYLESETFORE, #STYLE_DEFAULT, RGB(195, 213, 255))
ScintillaSendMessage(0, #SCI_STYLECLEARALL)
; Set Margin size and style
ScintillaSendMessage(0, #SCI_STYLESETFONT, #STYLE_LINENUMBER, MakeUTF8Text("Arial"))
ScintillaSendMessage(0, #SCI_STYLESETBACK, #STYLE_LINENUMBER, RGB(53, 55, 57))
ScintillaSendMessage(0, #SCI_STYLESETFORE, #STYLE_LINENUMBER, RGB(200, 200, 200))
marginWidth=ScintillaSendMessage(0, #SCI_TEXTWIDTH, #STYLE_LINENUMBER, MakeUTF8Text("_999"))
ScintillaSendMessage(0, #SCI_SETMARGINTYPEN, 0, #SC_MARGIN_NUMBER)
ScintillaSendMessage(0, #SCI_SETMARGINWIDTHN, 0, marginWidth)
marginWidth=0
ScintillaSendMessage(0, #SCI_SETMARGINMASKN, 2, #SC_MASK_FOLDERS)
ScintillaSendMessage(0, #SCI_SETMARGINWIDTHN, 2, marginWidth)
ScintillaSendMessage(0, #SCI_SETMARGINSENSITIVEN, 2, #True)
; Set Main Caret and Selection
ScintillaSendMessage(0, #SCI_SETCARETSTICKY, 1) ;make always visible
ScintillaSendMessage(0, #SCI_SETCARETWIDTH, 3) ;make thicker
ScintillaSendMessage(0, #SCI_SETCARETFORE, RGB(255, 160, 136))
ScintillaSendMessage(0, #SCI_SETSELALPHA, 100)
ScintillaSendMessage(0, #SCI_SETSELBACK, 1, RGB(255, 160, 136))
ScintillaSendMessage(0, #SCI_SETSELFORE, 1, RGB(200, 200, 200))
; Set Additional Caret and Selection
ScintillaSendMessage(0, #SCI_SETADDITIONALCARETFORE, RGB(157, 64, 41))
ScintillaSendMessage(0, #SCI_SETADDITIONALCARETSBLINK, 1)
ScintillaSendMessage(0, #SCI_SETADDITIONALSELALPHA, 100)
ScintillaSendMessage(0, #SCI_SETADDITIONALSELBACK, RGB(255, 160, 136))
ScintillaSendMessage(0, #SCI_SETADDITIONALSELFORE, RGB(200, 200, 200))
; Enable multi cursor editing
ScintillaSendMessage(0, #SCI_SETRECTANGULARSELECTIONMODIFIER, #SCMOD_ALT) ; select rectangle range by holding down the ALT key while dragging with the mouse
ScintillaSendMessage(0, #SCI_SETMULTIPLESELECTION, 1) ; select multiple ranges by holding down the CTRL or CMD key while dragging with the mouse
ScintillaSendMessage(0, #SCI_SETMULTIPASTE, #SC_MULTIPASTE_EACH)
ScintillaSendMessage(0, #SCI_SETADDITIONALSELECTIONTYPING, 1)
; Enable hotkey for selection auto extension CTRL + D
AddKeyboardShortcut(100, #PB_Shortcut_Control | #PB_Shortcut_D, #MENU_EXTEND_SELECTION)
BindEvent(#PB_Event_Menu, ExtendScintillaSelection())
; Change text
ScintillaSendMessage(0, #SCI_SETTEXT, 0, MakeUTF8Text(txt$))
ScintillaSendMessage(0, #SCI_GOTOPOS, txtLen)
SetActiveGadget(0)
Repeat: Until WaitWindowEvent()=#PB_Event_CloseWindow