April 18, 2024, 01:14:57 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


How to use SCI_MARKERGET in scintilla?

Started by sapero, July 07, 2010, 05:48:46 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

sapero

I want to implement language independant auto-indentation. I can handle Enter key, to increment the indent, but have no idea how to unindent an "endif" like line.
I don't want to compare the text from editor with hardcoded keywords, or keyword-parts.

My editor has predefined markers for the folding. If there is an IF, a box-minus marker appears. On a line with endif, or '}' - there is an L marker (two lines).
My first idea was to detect a keystoke, and check if the marker changed to L, but SCI_MARKERGET always returns zero. So what do I need to do, to use this message?

Ficko

This is just an idea could be absolutely stupid. :P

You have somewhere the words defined for the syntax highlight and there must be an interseption allready for do the highlight.

What would be if you would define the "endwords" - endif, endselect ....- with additional out of range ASCII chars like : endif + chr$(1) or maybe just an extra LF.
You could hack the syntax highlight callback to check for this extra char(s). ;)

Ficko

July 08, 2010, 03:39:17 AM #2 Last Edit: July 08, 2010, 03:41:03 AM by Ficko
Ok I just recognized what you actually wrote.

Quote
...but SCI_MARKERGET always returns zero...

I found this sample may help: ::)

Quote
int nCurLine = GetCurrentLineNumber();
// what is the current line number?
int nState = SendEditor(SCI_MARKERGET, nCurLine); // what are
the markers on this line
if ( nState & (1 << SCINTILLA_BOOKMARK)) // is the
bookmark there?
{
SendEditor(SCI_MARKERDELETE, nCurLine, SCINTILLA_BOOKMARK); // delete it!
m_nBookmarks--;
if (m_nBookmarks < 0)
m_nBookmarks = 0;
}
else
{
SendEditor(SCI_MARKERADD, nCurLine, SCINTILLA_BOOKMARK); // add it!
m_nBookmarks++;
}

sapero

It seems that SCI_MARKERGET does not include auto-folding markers. I just saw in scintilla sources, that all folding markers, before drawing, are computed from fold level in the current and next line - editor.cxx -> Editor::PaintSelMargin -> find "Decide which fold indicator should be displayed".

Ficko

QuoteIt seems that SCI_MARKERGET does not include auto-folding markers..

I don't know about thet but they are "special":


Marker numbers 25 to 31 are used by Scintilla in folding margins, and have symbolic names of the form SC_MARKNUM_*, for example SC_MARKNUM_FOLDEROPEN.