mirror of https://github.com/buggins/dlangui.git
editors: modification marks for lines support, part 2
This commit is contained in:
parent
e7fe0e818c
commit
9194cecd12
|
@ -458,6 +458,7 @@ class EditableContent {
|
||||||
|
|
||||||
/// call listener to say that whole content is replaced e.g. by loading from file
|
/// call listener to say that whole content is replaced e.g. by loading from file
|
||||||
void notifyContentReplaced() {
|
void notifyContentReplaced() {
|
||||||
|
clearEditMarks();
|
||||||
TextRange rangeBefore;
|
TextRange rangeBefore;
|
||||||
TextRange rangeAfter;
|
TextRange rangeAfter;
|
||||||
// notify about content change
|
// notify about content change
|
||||||
|
@ -532,6 +533,7 @@ class EditableContent {
|
||||||
/// clear content
|
/// clear content
|
||||||
void clear() {
|
void clear() {
|
||||||
clearUndo();
|
clearUndo();
|
||||||
|
clearEditMarks();
|
||||||
_lines.length = 0;
|
_lines.length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -704,7 +706,7 @@ class EditableContent {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// inserts or removes lines, removes text in range
|
/// inserts or removes lines, removes text in range
|
||||||
protected void replaceRange(TextRange before, TextRange after, dstring[] newContent) {
|
protected void replaceRange(TextRange before, TextRange after, dstring[] newContent, EditStateMark[] marks = null) {
|
||||||
dstring firstLineBefore = line(before.start.line);
|
dstring firstLineBefore = line(before.start.line);
|
||||||
dstring lastLineBefore = before.singleLine ? firstLineBefore : line(before.end.line);
|
dstring lastLineBefore = before.singleLine ? firstLineBefore : line(before.end.line);
|
||||||
dstring firstLineHead = before.start.pos > 0 && before.start.pos <= firstLineBefore.length ? firstLineBefore[0..before.start.pos] : ""d;
|
dstring firstLineHead = before.start.pos > 0 && before.start.pos <= firstLineBefore.length ? firstLineBefore[0..before.start.pos] : ""d;
|
||||||
|
@ -720,6 +722,10 @@ class EditableContent {
|
||||||
removeLines(before.start.line + 1, linesBefore - linesAfter);
|
removeLines(before.start.line + 1, linesBefore - linesAfter);
|
||||||
}
|
}
|
||||||
for (int i = after.start.line; i <= after.end.line; i++) {
|
for (int i = after.start.line; i <= after.end.line; i++) {
|
||||||
|
if (marks) {
|
||||||
|
if (i - after.start.line < marks.length)
|
||||||
|
_editMarks[i] = marks[i - after.start.line];
|
||||||
|
}
|
||||||
dstring newline = newContent[i - after.start.line];
|
dstring newline = newContent[i - after.start.line];
|
||||||
if (i == after.start.line && i == after.end.line) {
|
if (i == after.start.line && i == after.end.line) {
|
||||||
dchar[] buf;
|
dchar[] buf;
|
||||||
|
@ -926,9 +932,10 @@ class EditableContent {
|
||||||
TextRange rangeBefore = op.newRange;
|
TextRange rangeBefore = op.newRange;
|
||||||
dstring[] oldcontent = op.content;
|
dstring[] oldcontent = op.content;
|
||||||
dstring[] newcontent = op.oldContent;
|
dstring[] newcontent = op.oldContent;
|
||||||
|
EditStateMark[] newmarks = op.oldEditMarks;
|
||||||
TextRange rangeAfter = op.range;
|
TextRange rangeAfter = op.range;
|
||||||
//Log.d("Undoing op rangeBefore=", rangeBefore, " contentBefore=`", oldcontent, "` rangeAfter=", rangeAfter, " contentAfter=`", newcontent, "`");
|
//Log.d("Undoing op rangeBefore=", rangeBefore, " contentBefore=`", oldcontent, "` rangeAfter=", rangeAfter, " contentAfter=`", newcontent, "`");
|
||||||
replaceRange(rangeBefore, rangeAfter, newcontent);
|
replaceRange(rangeBefore, rangeAfter, newcontent, newmarks);
|
||||||
handleContentChange(op, rangeBefore, rangeAfter, this);
|
handleContentChange(op, rangeBefore, rangeAfter, this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -317,6 +317,7 @@ class Window {
|
||||||
static immutable int PERFORMANCE_LOGGING_THRESHOLD_MS = 20;
|
static immutable int PERFORMANCE_LOGGING_THRESHOLD_MS = 20;
|
||||||
|
|
||||||
void onDraw(DrawBuf buf) {
|
void onDraw(DrawBuf buf) {
|
||||||
|
try {
|
||||||
bool needDraw = false;
|
bool needDraw = false;
|
||||||
bool needLayout = false;
|
bool needLayout = false;
|
||||||
bool animationActive = false;
|
bool animationActive = false;
|
||||||
|
@ -366,6 +367,9 @@ class Window {
|
||||||
if (animationActive)
|
if (animationActive)
|
||||||
scheduleAnimation();
|
scheduleAnimation();
|
||||||
_actionsUpdateRequested = false;
|
_actionsUpdateRequested = false;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.e("Exception inside winfow.onDraw: ", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// after drawing, call to schedule redraw if animation is active
|
/// after drawing, call to schedule redraw if animation is active
|
||||||
|
|
|
@ -196,8 +196,8 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction
|
||||||
protected uint _leftPaneLineNumberColor = 0x4060D0;
|
protected uint _leftPaneLineNumberColor = 0x4060D0;
|
||||||
protected uint _leftPaneLineNumberBackgroundColor = 0xF0F0F0;
|
protected uint _leftPaneLineNumberBackgroundColor = 0xF0F0F0;
|
||||||
protected uint _iconsPaneWidth = 16;
|
protected uint _iconsPaneWidth = 16;
|
||||||
protected uint _foldingPaneWidth = 16;
|
protected uint _foldingPaneWidth = 12;
|
||||||
protected uint _modificationMarksPaneWidth = 8;
|
protected uint _modificationMarksPaneWidth = 4;
|
||||||
/// when true, call measureVisibileText on next layout
|
/// when true, call measureVisibileText on next layout
|
||||||
protected bool _contentChanged = true;
|
protected bool _contentChanged = true;
|
||||||
|
|
||||||
|
@ -249,7 +249,7 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction
|
||||||
buf.fillRect(rc, 0xFFD040);
|
buf.fillRect(rc, 0xFFD040);
|
||||||
} else if (m == EditStateMark.saved) {
|
} else if (m == EditStateMark.saved) {
|
||||||
// modified, not saved
|
// modified, not saved
|
||||||
buf.fillRect(rc, 0x80FF60);
|
buf.fillRect(rc, 0x20C020);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue