private void toFilter_Click(object sender, EventArgs e) { search_ = current_search(); if (search_.fg == util.transparent) { var sel = new select_color_form("Filter Foreground Color", Color.Red); if (sel.ShowDialog() == DialogResult.OK) { fg.BackColor = sel.SelectedColor; search_ = current_search(); Debug.Assert(search_.fg != util.transparent); } else { // user did not select a foreground - this is required return; } } if (markAsNewEntry.Checked) { unique_search_id_ = 0; } search_.unique_id = unique_search_id_; wants_to_filter_ = true; DialogResult = DialogResult.OK; }
protected bool Equals(search_for other) { bool equals = case_sensitive == other.case_sensitive && full_word == other.full_word && String.Equals(text, other.text) && type == other.type && all_columns == other.all_columns; return equals; }
private void load_from_search(search_for search) { unique_search_id_ = search.unique_id; last_view_names_ = search.last_view_names.ToList(); fg.BackColor = search.fg; bg.BackColor = search.bg; caseSensitive.Checked = search.case_sensitive; fullWord.Checked = search.full_word; friendlyRegexName.Text = search.friendly_regex_name; switch (search.type) { case 0: radioAutoRecognize.Checked = true; break; case 1: radioText.Checked = true; break; case 2: radioRegex.Checked = true; break; default: Debug.Assert(false); break; } combo.Text = search.text; allColumns.Checked = search.all_columns; update_autorecognize_radio(); update_negate(); update_to_filter_button(); }
// FIXME use load_save internal static search_for load(string prefix) { var sett = app.inst.sett; int type = int.Parse(sett.get(prefix + ".type", "0")); Debug.Assert(type >= 0 && type <= 2); search_for cur = new search_for { fg = util.str_to_color(sett.get(prefix + ".fg", "transparent")), bg = util.str_to_color(sett.get(prefix + ".bg", DEFAULT_BG)), case_sensitive = sett.get(prefix + ".case_sensitive", "0") != "0", full_word = sett.get(prefix + ".full_word", "0") != "0", mark_lines_with_color = sett.get(prefix + ".mark_lines_with_color", "1") != "0", text = sett.get(prefix + ".text"), type = type, friendly_regex_name = sett.get(prefix + ".friendly_regex_name"), // FIXME i need more testing on split class //last_view_names = split.to_list( sett.get(prefix + ".last_view_names"), ",", split.type.use_any_quotes ).ToArray() last_view_names = sett.get(prefix + ".last_view_names").Split('|'), // 1.6.23+ - by default, don't search all columns - did profiling, and can take a looot of time (example: Event Log) all_columns = sett.get(prefix + ".all_columns", "0") != "0", negate = sett.get(prefix + ".negate", "0") != "0" }; return(cur); }
// saves this as being the last search public void save_last_search(search_for last) { Debug.Assert(last.unique_id >= 0); Debug.Assert(last.text != ""); if (last.text == "") return; // no text? // moves this search to the end! (which visually means - to the top) var exists = history_.FirstOrDefault(x => x.unique_id == last.unique_id); if (exists != null) history_.Remove(exists); else { // 1.4.9 - if we already have this search, just bring it to the top exists = history_.FirstOrDefault(x => x == last); if ( exists != null) history_.Remove(exists); } if (last.unique_id == 0) last.unique_id = ++next_unique_id_; history_.Add(last); while ( history_.Count > MAX_SEARCH_COUNT) history_.RemoveAt(0); // if it's from history, bring to top! save(); }
public static List< Tuple<int,int>> match_indexes(string line, search_for search) { if (search.use_regex && search.regex == null) // the regex is invalid return new List<Tuple<int, int>>(); if (search.use_regex) { var matches = search.regex.Match(line); if ( !matches.Success) return new List<Tuple<int, int>>(); List<Tuple<int, int>> result = new List<Tuple<int, int>>(); while (matches.Success) { result.Add( new Tuple<int, int>(matches.Index, matches.Length)); matches = matches.NextMatch(); } return result; } else { // case sensitive and/or full word string search_for = search.case_sensitive ? search.text : search.text.ToLower(); string search_line = search.case_sensitive ? line : line.ToLower(); if (search.full_word) return util.find_all_matches(search_line, search_for).Where( x => is_delim_or_does_not_exist(search_line, x - 1) && is_delim_or_does_not_exist(search_line, x + search_for.Length) ).Select(x => new Tuple<int,int>(x, search_for.Length)). ToList(); else return util.find_all_matches(search_line, search_for).Select(x => new Tuple<int,int>(x, search_for.Length)). ToList(); } }
public static bool matches(filter.match item, IEnumerable<info_type> cols, search_for search) { // 1.6.27+ faster way to find out if the message is contained - just look at the full message (instead of looking at each part) if (matches_cell(item.line.raw_full_msg(), search)) return cols.Any(x => matches_cell(item.line.part(x), search)); else return false; }
protected bool Equals(search_for other) { bool equals = case_sensitive == other.case_sensitive && full_word == other.full_word && String.Equals(text, other.text) && type == other.type && all_columns == other.all_columns; return(equals); }
private void ok_Click(object sender, EventArgs e) { if (combo.Text != "") { search_ = current_search(); if (markAsNewEntry.Checked) { unique_search_id_ = 0; } search_.unique_id = unique_search_id_; search_form_history.inst.save_last_search(search_); DialogResult = DialogResult.OK; } }
private void do_searches_thread_impl() { // first time, show all run_search(); this.async_call_and_wait(() => { rebuild_result(); update_preview_text(); }); while (!closed_) { Thread.Sleep(250); search_for cur = null; this.async_call_and_wait(() => { if (combo.DroppedDown) { return; } var cur_search = current_search(); if (prev_search_ == cur_search) { // nothing changed return; } cur = cur_search; prev_search_ = cur; preview.Text = "Computing [" + prev_search_ + "]"; }); if (cur == null) { continue; } logger.Info("[search] searching: " + cur.text); run_search(); this.async_call_and_wait(() => { rebuild_result(); update_preview_text(); }); logger.Info("[search] searching: " + cur.text + " - complete"); } }
/* Edit mode: * 1. if more than 1 entry, the combo is dropped down by default * 2. if you type any letter while the combo is first dropped down (or paste something), it will auto close the dropdown * 3. if you select any entry from the combo, you are EDITING that entry. If you don't select anything, you are ADDING */ // 1.2.7+ if there's something selected by the user, override what we had public search_form(Form parent, log_view lv, string smart_edit_search_for_text) { InitializeComponent(); TopMost = parent.TopMost; result.Font = lv.list.Font; lv_ = lv; render_ = new search_renderer(lv, this); history_ = search_form_history.inst.all_searches_cur_view_first(lv.name); // use the last ones... fg.BackColor = history_[0].fg; bg.BackColor = history_[0].bg; allColumns.Checked = history_[0].all_columns; load_combo(); find_result_columns(lv); if (smart_edit_search_for_text != "") { combo.Text = smart_edit_search_for_text; radioText.Checked = true; } update_autorecognize_radio(); update_negate(); update_to_filter_button(); prev_search_ = current_search(); util.postpone(() => { combo.Focus(); if (combo.Items.Count > 1) { dropped_first_time_ = true; combo.DroppedDown = true; } }, 1); new Thread(do_searches_thread) { IsBackground = true }.Start(); }
// FIXME use load_save internal static search_for load(string prefix) { var sett = app.inst.sett; int type = int.Parse(sett.get(prefix + ".type", "0")); Debug.Assert(type >= 0 && type <= 2); search_for cur = new search_for { fg = util.str_to_color(sett.get(prefix + ".fg", "transparent")), bg = util.str_to_color(sett.get(prefix + ".bg", "#faebd7")), case_sensitive = sett.get(prefix + ".case_sensitive", "0") != "0", full_word = sett.get(prefix + ".full_word", "0") != "0", mark_lines_with_color = sett.get(prefix + ".mark_lines_with_color", "1") != "0", text = sett.get(prefix + ".text"), type = type, friendly_regex_name = sett.get(prefix + ".friendly_regex_name"), // FIXME i need more testing on split class //last_view_names = split.to_list( sett.get(prefix + ".last_view_names"), ",", split.type.use_any_quotes ).ToArray() last_view_names = sett.get(prefix + ".last_view_names").Split('|') }; return(cur); }
// saves this as being the last search public void save_last_search(search_for last) { Debug.Assert(last.unique_id >= 0); Debug.Assert(last.text != ""); if (last.text == "") { return; // no text? } // moves this search to the end! (which visually means - to the top) var exists = history_.FirstOrDefault(x => x.unique_id == last.unique_id); if (exists != null) { history_.Remove(exists); } else { // 1.4.9 - if we already have this search, just bring it to the top exists = history_.FirstOrDefault(x => x == last); if (exists != null) { history_.Remove(exists); } } if (last.unique_id == 0) { last.unique_id = ++next_unique_id_; } history_.Add(last); while (history_.Count > MAX_SEARCH_COUNT) { history_.RemoveAt(0); } // if it's from history, bring to top! save(); }
public void escape() { var msg_details = this.msg_details; if (msg_details != null && msg_details.visible()) { msg_details.force_temporary_hide(this); } else if (edit.sel_text != "") { edit.escape(); } else if (cur_search_ != null) { cur_search_ = null; list.Refresh(); } else if (cur_filter_row_idx_ >= 0) { unmark(); } else if (app.inst.edit_mode != app.edit_mode_type.always && is_editing) { is_editing_ = false; edit.update_ui(); } if ( edit.sel_text == "") edit.force_refresh(); }
public void set_search_for_text(search_for search) { cur_search_ = search; render_.clear_format_cache("search changed"); // as of 1.2.6, we mark the words visually list.Refresh(); }
public void search_for_text(search_for search) { cur_search_ = search; // as of 1.2.6, we mark the words visually list.Refresh(); }
// FIXME use load_save internal static search_for load(string prefix) { var sett = app.inst.sett; int type = int.Parse(sett.get(prefix + ".type", "0")); Debug.Assert( type >= 0 && type <= 2); search_for cur = new search_for { fg = util.str_to_color( sett.get(prefix + ".fg", "transparent")), bg = util.str_to_color( sett.get(prefix + ".bg", "#faebd7") ), case_sensitive = sett.get(prefix + ".case_sensitive", "0") != "0", full_word = sett.get(prefix + ".full_word", "0") != "0", mark_lines_with_color = sett.get(prefix + ".mark_lines_with_color", "1") != "0", text = sett.get(prefix + ".text"), type = type, friendly_regex_name = sett.get(prefix + ".friendly_regex_name"), // FIXME i need more testing on split class //last_view_names = split.to_list( sett.get(prefix + ".last_view_names"), ",", split.type.use_any_quotes ).ToArray() last_view_names = sett.get(prefix + ".last_view_names").Split('|'), // 1.6.23+ - by default, don't search all columns - did profiling, and can take a looot of time (example: Event Log) all_columns = sett.get(prefix + ".all_columns", "0") != "0" }; return cur; }
public static bool matches(filter.match item, IEnumerable<info_type> cols, search_for search) { return matches(item.line, cols, search); }
public static bool matches(filter.match item, search_for search) { if (search.all_columns) return matches(item, info_type_io.searchable, search); else return matches_cell(item.line.part(info_type.msg), search); }
public void clear() { render_.clear_format_cache("file rewritten"); filter_.clear(); // 1.8.18+ at this point, we clear the filter and/or search model_.set_filter(false, true); edit.clear_sel(); cur_search_ = null; snooper_.clear(); // 1.8.21+ delete old bookmarks - they would not make sense anymore bookmarks.Clear(); refresh(); }
/* Edit mode: 1. if more than 1 entry, the combo is dropped down by default 2. if you type any letter while the combo is first dropped down (or paste something), it will auto close the dropdown 3. if you select any entry from the combo, you are EDITING that entry. If you don't select anything, you are ADDING */ // 1.2.7+ if there's something selected by the user, override what we had public search_form(Form parent, log_view lv, string smart_edit_search_for_text) { InitializeComponent(); TopMost = parent.TopMost; result.Font = lv.list.Font; lv_ = lv; render_ = new search_renderer(lv, this); history_ = search_form_history.inst.all_searches_cur_view_first(lv.name); // use the last ones... fg.BackColor = history_[0].fg; bg.BackColor = history_[0].bg; allColumns.Checked = history_[0].all_columns; load_combo(); load_surrounding_rows(lv); if (smart_edit_search_for_text != "") { combo.Text = smart_edit_search_for_text; radioText.Checked = true; } update_autorecognize_radio(); prev_search_ = current_search(); util.postpone(() => { combo.Focus(); if (combo.Items.Count > 1) { dropped_first_time_ = true; combo.DroppedDown = true; } },1); new Thread(do_searches_thread) {IsBackground = true }.Start(); }
private void load_from_search(search_for search) { unique_search_id_ = search.unique_id; last_view_names_ = search.last_view_names.ToList(); fg.BackColor = search.fg; bg.BackColor = search.bg; caseSensitive.Checked = search.case_sensitive; fullWord.Checked = search.full_word; friendlyRegexName.Text = search.friendly_regex_name; switch (search.type) { case 0: radioAutoRecognize.Checked = true; break; case 1: radioText.Checked = true; break; case 2: radioRegex.Checked = true; break; default: Debug.Assert(false); break; } combo.Text = search.text; allColumns.Checked = search.all_columns; update_autorecognize_radio(); }
private static bool matches_cell(string line, search_for search) { if (search.use_regex && search.regex == null) // the regex is invalid return true; if (line == "") // optimization return false; if (search.use_regex) { return search.regex.IsMatch(line); } else { // case sensitive and/or full word string search_for = search.case_sensitive ? search.text : search.text.ToLower(); string seach_line = search.case_sensitive ? line : line.ToLower(); if (search.full_word) return matches_full_word(seach_line, search_for); else return seach_line.Contains(search_for); } }
private void ok_Click(object sender, EventArgs e) { if (combo.Text != "") { search_ = current_search(); if ( markAsNewEntry.Checked) unique_search_id_ = 0; search_.unique_id = unique_search_id_; search_form_history.inst.save_last_search( search_); DialogResult = DialogResult.OK; } }
public static bool matches(filter.match item, IEnumerable<info_type> cols, search_for search) { return cols.Any(x => matches_cell(item.line.part(x), search)); }
private void do_searches_thread_impl() { // first time, show all run_search(); this.async_call_and_wait(() => { rebuild_result(); update_preview_text(); }); while (!closed_) { Thread.Sleep(250); search_for cur = null; this.async_call_and_wait(() => { if (combo.DroppedDown) return; var cur_search = current_search(); if (prev_search_ == cur_search) // nothing changed return; cur = cur_search; prev_search_ = cur; preview.Text = "Computing [" + prev_search_ + "]"; }); if (cur == null) continue; logger.Info("[search] searching: " + cur.text); run_search(); this.async_call_and_wait(() => { rebuild_result(); update_preview_text(); }); logger.Info("[search] searching: " + cur.text + " - complete"); } }
public static bool matches(IEnumerable<string> cells, search_for search) { return cells.Any(cell => matches_cell(cell, search)); }
private void toFilter_Click(object sender, EventArgs e) { search_ = current_search(); if (search_.fg == util.transparent) { var sel = new select_color_form("Filter Foreground Color", Color.Red); if (sel.ShowDialog() == DialogResult.OK) { fg.BackColor = sel.SelectedColor; search_ = current_search(); Debug.Assert(search_.fg != util.transparent); } else // user did not select a foreground - this is required return; } if ( markAsNewEntry.Checked) unique_search_id_ = 0; search_.unique_id = unique_search_id_; wants_to_filter_ = true; DialogResult = DialogResult.OK; }