I am finding myself once again spending inordinate amounts of time dealing with [non-]stickyness of markers... yes, as is often observed, they are hard to get "right" (read: "please everybody"). :)

BUT, I have a suggestion/request for a [shudder] new Scintilla primitive: RestoreMark. This is the symmetric "other side" of the GetMark call which returns the set/mask of the marker numbers that are present on a given line.

In detail, RestoreMark would take a line and a set/mask (presumably from a GetMark call) and sets all of the indicated markers at once. A key point to note is that, unlike multiple calls to AddMark, RestoreMark would NOT cause SC_MOD_CHANGEMARKER-flavored SCN_MODIFIED notifications to be issued...

Why RestoreMark? In "programming around" the Scintilla marker system, I often find it necessary to remove all markers from a line, do some line inserts/deletes, and then put all of the markers back (after deciding which is the line they should have been sticking to).

So, just being able to do this by handing the return from GetMark to a primitive to "restore" the markers is both convenient, because it saves multiple "interpret the mask" and Document-level AddMark sequences, AND it has the useful property of not generating unwanted change notifications ("unwanted" because of the nature of this as a "put things back" operation).

Possible sample implementation:

// in Editor.cxx:
        case SCI_MARKERRESTORE:
                pdoc->RestoreMark(wParam, lParam);
                InvalidateStyleData();
                RedrawSelMargin();
                break;

// in Document.h:
void RestoreMark(int line, int valueSet)
        { cb.RestoreMark(line, valueSet); }

// in CellBuffer.cxx:
// (note that these AddMarks do NOT cause change notifications)
void CellBuffer::RestoreMark(int line, int valueSet) {
        if ((line >= 0) && (line < lv.lines)) {
                unsigned int m = valueSet;
                for (int i = 0; m; i++, m >>= 1)
                        if (m & 1)
                                lv.AddMark(line, i);
        }
}

Comments?

Robert Roessler
[EMAIL PROTECTED]
http://www.rftp.com
_______________________________________________
Scintilla-interest mailing list
[email protected]
http://mailman.lyra.org/mailman/listinfo/scintilla-interest

Reply via email to