Second contribution

-
append / prepend text mode for GOSCI_SetText()
Code:
;General function options.
;Use with GOSCI_SetText()
Enumeration 0
#GOSCI_TEXT_RELOAD ; Replace the current text
#GOSCI_TEXT_RELOAD_CLEARUNDOSTACK ; Replace the current text and clear undo stack
#GOSCI_TEXT_APPEND ; Add text at the end of current text
#GOSCI_TEXT_PREPEND ; Insert text before the beginning of current text
EndEnumeration
;/////////////////////////////////////////////////////////////////////////////////
;The following function sets the text for the entire control.
;No return value.
Procedure GOSCI_SetText(id, text$, mode=#GOSCI_TEXT_RELOAD)
Protected utf8Buffer
If IsGadget(id) And GadgetType(id)=#PB_GadgetType_Scintilla
;Need to convert to utf-8 first.
utf8Buffer=AllocateMemory(StringByteLength(text$, #PB_UTF8)+1)
If utf8Buffer
PokeS(utf8Buffer, text$, -1, #PB_UTF8)
Select mode
Case #GOSCI_TEXT_APPEND
ScintillaSendMessage(id, #SCI_APPENDTEXT, MemorySize(utf8Buffer)-1, utf8Buffer)
Case #GOSCI_TEXT_PREPEND
ScintillaSendMessage(id, #SCI_INSERTTEXT, 0, utf8Buffer)
Case #GOSCI_TEXT_RELOAD, #GOSCI_TEXT_RELOAD_CLEARUNDOSTACK
ScintillaSendMessage(id, #SCI_SETTEXT, 0, utf8Buffer)
If #GOSCI_TEXT_RELOAD_CLEARUNDOSTACK
ScintillaSendMessage(id, #SCI_EMPTYUNDOBUFFER)
EndIf
EndSelect
FreeMemory(utf8Buffer)
EndIf
EndIf
EndProcedure
;/////////////////////////////////////////////////////////////////////////////////
Here is a code sample :
Code:
;you have to active 'CREATE UNICODE EXECUTABLE' options
CompilerIf #PB_Compiler_Unicode
GOSCI_SetText(1, "ă prepended text", #GOSCI_TEXT_PREPEND)
GOSCI_SetText(1, "ă appended text", #GOSCI_TEXT_APPEND)
CompilerEndIf