mirror of https://github.com/buggins/dlangide.git
Started work on search function and refactoring of output panel
This commit is contained in:
parent
ed758dcdd8
commit
7986220a0e
|
@ -341,6 +341,11 @@ class IDEFrame : AppFrame {
|
||||||
_logPanel.appendText(null, "cannot start dcd-server: code completion for D code will not work"d);
|
_logPanel.appendText(null, "cannot start dcd-server: code completion for D code will not work"d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
import dlangide.ui.searchPanel;
|
||||||
|
auto searchPanel = new SearchWidget("search", this);
|
||||||
|
|
||||||
|
_logPanel.getTabs.addTab( searchPanel, "Search"d, null, true);
|
||||||
|
|
||||||
_dockHost.addDockedWindow(_logPanel);
|
_dockHost.addDockedWindow(_logPanel);
|
||||||
|
|
||||||
return _dockHost;
|
return _dockHost;
|
||||||
|
|
|
@ -3,16 +3,19 @@ module dlangide.ui.outputpanel;
|
||||||
import dlangui;
|
import dlangui;
|
||||||
import dlangide.workspace.workspace;
|
import dlangide.workspace.workspace;
|
||||||
import dlangide.workspace.project;
|
import dlangide.workspace.project;
|
||||||
|
import dlangide.ui.frame;
|
||||||
|
|
||||||
import std.utf;
|
import std.utf;
|
||||||
import std.regex;
|
import std.regex;
|
||||||
import std.algorithm : startsWith;
|
import std.algorithm : startsWith;
|
||||||
|
import std.string;
|
||||||
|
|
||||||
/// event listener to navigate by error/warning position
|
/// event listener to navigate by error/warning position
|
||||||
interface CompilerLogIssueClickHandler {
|
interface CompilerLogIssueClickHandler {
|
||||||
bool onCompilerLogIssueClick(dstring filename, int line, int column);
|
bool onCompilerLogIssueClick(dstring filename, int line, int column);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Log widget with parsing of compiler output
|
/// Log widget with parsing of compiler output
|
||||||
class CompilerLogWidget : LogWidget {
|
class CompilerLogWidget : LogWidget {
|
||||||
|
|
||||||
|
@ -113,20 +116,42 @@ class OutputPanel : DockWindow {
|
||||||
|
|
||||||
protected CompilerLogWidget _logWidget;
|
protected CompilerLogWidget _logWidget;
|
||||||
|
|
||||||
|
TabWidget _tabs;
|
||||||
|
|
||||||
|
@property TabWidget getTabs() { return _tabs;}
|
||||||
|
|
||||||
this(string id) {
|
this(string id) {
|
||||||
super(id);
|
_showCloseButton = false;
|
||||||
_caption.text = "Output"d;
|
|
||||||
dockAlignment = DockAlignment.Bottom;
|
dockAlignment = DockAlignment.Bottom;
|
||||||
|
super(id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override protected Widget createBodyWidget() {
|
override protected Widget createBodyWidget() {
|
||||||
|
_tabs = new TabWidget("OutputPanelTabs");
|
||||||
|
_tabs.setStyles(STYLE_DOCK_HOST_BODY, STYLE_TAB_UP_DARK, STYLE_TAB_UP_BUTTON_DARK, STYLE_TAB_UP_BUTTON_DARK_TEXT);
|
||||||
|
|
||||||
_logWidget = new CompilerLogWidget("logwidget");
|
_logWidget = new CompilerLogWidget("logwidget");
|
||||||
_logWidget.readOnly = true;
|
_logWidget.readOnly = true;
|
||||||
_logWidget.layoutHeight(FILL_PARENT).layoutHeight(FILL_PARENT);
|
_logWidget.layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT);
|
||||||
_logWidget.compilerLogIssueClickHandler = &onIssueClick;
|
_logWidget.compilerLogIssueClickHandler = &onIssueClick;
|
||||||
return _logWidget;
|
|
||||||
|
_tabs.addTab(_logWidget, "Compiler Log"d);
|
||||||
|
_tabs.selectTab("logwidget");
|
||||||
|
|
||||||
|
return _tabs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override protected void init() {
|
||||||
|
|
||||||
|
styleId = STYLE_DOCK_WINDOW;
|
||||||
|
_bodyWidget = createBodyWidget();
|
||||||
|
_bodyWidget.styleId = STYLE_DOCK_WINDOW_BODY;
|
||||||
|
addChild(_bodyWidget);
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: Refactor OutputPanel to expose CompilerLogWidget
|
||||||
|
|
||||||
void appendText(string category, dstring msg) {
|
void appendText(string category, dstring msg) {
|
||||||
_logWidget.appendText(msg);
|
_logWidget.appendText(msg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
module dlangide.ui.searchPanel;
|
||||||
|
|
||||||
|
import dlangide.ui.frame;
|
||||||
|
import dlangui;
|
||||||
|
|
||||||
|
class SearchWidget : TabWidget {
|
||||||
|
HorizontalLayout _layout;
|
||||||
|
EditLine _findText;
|
||||||
|
LogWidget _resultLog;
|
||||||
|
|
||||||
|
|
||||||
|
protected IDEFrame _frame;
|
||||||
|
|
||||||
|
this(string ID, IDEFrame frame) {
|
||||||
|
super(ID);
|
||||||
|
_frame = frame;
|
||||||
|
|
||||||
|
//Remove title, more button
|
||||||
|
removeAllChildren();
|
||||||
|
|
||||||
|
_layout = new HorizontalLayout();
|
||||||
|
_layout.addChild(new TextWidget("FindLabel", "Find: "d));
|
||||||
|
|
||||||
|
_findText = new EditLine();
|
||||||
|
_findText.padding(Rect(5,4,50,4));
|
||||||
|
_findText.layoutWidth(400);
|
||||||
|
_layout.addChild(_findText);
|
||||||
|
|
||||||
|
auto goButton = new ImageButton("findTextButton", "edit-redo");
|
||||||
|
goButton.addOnClickListener( delegate(Widget) {
|
||||||
|
findText(_findText.text);
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
_layout.addChild(goButton);
|
||||||
|
addChild(_layout);
|
||||||
|
|
||||||
|
_resultLog = new LogWidget("SearchLogWidget");
|
||||||
|
_resultLog.layoutHeight(FILL_PARENT);
|
||||||
|
addChild(_resultLog);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool findText(dstring source) {
|
||||||
|
struct SearchMatch {
|
||||||
|
int line;
|
||||||
|
long col;
|
||||||
|
string fileName;
|
||||||
|
}
|
||||||
|
|
||||||
|
import std.string;
|
||||||
|
SearchMatch[] matches;
|
||||||
|
//TODO Should not crash when in homepage.
|
||||||
|
foreach(int lineIndex, dstring line; _frame.currentEditor.content.lines) {
|
||||||
|
auto colIndex = line.indexOf(source);
|
||||||
|
if( colIndex != -1) {
|
||||||
|
matches ~= SearchMatch(lineIndex+1, colIndex, "");
|
||||||
|
_resultLog.appendText( " " ~ to!dstring(matches[$-1]) ~ '\n');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// _resultLog.text = "";
|
||||||
|
// if(matches.length > 1){
|
||||||
|
// _resultLog.appendText(to!dstring(matches[0].line));
|
||||||
|
// }
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue