mirror of https://github.com/buggins/dlangide.git
Using only keyboard is now better supported for searching.
The appropiate fields are focused, old text highlighted, and pressing enter on result will open it
This commit is contained in:
parent
e9a668407c
commit
81581df3b9
|
@ -631,12 +631,18 @@ class IDEFrame : AppFrame {
|
||||||
Log.d("Opening Search Field");
|
Log.d("Opening Search Field");
|
||||||
import dlangide.ui.searchPanel;
|
import dlangide.ui.searchPanel;
|
||||||
int searchPanelIndex = _logPanel.getTabs.tabIndex("search");
|
int searchPanelIndex = _logPanel.getTabs.tabIndex("search");
|
||||||
|
SearchWidget searchPanel = null;
|
||||||
if(searchPanelIndex == -1) {
|
if(searchPanelIndex == -1) {
|
||||||
SearchWidget searchPanel = new SearchWidget("search", this);
|
searchPanel = new SearchWidget("search", this);
|
||||||
_logPanel.getTabs.addTab( searchPanel, "Search"d, null, true);
|
_logPanel.getTabs.addTab( searchPanel, "Search"d, null, true);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
searchPanel = cast(SearchWidget) _logPanel.getTabs.tabBody(searchPanelIndex);
|
||||||
|
}
|
||||||
_logPanel.getTabs.selectTab("search");
|
_logPanel.getTabs.selectTab("search");
|
||||||
//TODO: Focus search field
|
if(searchPanel !is null) {
|
||||||
|
searchPanel.focus();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return super.handleAction(a);
|
return super.handleAction(a);
|
||||||
|
|
|
@ -112,7 +112,7 @@ class SearchLogWidget : LogWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
override bool onMouseEvent(MouseEvent event) {
|
override bool onMouseEvent(MouseEvent event) {
|
||||||
super.onMouseEvent(event);
|
bool res = super.onMouseEvent(event);
|
||||||
if (event.action == MouseAction.ButtonDown && event.button == MouseButton.Left) {
|
if (event.action == MouseAction.ButtonDown && event.button == MouseButton.Left) {
|
||||||
int line = _caretPos.line;
|
int line = _caretPos.line;
|
||||||
if (searchResultClickHandler.assigned) {
|
if (searchResultClickHandler.assigned) {
|
||||||
|
@ -120,7 +120,18 @@ class SearchLogWidget : LogWidget {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
override bool onKeyEvent(KeyEvent event) {
|
||||||
|
if (event.action == KeyAction.KeyDown && event.keyCode == KeyCode.RETURN) {
|
||||||
|
int line = _caretPos.line;
|
||||||
|
if (searchResultClickHandler.assigned) {
|
||||||
|
searchResultClickHandler(line);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.onKeyEvent(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,10 +157,17 @@ class SearchWidget : TabWidget {
|
||||||
protected IDEFrame _frame;
|
protected IDEFrame _frame;
|
||||||
protected SearchMatchList[] _matchedList;
|
protected SearchMatchList[] _matchedList;
|
||||||
|
|
||||||
|
//Sets focus on result;
|
||||||
|
void focus() {
|
||||||
|
_findText.setFocus();
|
||||||
|
_findText.handleAction(new Action(EditorActions.SelectAll));
|
||||||
|
}
|
||||||
bool onFindButtonPressed(Widget source) {
|
bool onFindButtonPressed(Widget source) {
|
||||||
dstring txt = _findText.text;
|
dstring txt = _findText.text;
|
||||||
if (txt.length > 0)
|
if (txt.length > 0) {
|
||||||
findText(txt);
|
findText(txt);
|
||||||
|
_resultLog.setFocus();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,9 +244,9 @@ class SearchWidget : TabWidget {
|
||||||
|
|
||||||
switch (_searchScope.text) {
|
switch (_searchScope.text) {
|
||||||
case "File":
|
case "File":
|
||||||
auto currentFileItem = _frame._wsPanel.workspace.findSourceFileItem(_frame.currentEditor.filename);
|
SearchMatchList match = findMatches(_frame.currentEditor.filename, source);
|
||||||
if(currentFileItem !is null)
|
if(match.matches.length > 0)
|
||||||
taskPool.put(task(&searchInProject, currentFileItem, source));
|
_matchedList ~= match;
|
||||||
break;
|
break;
|
||||||
case "Project":
|
case "Project":
|
||||||
foreach(Project project; _frame._wsPanel.workspace.projects) {
|
foreach(Project project; _frame._wsPanel.workspace.projects) {
|
||||||
|
|
Loading…
Reference in New Issue