Make current line number stand out?

26 views
Skip to first unread message

Andrew Truckle

unread,
May 25, 2024, 10:23:58 AMMay 25
to scintilla-interest
In Visual Studio the current line number stands out with bold text:

LineNumbers.png

Can we do this with Scintilla? I can see STYLE_LINENUMBER in the documentation. At the moment the current line number is not distinguished from the rest:

LineNumbers2.png

Thank you in advance.

Neil Hodgson

unread,
May 25, 2024, 5:53:50 PMMay 25
to scintilla...@googlegroups.com
Andrew Truckle:
In Visual Studio the current line number stands out with bold text:

Can we do this with Scintilla? I can see STYLE_LINENUMBER in the documentation. At the moment the current line number is not distinguished from the rest:

Not easily. Text margins could be used but the application would have to track the selection.

Neil

Andrew Truckle

unread,
May 26, 2024, 4:35:03 AMMay 26
to scintilla-interest
On Saturday 25 May 2024 at 22:53:50 UTC+1 Neil wrote:

Not easily. Text margins could be used but the application would have to track the selection.

 OK. I did ask OpenAI and it suggests doing this instead:

// Set the caret line background color (RGB format)
COLORREF caretLineColor = RGB(240, 240, 240); // Light gray color
SendMessage(hScintilla, SCI_SETCARETLINEBACK, caretLineColor, 0);

// Optionally, set the caret line background transparency (0 to 255)
int alpha = 100; // Transparency level (0 = fully transparent, 255 = fully opaque)
SendMessage(hScintilla, SCI_SETCARETLINEBACKALPHA, alpha, 0);

So I think I'll give it a go. Although I am concerned about possibly clashing with syntax text colours. We'll see.

Andrew Truckle

unread,
May 26, 2024, 7:24:42 AMMay 26
to scintilla-interest
On Sunday 26 May 2024 at 09:35:03 UTC+1 Andrew Truckle wrote:
 OK. I did ask OpenAI and it suggests doing this instead:

// Set the caret line background color (RGB format)
COLORREF caretLineColor = RGB(240, 240, 240); // Light gray color
SendMessage(hScintilla, SCI_SETCARETLINEBACK, caretLineColor, 0);

// Optionally, set the caret line background transparency (0 to 255)
int alpha = 100; // Transparency level (0 = fully transparent, 255 = fully opaque)
SendMessage(hScintilla, SCI_SETCARETLINEBACKALPHA, alpha, 0);

So I think I'll give it a go. Although I am concerned about possibly clashing with syntax text colours. We'll see.

I tried:

// Set the caret line background color (RGB format)
COLORREF caretLineColor = RGB(240, 240, 240); // Light gray color
m_edit.SetElementColour(Scintilla::Element::CaretLineBack, caretLineColor);

And that seems to be sufficient:

LineNumbers3.png

There appears to be no clashes with syntax colours (at this stage). I was unable to try the SCI_SETCARETLINEBACKALPHA suggestion as I could not work out how to port it to my MFC wrapper. But I don't think I need to anyway. 😊
Reply all
Reply to author
Forward
0 new messages