public void copy_from(font_info other) { fg = other.fg; bg = other.bg; match_fg = other.match_fg; match_bg = other.match_bg; }
public match(BitArray matches, font_info font, line line, int line_idx) { this.matches = matches; this.font = font; this.line = line; this.line_idx = line_idx; }
public font_info copy() { var new_ = new font_info(); new_.copy_from(this); return(new_); }
public void merge(font_info other) { if (fg == util.transparent) fg = other.fg; if (bg == util.transparent) bg = other.bg; if (match_fg == util.transparent) match_fg = other.match_fg; if (match_bg == util.transparent) match_bg = other.match_bg; }
public raw_filter_row(raw_filter_row other) { items_ = other.items_.ToList(); lines_ = other.lines_.ToArray(); additions_ = other.additions.ToList(); unique_id_ = other.unique_id_; valid_ = other.valid_; enabled_ = other.enabled; font_ = font_info.default_font.copy(); update_font(); }
public raw_filter_row(raw_filter_row other) { items_ = other.items_.ToList(); lines_ = other.lines_.ToArray(); additions_ = other.additions.ToList(); apply_to_existing_lines = other.apply_to_existing_lines; unique_id_ = other.unique_id_; valid_ = other.valid_; enabled_ = other.enabled; dimmed_ = other.dimmed_; font_ = font_info.default_font_copy; update_font(); }
public raw_filter_row(string text, bool apply_to_existing_lines) { this.apply_to_existing_lines = apply_to_existing_lines; List <filter_line> lines = new List <filter_line>(); List <addition> additions = new List <addition>(); lines_ = text.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); foreach (string line in lines_) { filter_line item = filter_line.parse(line); if (item != null) { lines.Add(item); } addition add = addition.parse(line); if (add != null) { additions.Add(add); } bool is_comment = line.StartsWith("#"), is_empty = line.Trim() == ""; if (!is_comment && !is_empty && !filter_line.is_color_or_font_line(line)) { unique_id_ += line.Trim() + "\r\n"; } if (item == null && add == null) { if (!is_comment && !is_empty) { // in this case, the line is not valid yet valid_ = false; } } } unique_id_ += "" + apply_to_existing_lines; font_ = font_info.default_font_copy; init(lines, additions); if (items_.Count < 1) { valid_ = false; } }
public void merge(font_info other) { if (fg == util.transparent) { fg = other.fg; } if (bg == util.transparent) { bg = other.bg; } if (match_fg == util.transparent) { match_fg = other.match_fg; } if (match_bg == util.transparent) { match_bg = other.match_bg; } }
private font_info get_raw_font_info() { var result = new font_info(); foreach (var item in items_) { if (item.part == part_type.font) { if (item.fi.fg != util.transparent || item.fi.bg != util.transparent) { result.fg = item.fi.fg; result.bg = item.fi.bg; } else if (item.fi.match_fg != util.transparent || item.fi.match_bg != util.transparent) { result.match_fg = item.fi.match_fg; result.match_bg = item.fi.match_bg; } } } return(result); }
protected bool Equals(font_info other) { return(fg.ToArgb() == other.fg.ToArgb() && bg.ToArgb() == other.bg.ToArgb() && match_fg.ToArgb() == other.match_fg.ToArgb() && match_bg.ToArgb() == other.match_bg.ToArgb()); }
public raw_filter_row(string text, bool apply_to_existing_lines) { this.apply_to_existing_lines = apply_to_existing_lines; List<filter_line> lines = new List<filter_line>(); List<addition> additions = new List<addition>(); lines_ = text.Split(new string[] {"\r\n"}, StringSplitOptions.RemoveEmptyEntries); foreach ( string line in lines_) { filter_line item = filter_line.parse(line); if ( item != null) lines.Add(item); addition add = addition.parse(line); if ( add != null) additions.Add(add); bool is_comment = line.StartsWith("#"), is_empty = line.Trim() == ""; if (!is_comment && !is_empty && !filter_line.is_color_or_font_line(line)) unique_id_ += line.Trim() + "\r\n"; if (item == null && add == null) { if (!is_comment && !is_empty) // in this case, the line is not valid yet valid_ = false; } } unique_id_ += "" + apply_to_existing_lines; font_ = font_info.default_font_copy; init(lines, additions); if (items_.Count < 1) valid_ = false; }
private font_info get_raw_font_info() { var result = new font_info(); foreach ( var item in items_) if (item.part == part_type.font) { if (item.fi.fg != util.transparent || item.fi.bg != util.transparent) { result.fg = item.fi.fg; result.bg = item.fi.bg; } else if (item.fi.match_fg != util.transparent || item.fi.match_bg != util.transparent) { result.match_fg = item.fi.match_fg; result.match_bg = item.fi.match_bg; } } return result; }
private match new_match(BitArray ba, line l, int idx, font_info f ) { match m = create_match(ba, f, l, idx); return m; }
public match(BitArray matches, font_info font, line line, int lineIdx) { this.matches = matches; this.font = font; this.line = line; line_idx = lineIdx; }
protected bool Equals(font_info other) { return fg.ToArgb() == other.fg.ToArgb() && bg.ToArgb() == other.bg.ToArgb() && match_fg.ToArgb() == other.match_fg.ToArgb() && match_bg.ToArgb() == other.match_bg.ToArgb(); }
private void compute_matches_impl(log_reader new_log, log_reader old_log) { Debug.Assert(new_log != null); if (app.inst.no_ui.read_full_log_first) { // 1.0.76d+ - wait until log has fully loaded - in the hopes of using less memory if (new_log == old_log) { bool at_least_once; lock (this) at_least_once = new_log_fully_read_at_least_once_; if (!at_least_once) { if (!new_log.parser_up_to_date) { return; } lock (this) new_log_fully_read_at_least_once_ = true; } } } int old_line_count = new_log.line_count; new_log.refresh(); if (new_log != old_log || new_log.forced_reload) { bool changed_log = new_log != old_log && old_log_ == null; if (changed_log || old_log == new_log) { logger.Info((new_log != old_log ? "[filter] new log " : "[filter] forced refresh of ") + new_log.tab_name + " / " + new_log.log_name); } lock (this) if (matches_.count > 0) { force_recompute_matches_ = true; } } lock (this) if (force_recompute_matches_) { old_line_count = 0; } bool has_new_lines = (old_line_count != new_log.line_count); // get a pointer to the rows_; in case it changes on the main thread, we don't care, // since next time we will have the new rows List <filter_row> rows; lock (this) rows = rows_; if (old_line_count == 0) { foreach (filter_row row in rows) { row.refresh(); } } foreach (filter_row row in rows) { row.compute_line_matches(new_log); } if (has_new_lines) { status?.set_status("Computing filters... This might take a moment", status_ctrl.status_type.msg, 10000); bool is_full_log = row_count < 1; int expected_capacity = is_full_log ? (new_log.line_count - old_line_count) : (new_log.line_count - old_line_count) / 5; // the filter matches memory_optimized_list <match> new_matches = new memory_optimized_list <match> { min_capacity = expected_capacity, name = "temp_m " + name, increase_percentage = .7 }; // from old_lines to log.line_count -> these need recomputing int old_match_count = matches_.count; bool[] row_matches_filter = new bool[rows.Count]; // handle the case where all the filters are disabled (thus, show all lines) int run_filter_count = rows.Count(x => x.enabled); for (int line_idx = old_line_count; line_idx < new_log.line_count; ++line_idx) { bool any_match = false; // Go through all filters for (int filter_idx = 0; filter_idx < row_matches_filter.Length; ++filter_idx) { var row = rows[filter_idx]; if (row.enabled && row.line_matches.Contains(line_idx)) { row_matches_filter[filter_idx] = true; any_match = true; } } if (any_match) { font_info font = font_info.default_font.copy(); // 1.3.29g+ apply and merge all enabled filters for (int filter_idx = 0; filter_idx < row_matches_filter.Length; ++filter_idx) { if (row_matches_filter[filter_idx]) { font.merge(rows[filter_idx].get_match(line_idx).font); } } new_matches.Add(new_match(new BitArray(row_matches_filter), new_log.line_at(line_idx), line_idx, font)); continue; } if (run_filter_count == 0) { new_matches.Add(new_match(new BitArray(0), new_log.line_at(line_idx), line_idx, font_info.default_font)); } } bool replace = false; lock (this) if (force_recompute_matches_) { replace = true; force_recompute_matches_ = false; } if (new_matches.Count > 0) { if (replace) { matches_.set_range(new_matches); } else { matches_.add_range(new_matches); } lock (this) last_change_ = DateTime.Now; } apply_additions(old_match_count, new_log, rows); if (new_matches.Count > app.inst.no_ui.min_filter_capacity) { logger.Debug("[memory] GC.collect - from filter " + name); GC.Collect(); } } bool is_up_to_date = new_log.up_to_date; lock (this) is_up_to_date_ = is_up_to_date; }
private void compute_matches_impl(log_reader new_log, log_reader old_log) { Debug.Assert(new_log != null); if (app.inst.no_ui.read_full_log_first) { // 1.0.76d+ - wait until log has fully loaded - in the hopes of using less memory if (new_log == old_log) { bool at_least_once; lock (this) at_least_once = new_log_fully_read_at_least_once_; if (!at_least_once) { if (!new_log.parser_up_to_date) { return; } lock (this) new_log_fully_read_at_least_once_ = true; } } } int old_line_count = new_log.line_count; new_log.refresh(); if (new_log != old_log || new_log.forced_reload) { bool changed_log = new_log != old_log && old_log_ == null; if (changed_log || old_log == new_log) { logger.Info((new_log != old_log ? "[filter] new log " : "[filter] forced refresh of ") + new_log.tab_name + " / " + new_log.log_name); } lock (this) if (matches_.count > 0) { force_recompute_matches_ = true; } } lock (this) if (force_recompute_matches_) { old_line_count = 0; } bool has_new_lines = (old_line_count != new_log.line_count); // get a pointer to the rows_; in case it changes on the main thread, we don't care, // since next time we will have the new rows List <filter_row> rows; lock (this) rows = rows_; if (old_line_count == 0) { foreach (filter_row row in rows) { row.refresh(); } } foreach (filter_row row in rows) { row.compute_line_matches(new_log); } if (has_new_lines) { bool is_full_log = row_count < 1; int expected_capacity = is_full_log ? (new_log.line_count - old_line_count) : (new_log.line_count - old_line_count) / 5; // the filter matches memory_optimized_list <match> new_matches = new memory_optimized_list <match>() { min_capacity = expected_capacity, name = "temp_m " + name, increase_percentage = .7 }; // from old_lines to log.line_count -> these need recomputing int old_match_count = matches_.count; BitArray matches = new BitArray(rows.Count); // handle the case where all the filters are disabled (thus, show all lines) int run_filter_count = rows.Count(x => x.enabled || x.dimmed); for (int line_idx = old_line_count; line_idx < new_log.line_count; ++line_idx) { bool any_match = false; bool any_non_apply_to_existing_lines_filters = false; // 1.0.69 added "apply to existing filters" for (int filter_idx = 0; filter_idx < matches.Length; ++filter_idx) { var row = rows[filter_idx]; if ((row.enabled || row.dimmed) && !row.apply_to_existing_lines) { matches[filter_idx] = row.line_matches.Contains(line_idx); any_non_apply_to_existing_lines_filters = true; } else { matches[filter_idx] = false; } if (matches[filter_idx]) { any_match = true; } } if (!any_non_apply_to_existing_lines_filters) { // in this case - all filters apply to existing lines - thus, by default, we show all the lines any_match = true; } // 1.0.69 "apply to existing filters" is applied afterwards font_info existing_filter_font = null; if (any_match) { for (int filter_idx = 0; filter_idx < matches.Length && any_match; ++filter_idx) { var row = rows[filter_idx]; if ((row.enabled || row.dimmed) && row.apply_to_existing_lines) { bool is_font_only = row.has_font_info; if (row.line_matches.Contains(line_idx)) { if (existing_filter_font == null && is_font_only) { // in this case, use the font from "apply to existing filters" - only if the user has specifically set it existing_filter_font = row.get_match(line_idx).font; matches[filter_idx] = true; } } else if (!is_font_only) { // we're filtering this line out any_match = false; } } } } if (any_match) { font_info font = (existing_filter_font ?? font_info.default_font).copy(); int enabled_idx = -1; for (int filter_idx = 0; filter_idx < matches.Length && enabled_idx < 0; ++filter_idx) { if (matches[filter_idx] && rows[filter_idx].enabled) { enabled_idx = filter_idx; } } int used_idx = -1; if (enabled_idx < 0) { for (int filter_idx = 0; filter_idx < matches.Length && used_idx < 0; ++filter_idx) { if (matches[filter_idx] && rows[filter_idx].dimmed) { used_idx = filter_idx; } } } if (enabled_idx >= 0 || used_idx >= 0) { if (enabled_idx >= 0) { // 1.3.29g+ apply and merge all enabled filters for (int filter_idx = 0; filter_idx < matches.Length; ++filter_idx) { if (matches[filter_idx] && rows[filter_idx].enabled) { font.merge(rows[filter_idx].get_match(line_idx).font); } } } else { font.merge(rows[used_idx].get_match(line_idx).font); } } new_matches.Add(new_match(new BitArray(matches), new_log.line_at(line_idx), line_idx, font)); continue; } if (run_filter_count == 0) { new_matches.Add(new_match(new BitArray(0), new_log.line_at(line_idx), line_idx, font_info.default_font)); } } bool replace = false; lock (this) if (force_recompute_matches_) { replace = true; force_recompute_matches_ = false; } if (new_matches.Count > 0) { if (replace) { matches_.set_range(new_matches); } else { matches_.add_range(new_matches); } lock (this) last_change_ = DateTime.Now; } apply_additions(old_match_count, new_log, rows); if (new_matches.Count > app.inst.no_ui.min_filter_capacity) { logger.Debug("[memory] GC.collect - from filter " + name); GC.Collect(); } } bool is_up_to_date = new_log.up_to_date; lock (this) is_up_to_date_ = is_up_to_date; }
private match new_match(BitArray ba, line l, int idx, font_info f) { match m = create_match(ba, f, l, idx); return(m); }
private filter.match create_match_object(BitArray matches, font_info font, line line, int lineIdx) { return is_full_log ? new full_log_match_item(matches, font, line, lineIdx, this) : new match_item(matches, font, line, lineIdx, this); }
public font_info copy() { var new_ = new font_info(); new_.copy_from(this); return new_; }