How can i set Hexnumbers ($0F) and "= * + / -" to NumbersStyle/Color?
GoScintilla - 2.7 (Purebasic 4.5 onwards)
Re: GoScintilla - 1.0 (PB 4.4 only)
Next Problem
How can i set Hexnumbers ($0F) and "= * + / -" to NumbersStyle/Color?
How can i set Hexnumbers ($0F) and "= * + / -" to NumbersStyle/Color?
Re: GoScintilla - 1.0 (PB 4.4 only)
Code: Select all
GOSCI_AddKeywords(1, "+ - * /", #STYLES_NUMBERS)
GOSCI_AddKeywords(1, "$", #STYLES_NUMBERS, #GOSCI_LEFTDELIMITWITHOUTWHITESPACE)
I may look like a mule, but I'm not a complete ass.
Re: GoScintilla - 1.0 (PB 4.4 only)
thx, i am slow coach but i understand more and more 
Re: GoScintilla - 1.0 (PB 4.4 only)
Yes, configuring the GoScintilla lexer can be a little fiddly, more so than I had hoped when I wrote this little lib. There was a fine balance to be found between ease of use and flexibility/power and, as it turned out, I leaned towards giving the lexer the greatest power at some cost to the ease of use of this utility.ts-soft wrote:thx, i am slow coach but i understand more and more
Still, once you get used to it I'm sure that you'll find it is not too bad. The biggest problem is getting the right combination of delimiters and separators!
I may look like a mule, but I'm not a complete ass.
Re: GoScintilla - 1.0 (PB 4.4 only)
Use the #SCI_TOGGLEFOLD message to toggle/expand a line. Only works of course for those lines marked for folding (folding header lines).
You can test to see if a line is marked for folding by using something like :
To see if a particular folding header line is expanded use :
and so on.
All of these messages are detailed over at the Scintilla site.
You can test to see if a line is marked for folding by using something like :
Code: Select all
If ScintillaSendMessage(id, #SCI_GETFOLDLEVEL, lineIndex) & #SC_FOLDLEVELHEADERFLAGCode: Select all
If ScintillaSendMessage(id, #SCI_GETFOLDEXPANDED, lineIndex)All of these messages are detailed over at the Scintilla site.
I may look like a mule, but I'm not a complete ass.
Re: GoScintilla - 1.0 (PB 4.4 only)
Add the following line immediately after GOSCI_SetText()...
===============================
Code: Select all
UpdateWindow_(GadgetID(1))
Yes but that will not help you identify those lines in the text which are folding header lines without performing some complex parsing and lexing. You are best off simply querying each line's fold-level using the appropriate Scintilla messages as shown above.Arent the "folding header lines" the lines created with:
Or do i miss something?Code: Select all
;Add some folding keywords. GOSCI_AddKeywords(1, "Procedure Macro", #STYLES_COMMANDS, #GOSCI_OPENFOLDKEYWORD|#GOSCI_DELIMITNONE) GOSCI_AddKeywords(1, "EndProcedure EndMacro", #STYLES_COMMANDS, #GOSCI_CLOSEFOLDKEYWORD|#GOSCI_DELIMITNONE)
I may look like a mule, but I'm not a complete ass.
Re: GoScintilla - 1.0 (PB 4.4 only)
This is indeed a little more complex than I first thought and our method is flawed.
If you expand a folding header line which is itself part of another collapsed group then the 'parent' will also be expanded. This can effectively destroy our previous attempt to collapse all groups etc.
What you can do is either collapse just the 'top level' folding header items...
or take steps to toggle only those items which are not already collapsed etc. The following code throws up two buttons. Click the first to collapse everything and the second to expand everything etc. Seems to work fine.
If you expand a folding header line which is itself part of another collapsed group then the 'parent' will also be expanded. This can effectively destroy our previous attempt to collapse all groups etc.
What you can do is either collapse just the 'top level' folding header items...
Code: Select all
For I=0 To ScintillaSendMessage(1, #SCI_GETLINECOUNT)-1
If ScintillaSendMessage(1, #SCI_GETFOLDLEVEL, I) = #SC_FOLDLEVELBASE|#SC_FOLDLEVELHEADERFLAG
ScintillaSendMessage(1, #SCI_TOGGLEFOLD, I)
EndIf
Next
Code: Select all
IncludePath "..\..\"
XIncludeFile "GoScintilla.pbi"
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
InitScintilla()
CompilerEndIf
If OpenWindow(0, 100, 200, 600, 600, "GoScintilla demo!", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)
RemoveKeyboardShortcut(0, #PB_Shortcut_Tab) ;Required for the tab key to function correctly when the Scintilla control has the focus.
GOSCI_Create(1, 10, 40, 580, 550, 0, #GOSCI_AUTOSIZELINENUMBERSMARGIN|#GOSCI_ALLOWCODEFOLDING)
ButtonGadget(10, 0, 10, 150, 20, "COLLAPSE ALL ITEMS!")
ButtonGadget(11, 180, 10, 150, 20, "EXPAND ALL ITEMS!")
GOSCI_SetAttribute(1, #GOSCI_LINENUMBERAUTOSIZEPADDING, 10)
GOSCI_SetMarginWidth(1, #GOSCI_MARGINFOLDINGSYMBOLS, 24)
GOSCI_SetColor(1, #GOSCI_CARETLINEBACKCOLOR, $B4FFFF)
GOSCI_SetFont(1, "Courier New", 10)
GOSCI_SetTabs(1, 2)
;Set styles for our syntax highlighting.
;=======================================
Enumeration
#STYLES_COMMANDS = 1
#STYLES_COMMENTS
#STYLES_LITERALSTRINGS
#STYLES_NUMBERS
#STYLES_CONSTANTS
#STYLES_FUNCTIONS
EndEnumeration
;Set individual styles for commands.
GOSCI_SetStyleFont(1, #STYLES_COMMANDS, "", -1, #PB_Font_Bold)
GOSCI_SetStyleColors(1, #STYLES_COMMANDS, $800000) ;We have omitted the optional back color.
;Set individual styles for comments.
GOSCI_SetStyleFont(1, #STYLES_COMMENTS, "", -1, #PB_Font_Italic)
GOSCI_SetStyleColors(1, #STYLES_COMMENTS, $006400) ;We have omitted the optional back color.
;Set individual styles for literal strings.
GOSCI_SetStyleColors(1, #STYLES_LITERALSTRINGS, #Gray) ;We have omitted the optional back color.
;Set individual styles for numbers.
GOSCI_SetStyleColors(1, #STYLES_NUMBERS, #Red) ;We have omitted the optional back color.
;Set individual styles for constants.
GOSCI_SetStyleColors(1, #STYLES_CONSTANTS, $2193DE) ;We have omitted the optional back color.
;Set individual styles for functions.
GOSCI_SetStyleColors(1, #STYLES_FUNCTIONS, #Blue) ;We have omitted the optional back color.
;Set keywords for our syntax highlighting.
;=========================================
GOSCI_AddKeywords(1, "Debug End If ElseIf Else EndIf For To Next Step Protected ProcedureReturn", #STYLES_COMMANDS)
GOSCI_AddKeywords(1, ";", #STYLES_COMMENTS, #GOSCI_DELIMITTOENDOFLINE)
GOSCI_AddKeywords(1, Chr(34) + Chr(34), #STYLES_LITERALSTRINGS, #GOSCI_DELIMITBETWEEN)
GOSCI_AddKeywords(1, "#", #STYLES_CONSTANTS, #GOSCI_LEFTDELIMITWITHOUTWHITESPACE)
GOSCI_AddKeywords(1, "(", #STYLES_FUNCTIONS, #GOSCI_RIGHTDELIMITWITHWHITESPACE)
GOSCI_AddKeywords(1, ")", #STYLES_FUNCTIONS)
;Add some folding keywords.
GOSCI_AddKeywords(1, "Procedure Macro", #STYLES_COMMANDS, #GOSCI_OPENFOLDKEYWORD|#GOSCI_DELIMITNONE)
GOSCI_AddKeywords(1, "EndProcedure EndMacro", #STYLES_COMMANDS, #GOSCI_CLOSEFOLDKEYWORD|#GOSCI_DELIMITNONE)
;Additional lexer options.
;=========================
GOSCI_SetLexerOption(1, #GOSCI_LEXEROPTION_SEPARATORSYMBOLS, @"=+-*/%()[],.") ;You would use GOSCI_AddKeywords() to set a style for some of these if required.
GOSCI_SetLexerOption(1, #GOSCI_LEXEROPTION_NUMBERSSTYLEINDEX, #STYLES_NUMBERS)
;Set some initial text.
;======================
text$ = "; GoScintilla." + #CRLF$
text$ + "; By Stephen Rodriguez." + #CRLF$ + #CRLF$
text$ + "#MyConstant$ = " + Chr(34) + "Version = 1.0" + Chr(34) + #CRLF$ + #CRLF$
text$ + "Procedure.i AddIntegers(a, b)" + #CRLF$
text$ + #TAB$ + "Protected result" + #CRLF$
text$ + #TAB$ + "result = a + b ; Calculate the sum of the 2 integers." + #CRLF$
text$ + #TAB$ + "ProcedureReturn result" + #CRLF$
text$ + "EndProcedure" + #CRLF$ + #CRLF$
text$ + "Debug " + Chr(34) + "The sum of 10 and 20 is " + Chr(34) + " + Str(AddIntegers(10, 20))" + #CRLF$ + #CRLF$
text$ + "End" + #CRLF$
GOSCI_SetText(1, text$)
Repeat
eventID = WaitWindowEvent()
Select eventID
Case #PB_Event_Gadget
Select EventGadget()
Case 10 ;Collapse all items.
For I=0 To ScintillaSendMessage(1, #SCI_GETLINECOUNT)-1
If ScintillaSendMessage(1, #SCI_GETFOLDLEVEL, I) & #SC_FOLDLEVELHEADERFLAG
If ScintillaSendMessage(1, #SCI_GETFOLDEXPANDED, I)
ScintillaSendMessage(1, #SCI_TOGGLEFOLD, I)
EndIf
EndIf
Next
Case 11 ;Expand all items.
For I=0 To ScintillaSendMessage(1, #SCI_GETLINECOUNT)-1
If ScintillaSendMessage(1, #SCI_GETFOLDLEVEL, I) & #SC_FOLDLEVELHEADERFLAG
If ScintillaSendMessage(1, #SCI_GETFOLDEXPANDED, I) = 0
ScintillaSendMessage(1, #SCI_TOGGLEFOLD, I)
EndIf
EndIf
Next
EndSelect
EndSelect
Until eventID = #PB_Event_CloseWindow
;Free the Scintilla gadget.
GOSCI_Free(1)
EndIf
I may look like a mule, but I'm not a complete ass.
Re: GoScintilla - 1.0 (PB 4.4 only)
Ah yes, I see the problem. Because of the way GoScintilla implements code folding, we need to make sure that the lexer charges through the entire text as soon as we populate the control in order for the folding levels to be correctly established before we use code to collapse all folding regions etc. Not a problem if we are not collapsing regions through code.
Can you try the following to see if this fixes the problem?
Immediately after the GOSCI_SetText(1, text$) line, place the following :
If this fixes it then I shall make a change to GoScintilla.
Can you try the following to see if this fixes the problem?
Immediately after the GOSCI_SetText(1, text$) line, place the following :
Code: Select all
GOSCI_RestyleLinesXXX(1, 0, -1)I may look like a mule, but I'm not a complete ass.
Re: GoScintilla - 1.0 (PB 4.4 only)
thnaks srod, very simple and good source.
this source dont have AutoComplete feature ? (autocomplete features is very good as you know)
this source dont have AutoComplete feature ? (autocomplete features is very good as you know)
Sorry for my bad english.
Re: GoScintilla - 1.0 (PB 4.4 only)
Feel free to add it and I'll take the credit for it of course!Peyman wrote:thnaks srod, very simple and good source.
this source dont have AutoComplete feature ? (autocomplete features is very good as you know)
Seriously, I have no need for auto-complete at this time.
I may look like a mule, but I'm not a complete ass.
Re: GoScintilla - 1.0 (PB 4.4 only)
thanks srod allow me to add it, i add something in your source and it works :
added :
1 ) Auto Complete
2 ) Auto Indention
Add this Structure in end of GoScintilla_HeaderFile.pbi :
add this in GoScintilla.pbi :
Replace this with GOSCI_ScintillaCallBackXXX Procedure :
replace this with _GoScintilla Structure :
replace this with GOSCI_Free procedure :
And three procedure for using indention and auto complete in GoScintilla.pbi :
And this is a example :
but anyway i think this is not works in Unicode mode. (i dont have info for using Unicode because i dont use unicode atall)
added :
1 ) Auto Complete
2 ) Auto Indention
Add this Structure in end of GoScintilla_HeaderFile.pbi :
Code: Select all
Structure GoScintillaApis
id.i ;Scintilla#
fname$ ;Name of function or variable or ...
args$ ;Arguments of function.
sDecs$ ;Description of function.
EndStructure
Code: Select all
Global NewMap gGOSCI_Apis.GoScintillaApis()Code: Select all
ProcedureDLL GOSCI_ScintillaCallBackXXX(id, *scinotify.SCNotification)
Protected *this._GoScintilla, startLine, endLine, lineLength, utf8Buffer, i, level, newLevel, startPos
Protected nPos, txtr.TEXTRANGE, sWord.s, sFunc.s, sFunc2.s
*this = GetGadgetData(id)
Select *scinotify\nmhdr\code
Case #SCN_NEEDSHOWN
;Here we arrange for lines which may be collapsed to be expanded in the case that the folded section has been altered by the user.
startLine = ScintillaSendMessage(id, #SCI_LINEFROMPOSITION, *scinotify\position)
endLine = ScintillaSendMessage(id, #SCI_LINEFROMPOSITION, *scinotify\position + *scinotify\length)
For i = startLine To endLine
ScintillaSendMessage(id, #SCI_ENSUREVISIBLE, i)
Next
If ScintillaSendMessage(id, #SCI_GETFOLDLEVEL, endLine)&#SC_FOLDLEVELHEADERFLAG
level = ScintillaSendMessage(id, #SCI_GETFOLDLEVEL, endLine) & #SC_FOLDLEVELNUMBERMASK
newLevel = ScintillaSendMessage(id, #SCI_GETFOLDLEVEL, endLine+1) & #SC_FOLDLEVELNUMBERMASK
If newLevel > level
ScintillaSendMessage(id, #SCI_ENSUREVISIBLE, endLine+1)
EndIf
EndIf
Case #SCN_MARGINCLICK
Select *scinotify\margin
Case #GOSCI_MARGINFOLDINGSYMBOLS
startLine = ScintillaSendMessage(id, #SCI_LINEFROMPOSITION, *scinotify\position)
;Check it is a header line.
If ScintillaSendMessage(id, #SCI_GETFOLDLEVEL, startLine) & #SC_FOLDLEVELHEADERFLAG
ScintillaSendMessage(id, #SCI_TOGGLEFOLD, startLine)
EndIf
EndSelect
Case #SCN_MODIFIED
If *scinotify\linesAdded
GOSCI_AutosizeLineNumberMarginXXX(id)
EndIf
Case #SCN_STYLENEEDED
startLine = ScintillaSendMessage(id, #SCI_LINEFROMPOSITION, ScintillaSendMessage(id, #SCI_GETENDSTYLED))
startPos = ScintillaSendMessage(id, #SCI_POSITIONFROMLINE, startLine)
endLine = ScintillaSendMessage(id, #SCI_LINEFROMPOSITION, *scinotify\position)
endLine = ScintillaSendMessage(id, #SCI_VISIBLEFROMDOCLINE, endLine)
GOSCI_RestyleLinesXXX(id, startLine, endLine, *scinotify\position)
Case #SCN_CHARADDED
nPos = ScintillaSendMessage(id, #SCI_GETCURRENTPOS)
txtr\chrg\cpMin = ScintillaSendMessage(id, #SCI_WORDSTARTPOSITION, nPos, 1)
txtr\chrg\cpMax = ScintillaSendMessage(id, #SCI_WORDENDPOSITION, nPos, 1)
If (txtr\chrg\cpMax - txtr\chrg\cpMin) >= *this\autocchar
txtr\lpstrText = AllocateMemory(txtr\chrg\cpMax - txtr\chrg\cpMin + 1)
ScintillaSendMessage(id, #SCI_GETTEXTRANGE, #Null, txtr)
sWord = PeekS(txtr\lpstrText, -1, #PB_UTF8)
FreeMemory(txtr\lpstrText)
If sWord
ForEach gGOSCI_Apis()
If LCase(sWord) = LCase(Mid(gGOSCI_Apis()\fname$, 1, Len(sWord))) And gGOSCI_Apis()\id = id
sFunc = gGOSCI_Apis()\fname$
If sFunc
sFunc2 + sFunc + " "
EndIf
EndIf
Next
sFunc = RTrim(sFunc2)
If sFunc
If ScintillaSendMessage(id, #SCI_AUTOCACTIVE)
ScintillaSendMessage(id, #SCI_AUTOCCANCEL)
EndIf
ScintillaSendMessage(id, #SCI_AUTOCSETIGNORECASE, #True)
ScintillaSendMessage(id, #SCI_AUTOCSHOW, Len(sWord), @sFunc)
Else
If ScintillaSendMessage(id, #SCI_AUTOCACTIVE)
ScintillaSendMessage(id, #SCI_AUTOCCANCEL)
EndIf
EndIf
EndIf
EndIf
Select *scinotify\ch
Case 10 ; Enter for Automaticaly Indention
If *this\indention
ScintillaSendMessage(id, #SCI_BEGINUNDOACTION)
nPos = ScintillaSendMessage(id, #SCI_GETCURRENTPOS)
nLine = ScintillaSendMessage(id, #SCI_LINEFROMPOSITION, nPos) - 1
nLineIndentation = ScintillaSendMessage(id, #SCI_GETLINEINDENTATION, nLine)
If nLineIndentation
ScintillaSendMessage(id, #SCI_SETLINEINDENTATION, nLine + 1, nLineIndentation)
nNewPos = ScintillaSendMessage(id, #SCI_GETLINEINDENTPOSITION, nLine + 1)
ScintillaSendMessage(id, #SCI_GOTOPOS, nNewPos)
EndIf
ScintillaSendMessage(id, #SCI_ENDUNDOACTION)
EndIf
Case 40 ; "(" start comment calltip
nPos = ScintillaSendMessage(id, #SCI_GETCURRENTPOS) - 1
txtr\chrg\cpMin = ScintillaSendMessage(id, #SCI_WORDSTARTPOSITION, nPos, 1)
txtr\chrg\cpMax = ScintillaSendMessage(id, #SCI_WORDENDPOSITION, nPos, 1)
txtr\lpstrText = AllocateMemory(txtr\chrg\cpMax - txtr\chrg\cpMin + 1)
ScintillaSendMessage(id, #SCI_GETTEXTRANGE, #Null, txtr)
sWord = PeekS(txtr\lpstrText, -1, #PB_UTF8)
FreeMemory(txtr\lpstrText)
If FindMapElement(gGOSCI_Apis(), sWord) And gGOSCI_Apis()\id = id
sFunc = gGOSCI_Apis()\fname$ + gGOSCI_Apis()\args$ + #CRLF$ + gGOSCI_Apis()\sDecs$
ScintillaSendMessage(id, #SCI_CALLTIPSHOW, nPos + 1, @sFunc)
EndIf
Case 41 ; ")" end comment calltip
ScintillaSendMessage(id, #SCI_CALLTIPCANCEL)
EndSelect
EndSelect
;Call the user's Scintilla callback.
If *this And *this\callback
*this\callback(id, *scinotify)
EndIf
EndProcedureCode: Select all
Structure _GoScintilla
;Creation fields.
id.i
callback.GOSCI_proto_Callback
flags.i
state.i
;Custom line styling function.
stylingFunction.GOSCI_proto_StyleLine
;Additional user-supplied data.
userData.i
lineNumberAutoSizePadding.i
lexerSeparators$
lexerNumbersStyleIndex.i
;Code folding.
blnLineCodeFoldOption.i ;0 = no code folding, 1 = open fold, 2 = close fold.
foldLevel.i
;Styling.
previouslyRecordedStyle.i ;Used for left delimiters (separators).
*bytePointer.i ;Used for left delimiters (separators).
;Miscellaneous.
blnEmptyLineAdded.i
;Indention
indention.b
;AutoC Character
autocchar.b
EndStructureCode: Select all
;/////////////////////////////////////////////////////////////////////////////////
;The following function creates a Scintilla gadget within the current gadget list and initialises it as appropriate.
;Returns either a gadget# or hWnd as per usual.
Procedure GOSCI_Free(id)
Protected *this._GoScintilla
;Remove all appropriate elements from the global keyword map.
ForEach gGOSCI_Keywords()
If gGOSCI_Keywords()\id = id
DeleteMapElement(gGOSCI_Keywords())
EndIf
Next
ForEach gGOSCI_Apis()
If gGOSCI_Apis()\id = id
DeleteMapElement(gGOSCI_Apis())
EndIf
Next
If IsGadget(id) And GadgetType(id) = #PB_GadgetType_Scintilla
*this = GetGadgetData(id)
If *this
;Free structured strings.
GOSCI_FreeStructureStringXXX(@*this\lexerSeparators$)
FreeMemory(*this)
EndIf
FreeGadget(id)
EndIf
EndProcedure
;/////////////////////////////////////////////////////////////////////////////////
And three procedure for using indention and auto complete in GoScintilla.pbi :
Code: Select all
;/////////////////////////////////////////////////////////////////////////////////
;The following function sets the the AutoIndention is true or false.
;No return value.
Procedure GOSCI_AutoIndention(id, value.b)
Protected *this._GoScintilla
If IsGadget(id) And GadgetType(id) = #PB_GadgetType_Scintilla
*this = GetGadgetData(id)
If *this
*this\indention = value
EndIf
EndIf
EndProcedure
;/////////////////////////////////////////////////////////////////////////////////
;/////////////////////////////////////////////////////////////////////////////////
;The following function set how character needed to show AutoC
;No return value.
Procedure GOSCI_AutoCCharacter(id, value.b)
Protected *this._GoScintilla
If IsGadget(id) And GadgetType(id) = #PB_GadgetType_Scintilla
*this = GetGadgetData(id)
If *this
*this\autocchar = value
EndIf
EndIf
EndProcedure
;/////////////////////////////////////////////////////////////////////////////////
;/////////////////////////////////////////////////////////////////////////////////
;The following function records a list of keywords to use with AutoC. The list of words are to be separated by space characters.
;Note that only Ascii characters must be used within each keyword.
;Duplicates are simply replaced.
;For adding command just seprate them with a space and leave to last parameter alone
;For adding procedures use sArgs for arguments of that procedure and sDecs for Description
Procedure GOSCI_AddAutoC(id, sFunc$, sArgs$ = "", sDesc$ = "")
Protected spacecount
If IsGadget(id) And GadgetType(id) = #PB_GadgetType_Scintilla
spacecount = CountString(sFunc$, " ")
If spacecount
For i = 1 To spacecount + 1
If AddMapElement(gGOSCI_Apis(), StringField(sFunc$, i, " "))
gGOSCI_Apis()\id = id
gGOSCI_Apis()\fname$ = StringField(sFunc$, i, " ")
gGOSCI_Apis()\args$ = sArgs$
gGOSCI_Apis()\sDecs$ = sDesc$
EndIf
Next
Else
If AddMapElement(gGOSCI_Apis(), sFunc$)
gGOSCI_Apis()\id = id
gGOSCI_Apis()\fname$ = sFunc$
gGOSCI_Apis()\args$ = sArgs$
gGOSCI_Apis()\sDecs$ = sDesc$
EndIf
EndIf
EndIf
EndProcedure
;/////////////////////////////////////////////////////////////////////////////////
And this is a example :
Code: Select all
IncludePath "..\..\"
XIncludeFile "GoScintilla.pbi"
;Initialise the Scintilla library for Windows.
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
InitScintilla()
CompilerEndIf
If OpenWindow(0, 100, 200, 600, 600, "GoScintilla demo!(Edited By Peyman)", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)
RemoveKeyboardShortcut(0, #PB_Shortcut_Tab) ;Required for the tab key to function correctly when the Scintilla control has the focus.
;Create our Scintilla control. Note that we do not specify a callback; this is optional for GoSctintilla.
GOSCI_Create(1, 10, 10, 580, 580, 0, #GOSCI_AUTOSIZELINENUMBERSMARGIN|#GOSCI_ALLOWCODEFOLDING)
;Set the padding added to the width of the line-number margin.
GOSCI_SetAttribute(1, #GOSCI_LINENUMBERAUTOSIZEPADDING, 10)
;Set folding symbols margin width.
GOSCI_SetMarginWidth(1, #GOSCI_MARGINFOLDINGSYMBOLS, 24)
;Set the back color of the line containing the caret.
GOSCI_SetColor(1, #GOSCI_CARETLINEBACKCOLOR, $B4FFFF)
;Set font.
GOSCI_SetFont(1, "Courier New", 10)
;Set tabs. Here we use a 'hard' tab in which a tab character is physically inserted. Set the 3rd (optional) parameter to 1 to use soft-tabs.
GOSCI_SetTabs(1, 2)
;Set styles for our syntax highlighting.
;=======================================
;First define some constants to identify our various styles.
;You can name these as we wish.
Enumeration
#STYLES_COMMANDS = 1
#STYLES_COMMENTS
#STYLES_LITERALSTRINGS
#STYLES_NUMBERS
#STYLES_CONSTANTS
#STYLES_FUNCTIONS
EndEnumeration
;Set individual styles for commands.
GOSCI_SetStyleFont(1, #STYLES_COMMANDS, "", -1, #PB_Font_Bold)
GOSCI_SetStyleColors(1, #STYLES_COMMANDS, $800000) ;We have omitted the optional back color.
;Set individual styles for comments.
GOSCI_SetStyleFont(1, #STYLES_COMMENTS, "", -1, #PB_Font_Italic)
GOSCI_SetStyleColors(1, #STYLES_COMMENTS, $006400) ;We have omitted the optional back color.
;Set individual styles for literal strings.
GOSCI_SetStyleColors(1, #STYLES_LITERALSTRINGS, #Gray) ;We have omitted the optional back color.
;Set individual styles for numbers.
GOSCI_SetStyleColors(1, #STYLES_NUMBERS, #Red) ;We have omitted the optional back color.
;Set individual styles for constants.
GOSCI_SetStyleColors(1, #STYLES_CONSTANTS, $2193DE) ;We have omitted the optional back color.
;Set individual styles for functions.
GOSCI_SetStyleColors(1, #STYLES_FUNCTIONS, #Blue) ;We have omitted the optional back color.
;Set keywords for our syntax highlighting.
;=========================================
;First some commands.
GOSCI_AddKeywords(1, "If End Endif While Wend Repeat Until For To Next ForEach ForEver Break Return Procedure ProcedureReturn Macro Debug", #STYLES_COMMANDS)
GOSCI_AddKeywords(1, "Protected Shared Global Goto NewMap NewList Dim List Map Array Static ProcedureC ProcedureCDLL ProcedureDLL EndMacro", #STYLES_COMMANDS)
;Now set up a ; symbol to denote a comment. Note the use of #GOSCI_DELIMITTOENDOFLINE.
;Note also that this symbol will act as an additional separator.
GOSCI_AddKeywords(1, ";", #STYLES_COMMENTS, #GOSCI_DELIMITTOENDOFLINE)
;Now set up quotes to denote literal strings.
;We do this by passing the beginning and end delimiting characters; in this case both are quotation marks. Note the use of #GOSCI_DELIMITBETWEEN.
;Note also that a quote will subsequently act as an additional separator.
GOSCI_AddKeywords(1, Chr(34) + Chr(34), #STYLES_LITERALSTRINGS, #GOSCI_DELIMITBETWEEN)
;Now set up a # symbol to denote a constant. Note the use of #GOSCI_LEFTDELIMITWITHOUTWHITESPACE.
GOSCI_AddKeywords(1, "#", #STYLES_CONSTANTS, #GOSCI_LEFTDELIMITWITHOUTWHITESPACE)
;Now set up a ( symbol to denote a function. Note the use of #GOSCI_RIGHTDELIMITWITHWHITESPACE.
GOSCI_AddKeywords(1, "(", #STYLES_FUNCTIONS, #GOSCI_RIGHTDELIMITWITHWHITESPACE)
;We arrange for a ) symbol to match the coloring of the ( symbol.
GOSCI_AddKeywords(1, ")", #STYLES_FUNCTIONS)
;Add some folding keywords.
GOSCI_AddKeywords(1, "Procedure Macro", #STYLES_COMMANDS, #GOSCI_OPENFOLDKEYWORD|#GOSCI_DELIMITNONE)
GOSCI_AddKeywords(1, "EndProcedure EndMacro", #STYLES_COMMANDS, #GOSCI_CLOSEFOLDKEYWORD|#GOSCI_DELIMITNONE)
;Register ProgramFilename and Str procedure with its details and parameters for AutoC
GOSCI_AddAutoC(1, "ProgramFilename", "()", "Get the full path and filename of executable of this program.")
GOSCI_AddAutoC(1, "Str", "(Value)", "Convert a signed integer number into a string.")
;Register all purebasic command for AutoC
GOSCI_AddAutoC(1, "If End Endif While Wend Repeat Until For To Next ForEach ForEver Break Return Procedure ProcedureReturn EndProcedure")
GOSCI_AddAutoC(1, "Protected Shared Global Goto NewMap NewList Dim List Map Array Static ProcedureC ProcedureCDLL ProcedureDLL")
;I want AutoIndention so set it true for better codin.
GOSCI_AutoIndention(1, #True)
;I want after 2 character AutoC show me suggestions
GOSCI_AutoCCharacter(1, 2)
;Additional lexer options.
;=========================
;The lexer needs to know what separator characters we are using.
GOSCI_SetLexerOption(1, #GOSCI_LEXEROPTION_SEPARATORSYMBOLS, @"=+-*/%()[],.") ;You would use GOSCI_AddKeywords() to set a style for some of these if required.
;We can also set a style for numbers.
GOSCI_SetLexerOption(1, #GOSCI_LEXEROPTION_NUMBERSSTYLEINDEX, #STYLES_NUMBERS)
;Set some initial text.
;======================
text$ = "; GoScintilla." + #CRLF$
text$ + "; By Stephen Rodriguez." + #CRLF$
text$ + "; AutoC & AutoIndention By Peyman." + #CRLF$ + #CRLF$
text$ + "; Please write this syntax to see AutoC : Str(50)" + #CRLF$ + #CRLF$
GOSCI_SetText(1, text$)
SetActiveGadget(1)
GOSCI_GotoLine(1, 7)
Repeat
eventID = WaitWindowEvent()
Select eventID
Case #PB_Event_Gadget
Select EventGadget()
EndSelect
EndSelect
Until eventID = #PB_Event_CloseWindow
;Free the Scintilla gadget.
;This needs explicitly calling in order to free resources used by GoScintilla.
GOSCI_Free(1)
EndIf
Sorry for my bad english.
Re: GoScintilla - 1.0 (PB 4.4 only)
Hi Peyman,
Nice work, very impressive.
When I get a chance I'll take a look and see about integrating this more closely into GoScintilla (using existing functions etc.) We'll have to get it working in Unicode mind. That shouldn't be difficult.
I'll pm an e-mail address so that, if you don't mind, you can e-mail me the complete source. From there I'll set about integrating this into GoScintilla, update the manual etc. GoScintilla 2 will then go down as a joint Peyman/srod project.
Thanks again.
Nice work, very impressive.
When I get a chance I'll take a look and see about integrating this more closely into GoScintilla (using existing functions etc.) We'll have to get it working in Unicode mind. That shouldn't be difficult.
I'll pm an e-mail address so that, if you don't mind, you can e-mail me the complete source. From there I'll set about integrating this into GoScintilla, update the manual etc. GoScintilla 2 will then go down as a joint Peyman/srod project.
Thanks again.
I may look like a mule, but I'm not a complete ass.
Re: GoScintilla - 1.0 (PB 4.4 only)
Hi srod, have you noticed that if you press ctrl+s, ctrl+f, ctrl+g strange symbols appear?
Re: GoScintilla - 1.0 (PB 4.4 only)
Quote from the Scintilla documentation...Justin wrote:Hi srod, have you noticed that if you press ctrl+s, ctrl+f, ctrl+g strange symbols appear?
By default, Scintilla displays control characters (characters with codes less than 32) in a rounded rectangle as ASCII mnemonics: "NUL", "SOH", "STX", "ETX", "EOT", "ENQ", "ACK", "BEL", "BS", "HT", "LF", "VT", "FF", "CR", "SO", "SI", "DLE", "DC1", "DC2", "DC3", "DC4", "NAK", "SYN", "ETB", "CAN", "EM", "SUB", "ESC", "FS", "GS", "RS", "US". These mnemonics come from the early days of signaling, though some are still used (LF = Line Feed, BS = Back Space, CR = Carriage Return, for example).
To remove these you can either mess around with the #SCI_SETCONTROLCHARSYMBOL message and change the #STYLE_CONTROLCHAR style (font, color etc.) Alternatively add a keyboard shortcut which can be used to swallow individual characters. For example, AddKeyboardShortcut(0, #PB_Shortcut_Control|#PB_Shortcut_F, 10000) will swallow Ctrl-F etc. Just check for the active gadget and so on.
I think the PB IDE uses a combination of these things.
btw, GoScintilla 2 is nearly complete. This has code-completion, nested call-tips as well as a few other useful
I may look like a mule, but I'm not a complete ass.
Re: GoScintilla - 1.0 (PB 4.4 only)
It was easier for me to subclass the control and handle the WM_CHAR message, it works well.
GoScintilla 2 are great news, i'm looking forward to it, thanks.
GoScintilla 2 are great news, i'm looking forward to it, thanks.
Code: Select all
case #WM_CHAR
if wParam<32
procedurereturn 0
else
procedurereturn CallWindowProc_(oldProc, hwnd, msg, wParam, lParam)
endif



