How to make a text margin in Scintilla?

325 views Asked by At

I'm currently making a class wrapper in AutoHotkey for Scintilla (currently v5.0.1). I'm not sure what issue I'm having trying to make a text margin. It seems it should be incredibly simple. I'm just asking for help with order of operations using Scintilla (not for AHK help).

I'm trying to perform the following:

ctl := g.AddScintilla("vMyScintilla w500 h500")

m1 := ctl.Margin     ; isolate Margin object from control (used internally)
m1.ID := 1           ; selecting margin ID (used internally by the class)
m1.Width := 100      ; setting margin width (SCI_SETMARGINWIDTHN)
m1.Type := 4         ; set margin type 4, text margin (SCI_SETMARGINTYPEN)
m1.Text(1,"asdf")    ; SCI_MARGINSETTEXT (insert text to line 1)

msgbox m1.Text(1)    ; try to get text from margin line 1 ... "asdf"

I see the margin extend itself to 100px as specified in the code (hard to miss). I left everything as 0-based, so margin 1 is the symbol margin after the number margin.

The msgbox at the end shows the text i put in the margin, so it appears to succeed, but the text is not displaying.

I have tried adding a style to the text with SCI_MARGINSETSTYLE, but it has had no effect. I've even changed my windows theme to make sure the text didn't happen to be the same color as the margin background, but that doesn't seem to be the case.

I get no errors from the AHK script.

I can't figure out what I'm missing. I've made it through over 50% of the Scintilla docs with no issues, but I'm stumped.

1

There are 1 answers

0
Jeb Dude On

It was laughably simple.

I was testing on a single line document. And I set my "test line" to 1, instead of 0 (because it's 0-based).