Platforms to show: All Mac Windows Linux Cross-Platform

/Scintilla/ScintillaTest


Required plugins for this example: MBS Scintilla Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Scintilla/ScintillaTest

This example is the version from Wed, 27th Jun 2023.

Project "ScintillaTest.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
EventHandler Sub Open() Dim wM As New ScintillaWindow wM.SetupMySQL wM.Title = "Scintilla MySQL Example" Dim wH As New ScintillaWindow wH.SetupHTML wH.Title = "Scintilla HTML Example" Dim wX As New ScintillaWindow wX.SetupXojo wX.Title = "Scintilla Xojo Example" End EventHandler
Sub LoadLIbs() #If True Then // we use built-in for macOS and Windows! #ElseIf TargetMacOS Then Dim ExecutableFolder As FolderItem = app.ExecutableFile.Parent Dim ContentsFolder As FolderItem = ExecutableFolder.Parent Dim FrameworksFolder As FolderItem = ContentsFolder.Child("Frameworks") Dim libFile As FolderItem = FrameworksFolder.Child("liblexilla.dylib") If ScintillaControlMBS.LoadLibrary(libFile) Then 'MessageBox "OK" Else MessageBox "Failed to load Lexilla." End If Dim FrameworkFile As FolderItem = FrameworksFolder.Child("Scintilla.framework") If ScintillaControlMBS.LoadFramework(FrameworkFile) Then 'MessageBox "OK" Else MessageBox "Failed to load Scintilla." End If #ElseIf TargetWindows Then Const libPath = "Lexilla.dll" Dim libFile As FolderItem = New FolderItem(libPath) System.DebugLog "LibFile: "+libFile.NativePath If ScintillaControlMBS.LoadLibrary(libFile) Then 'MessageBox "OK" Else MessageBox "Failed to load Lexilla." End If Const ScintillaPath = "Scintilla.dll" Dim ScintillaFile As FolderItem = New FolderItem(ScintillaPath) System.DebugLog "ScintillaFile: "+ScintillaFile.NativePath If ScintillaControlMBS.LoadLibrary(ScintillaFile) Then 'MessageBox "OK" Else MessageBox "Failed to load Scintilla." End If #EndIf End Sub
End Class
Class ScintillaWindow Inherits Window
Const SampleHTML = "<!DOCTYPE html>\n<html>\n<head>\n\t<title>Hello World</title>\n</head>\n<body>\n\n<div test=123>\n<P>Hello World</P>\n</div>\n\n<!-- some comment -->\n\n<script>\nif (i + 5 == 6)\n{\n\talert('hello');\n}\n</script>\n\n</body>\n</html>\n"
Control ScintillaControl Inherits ScintillaControlMBS
ControlInstance ScintillaControl Inherits ScintillaControlMBS
EventHandler Sub AutoCompleteCancelled() System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub AutoCompleteCharacterDeleted() System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub AutoCompleteCompleted(Position as Integer, Character as Integer, Text as String, listCompletionMethod as Integer) System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub AutoCompleteSelection(Position as Integer, Character as Integer, Text as String, listCompletionMethod as Integer) System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub AutoCompleteSelectionChange(Position as Integer, Text as String, listType as Integer) System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub CallTipClick(Position as Integer) System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub CharacterAdded(Character as Integer, CharacterSource as Integer) System.DebugLog CurrentMethodName // new line -> let's indent the text a bit If Character = 13 Or Character = 10 Then Dim CurrentPosition As Integer = Me.Position Dim curLine As Integer = Me.LineFromPosition(CurrentPosition) Dim lineLength As Integer = Me.LineLength(curLine) If curLine > 0 And lineLength < 2 Then // beginning on a new line Dim prevLine As String = Me.Line(curLine-1) Dim Len As Integer = 0 For i As Integer = 1 To prevLine.Len Dim ch As String = prevLine.Mid(i, 1) If Asc(ch) = 9 Or Asc(ch) = 32 Then // we take that Len = i Else // start of text, so exit Exit End If Next Dim prefix As String = prevLine.Left(Len) Me.ReplaceSelection(prefix) return End If End If // no selection? If Me.SelectionEnd = Me.SelectionStart Then If Me.SelectionStart > 0 Then // already active? If Me.AutoCompleteActive Then Else StartAutoComplete End If End If End If End EventHandler
EventHandler Sub Close() System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub DWellEnd(Position as Integer, X as Integer, Y as Integer) System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub DWellStart(Position as Integer, X as Integer, Y as Integer) System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub DoubleClick(Position as Integer, line as integer, modifiers as Integer) System.DebugLog CurrentMethodName End EventHandler
EventHandler Function DragEnter(obj As DragItem, action As Integer) As Boolean System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub DragExit(obj As DragItem, action As Integer) System.DebugLog CurrentMethodName End EventHandler
EventHandler Function DragOver(x As Integer, y As Integer, obj As DragItem, action As Integer) As Boolean System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub DropObject(obj As DragItem, action As Integer) System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub FocusIn() System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub FocusOut() System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub FolderToggled(Line as Integer, Position as Integer, Margin as ScintillaMarginMBS) System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub HotSpotClick(Position as Integer, modifiers as Integer) System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub HotSpotDoubleCLick(Position as Integer, modifiers as Integer) System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub HotspotReleaseClick(Position as Integer, modifiers as Integer) System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub IndicatorClick(Position as Integer, modifiers as Integer) System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub IndicatorRelease(Position as Integer, modifiers as Integer) System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub Key(Character as Integer, modifiers as Integer) System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub MacroRecord(Message as Integer, wParam as Integer, lParam as Integer) System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub MarginClick(Position as Integer, modifiers as Integer, Margin as ScintillaMarginMBS) System.DebugLog CurrentMethodName dim line as integer = me.LineFromPosition(Position) if margin.Margin = 1 then // bookmark dim old as integer = me.MarkerGet(line) if old = 2 then // bit 2 is set for marker element 1 me.MarkerDelete(line, 1) else call me.MarkerAdd(line, 1) end if end if End EventHandler
EventHandler Sub MarginRightClick(Position as Integer, modifiers as Integer, Margin as ScintillaMarginMBS) System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub Modified(Position as Integer, modificationType as Integer, Text as String, length as Integer, linesAdded as Integer, line as Integer, foldLevelNow as Integer, foldLevelPrev as Integer, token as Integer, annotationLinesAdded as Integer) System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub ModifyAttemptReadOnly() System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub MouseEnter() System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub MouseExit() System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub MouseMove(X As Integer, Y As Integer) 'System.DebugLog CurrentMethodName End EventHandler
EventHandler Function MouseWheel(X As Integer, Y As Integer, deltaX as Integer, deltaY as Integer) As Boolean System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub NeedsShown(Position as Integer, length as Integer) System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub Open() System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub Painted() 'System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub SavePointLeft() System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub SavePointReached() System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub ScaleFactorChanged(NewFactor as double) System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub SelectionChanged(updated as Integer) System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub StyleNeeded(Position as Integer) System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub TextChanged(Position as Integer, modificationType as Integer, Text as String, length as Integer, linesAdded as Integer, line as Integer) System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub URIDropped(text as String) System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub UpdateUI(updated as Integer) System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub UserListSelection(Position as Integer, Character as Integer, Text as String, listType as Integer, listCompletionMethod as Integer) System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub Zoom() System.DebugLog CurrentMethodName End EventHandler
End Control
EventHandler Sub Open() ps = New PrinterSetup End EventHandler
Function EditFind() As Boolean ShowFind Return True End Function
Function FileLoadBigText() As Boolean // for small text, you can just assign text for control. // but the ScintillaLoaderMBS class lets you load several Megabytes of text without blocking GUI dim file as FolderItem = GetOpenFolderitem("") if file <> nil then dim loader as ScintillaLoaderMBS = ScintillaControl.CreateLoader dim b as BinaryStream = BinaryStream.Open(file) // you could do this in a thread via timer... while not b.EndOfFile dim t as string = b.Read(1000000) dim e as integer = loader.AddData(t) if e < 0 then Break MessageBox "Out of memory!" return true end if wend // finally if loader.Finished then dim LineCount as integer = ScintillaControl.LineCount // make more room for bigger line numbers if LineCount > 999999 then ScintillaControl.Margin(0).Width = 35 + 27 elseif LineCount > 99999 then ScintillaControl.Margin(0).Width = 35 + 18 elseif LineCount > 9999 then ScintillaControl.Margin(0).Width = 35 + 9 end if else MessageBox "Failed?" end if end if Return True End Function
Function FilePrint() As Boolean If TargetWindows and not Keyboard.AsyncShiftKey Then PrintWin Return True End If Print Return True End Function
Function FilePrintPreview() As Boolean PrintPreview Return True End Function
Sub AddWordsForAutoComplete(list as string) Dim words() As String = Split(list, " ") For Each word As String In words AutoCompleteWords.Append word Next End Sub
Sub Print() ps.MaximumHorizontalResolution = 150 ps.MaximumVerticalResolution = 150 Dim g As Graphics = ps.ShowPrinterDialog If g <> Nil Then System.DebugLog "graphics "+g.Width.ToString+" x "+g.Height.ToString System.DebugLog "paper "+ps.PageWidth.ToString+" x "+ps.PageHeight.ToString Dim f As New ScintillaRangeToFormatMBS f.PageLeft = ps.PageLeft f.PageTop = ps.PageTop f.PageWidth = ps.PageWidth f.PageHeight = ps.PageHeight f.AreaLeft = 0 f.AreaTop = 0 f.AreaRight = g.Width f.AreaBottom = g.Height Dim Page As Integer = 0 Dim Len As Integer = ScintillaControl.Length Dim pos As Integer While pos < Len If page > 0 Then g.NextPage End If #If TargetCocoa Then f.PrinterHandle = Integer(g.Handle(Graphics.HandleTypes.CGContextRef)) #ElseIf TargetWindows Then // draws 2x in 1x graphics context f.PrinterHandle = Integer(g.Handle(Graphics.HandleTypes.HDC)) #ElseIf TargetLinux Then f.PrinterHandle = Integer(g.Handle(Graphics.HandleTypes.CairoContext)) #Else #Pragma Error "not implemented" #EndIf f.CharacterRangePosition = pos f.CharacterRangeEnd = Len Dim CharsOutput As Integer = ScintillaControl.FormatRange(True, f) System.DebugLog "CharsOutput: " + CharsOutput.ToString page = page + 1 pos = CharsOutput If page = 10 Then Exit // 10 page is enough to test here Wend // print finished g = Nil End If End Sub
Sub PrintPreview() Dim f As New ScintillaRangeToFormatMBS f.PageLeft = 0 f.PageTop = 0 f.PageWidth = 600 f.PageHeight = 800 #If TargetWindows Then // on windows, Scintilla draws at HiDPI Dim scale As Double = Screen(0).ScaleFactor f.PageWidth = f.PageWidth * scale f.PageHeight = f.PageHeight * scale #EndIf f.AreaLeft = 20 f.AreaTop = 20 f.AreaRight = f.PageWidth - 20 f.AreaBottom = f.PageHeight - 20 Dim Page As Integer = 0 Dim Len As Integer = ScintillaControl.Length Dim pos As Integer While pos < Len #If TargetCocoa Then // creates 2x bitmap Dim p As Picture = BitmapForCaching(f.PageWidth, f.PageHeight) Dim g As Graphics = p.Graphics Dim CGContextHandle As Integer = Integer(g.Handle(Graphics.HandleTypes.CGContextRef)) f.PrinterHandle = CGContextHandle #ElseIf TargetWindows Then Dim p As New Picture(f.PageWidth, f.PageHeight, 32) Dim g As Graphics = p.Graphics f.PrinterHandle = Integer(g.Handle(Graphics.HandleTypes.HDC)) #ElseIf TargetLinux Then Dim p As New Picture(f.PageWidth, f.PageHeight, 32) Dim g As Graphics = p.Graphics f.PrinterHandle = Integer(g.Handle(Graphics.HandleTypes.CairoContext)) #Else #Pragma Error "not implemented" #EndIf f.CharacterRangePosition = pos f.CharacterRangeEnd = Len Dim CharsOutput As Integer = ScintillaControl.FormatRange(True, f) System.DebugLog "CharsOutput: " + CharsOutput.ToString page = page + 1 Dim pw As New PrintPreviewWindow pw.pic = p pw.Title = "Preview Page "+Str(page) pos = CharsOutput If page = 10 Then Exit // 10 page is enough to test here Wend End Sub
Sub PrintWin() // workaround version where we draw to picture first! // because Scintilla draws 2x into the printer context ps.MaximumHorizontalResolution = 150 ps.MaximumVerticalResolution = 150 Dim g As Graphics = ps.ShowPrinterDialog If g <> Nil Then System.DebugLog "graphics "+g.Width.ToString+" x "+g.Height.ToString System.DebugLog "paper "+ps.PageWidth.ToString+" x "+ps.PageHeight.ToString Dim f As New ScintillaRangeToFormatMBS f.PageTop = ps.PageTop f.PageLeft = ps.PageLeft f.PageWidth = ps.PageWidth f.PageHeight = ps.PageHeight f.AreaLeft = 0 f.AreaTop = 0 f.AreaRight = g.Width f.AreaBottom = g.Height // we make a temp picture Dim p As New Picture(g.Width, g.Height, 32) Dim pg As Graphics = p.Graphics Dim Page As Integer = 0 Dim Len As Integer = ScintillaControl.Length Dim pos As Integer While pos < Len If page > 0 Then g.NextPage End If pg.ClearRect(0, 0, pg.Width, pg.Height) f.PrinterHandle = Integer(pg.Handle(Graphics.HandleTypes.HDC)) f.CharacterRangePosition = pos f.CharacterRangeEnd = Len Dim CharsOutput As Integer = ScintillaControl.FormatRange(True, f) System.DebugLog "CharsOutput: " + CharsOutput.ToString // draw to fit page g.DrawPicture p, 0, 0, g.Width, g.Height, 0, 0, p.Width, p.Height page = page + 1 pos = CharsOutput If page = 10 Then Exit // 10 page is enough to test here Wend // print finished g = Nil End If End Sub
Sub SetupHTML() dim c as ScintillaControlMBS = me.ScintillaControl c.InitializeLexer "hypertext" // HTML lexer does hypertext, xml and phpscript // a ton of styles for html, JavaScript, VBScript, phyton and php // we adapt styles from html.properties // https://fossies.org/linux/gscite/html.properties // https://searchcode.com/file/77957307/lexers/LexHTML.cxx/ Const SCE_H_DEFAULT = 0 // default Text Const SCE_H_TAG = 1 // tag Tags Const SCE_H_ERRORTAGUNKNOWN = 2 // error tag Unknown Tags Const SCE_H_ATTRIBUTE = 3 // attribute Attributes Const SCE_H_ATTRIBUTEUNKNOWN = 4 // error attribute Unknown Attributes Const SCE_H_NUMBER = 5 // literal numeric Numbers Const SCE_H_DOUBLESTRING = 6 // literal string Double quoted strings Const SCE_H_SINGLESTRING = 7 // literal string Single quoted strings Const SCE_H_OTHER = 8 // tag operator Other inside tag, including space and '=' Const SCE_H_COMMENT = 9 // comment Comment Const SCE_H_ENTITY = 10 // literal Entities Const SCE_H_TAGEND = 11 // tag XML style tag ends '/>' Const SCE_H_XMLSTART = 12 // identifier XML identifier start '<?' Const SCE_H_XMLEND = 13 // identifier XML identifier end '?>' Const SCE_H_SCRIPT = 14 // error Internal state which should never be visible Const SCE_H_ASP = 15 // preprocessor ASP <% ... %> Const SCE_H_ASPAT = 16 // preprocessor ASP <% ... %> Const SCE_H_CDATA = 17 // literal CDATA Const SCE_H_QUESTION = 18 // preprocessor PHP Const SCE_H_VALUE = 19 // literal string Unquoted values Const SCE_H_XCCOMMENT = 20 // comment JSP Comment <%-- ... --%> Const SCE_H_SGML_DEFAULT = 21 // default SGML tags <! ... > Const SCE_H_SGML_COMMAND = 22 // preprocessor SGML command Const SCE_H_SGML_1ST_PARAM = 23 // preprocessor SGML 1st param Const SCE_H_SGML_DOUBLESTRING = 24 // literal string SGML double string Const SCE_H_SGML_SIMPLESTRING = 25 // literal string SGML single string Const SCE_H_SGML_ERROR = 26 // error SGML error Const SCE_H_SGML_SPECIAL = 27 // literal SGML special (#XXXX type) Const SCE_H_SGML_ENTITY = 28 // literal SGML entity Const SCE_H_SGML_COMMENT = 29 // comment SGML comment Const SCE_H_SGML_1ST_PARAM_COMMENT = 30 // error comment SGML first parameter - lexer internal. It is an error if any text is in this style. Const SCE_H_SGML_BLOCK_DEFAULT = 31 // default SGML block Const SCE_HJ_START = 40 // client javascript default JS Start - allows eol filled background to not start on same line as SCRIPT tag Const SCE_HJ_DEFAULT = 41 // client javascript default JS Default Const SCE_HJ_COMMENT = 42 // client javascript comment JS Comment Const SCE_HJ_COMMENTLINE = 43 // client javascript comment line JS Line Comment Const SCE_HJ_COMMENTDOC = 44 // client javascript comment documentation JS Doc comment Const SCE_HJ_NUMBER = 45 // client javascript literal numeric JS Number Const SCE_HJ_WORD = 46 // client javascript identifier JS Word Const SCE_HJ_KEYWORD = 47 // client javascript keyword JS Keyword Const SCE_HJ_DOUBLESTRING = 48 // client javascript literal string JS Double quoted string Const SCE_HJ_SINGLESTRING = 49 // client javascript literal string JS Single quoted string Const SCE_HJ_SYMBOLS = 50 // client javascript operator JS Symbols Const SCE_HJ_STRINGEOL = 51 // client javascript error literal string JavaScript EOL Const SCE_HJ_REGEX = 52 // JavaScript RegEx Const SCE_HJA_START = 55 // server javascript default JS Start - allows eol filled background to not start on same line as SCRIPT tag Const SCE_HJA_DEFAULT = 56 // server javascript default JS Default Const SCE_HJA_COMMENT = 57 // server javascript comment JS Comment Const SCE_HJA_COMMENTLINE = 58 // server javascript comment line JS Line Comment Const SCE_HJA_COMMENTDOC = 59 // server javascript comment documentation JS Doc comment Const SCE_HJA_NUMBER = 60 // server javascript literal numeric JS Number Const SCE_HJA_WORD = 61 // server javascript identifier JS Word Const SCE_HJA_KEYWORD = 62 // server javascript keyword JS Keyword Const SCE_HJA_DOUBLESTRING = 63 // server javascript literal string JS Double quoted string Const SCE_HJA_SINGLESTRING = 64 // server javascript literal string JS Single quoted string Const SCE_HJA_SYMBOLS = 65 // server javascript operator JS Symbols Const SCE_HJA_STRINGEOL = 66 // server javascript error literal string JavaScript EOL Const SCE_HJA_REGEX = 67 // server javascript literal regex JavaScript RegEx Const SCE_HB_START = 70 // client basic default Start Const SCE_HB_DEFAULT = 71 // client basic default Default Const SCE_HB_COMMENTLINE = 72 // client basic comment line Comment Const SCE_HB_NUMBER = 73 // client basic literal numeric Number Const SCE_HB_WORD = 74 // client basic keyword KeyWord Const SCE_HB_STRING = 75 // client basic literal string String Const SCE_HB_IDENTIFIER = 76 // client basic identifier Identifier Const SCE_HB_STRINGEOL = 77 // client basic literal string Unterminated string Const SCE_HBA_START = 80 // server basic default Start Const SCE_HBA_DEFAULT = 81 // server basic default Default Const SCE_HBA_COMMENTLINE = 82 // server basic comment line Comment Const SCE_HBA_NUMBER = 83 // server basic literal numeric Number Const SCE_HBA_WORD = 84 // server basic keyword KeyWord Const SCE_HBA_STRING = 85 // server basic literal string String Const SCE_HBA_IDENTIFIER = 86 // server basic identifier Identifier Const SCE_HBA_STRINGEOL = 87 // server basic literal string Unterminated string Const SCE_HP_START = 90 // client python default Embedded Python Const SCE_HP_DEFAULT = 91 // client python default Embedded Python Const SCE_HP_COMMENTLINE = 92 // client python comment line Comment Const SCE_HP_NUMBER = 93 // client python literal numeric Number Const SCE_HP_STRING = 94 // client python literal string String Const SCE_HP_CHARACTER = 95 // client python literal string character Single quoted string Const SCE_HP_WORD = 96 // client python keyword Keyword Const SCE_HP_TRIPLE = 97 // client python literal string Triple quotes Const SCE_HP_TRIPLEDOUBLE = 98 // client python literal string Triple double quotes Const SCE_HP_CLASSNAME = 99 // client python identifier Class name definition Const SCE_HP_DEFNAME = 100 // client python identifier Function or method name definition Const SCE_HP_OPERATOR = 101 // client python operator Operators Const SCE_HP_IDENTIFIER = 102 // client python identifier Identifiers Const SCE_HPHP_COMPLEX_VARIABLE = 104 // server php identifier PHP complex variable Const SCE_HPA_START = 105 // server python default ASP Python Const SCE_HPA_DEFAULT = 106 // server python default ASP Python Const SCE_HPA_COMMENTLINE = 107 // server python comment line Comment Const SCE_HPA_NUMBER = 108 // server python literal numeric Number Const SCE_HPA_STRING = 109 // server python literal string String Const SCE_HPA_CHARACTER = 110 // server python literal string character Single quoted string Const SCE_HPA_WORD = 111 // server python keyword Keyword Const SCE_HPA_TRIPLE = 112 // server python literal string Triple quotes Const SCE_HPA_TRIPLEDOUBLE = 113 // server python literal string Triple double quotes Const SCE_HPA_CLASSNAME = 114 // server python identifier Class name definition Const SCE_HPA_DEFNAME = 115 // server python identifier Function or method name definition Const SCE_HPA_OPERATOR = 116 // server python operator Operators Const SCE_HPA_IDENTIFIER = 117 // server python identifier Identifiers Const SCE_HPHP_DEFAULT = 118 // server php default Default Const SCE_HPHP_HSTRING = 119 // server php literal string Double quoted String Const SCE_HPHP_SIMPLESTRING = 120 // server php literal string Single quoted string Const SCE_HPHP_WORD = 121 // server php keyword Keyword Const SCE_HPHP_NUMBER = 122 // server php literal numeric Number Const SCE_HPHP_VARIABLE = 123 // server php identifier Variable Const SCE_HPHP_COMMENT = 124 // server php comment Comment Const SCE_HPHP_COMMENTLINE = 125 // server php comment line One line comment Const SCE_HPHP_HSTRING_VARIABLE = 126 // server php literal string identifier PHP variable in double quoted string Const SCE_HPHP_OPERATOR = 127 // server php operator PHP operator Const hypertextElements = "a abbr acronym address applet area b base basefont bdo bgsound big blink blockquote body br button caption center cite code col colgroup dd del dfn dir div dl dt em fieldset Font form frame frameset h1 h2 h3 h4 h5 h6 head hr html i iframe img Input ins isindex kbd label legend li link listing map marquee menu menuitem meta multicol nobr noembed noframes noscript Object ol optgroup option p param plaintext pre q s samp script Select small spacer span strike strong style Sub sup table tbody td textarea tfoot th thead title tr tt u ul var xml xmlns xmp " Const hypertextAttributes = "abbr accept-charset accept accesskey action align alink allowtransparency alt archive axis background bgcolor border bordercolor bottommargin cellpadding cellspacing char charoff charset checked cite class classid clear codebase codetype color cols colspan compact content coords data datafld dataformatas datapagesize datasrc datetime declare defer dir disabled enctype event face for frame frameborder framespacing headers height href hreflang hspace http-equiv id is ismap itemid itemprop itemref itemscope itemtype label lang language leftmargin link longdesc lowsrc marginwidth marginheight maxlength media method methods multiple name nohref noresize noshade nowrap object onblur onchange onclick ondblclick onfocus onkeydown onkeypress onkeyup onload onmousedown onmousemove onmouseover onmouseout onmouseup onreset onselect onsubmit onunload profile prompt readonly rel rev rightmargin rows rowspan rules scheme scope scrolling selected shape size span src standby start style summary tabindex target text title topmargin type usemap urn valign value valuetype version vlink vspace width text password checkbox radio submit reset file hidden image ^data- " Const html5elements = "address article aside audio base bdi canvas command details datalist dialog embed figure figcaption footer header hgroup keygen main mark menu meter nav output picture progress ruby rb rt rtc rp section source template track time video wbr " Const html5attributes = "allowfullscreen allowpaymentrequest async autocomplete autofocus autoplay controls contenteditable contextmenu crossorigin default dirname download draggable form formaction formenctype formmethod formnovalidate formtarget high kind list low loop manifest max muted min minlength nonce novalidate open optimum onabort onaddtrack onafterprint onauxclick onbeforeprint onbeforeunload oncancel oncanplay oncanplaythrough onclose oncopy oncuechange oncut ondrag ondragend ondragenter ondragexit ondragleave ondragover ondragstart ondrop ondurationchange onemptied onended onerror onenter onexit onhashchange oninput oninvalid onlanguagechange onloadeddata onloadedmetadata onloadend onloadstart onmessage onmouseenter onmouseleave onoffline ononline onpagehide onpageshow onpaste onpause onplay onplaying onprogress onpopstate onratechange onremovetrack onresize onrejectionhandled onresize onscroll onseeked onseeking onshow onstalled onstorage onsuspend ontimeupdate ontoggle onunhandledrejection onvolumechange onwaiting onwheel pattern placeholder poster preload referrerpolicy required reversed role sandbox scoped seamless sizes spellcheck srcdoc srclang srcset step translate typemustmatch wrap " Const keywordclassHypertext = hypertextElements+hypertextAttributes+html5elements+html5attributes+"public !doctype" Const keywordclassJavascript = "abstract boolean break byte case catch char class const continue debugger default delete do double else enum export extends final finally float for function goto if implements import in instanceof int interface long native new package private protected public return short static super switch synchronized this throw throws transient try typeof var void volatile while with " // we skip VBScript, PHP, SGML and Python here. // we could also do html AddWordsForAutoComplete keywordclassHypertext AddWordsForAutoComplete keywordclassJavascript // Keywords to highlight. Indices are: // 0: HTML elements and attributes // 1: JavaScript keywords // 2: VBScript keywords // 3: Python keywords // 4: PHP keywords // 5: SGML and DTD keywords c.KeyWords(0) = keywordclassHypertext c.KeyWords(1) = keywordclassJavascript Dim Factor As Double = 1 Dim style As ScintillaStyleMBS = c.Style(ScintillaStyleMBS.kStylesCommonDefault) // Colors and styles for various syntactic elements. First the default style. style.Font = "Helvetica" // c.StyleFont(c.kStylesCommonDefault) = "Monospac821 BT" // Very pleasing programmer's font. #If TargetWindows Then style.size = 10 // on Windows it is 96 dpi insteasd of 72dpi Factor = Self.ScaleFactor // and we have to do margins *2 #Else Factor = 1 style.size = 14 #EndIf style.ForeColor = &c000000 c.StyleClearAll // normal Text c.Style(SCE_H_DEFAULT).ForeColor = &c000000 // Tags c.Style(SCE_H_TAG).ForeColor = &c000080 // Unknown Tags c.Style(SCE_H_ERRORTAGUNKNOWN).ForeColor = &cFF0000 // Attributes c.Style(SCE_H_ATTRIBUTE).ForeColor = &c008080 // Unknown Attributes c.Style(SCE_H_ATTRIBUTEUNKNOWN).BackColor = &cFF0000 // Numbers c.Style(SCE_H_NUMBER).ForeColor = &c378EA5 // Double/single quoted strings c.Style(SCE_H_DOUBLESTRING).ForeColor = &cFFAA3E c.Style(SCE_H_SINGLESTRING).ForeColor = &cFFAA3E // Other inside tag, including space and '=' c.Style(SCE_H_OTHER).ForeColor = &c800080 // Comment c.Style(SCE_H_COMMENT).ForeColor = &c808000 // Entities c.Style(SCE_H_ENTITY).ForeColor = &c800080 // XML style tag ends '/>' c.Style(SCE_H_TAGEND).ForeColor = &c000080 // XML identifier start '<?' c.Style(SCE_H_XMLSTART).ForeColor = &c0000FF // XML identifier end '?>' c.Style(SCE_H_XMLEND).ForeColor = &c0000FF // Line number style. c.Style(ScintillaStyleMBS.kStylesCommonLineNumber).ForeColor = &cF0F0F0 c.Style(ScintillaStyleMBS.kStylesCommonLineNumber).BackColor = &c808080 c.Margin(0).Type = ScintillaMarginMBS.kMarginTypeNumber c.Margin(0).Width = 35 * Factor // Marker for bookmark c.Margin(1).Width = 16 * Factor c.Margin(1).Sensitive = true // allow click // Some special lexer properties. c.PropertyValue("fold") = "1" c.PropertyValue("fold.html") = "1" c.PropertyValue("fold.hypertext.comment") = "1" // you can query property name list for this lexer Dim PropertyNames() As String = c.PropertyNames.Split(EndOfLine.UNIX) // and learn what keyword sets do Dim DescribeKeyWordSets() As String = c.DescribeKeyWordSets.Split(EndOfLine.UNIX) // and query details on each property Dim FoldHTMLPropertyDescription As String = c.DescribeProperty("fold.html") 'Break // stop here to read properties // Folder setup. c.Margin(2).Width = 16 c.Margin(2).Mask = c.kMaskFolders c.Margin(2).Sensitive = True c.Marker(ScintillaMarkerMBS.kMarkerOutlineFolderOpen).Symbol = ScintillaMarkerMBS.kMarkerSymbolBoxMinus c.Marker(ScintillaMarkerMBS.kMarkerOutlineFolder).Symbol = ScintillaMarkerMBS.kMarkerSymbolBoxPlus c.Marker(ScintillaMarkerMBS.kMarkerOutlineFolderSub).Symbol = ScintillaMarkerMBS.kMarkerSymbolVLine c.Marker(ScintillaMarkerMBS.kMarkerOutlineFolderTail).Symbol = ScintillaMarkerMBS.kMarkerSymbolLCorner c.Marker(ScintillaMarkerMBS.kMarkerOutlineFolderEnd).Symbol = ScintillaMarkerMBS.kMarkerSymbolBoxPlusConnected c.Marker(ScintillaMarkerMBS.kMarkerOutlineFolderOpenMid).Symbol = ScintillaMarkerMBS.kMarkerSymbolBoxMinusConnected c.Marker(ScintillaMarkerMBS.kMarkerOutlineFolderMidTail).Symbol = ScintillaMarkerMBS.kMarkerSymbolTCorner For n As Integer = 25 To 31 // Markers 25..31 are reserved for folding. c.Marker(n).ForeColor = &cFFFFFF c.Marker(n).BackColor = &c000000 Next // Init markers & indicators for highlighting of syntax errors. c.Indicator(0).ForeColor = &cFF0000 c.Indicator(0).Under = True c.Indicator(0).Style = ScintillaIndicatorMBS.kIndicatorStyleSquiggle c.Marker(0).BackColor = &cB1151C c.SetSelBackColor(True, Color.HighlightColor) // define the marker for breakpoint c.Marker(1).ForeColor = &cFF0000 c.Marker(1).Symbol = ScintillaMarkerMBS.kMarkerSymbolBookmark c.AutoCompleteIgnoreCase = True // Uncomment if you wanna see auto wrapping in action. // c.WrapMode = c.kWrapWord c.setStatusText "Operation complete" c.Text = SampleHTML End Sub
Sub SetupMySQL() Dim c As ScintillaControlMBS = Me.ScintillaControl c.InitializeLexer "mysql" Const SCE_MYSQL_DEFAULT = 0 Const SCE_MYSQL_COMMENT = 1 Const SCE_MYSQL_COMMENTLINE = 2 Const SCE_MYSQL_VARIABLE = 3 Const SCE_MYSQL_SYSTEMVARIABLE = 4 Const SCE_MYSQL_KNOWNSYSTEMVARIABLE = 5 Const SCE_MYSQL_NUMBER = 6 Const SCE_MYSQL_MAJORKEYWORD = 7 Const SCE_MYSQL_KEYWORD = 8 Const SCE_MYSQL_DATABASEOBJECT = 9 Const SCE_MYSQL_PROCEDUREKEYWORD = 10 Const SCE_MYSQL_STRING = 11 Const SCE_MYSQL_SQSTRING = 12 Const SCE_MYSQL_DQSTRING = 13 Const SCE_MYSQL_OPERATOR = 14 Const SCE_MYSQL_FUNCTION = 15 Const SCE_MYSQL_IDENTIFIER = 16 Const SCE_MYSQL_QUOTEDIDENTIFIER = 17 Const SCE_MYSQL_USER1 = 18 Const SCE_MYSQL_USER2 = 19 Const SCE_MYSQL_USER3 = 20 Const SCE_MYSQL_HIDDENCOMMAND = 21 Const SCE_MYSQL_PLACEHOLDER = 22 Dim major_keywords As String = _ "accessible add all alter analyze and as asc asensitive "+_ "before between bigint binary blob both by "+_ "call cascade case change char character check collate column condition connection constraint "+_ "continue convert create cross current_date current_time current_timestamp current_user cursor "+_ "database databases day_hour day_microsecond day_minute day_second dec decimal declare default "+_ "delayed delete desc describe deterministic distinct distinctrow div double drop dual "+_ "each else elseif enclosed escaped exists exit explain "+_ "false fetch float float4 float8 for force foreign from fulltext "+_ "goto grant group "+_ "having high_priority hour_microsecond hour_minute hour_second "+_ "if ignore in index infile inner inout insensitive insert int int1 int2 int3 int4 int8 integer "+_ "interval into is iterate "+_ "join "+_ "key keys kill "+_ "label leading leave left like limit linear lines load localtime localtimestamp lock long "+_ "longblob longtext loop low_priority "+_ "master_ssl_verify_server_cert match mediumblob mediumint mediumtext middleint minute_microsecond "+_ "minute_second mod modifies "+_ "natural not no_write_to_binlog null numeric "+_ "on optimize option optionally or order out outer outfile "+_ "precision primary procedure purge "+_ "range read reads read_only read_write real references regexp release rename repeat replace "+_ "require restrict return revoke right rlike "+_ "schema schemas second_microsecond select sensitive separator set show smallint spatial specific "+_ "sql sqlexception sqlstate sqlwarning sql_big_result sql_calc_found_rows sql_small_result ssl "+_ "starting straight_join "+_ "table terminated then tinyblob tinyint tinytext to trailing trigger true "+_ "undo union unique unlock unsigned update upgrade usage use using utc_date utc_time utc_timestamp "+_ "values varbinary varchar varcharacter varying "+_ "when where while with write "+_ "xor "+_ "year_month "+_ "zerofill" // Not reserved words but intrinsic part of procedure definitions. Dim procedure_keywords As String = "begin comment end" // Definition of keywords only used by clients, not the server itself. Dim client_keywords As String = "delimiter" // Definition of own keywords, not used by MySQL. Dim user_keywords As String = "edit" AddWordsForAutoComplete major_keywords AddWordsForAutoComplete procedure_keywords AddWordsForAutoComplete client_keywords AddWordsForAutoComplete user_keywords // Keywords to highlight. Indices are: // 0 - Major keywords (reserved keywords) // 1 - Normal keywords (everything not reserved but integral part of the language) // 2 - Database objects // 3 - Function keywords // 4 - System variable keywords // 5 - Procedure keywords (keywords used in procedures like "begin" and "end") // 6..8 - User keywords 1..3 c.KeyWords(0) = major_keywords c.KeyWords(5) = procedure_keywords c.KeyWords(6) = client_keywords c.KeyWords(7) = user_keywords Dim Factor As Double = 1 Dim style As ScintillaStyleMBS = c.Style(ScintillaStyleMBS.kStylesCommonDefault) // Colors and styles for various syntactic elements. First the default style. style.Font = "Helvetica" // c.StyleFont(c.kStylesCommonDefault) = "Monospac821 BT" // Very pleasing programmer's font. #If TargetWindows Then style.size = 10 // on Windows it is 96 dpi insteasd of 72dpi Factor = Self.ScaleFactor // and we have to do margins *2 #Else Factor = 1 style.size = 14 #EndIf style.ForeColor = &c000000 c.StyleClearAll c.Style(SCE_MYSQL_DEFAULT).ForeColor = &c000000 c.Style(SCE_MYSQL_COMMENT).ForeColor = &c097BF7 c.Style(SCE_MYSQL_COMMENTLINE).ForeColor = &c097BF7 c.Style(SCE_MYSQL_HIDDENCOMMAND).ForeColor = &c097BF7 c.Style(SCE_MYSQL_HIDDENCOMMAND).BackColor = &cF0F0F0 c.Style(SCE_MYSQL_VARIABLE).ForeColor = &c378EA5 c.Style(SCE_MYSQL_SYSTEMVARIABLE).ForeColor = &c378EA5 c.Style(SCE_MYSQL_KNOWNSYSTEMVARIABLE).ForeColor = &c3A37A5 c.Style(SCE_MYSQL_NUMBER).ForeColor = &c7F7F00 c.Style(SCE_MYSQL_SQSTRING).ForeColor = &cFFAA3E // Note: if we were using ANSI quotes we would set the DQSTRING to the same color as the // the back tick string. c.Style(SCE_MYSQL_DQSTRING).ForeColor = &c274A6D // Keyword highlighting. c.Style(SCE_MYSQL_MAJORKEYWORD).ForeColor = &c007F00 c.Style(SCE_MYSQL_MAJORKEYWORD).bold = True c.Style(SCE_MYSQL_KEYWORD).ForeColor = &c007F00 c.Style(SCE_MYSQL_KEYWORD).bold = True c.Style(SCE_MYSQL_PROCEDUREKEYWORD).ForeColor = &c56007F c.Style(SCE_MYSQL_PROCEDUREKEYWORD).bold = True c.Style(SCE_MYSQL_USER1).ForeColor = &c808080 c.Style(SCE_MYSQL_USER2).ForeColor = &c808080 c.Style(SCE_MYSQL_USER2).BackColor = &cF0E0E0 // The following 3 styles have no impact as we did not set a keyword list for any of them. c.Style(SCE_MYSQL_DATABASEOBJECT).ForeColor = &cFF0000 c.Style(SCE_MYSQL_FUNCTION).ForeColor = &cFF0000 c.Style(SCE_MYSQL_IDENTIFIER).ForeColor = &c000000 c.Style(SCE_MYSQL_QUOTEDIDENTIFIER).ForeColor = &c274A6D c.Style(SCE_MYSQL_OPERATOR).Bold = True // Line number style. c.Style(ScintillaStyleMBS.kStylesCommonLineNumber).ForeColor = &cF0F0F0 c.Style(ScintillaStyleMBS.kStylesCommonLineNumber).BackColor = &c808080 c.Margin(0).Type = ScintillaMarginMBS.kMarginTypeNumber c.Margin(0).Width = 35 * Factor // Marker for bookmark c.Margin(1).Width = 16 * Factor c.Margin(1).Sensitive = True // allow click // Some special lexer properties. c.PropertyValue("fold") = "1" c.PropertyValue("fold.compact") = "0" c.PropertyValue("fold.comment") = "1" c.PropertyValue("fold.preprocessor") = "1" // Folder setup. c.Margin(2).Width = 16 c.Margin(2).Mask = c.kMaskFolders c.Margin(2).Sensitive = True c.Marker(ScintillaMarkerMBS.kMarkerOutlineFolderOpen).Symbol = ScintillaMarkerMBS.kMarkerSymbolBoxMinus c.Marker(ScintillaMarkerMBS.kMarkerOutlineFolder).Symbol = ScintillaMarkerMBS.kMarkerSymbolBoxPlus c.Marker(ScintillaMarkerMBS.kMarkerOutlineFolderSub).Symbol = ScintillaMarkerMBS.kMarkerSymbolVLine c.Marker(ScintillaMarkerMBS.kMarkerOutlineFolderTail).Symbol = ScintillaMarkerMBS.kMarkerSymbolLCorner c.Marker(ScintillaMarkerMBS.kMarkerOutlineFolderEnd).Symbol = ScintillaMarkerMBS.kMarkerSymbolBoxPlusConnected c.Marker(ScintillaMarkerMBS.kMarkerOutlineFolderOpenMid).Symbol = ScintillaMarkerMBS.kMarkerSymbolBoxMinusConnected c.Marker(ScintillaMarkerMBS.kMarkerOutlineFolderMidTail).Symbol = ScintillaMarkerMBS.kMarkerSymbolTCorner For n As Integer = 25 To 31 // Markers 25..31 are reserved for folding. c.Marker(n).ForeColor = &cFFFFFF c.Marker(n).BackColor = &c000000 Next // Init markers & indicators for highlighting of syntax errors. c.Indicator(0).ForeColor = &cFF0000 c.Indicator(0).Under = True c.Indicator(0).Style = ScintillaIndicatorMBS.kIndicatorStyleSquiggle c.Marker(0).BackColor = &cB1151C c.SetSelBackColor(True, Color.HighlightColor) // define the marker for breakpoint c.Marker(1).ForeColor = &cFF0000 // define red dot for breakpoints Const size = 18 Dim r As New Picture(size, size) // red dot Dim m As New Picture(size, size) // mask, a white dot on black, black is transparent Dim rg As Graphics = r.Graphics Dim mg As Graphics = m.Graphics // we draw the image and the mask one rg.DrawingColor = &c000000 rg.FillRectangle 0, 0, size, size rg.DrawingColor = &cFF0000 rg.FillOval 0, 0, size, size mg.DrawingColor = &c000000 mg.FillRectangle 0, 0, size, size mg.DrawingColor = &cFFFFFF mg.FillOval 0, 0, size, size // now we convert to memoryblock Dim rr As RGBSurface = r.RGBSurface Dim mr As RGBSurface = m.RGBSurface Dim pixels As New MemoryBlock(size * size * 4) Dim PixelPtr As ptr = pixels Dim o As Integer = 0 For y As Integer = 0 To size-1 For x As Integer = 0 To size-1 Dim mc As Color = mr.Pixel(x,y) Dim rc As Color = rr.Pixel(x,y) PixelPtr.UInt8(o+0) = rc.Red PixelPtr.UInt8(o+1) = rc.Green PixelPtr.UInt8(o+2) = rc.Blue PixelPtr.UInt8(o+3) = mc.Green o = o + 4 Next Next // and define the marker c.Marker(1).Symbol = ScintillaMarkerMBS.kMarkerSymbolPixmap c.MarkerDefineRGBAImage(1, size, size, 100, pixels) c.AutoCompleteIgnoreCase = True // Uncomment if you wanna see auto wrapping in action. // c.WrapMode = c.kWrapWord c.setStatusText "Operation complete" c.Text = TestData End Sub
Sub SetupXojo() Dim c As ScintillaControlMBS = Me.ScintillaControl // if you got newer lexer with Xojo c.InitializeLexer "xojo" // all miss the // comments, so we may eventually need to make an extra one. Const SCE_XOJO_DEFAULT = 0 Const SCE_XOJO_COMMENT = 1 // // or ' or starts with "REM " Const SCE_XOJO_NUMBER = 2 // &h, &b, &o or other literals Const SCE_XOJO_COLOR = 3 // starts &c Const SCE_XOJO_UNICODE = 4 // starts &u Const SCE_XOJO_STRING = 5 // starts with "....." Const SCE_XOJO_OPERATOR = 6 Const SCE_XOJO_PREPROCESSOR = 7 // #if #pragma Const SCE_XOJO_KEYWORD = 8 Const SCE_XOJO_BOOLEAN = 9 // ie TRUE / FALSE Const SCE_XOJO_IDENTIFIER = 10 Const SCE_XOJO_COLOR_RED = 11 // starts &c default color is RED Const SCE_XOJO_COLOR_GREEN = 12 // starts &c default color is GREEN Const SCE_XOJO_COLOR_BLUE = 13 // starts &c default color is BLUE Const SCE_XOJO_COLOR_ALPHA = 14 // starts &c default color is the system default text color based on light mode dark mode Const SCE_XOJO_INTEGER = 15 Const SCE_XOJO_FLOATING = 16 Dim Factor As Double = 1 Dim ReservedWords As String = "addhandler addressof aggregates and array as assigns async attributes await break byref byval call case catch class const continue ctype declare delegate dim do downto each else elseif end enum event exception exit extends false finally for function global goto handles if implements in inherits interface is isa lib loop me mod module namespace new next nil not object of optional or paramarray private property [[protected] public raise raiseevent redim rem removehandler return select self shared soft static step structure sub super then to true try until using var weakaddressof wend while with xor" Dim DataTypes As String = "auto boolean cfstringref cgfloat color cstring currency double "+_ "int16 int32 int64 int8 integer object ostype pstring ptr "+_ "short single string text uint16 uint32 uint64 uint8 uinteger "+_ "variant windowptr wstring" Dim FunctionKeyWords As String = "private protected public sub function handles extends assigns" Dim PragmaKeyWords As String = "#pragma #if #elseif #endif" AddWordsForAutoComplete ReservedWords AddWordsForAutoComplete DataTypes // Keywords to highlight. Indices are: // 0 - Major keywords (reserved keywords) // 1 - Normal keywords (everything not reserved but integral part of the language) // 2 - Database objects // 3 - Function keywords // 4 - System variable keywords // 5 - Procedure keywords (keywords used in procedures like "begin" and "end") // 6..8 - User keywords 1..3 c.KeyWords(0) = ReservedWords c.KeyWords(1) = DataTypes c.KeyWords(3) = FunctionKeyWords c.KeyWords(7) = PragmaKeyWords Dim style As ScintillaStyleMBS = c.Style(ScintillaStyleMBS.kStylesCommonDefault) // Colors and styles for various syntactic elements. First the default style. style.Font = "Helvetica" // c.StyleFont(c.kStylesCommonDefault) = "Monospac821 BT" // Very pleasing programmer's font. #If TargetWindows Then style.size = 10 // on Windows it is 96 dpi insteasd of 72dpi Factor = Self.ScaleFactor // and we have to do margins *2 #Else Factor = 1 style.size = 14 #endif style.ForeColor = &c000000 c.StyleClearAll c.Style(SCE_XOJO_DEFAULT).ForeColor = &c000000 c.Style(SCE_XOJO_COMMENT).ForeColor = &c7D1012 c.Style(SCE_XOJO_COLOR_RED).ForeColor = &cFF0000 c.Style(SCE_XOJO_COLOR_GREEN).ForeColor = &c00FF00 c.Style(SCE_XOJO_COLOR_BLUE).ForeColor = &c0000FF c.Style(SCE_XOJO_COLOR_ALPHA).ForeColor = &c000000 c.Style(SCE_XOJO_UNICODE).ForeColor = &c3A37A5 c.Style(SCE_XOJO_STRING).ForeColor = &c9D33D5 c.Style(SCE_XOJO_NUMBER).ForeColor = &c28C732 c.Style(SCE_XOJO_OPERATOR).ForeColor = &c333333 c.Style(SCE_XOJO_OPERATOR).bold = True c.Style(SCE_XOJO_PREPROCESSOR).ForeColor = &c595BB4 c.Style(SCE_XOJO_KEYWORD).ForeColor = &c0A5FFE c.Style(SCE_XOJO_KEYWORD).bold = True c.Style(SCE_XOJO_BOOLEAN).ForeColor = &c671782 c.Style(SCE_XOJO_IDENTIFIER).ForeColor = &c000000 c.Style(SCE_XOJO_NUMBER).ForeColor = &c28C732 // &b, &h, &o c.Style(SCE_XOJO_INTEGER).ForeColor = &c28C732 c.Style(SCE_XOJO_FLOATING).ForeColor = &c146319 // Line number style. c.Style(ScintillaStyleMBS.kStylesCommonLineNumber).ForeColor = &cF0F0F0 c.Style(ScintillaStyleMBS.kStylesCommonLineNumber).BackColor = &c808080 c.Margin(0).Type = ScintillaMarginMBS.kMarginTypeNumber c.Margin(0).Width = 35 * Factor // Markers. c.Margin(1).Width = 16 * Factor c.Margin(1).Sensitive = true // allow click // Some special lexer properties. c.PropertyValue("fold") = "1" c.PropertyValue("fold.compact") = "0" c.PropertyValue("fold.comment") = "1" c.PropertyValue("fold.preprocessor") = "1" // Folder setup. c.Margin(2).Width = 16 c.Margin(2).Mask = c.kMaskFolders c.Margin(2).Sensitive = True c.Marker(ScintillaMarkerMBS.kMarkerOutlineFolderOpen).Symbol = ScintillaMarkerMBS.kMarkerSymbolBoxMinus c.Marker(ScintillaMarkerMBS.kMarkerOutlineFolder).Symbol = ScintillaMarkerMBS.kMarkerSymbolBoxPlus c.Marker(ScintillaMarkerMBS.kMarkerOutlineFolderSub).Symbol = ScintillaMarkerMBS.kMarkerSymbolVLine c.Marker(ScintillaMarkerMBS.kMarkerOutlineFolderTail).Symbol = ScintillaMarkerMBS.kMarkerSymbolLCorner c.Marker(ScintillaMarkerMBS.kMarkerOutlineFolderEnd).Symbol = ScintillaMarkerMBS.kMarkerSymbolBoxPlusConnected c.Marker(ScintillaMarkerMBS.kMarkerOutlineFolderOpenMid).Symbol = ScintillaMarkerMBS.kMarkerSymbolBoxMinusConnected c.Marker(ScintillaMarkerMBS.kMarkerOutlineFolderMidTail).Symbol = ScintillaMarkerMBS.kMarkerSymbolTCorner For n As Integer = 25 To 31 // Markers 25..31 are reserved for folding. c.Marker(n).ForeColor = &cFFFFFF c.Marker(n).BackColor = &c000000 Next // Init markers & indicators for highlighting of syntax errors. c.Indicator(0).ForeColor = &cFF0000 c.Indicator(0).Under = True c.Indicator(0).Style = ScintillaIndicatorMBS.kIndicatorStyleSquiggle c.Marker(0).BackColor = &cB1151C c.SetSelBackColor(True, Color.HighlightColor) // define the marker for breakpoint c.Marker(1).ForeColor = &cFF0000 c.Marker(1).Symbol = ScintillaMarkerMBS.kMarkerSymbolBookmark // more possible options c.AutoCompleteIgnoreCase = True If False Then c.EOLMode = c.kEndOfLineLf // Unix c.ViewEOL = True c.Zoom = 4 End If If False Then // custom line wrapping // Set the Text wrapping mode To word wrap c.WrapMode = c.kWrapWord // Set the Text wrapping mode visual indication c.WrapVisualFlagsLocation = c.kWrapVisualLocationEndByText // Set the Text wrapping To indent the wrapped lines c.WrapIndentMode = c.kWrapIndentModeSame End If If False Then // custom edge marker // Set the edge marker's position and set it to color the background // when a line goes over the limit Of 50 characters c.EdgeMode = c.kEdgeVisualStyleBackground c.EdgeColumn = 50 c.EdgeColor = &cff00ff00 End If If False Then // custom indentation //Set indentation With spaces instead Of tabs c.UseTabs = False // Set the tab width To 4 spaces c.TabWidth = 4 // Set tab indent mode c.TabIndents = true // Set autoindentation mode To maintain the indentation // level Of the previous line (the editor's lexer HAS // To be disabled) c.Indent = 4 // Make the backspace jump back To the tab width guides // instead Of deleting one character, but only when // there are ONLY whitespaces on the Left side Of the // cursor c.BackSpaceUnIndents = True // Set indentation guides To be visible c.IndentationGuides = c.kIndentViewLookBoth End If If False Then // Customization - CARET (the blinking cursor indicator) // Set the caret color to red c.CaretForeColor = &cffff0000 // Enable and set the caret line background color to slightly transparent blue c.CaretLineVisible = True c.CaretLineBackColor = &c7f0000ff // Set the caret width of 4 pixels c.CaretWidth = 4 end if // now put in some text 'c.ReadOnly = true c.setStatusText "Operation complete" c.Text = testXojo End Sub
Sub ShowFind() if myFindWindow <> nil then myFindWindow.show else dim w as new FindWindow w.parent = self w.control = self.ScintillaControl w.top = self.top + 100 w.Left = self.left + self.Width - 100 w.show self.myFindWindow = w end if End Sub
Sub StartAutoComplete() Dim editor As ScintillaControlMBS = ScintillaControl 'Dim CurrentPosition As Integer = editor.Position 'Dim lineCurrentPos As Integer = editor.LineFromPosition(CurrentPosition) 'Dim lineStart As Integer = editor.LineStart(lineCurrentPos) 'Dim lineEnd As Integer = editor.LineStart(lineCurrentPos + 1) Dim line As String = editor.CurrentLine Dim positon As Integer = editor.GetCaretInLine Dim wordCharacters As String = editor.WordChars Dim startword As Integer = positon // Autocompletion of pure numbers is mostly an annoyance Dim allNumber As Boolean = True Dim Numbers As String = "0123456789" While (startword > 0 And wordCharacters.IndexOfBytes(line.MiddleBytes(startword-1, 1)) >= 0) startword = startword - 1 Dim c As String = line.MiddleBytes(startword, 1) If Numbers.IndexOf(c) < 0 Then // not a number allNumber = False End If Wend If startword = positon Or allNumber Then // nothing to do Return End If // build word list Dim root As String = line.MiddleBytes(startword, positon - startword) Dim rootLength As Integer = root.Bytes // simple auto complete based on key words Dim words() As String For Each n As String In AutoCompleteWords If n.Bytes > rootLength And n.LeftB(rootLength) = root Then words.Append n End If Next If words.Ubound = -1 Then // no words editor.AutoCompleteCancel Return Else Const autoCompleteVisibleItemCount = 9 Dim wordList As String = Join(Words, " ") editor.AutoCompleteMaxHeight = autoCompleteVisibleItemCount editor.AutoCompleteSeparator = 32 editor.AutoCompleteShow(rootLength, wordList) End If End Sub
Property AutoCompleteWords() As string
Property myFindWindow As FindWindow
Property ps As PrinterSetup
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileLoadBigText = "Load Big Text..."
MenuItem FilePrintPreview = "Print Preview"
MenuItem FilePrint = "Print..."
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
MenuItem UntitledSeparator = "-"
MenuItem EditFind = "Find"
End MenuBar
ExternalFile TestData
End ExternalFile
ExternalFile testXojo
End ExternalFile
Module Utils
Function GetCaretInLine(extends editor As ScintillaControlMBS) As Integer // find position within line Dim caret As Integer = editor.Position Dim line As Integer = editor.LineFromPosition(caret) Dim lineStart As Integer = editor.LineStart(line) Return caret - lineStart End Function
End Module
Class FindWindow Inherits Window
Control SearchLabel Inherits Label
ControlInstance SearchLabel Inherits Label
End Control
Control FindField Inherits TextField
ControlInstance FindField Inherits TextField
EventHandler Function KeyDown(Key As String) As Boolean if asc(key) = 3 or asc(key) = 13 then if me.Text.Length > 0 then find return true end if end if End EventHandler
EventHandler Sub TextChange() FindButton.Enabled = me.Text.Length > 0 ReplaceButton.Enabled = me.Text.Length > 0 End EventHandler
End Control
Control ReplaceLabel Inherits Label
ControlInstance ReplaceLabel Inherits Label
End Control
Control ReplaceField Inherits TextField
ControlInstance ReplaceField Inherits TextField
End Control
Control CheckMatchCase Inherits CheckBox
ControlInstance CheckMatchCase Inherits CheckBox
EventHandler Sub Action() dim Flag as Integer = ScintillaControlMBS.kFindOptionMatchCase if me.Value then SearchFlags = Bitwise.BitOr(SearchFlags, Flag) else SearchFlags = Bitwise.BitAnd(SearchFlags, Bitwise.OnesComplement(Flag)) end if End EventHandler
End Control
Control CheckWholeWord Inherits CheckBox
ControlInstance CheckWholeWord Inherits CheckBox
EventHandler Sub Action() dim Flag as Integer = ScintillaControlMBS.kFindOptionWholeWord if me.Value then SearchFlags = Bitwise.BitOr(SearchFlags, Flag) else SearchFlags = Bitwise.BitAnd(SearchFlags, Bitwise.OnesComplement(Flag)) end if End EventHandler
End Control
Control CheckWordStart Inherits CheckBox
ControlInstance CheckWordStart Inherits CheckBox
EventHandler Sub Action() dim Flag as Integer = ScintillaControlMBS.kFindOptionWordStart if me.Value then SearchFlags = Bitwise.BitOr(SearchFlags, Flag) else SearchFlags = Bitwise.BitAnd(SearchFlags, Bitwise.OnesComplement(Flag)) end if End EventHandler
End Control
Control CheckRegEx Inherits CheckBox
ControlInstance CheckRegEx Inherits CheckBox
EventHandler Sub Action() dim Flag as Integer = ScintillaControlMBS.kFindOptionRegExp if me.Value then SearchFlags = Bitwise.BitOr(SearchFlags, Flag) else SearchFlags = Bitwise.BitAnd(SearchFlags, Bitwise.OnesComplement(Flag)) end if End EventHandler
End Control
Control FindButton Inherits PushButton
ControlInstance FindButton Inherits PushButton
EventHandler Sub Action() NextPos = 0 Find End EventHandler
End Control
Control NextButton Inherits PushButton
ControlInstance NextButton Inherits PushButton
EventHandler Sub Action() Find End EventHandler
End Control
Control ReplaceButton Inherits PushButton
ControlInstance ReplaceButton Inherits PushButton
EventHandler Sub Action() control.TargetStart = control.SelectionStart control.TargetEnd = control.SelectionEnd control.SearchFlags = SearchFlags dim pos as integer if CheckRegEx.Value then pos = control.ReplaceTargetRE(ReplaceField.Text) else pos = control.ReplaceTarget(ReplaceField.Text) end if me.Enabled = false dim RangeStart as integer = control.TargetStart dim RangeEnd as integer = control.TargetEnd control.SelectionStart = RangeStart control.SelectionEnd = RangeEnd NextPos = RangeEnd End EventHandler
End Control
EventHandler Sub Close() if parent <> nil then parent.myFindWindow = nil end if parent = nil control = nil End EventHandler
EventHandler Sub Open() End EventHandler
Sub Find() dim RangeStart as integer = NextPos dim RangeEnd as integer = control.Length dim pos as integer = control.FindText(SearchFlags, FindField.Text, RangeStart, RangeEnd) if pos < 0 then // failed beep NextButton.Enabled = False ReplaceButton.Enabled = false else // found control.SetSelection RangeEnd, RangeStart // scroll to make sure this is visible 'control.ScrollCaret control.ScrollRange RangeEnd, RangeStart NextPos = RangeEnd NextButton.Enabled = true ReplaceButton.Enabled = true end if End Sub
Property NextPos As Integer
Property Parent As ScintillaWindow
Property SearchFlags As Integer
Property control As ScintillaControlMBS
End Class
Class PrintPreviewWindow Inherits Window
EventHandler Sub Paint(g As Graphics, areas() As REALbasic.Rect) if pic <> nil then g.DrawPicture pic, 0, 0, g.Width, g.Height, 0, 0, pic.Width, pic.Height End If End EventHandler
Property pic As Picture
End Class
End Project

See also:

The items on this page are in the following plugins: MBS Scintilla Plugin.


The biggest plugin in space...