diff --git a/src/dlangui/core/editable.d b/src/dlangui/core/editable.d index f166fd4b..f61427fd 100644 --- a/src/dlangui/core/editable.d +++ b/src/dlangui/core/editable.d @@ -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); diff --git a/src/dlangui/widgets/editors.d b/src/dlangui/widgets/editors.d index a7fe4f4e..89585176 100644 --- a/src/dlangui/widgets/editors.d +++ b/src/dlangui/widgets/editors.d @@ -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; }