diff --git a/src/dlangide/ui/frame.d b/src/dlangide/ui/frame.d index 67ea836..0168dd9 100644 --- a/src/dlangide/ui/frame.d +++ b/src/dlangide/ui/frame.d @@ -341,6 +341,11 @@ class IDEFrame : AppFrame { _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); return _dockHost; diff --git a/src/dlangide/ui/outputpanel.d b/src/dlangide/ui/outputpanel.d index f997429..5f1efa0 100644 --- a/src/dlangide/ui/outputpanel.d +++ b/src/dlangide/ui/outputpanel.d @@ -3,16 +3,19 @@ module dlangide.ui.outputpanel; import dlangui; import dlangide.workspace.workspace; import dlangide.workspace.project; +import dlangide.ui.frame; import std.utf; import std.regex; import std.algorithm : startsWith; +import std.string; /// event listener to navigate by error/warning position interface CompilerLogIssueClickHandler { bool onCompilerLogIssueClick(dstring filename, int line, int column); } + /// Log widget with parsing of compiler output class CompilerLogWidget : LogWidget { @@ -113,20 +116,42 @@ class OutputPanel : DockWindow { protected CompilerLogWidget _logWidget; + TabWidget _tabs; + + @property TabWidget getTabs() { return _tabs;} + this(string id) { + _showCloseButton = false; + dockAlignment = DockAlignment.Bottom; super(id); - _caption.text = "Output"d; - dockAlignment = DockAlignment.Bottom; - } + + } 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.readOnly = true; - _logWidget.layoutHeight(FILL_PARENT).layoutHeight(FILL_PARENT); + _logWidget.layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT); _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) { _logWidget.appendText(msg); } @@ -159,4 +184,4 @@ class OutputPanel : DockWindow { return true; } -} +} \ No newline at end of file diff --git a/src/dlangide/ui/searchPanel.d b/src/dlangide/ui/searchPanel.d new file mode 100644 index 0000000..3b61abb --- /dev/null +++ b/src/dlangide/ui/searchPanel.d @@ -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; + } +} \ No newline at end of file