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));
|
||||
}
|
||||
|
||||
/// 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
|
||||
TextPosition firstNonSpace(int lineIndex) {
|
||||
dstring s = line(lineIndex);
|
||||
|
|
|
@ -1982,6 +1982,29 @@ class EditBox : EditWidgetBase {
|
|||
}
|
||||
}
|
||||
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;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue