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 :
Code:
Structure GoScintillaApis
id.i ;Scintilla#
fname$ ;Name of function or variable or ...
args$ ;Arguments of function.
sDecs$ ;Description of function.
EndStructure
add this in GoScintilla.pbi :
Code:
Global NewMap gGOSCI_Apis.GoScintillaApis()
Replace this with GOSCI_ScintillaCallBackXXX Procedure :
Code:
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
EndProcedure
replace this with _GoScintilla Structure :
Code:
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
EndStructure
replace this with GOSCI_Free procedure :
Code:
;/////////////////////////////////////////////////////////////////////////////////
;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:
;/////////////////////////////////////////////////////////////////////////////////
;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:
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
but anyway i think this is not works in Unicode mode. (i dont have info for using Unicode because i dont use unicode atall)