Added comments and cleanup

This commit is contained in:
Hans-Albert Maritz 2015-03-10 15:28:15 +11:00
parent ceccd53123
commit 3c2d3d53d7
1 changed files with 9 additions and 6 deletions

View File

@ -2,11 +2,9 @@ module dlangide.ui.searchPanel;
import dlangui; import dlangui;
import dlangui.core.editable;
import dlangide.ui.frame; import dlangide.ui.frame;
import dlangide.ui.wspanel; import dlangide.ui.wspanel;
//import dlangui.widgets.tabs; //TODO: This is required for navigating to decleration of TabWidget / BUG
import dlangide.workspace.workspace; import dlangide.workspace.workspace;
import dlangide.workspace.project; import dlangide.workspace.project;
@ -17,8 +15,10 @@ interface SearchResultClickHandler {
bool onSearchResultClick(int line); bool onSearchResultClick(int line);
} }
//LogWidget with highlighting for search results.
class SearchLogWidget : LogWidget { class SearchLogWidget : LogWidget {
//Sends which line was clicked.
Signal!SearchResultClickHandler searchResultClickHandler; Signal!SearchResultClickHandler searchResultClickHandler;
this(string ID){ this(string ID){
@ -35,6 +35,8 @@ class SearchLogWidget : LogWidget {
uint flags = 0; uint flags = 0;
if (buf.length < txt.length) if (buf.length < txt.length)
buf.length = txt.length; buf.length = txt.length;
//Highlights the filename
if(txt.startsWith("Matches in ")) { if(txt.startsWith("Matches in ")) {
CustomCharProps[] colors = buf[0..txt.length]; CustomCharProps[] colors = buf[0..txt.length];
uint cl = defColor; uint cl = defColor;
@ -50,6 +52,7 @@ class SearchLogWidget : LogWidget {
} }
return colors; return colors;
} }
//Highlight line and collumn
else { else {
CustomCharProps[] colors = buf[0..txt.length]; CustomCharProps[] colors = buf[0..txt.length];
uint cl = filenameColor; uint cl = filenameColor;
@ -68,7 +71,7 @@ class SearchLogWidget : LogWidget {
colors[i].color = cl; colors[i].color = cl;
colors[i].textFlags = flags; colors[i].textFlags = flags;
//Colors to applay after current character. //Colors to apply in following iterations of the loop.
if(rest.startsWith("]")) { if(rest.startsWith("]")) {
cl = defColor; cl = defColor;
flags = 0; flags = 0;
@ -78,8 +81,6 @@ class SearchLogWidget : LogWidget {
} }
} }
auto getCaretPos() { return _caretPos; }
override bool onMouseEvent(MouseEvent event) { override bool onMouseEvent(MouseEvent event) {
super.onMouseEvent(event); super.onMouseEvent(event);
if (event.action == MouseAction.ButtonDown && event.button == MouseButton.Left) { if (event.action == MouseAction.ButtonDown && event.button == MouseButton.Left) {
@ -143,6 +144,7 @@ class SearchWidget : TabWidget {
addChild(_resultLog); addChild(_resultLog);
} }
//Recursively search for text in projectItem
void searchInProject(ProjectItem project, dstring text) { void searchInProject(ProjectItem project, dstring text) {
if (project.isFolder == true) { if (project.isFolder == true) {
ProjectFolder projFolder = cast(ProjectFolder) project; ProjectFolder projFolder = cast(ProjectFolder) project;
@ -197,6 +199,7 @@ class SearchWidget : TabWidget {
return true; return true;
} }
//Find the match/matchList that corrosponds to the line in _resultLog
bool onMatchClick(int line) { bool onMatchClick(int line) {
line++; line++;
foreach(matchList; _matchedList){ foreach(matchList; _matchedList){