Scintilla SCI_MARGINSETTEXT issue(s)
Posted: Mon Nov 10, 2014 1:33 am
Greetings,
I want to add text to margin, but when I try to do so, only first character appears instead of whole text?

Stupid me - I've sorted it out, I had to use MakeScintillaText(), naturally! The other question below still remains!
Also, I would like to make those margins permanent. Now, when I delete a line, marker (well, only first character, but hopefully this is correctable
) gets removed. How can I keep those permanent? I can preset length (number of lines) of this gadget, so it would have 36, 72 or whatever lines necessary, but without deleting those margins if possible.
I want to add text to margin, but when I try to do so, only first character appears instead of whole text?
Code: Select all
Procedure MakeScintillaText(text.s)
Static sciText.s
CompilerIf #PB_Compiler_Unicode
sciText = Space(StringByteLength(text, #PB_UTF8))
PokeS(@sciText, text, -1, #PB_UTF8)
CompilerElse
sciText = text
CompilerEndIf
ProcedureReturn @sciText
EndProcedure
If OpenWindow(0, 0, 0, 320, 240, "ScintillaGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If InitScintilla()
ScintillaGadget(0, 10, 10, 300, 220, #Null)
ScintillaSendMessage(0, #SCI_GETEDGEMODE, 1)
ScintillaSendMessage(0, #SCI_SETMARGINWIDTHN, 0, 16)
ScintillaSendMessage(0, #SCI_SETMARGINWIDTHN, 1, 0)
ScintillaSendMessage(0, #SCI_SETMARGINWIDTHN, 2, 0)
ScintillaSendMessage(0, #SCI_SETMARGINWIDTHN, 3, 0)
ScintillaSendMessage(0, #SCI_SETMARGINWIDTHN, 4, 50)
ScintillaSendMessage(0, #SCI_SETCARETLINEVISIBLE, 1)
ScintillaSendMessage(0, #SCI_SETCARETLINEVISIBLEALWAYS, 1)
ScintillaSendMessage(0, #SCI_SETCARETLINEBACKALPHA, 50)
ScintillaSendMessage(0, #SCI_SETCARETLINEBACK, RGB(100, 252, 195))
ScintillaSendMessage(0, #SCI_SETMARGINTYPEN, 4, #SC_MARGIN_TEXT)
; Generate random numbers and sort them
NewMap UniqueRandomMap()
NewList UniqueRandomList.i()
Text$ = ""
For i = 0 To 35
While MapSize(UniqueRandomMap()) < 7
AddMapElement(UniqueRandomMap(),Str(Random(90,1)))
Wend
ResetMap(UniqueRandomMap())
ForEach UniqueRandomMap()
AddElement(UniqueRandomList())
UniqueRandomList() = Val(MapKey(UniqueRandomMap()))
Next
SortList(UniqueRandomList(),#PB_Sort_Ascending)
ResetList(UniqueRandomList())
ForEach UniqueRandomList()
Text$ + UniqueRandomList() + " "
Next
Text$ = RTrim(Text$)
Text$ = RTrim(Text$)
If i <> 35 ; skip last line break
Text$ + #CRLF$
EndIf
ClearMap(UniqueRandomMap())
ClearList(UniqueRandomList())
Next
ScintillaSendMessage(0, #SCI_SETTEXT, 0, MakeScintillaText(Text$))
ScintillaSendMessage(0, #SCI_MARGINSETTEXT, 0, MakeScintillaText(":Batch 1"))
ScintillaSendMessage(0, #SCI_MARGINSETTEXT, 5, MakeScintillaText(":End"))
For i = 1 To 6
BatchBegin$ = ":Batch " + Str(i+1)
BatchEnd$ = ":End"
ScintillaSendMessage(0, #SCI_MARGINSETTEXT, i*6-1, MakeScintillaText(BatchEnd$))
ScintillaSendMessage(0, #SCI_MARGINSETTEXT, i*6, MakeScintillaText(BatchBegin$))
Next
EndIf
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Stupid me - I've sorted it out, I had to use MakeScintillaText(), naturally! The other question below still remains!
Also, I would like to make those margins permanent. Now, when I delete a line, marker (well, only first character, but hopefully this is correctable