Neil,
>
> If you mean whether the line has been modified and whether the
> modification has been saved (Visual Studio yellow / green margin
> states) then Scintilla does not keep such information.
>
> I wrote up an attempt at a change bar feature a while ago as
> "Experimental change bar feature" (can be found with google). The
> conclusion is that I couldn't find a way to do this that worked well
> enough to include in Scintilla.
I track undo/redo stat myself on each line, then use SCI_SETLINESTATE/
SCI_GETLINESTATE to write/read line undo state :
bool isProcessed = false;
int fromLine = _pEditView->execute(SCI_LINEFROMPOSITION, notification-
>position);
if ((notification->modificationType & (SC_MOD_DELETETEXT |
SC_MOD_INSERTTEXT)) &&
(notification->modificationType & SC_PERFORMED_USER))
{
//printStr(TEXT("user type"));
int undolevel = _pEditView->execute(SCI_GETLINESTATE, fromLine);
if (undolevel < 0)
undolevel = 0;
_pEditView->execute(SCI_SETLINESTATE, fromLine, ++undolevel);
_pEditView->execute(SCI_MARKERADD, fromLine,
MARK_LINEMODIFIEDUNSAVED);
if (notification->linesAdded > 0)
{
for (int i = 0 ; i < notification->linesAdded ; i++)
{
_pEditView->execute(SCI_MARKERADD, ++fromLine,
MARK_LINEMODIFIEDUNSAVED);
}
}
}
if ((notification->modificationType & (SC_MOD_DELETETEXT |
SC_MOD_INSERTTEXT)) &&
(notification->modificationType & SC_PERFORMED_REDO) &&
(notification->modificationType & SC_MULTISTEPUNDOREDO))
{
//printStr(TEXT("redo multiple"));
isProcessed = true;
int undolevel = _pEditView->execute(SCI_GETLINESTATE, fromLine);
if (undolevel < 0)
undolevel = 0;
_pEditView->execute(SCI_SETLINESTATE, fromLine, ++undolevel);
_pEditView->execute(SCI_MARKERADD, fromLine,
MARK_LINEMODIFIEDUNSAVED);
if (notification->linesAdded > 0)
{
for (int i = 0 ; i < notification->linesAdded ; i++)
{
_pEditView->execute(SCI_MARKERADD, ++fromLine,
MARK_LINEMODIFIEDUNSAVED);
}
}
}
if ((notification->modificationType & (SC_MOD_DELETETEXT |
SC_MOD_INSERTTEXT)) &&
(notification->modificationType & SC_PERFORMED_UNDO) &&
(notification->modificationType & SC_MULTISTEPUNDOREDO))
{
//printStr(TEXT("undo multiple"));
isProcessed = true;
int undolevel = _pEditView->execute(SCI_GETLINESTATE, fromLine);
if (undolevel > 0)
--undolevel;
else
undolevel = 0;
_pEditView->execute(SCI_SETLINESTATE, fromLine, undolevel);
}
if ((notification->modificationType & (SC_MOD_DELETETEXT |
SC_MOD_INSERTTEXT)) &&
(notification->modificationType & SC_PERFORMED_REDO) &&
(notification->modificationType & SC_LASTSTEPINUNDOREDO) && !
isProcessed)
{
//printStr(TEXT("redo LASTO"));
int undolevel = _pEditView->execute(SCI_GETLINESTATE, fromLine);
if (undolevel < 0)
undolevel = 0;
_pEditView->execute(SCI_SETLINESTATE, fromLine, ++undolevel);
_pEditView->execute(SCI_MARKERADD, fromLine,
MARK_LINEMODIFIEDUNSAVED);
if (notification->linesAdded > 0)
{
for (int i = 0 ; i < notification->linesAdded ; i++)
{
_pEditView->execute(SCI_MARKERADD, ++fromLine,
MARK_LINEMODIFIEDUNSAVED);
}
}
}
if ((notification->modificationType & (SC_MOD_DELETETEXT |
SC_MOD_INSERTTEXT)) &&
(notification->modificationType & SC_PERFORMED_UNDO) &&
(notification->modificationType & SC_LASTSTEPINUNDOREDO) && !
isProcessed)
{
//printStr(TEXT("undo LASTO"));
int undolevel = _pEditView->execute(SCI_GETLINESTATE, fromLine);
if (undolevel > 0)
--undolevel;
else
undolevel = 0;
_pEditView->execute(SCI_SETLINESTATE, fromLine, undolevel);
}
if (notification->modificationType & SC_MOD_CHANGELINESTATE)
{
int undolevel = _pEditView->execute(SCI_GETLINESTATE, notification-
>line);
if (undolevel == 0)
{
_pEditView->execute(SCI_MARKERDELETE, notification->line,
MARK_LINEMODIFIEDUNSAVED);
}
}
It works pretty good, except for the xml/html document - undolevel is
not zero even there's nothing to undo for this line.
I guess it's due to xml/html style set to 7 bits instead of 5 bits,
but I don't see why.
Do you have any idea to walk around it?
Regards,
Don