mirror of https://github.com/buggins/dlangui.git
delete line by Ctrl+Y, insert new line by Ctrl+Enter
This commit is contained in:
parent
688866b017
commit
15c911b7bd
|
@ -598,6 +598,16 @@ class EditableContent {
|
||||||
return TextPosition(lineIndex, lineLength(lineIndex));
|
return TextPosition(lineIndex, lineLength(lineIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// returns text position for begin of line lineIndex
|
||||||
|
TextPosition lineBegin(int lineIndex) {
|
||||||
|
return TextPosition(lineIndex, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// returns text range for whole line lineIndex
|
||||||
|
TextRange lineRange(int lineIndex) {
|
||||||
|
return TextRange(TextPosition(lineIndex, 0), lineIndex < _lines.length - 1 ? lineBegin(lineIndex + 1) : lineEnd(lineIndex));
|
||||||
|
}
|
||||||
|
|
||||||
/// returns position before first non-space character of line, returns 0 position if no non-space chars
|
/// returns position before first non-space character of line, returns 0 position if no non-space chars
|
||||||
TextPosition firstNonSpace(int lineIndex) {
|
TextPosition firstNonSpace(int lineIndex) {
|
||||||
dstring s = line(lineIndex);
|
dstring s = line(lineIndex);
|
||||||
|
|
|
@ -1980,6 +1980,29 @@ class EditBox : EditWidgetBase {
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
case EditorActions.ToggleLineComment:
|
||||||
|
// TODO
|
||||||
|
return true;
|
||||||
|
case EditorActions.ToggleBlockComment:
|
||||||
|
// TODO
|
||||||
|
return true;
|
||||||
|
case EditorActions.InsertLine:
|
||||||
|
{
|
||||||
|
correctCaretPos();
|
||||||
|
TextPosition p = _content.lineEnd(_caretPos.line);
|
||||||
|
TextRange r = TextRange(p, p);
|
||||||
|
EditOperation op = new EditOperation(EditAction.Replace, r, [""d, ""d]);
|
||||||
|
_content.performOperation(op, this);
|
||||||
|
_caretPos = oldCaretPos;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
case EditorActions.DeleteLine:
|
||||||
|
{
|
||||||
|
correctCaretPos();
|
||||||
|
EditOperation op = new EditOperation(EditAction.Replace, _content.lineRange(_caretPos.line), [""d]);
|
||||||
|
_content.performOperation(op, this);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue