Skip to content

Commit

Permalink
1.6.31b
Browse files Browse the repository at this point in the history
- solved #47 filtering / finding (next prev) - show progress
- busy cursor when this happens
- show progress in status bar
  • Loading branch information
jtorjo committed Jan 21, 2016
1 parent bf79c64 commit 14b1d57
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/docs/history.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
https://news.ycombinator.com/news (9 jan 2016)
quora

1.6.31b
- solved #47 filtering / finding (next prev) - show progress
- busy cursor when this happens
- show progress in status bar


1.6.31a
- find first/next/prev happen on a different thread
Expand Down
9 changes: 9 additions & 0 deletions src/lw_common/ui/log_view/log_view.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 51 additions & 1 deletion src/lw_common/ui/log_view/log_view.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ public partial class log_view : UserControl, IDisposable
// last time we received the last scroll event
private DateTime scrolling_time_ = DateTime.MinValue;

private int is_searching_ = 0;

public log_view(Form parent, string name)
{
Debug.Assert(parent is log_view_parent);
Expand Down Expand Up @@ -363,6 +365,25 @@ public log_view(Form parent, string name)
get { return filter_; }
}

private string last_search_status_ = "";
public string search_status {
get {
string status = "";
if (is_searching_ > 0)
status = "Seaching " + cur_search.friendly_name;
else if (model_.is_running_filter)
status = "Running Filter";

if (status != "") {
string suffix = new string('.', DateTime.Now.Second % 5);
status += " " + suffix;
}
bool was_seaching = last_search_status_ != "";
last_search_status_ = status;
// after search complete, return ' ', so that we clear the search status visually
return was_seaching && status == "" ? " " : status;
}
}
private filter.match create_match_object(BitArray matches, font_info font, line line, int line_idx) {
return is_full_log ? new full_log_match_item(matches, font, line, line_idx, this) : new match_item(matches, font, line, line_idx, this);
}
Expand Down Expand Up @@ -1590,6 +1611,11 @@ public enum select_type {


public async void search_next() {
if (is_searching_ > 0) {
// we're already searching (asynchronously)
util.beep(util.beep_type.err);
return;
}
/* 1.2.7+ implemented f3/shift-f3 on smart-edit first
note: this will never replace search form -> since there you can have extra settings: regexes, case-sensitivity ,full word
*/
Expand All @@ -1600,15 +1626,22 @@ public enum select_type {

string sel_text = edit.sel_text.ToLower();
await Task.Run((() => {
++is_searching_ ;
if (cur_search_ != null || sel_text != "")
search_for_text_next();
else if (cur_filter_row_idx_ >= 0)
search_for_next_match(cur_filter_row_idx_);
--is_searching_ ;
}));
lv_parent.sel_changed(log_view_sel_change_type.search);
}

public async void search_prev() {
if (is_searching_ > 0) {
// we're already searching (asynchronously)
util.beep(util.beep_type.err);
return;
}
/* 1.2.7+ implemented f3/shift-f3 on smart-edit first
note: this will never replace search form -> since there you can have extra settings: regexes, case-sensitivity ,full word
*/
Expand All @@ -1619,16 +1652,24 @@ public enum select_type {

string sel_text = edit.sel_text.ToLower();
await Task.Run((() => {
++is_searching_;
if (cur_search_ != null || sel_text != "")
search_for_text_prev();
else if (cur_filter_row_idx_ >= 0)
search_for_prev_match(cur_filter_row_idx_);
--is_searching_;
}));
lv_parent.sel_changed(log_view_sel_change_type.search);
}

// note: starts from the next row, or, if on row zero -> starts from row zero
public async void search_for_text_first() {
if (is_searching_ > 0) {
// we're already searching (asynchronously)
util.beep(util.beep_type.err);
return;
}

if (item_count < 1)
return;
Debug.Assert(cur_search_ != null);
Expand All @@ -1646,7 +1687,11 @@ public enum select_type {
ensure_row_visible(0);
lv_parent.sel_changed(log_view_sel_change_type.search);
} else
await Task.Run(() => search_for_text_next());
await Task.Run(() => {
++is_searching_;
search_for_text_next();
--is_searching_;
});
}

private bool row_contains_search_text(int row_idx, List<int> visible_indexes) {
Expand Down Expand Up @@ -2451,5 +2496,10 @@ public enum export_type {
private void log_view_LocationChanged(object sender, EventArgs e) {
edit.update_ui();
}

private void updateCursor_Tick(object sender, EventArgs e) {
bool busy = is_searching_ > 0 || model_.is_running_filter;
list.Cursor = busy ? Cursors.WaitCursor : Cursors.IBeam;
}
}
}
3 changes: 3 additions & 0 deletions src/lw_common/ui/log_view/log_view.resx
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,7 @@
<metadata name="tip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="updateCursor.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>83, 17</value>
</metadata>
</root>
13 changes: 11 additions & 2 deletions src/lw_common/ui/log_view/match/log_view_data_source.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ internal class log_view_data_source : AbstractVirtualListDataSource, IDisposable

private int item_count_ = 0;

private bool is_running_filter_ = false;

public log_view_data_source(VirtualObjectListView lv, log_view parent ) : base(lv) {
lv_ = lv;
parent_ = parent;
Expand Down Expand Up @@ -244,6 +246,10 @@ internal class log_view_data_source : AbstractVirtualListDataSource, IDisposable
}
}

public bool is_running_filter {
get { return is_running_filter_; }
}


public void refresh() {
if ( items_.count == 0)
Expand All @@ -269,10 +275,13 @@ internal class log_view_data_source : AbstractVirtualListDataSource, IDisposable
}

// see what changed
if (filter_view)
if (filter_view) {
// the user toggled on filtering
is_running_filter_ = true;
run_filter(show_full_log);

is_running_filter_ = false;
}

lock (this) {
filter_view_ = filter_view_now_;
show_full_log_ = show_full_log_now_;
Expand Down
7 changes: 6 additions & 1 deletion src/ui/log_wizard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,12 @@ private void LogNinja_FormClosed(object sender, FormClosedEventArgs e)

try {
refresh_cur_log_view();
show_tips_.handle_tips();
var sel = selected_view();
string search_status = sel != null ? sel.search_status : "";
if ( search_status != "")
status.set_status(search_status);
else
show_tips_.handle_tips();
} catch (Exception e) {
logger.Error("Refresh error" + e.Message);
}
Expand Down

0 comments on commit 14b1d57

Please sign in to comment.