editors find / replace enhancements

This commit is contained in:
Vadim Lopatin 2017-09-05 10:27:04 +03:00
parent b65fa61272
commit ddf9b82a18
2 changed files with 16 additions and 2 deletions

View File

@ -1254,6 +1254,18 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction
return true;
}
/// returns current selection range
@property TextRange selectionRange() {
return _selectionRange;
}
/// sets current selection range
@property void selectionRange(TextRange range) {
if (range.empty)
return;
_selectionRange = range;
_caretPos = range.end;
}
/// override to handle specific actions state (e.g. change enabled state for supported actions)
override bool handleActionStateRequest(const Action a) {
switch (a.id) with(EditorActions)
@ -3462,7 +3474,9 @@ class FindPanel : HorizontalLayout {
TextPosition pos = _editor.caretPos;
bool res = _editor.findNextPattern(pos, currentText, _cbCaseSensitive.checked, back ? -1 : 1);
if (res) {
_editor.setCaretPos(pos.line, pos.pos, true);
_editor.selectionRange = TextRange(pos, TextPosition(pos.line, pos.pos + cast(int)currentText.length));
_editor.ensureCaretVisible();
//_editor.setCaretPos(pos.line, pos.pos, true);
}
}

View File

@ -12,7 +12,7 @@
<color id="editor_matching_bracket_highlight" value="#60FFE0B0"/>
<color id="editor_selection_focused" value="#B060A0FF"/>
<color id="editor_selection_normal" value="#D060A0FF"/>
<color id="editor_search_highlight_current" value="#60FFC040"/>
<color id="editor_search_highlight_current" value="#60A0C0FF"/>
<color id="editor_search_highlight_other" value="#90F0D080"/>
<color id="editor_left_pane_background" value="#F4F4F4"/>
<color id="editor_left_pane_background2" value="#FFFFFF"/>