Пример #1
0
        static private bool has_value_at_column(log_view lv, info_type type, int max_rows_to_check) {
            // msg is always shown
            if (type == info_type.msg)
                return true;
            if (type == info_type.line || type == info_type.view)
                return true;

            if (max_rows_to_check == 0)
                // before reading anything from the log
                return false;

            var aliases = lv.filter.log.aliases;
            // 1.5.4+ if the user has already specified clearly that we have this column, we consider it true
            if (aliases.has_column(type))
                return true;

            for (int idx = 0; idx < max_rows_to_check; ++idx) {
                var i = lv.item_at(idx) ;
                if (i.line_idx < 0)
                    continue;
                if (log_view_cell.cell_value_by_type(i, type) != "")
                    return true;
            }
            return false;
        }
Пример #2
0
        public List <filter_line.match_index> match_indexes(line l, info_type type)
        {
            List <filter_line.match_index> indexes = null;
            bool has_match_color = font_.match_fg != util.transparent || font_.match_bg != util.transparent;

            if (has_match_color)
            {
                foreach (filter_line line in items_)
                {
                    var now = line.match_indexes(l, type);
                    if (now.Count > 0)
                    {
                        if (indexes == null)
                        {
                            indexes = new List <filter_line.match_index>();
                        }
                        // here, we need to set the match colors
                        foreach (var index in now)
                        {
                            index.fg = font_.match_fg;
                            index.bg = font_.match_bg;
                        }
                        indexes.AddRange(now);
                    }
                }
            }
            return(indexes ?? empty_);
        }
 // if true, I can find this part 
 public bool can_find(info_type part) {
     if (relative_syntax_) {
         var pos = relative_idx_in_line_.FirstOrDefault(x => x.type == part);
         return (pos != null);
     } else
         return idx_in_line_[(int) part].Item1 >= 0;
 }
Пример #4
0
        public string part(info_type i)
        {
            Debug.Assert(i < info_type.max);
            if (parts[(int)i * 2] < 0 || parts[(int)i * 2 + 1] <= 0)
            {
                return("");
            }

            string result = "";
            string msg    = sub_.msg;

            try {
                short start = parts[(int)i * 2], len = parts[(int)i * 2 + 1];
                if (start < msg.Length && start + len <= msg.Length)
                {
                    result = msg.Substring(parts[(int)i * 2], parts[(int)i * 2 + 1]);
                }
            } catch {
                // this can happen when the log has changed or has been re-written, thus, the sub_ has become suddenly empty
            }

            if (app.inst.force_text_as_multi_line)
            {
                result = util.split_into_multiple_fixed_lines(result, 15);
            }

            return(result);
        }
Пример #5
0
        public string part(info_type i)
        {
            Debug.Assert(i < info_type.max);
            var result = parts[(int)i];

            return(result ?? "");
        }
Пример #6
0
        private void show_sub_item(log_view lv, info_type type, RichTextBox text_ctrl)
        {
            match_item item = lv.sel;
            int        row  = lv.sel_row_idx;

            string txt     = (item as filter.match).line.part(type);
            int    col_idx = log_view_cell.info_type_to_cell_idx(type);
            var    prints  = lv.sel.override_print(lv, txt, col_idx, column_formatter_base.format_cell.location_type.details_pane).format_text.to_single_enter_char();

            // ... text has changed
            txt = prints.text;

            text_ctrl.Clear();
            text_ctrl.AppendText(txt);

            var full_row = lv.list.GetItem(row);

            text_ctrl.BackColor = drawer_.bg_color(full_row, col_idx, prints);

            var parts = prints.parts(default_print_);

            foreach (var part in parts)
            {
                text_ctrl.Select(part.start, part.len);
                text_ctrl.SelectionColor     = drawer_.print_fg_color(full_row, part);
                text_ctrl.SelectionBackColor = drawer_.print_bg_color(full_row, part);
            }
        }
Пример #7
0
        public static string to_friendly_str(info_type i) {
            switch (i) {
            case info_type.time:
                return "Time";
            case info_type.date:
                return "Date";
            case info_type.level:
                return "Level";
            case info_type.thread:
                return "Thread";
            case info_type.class_:
                return "Class";
            case info_type.file:
                return "File";
            case info_type.func:
                return "Func";
            case info_type.ctx1:
                return "Ctx1";
            case info_type.ctx2:
                return "Ctx2";
            case info_type.ctx3:
                return "Ctx3";
            case info_type.ctx4:
                return "Ctx4";
            case info_type.ctx5:
                return "Ctx5";
            case info_type.ctx6:
                return "Ctx6";
            case info_type.ctx7:
                return "Ctx7";
            case info_type.ctx8:
                return "Ctx8";
            case info_type.ctx9:
                return "Ctx9";
            case info_type.ctx10:
                return "Ctx10";
            case info_type.ctx11:
                return "Ctx11";
            case info_type.ctx12:
                return "Ctx12";
            case info_type.ctx13:
                return "Ctx13";
            case info_type.ctx14:
                return "Ctx14";
            case info_type.ctx15:
                return "Ctx15";
            case info_type.msg:
                return "Message";

            case info_type.view:
                return "View(s)";
            case info_type.line:
                return "Line";
            default:
            case info_type.max:
                Debug.Assert(false);
                return "";
            }
        }
Пример #8
0
        private void edit_column(info_type column)
        {
            var visible = get_visible_parts();

            Debug.Assert(visible.Select(x => x.type).Contains(column));
            edit_column_ = column;
            update_edit_column();
        }
Пример #9
0
 public Rectangle rect_for_column(info_type col_type)
 {
     if (column_to_controls_.ContainsKey(col_type))
     {
         var rect = column_to_controls_[col_type].Item2.RectangleToScreen(column_to_controls_[col_type].Item2.ClientRectangle);
         return(RectangleToClient(rect));
     }
     return(Rectangle.Empty);
 }
Пример #10
0
        internal static int info_type_to_cell_idx(info_type type)
        {
            switch (type)
            {
            case  info_type.line: return(0);

            case  info_type.view: return(1);

            case  info_type.date: return(2);

            case  info_type.time: return(3);

            case  info_type.level: return(4);

            case  info_type.thread: return(5);

            case  info_type.file: return(6);

            case  info_type.func: return(7);

            case  info_type.class_: return(8);

            case  info_type.ctx1: return(9);

            case  info_type.ctx2: return(10);

            case  info_type.ctx3: return(11);

            case  info_type.ctx4: return(12);

            case  info_type.ctx5: return(13);

            case  info_type.ctx6: return(14);

            case  info_type.ctx7: return(15);

            case  info_type.ctx8: return(16);

            case  info_type.ctx9: return(17);

            case  info_type.ctx10: return(18);

            case  info_type.ctx11: return(19);

            case  info_type.ctx12: return(20);

            case  info_type.ctx13: return(21);

            case  info_type.ctx14: return(22);

            case  info_type.ctx15: return(23);

            case  info_type.msg: return(24);

            default: Debug.Assert(false); return(0);
            }
        }
Пример #11
0
 public void set_colors(List<category_colors> colors, info_type column) {
     try {
         colors_ = colors.ToDictionary(x => x.name, x => x);
     } catch {
         colors_ = null;
         logger.Error("invalid color names " + util.concatenate(colors.Select(x => x.name), ", ") );
     }
     column_ = column;
 }
Пример #12
0
        internal static string cell_value_by_type(match_item i, info_type type)
        {
            switch (type)
            {
            case info_type.msg: return(i.msg);

            case info_type.time: return(i.time);

            case info_type.date: return(i.date);

            case info_type.level: return(i.level);

            case info_type.thread: return(i.thread);

            case info_type.class_: return(i.class_);

            case info_type.file: return(i.file);

            case info_type.func: return(i.func);

            case info_type.line: return("" + i.line);

            case info_type.view: return(i.view);

            case info_type.ctx1: return(i.ctx1);

            case info_type.ctx2: return(i.ctx2);

            case info_type.ctx3: return(i.ctx3);

            case info_type.ctx4: return(i.ctx4);

            case info_type.ctx5: return(i.ctx5);

            case info_type.ctx6: return(i.ctx6);

            case info_type.ctx7: return(i.ctx7);

            case info_type.ctx8: return(i.ctx8);

            case info_type.ctx9: return(i.ctx9);

            case info_type.ctx10: return(i.ctx10);

            case info_type.ctx11: return(i.ctx11);

            case info_type.ctx12: return(i.ctx12);

            case info_type.ctx13: return(i.ctx13);

            case info_type.ctx14: return(i.ctx14);

            case info_type.ctx15: return(i.ctx15);
            }
            Debug.Assert(false);
            return(i.msg);
        }
Пример #13
0
        internal static OLVColumn column(log_view lv, info_type type)
        {
            switch (type)
            {
            case info_type.line: return(lv.lineCol);

            case info_type.view: return(lv.viewCol);

            case info_type.msg: return(lv.msgCol);

            case info_type.time: return(lv.timeCol);

            case info_type.date: return(lv.dateCol);

            case info_type.level: return(lv.levelCol);

            case info_type.thread: return(lv.threadCol);

            case info_type.file: return(lv.fileCol);

            case info_type.func: return(lv.funcCol);

            case info_type.class_: return(lv.classCol);

            case info_type.ctx1: return(lv.ctx1Col);

            case info_type.ctx2: return(lv.ctx2Col);

            case info_type.ctx3: return(lv.ctx3Col);

            case info_type.ctx4: return(lv.ctx4Col);

            case info_type.ctx5: return(lv.ctx5Col);

            case info_type.ctx6: return(lv.ctx6Col);

            case info_type.ctx7: return(lv.ctx7Col);

            case info_type.ctx8: return(lv.ctx8Col);

            case info_type.ctx9: return(lv.ctx9Col);

            case info_type.ctx10: return(lv.ctx10Col);

            case info_type.ctx11: return(lv.ctx11Col);

            case info_type.ctx12: return(lv.ctx12Col);

            case info_type.ctx13: return(lv.ctx13Col);

            case info_type.ctx14: return(lv.ctx14Col);

            case info_type.ctx15: return(lv.ctx15Col);
            }
            Debug.Assert(false);
            return(lv.msgCol);
        }
Пример #14
0
 public void set_colors(List <category_colors> colors, info_type column)
 {
     try {
         colors_ = colors.ToDictionary(x => x.name, x => x);
     } catch {
         colors_ = null;
         logger.Error("invalid color names " + util.concatenate(colors.Select(x => x.name), ", "));
     }
     column_ = column;
 }
Пример #15
0
 public bool is_column_searchable(info_type col)
 {
     if (all_columns)
     {
         return(info_type_io.is_searchable(col));
     }
     else
     {
         return(col == info_type.msg);
     }
 }
Пример #16
0
 // if true, I can find this part
 public bool can_find(info_type part)
 {
     if (relative_syntax_)
     {
         var pos = relative_idx_in_line_.FirstOrDefault(x => x.type == part);
         return(pos != null);
     }
     else
     {
         return(idx_in_line_[(int)part].Item1 >= 0);
     }
 }
Пример #17
0
        public void set_colors(info_type type, List <category_colors> colors)
        {
            string str = "";

            foreach (var color in colors)
            {
                var same  = color.raw_same_category_bg != util.transparent ? util.color_to_str(color.raw_same_category_bg) : "";
                var this_ = color.raw_this_category_bg != util.transparent ? util.color_to_str(color.raw_this_category_bg) : "";
                str += color.name + inside_color_delim + util.color_to_str(color.bg_color) + inside_color_delim + same + inside_color_delim + this_ +
                       color_delim;
            }
            sett_.set(type.ToString(), str);
        }
Пример #18
0
        public string friendly_name(info_type info)
        {
            string as_string = info.ToString();
            var    found     = sett_.get(as_string);

            if (found == as_string)
            {
                return(info_type_io.to_friendly_str(info));
            }

            if (found != "")
            {
                // "ctx3 = City"
                return(found.Trim());
            }

            var found_as_idx = sett_.get("_" + (int)info);

            if (found_as_idx != "")
            {
                // we have a "_index = value" entry, lets parse it
                // the 'value' syntax is "name[{Friendly Name}]"
                if (found_as_idx.IndexOf("{") >= 0)
                {
                    return(get_friendly_name_part(found_as_idx));
                }
            }

            if (name_to_column_.has_value(info))
            {
                string name = name_to_column_.value_to_key(info);
                found = sett_.get(name);
                if (found != "")
                {
                    // hand=ctx1{Some Awesome Title}
                    // ctx1=Some Awesome Title
                    if (found != get_friendly_name_part(found))
                    {
                        return(get_friendly_name_part(found));
                    }
                }
                if (name == as_string)
                {
                    return(info_type_io.to_friendly_str(info));
                }
                return(name);
            }

            return(info_type_io.to_friendly_str(info));
        }
Пример #19
0
 public snoop_around_form snoop_for(info_type type)
 {
     Debug.Assert(!disposed_);
     Debug.Assert(info_type_io.is_snoopable(type));
     lock (this) {
         if (!snoops_.ContainsKey(type))
         {
             var use_now = unused_[0];
             unused_.RemoveAt(0);
             use_now.clear();
             snoops_.Add(type, use_now);
         }
         return(snoops_[type].form);
     }
 }
Пример #20
0
            public format_cell(match_item item, log_view parent, int col_idx, info_type col_type, formatted_text text, int row_index, int top_row_index, int sel_index, bool is_bookmark, string prev_text, location_type location) {
                this.item = item;
                this.parent = parent;
                this.col_idx = col_idx;
                this.col_type = col_type;
                this.format_text = text;
                this.row_index = row_index;
                this.top_row_index = top_row_index;
                this.prev_text = prev_text;
                this.location = location;
                this.sel_index = sel_index;
                this.is_bookmark = is_bookmark;

                fg_color = item.fg(parent);
                bg_color = item.bg(parent);
            }
Пример #21
0
            public format_cell(match_item item, log_view parent, int col_idx, info_type col_type, formatted_text text, int row_index, int top_row_index, int sel_index, bool is_bookmark, string prev_text, location_type location)
            {
                this.item          = item;
                this.parent        = parent;
                this.col_idx       = col_idx;
                this.col_type      = col_type;
                this.format_text   = text;
                this.row_index     = row_index;
                this.top_row_index = top_row_index;
                this.prev_text     = prev_text;
                this.location      = location;
                this.sel_index     = sel_index;
                this.is_bookmark   = is_bookmark;

                fg_color = item.fg(parent);
                bg_color = item.bg(parent);
            }
Пример #22
0
        private syntax_info parse_relative_syntax(string syntax)
        {
            syntax_info si = new syntax_info();

            si.relative_syntax_ = true;
            si.relative_idx_in_line_.Clear();

            // Example: "$time[0,12] $ctx1['[','-'] $func[' ',']'] $ctx2['[[',' ] ]'] $msg"
            syntax = syntax.Trim();
            while (syntax.Length > 0)
            {
                if (syntax[0] != '$')
                {
                    // invalid syntax
                    break;
                }

                syntax = syntax.Substring(1);
                string    type_str = syntax.Split('[')[0];
                info_type type     = info_type_io.from_str(type_str);
                if (type == info_type.max)
                {
                    // invalid syntax
                    break;
                }
                int bracket = syntax.IndexOf("[");
                syntax = bracket >= 0 ? syntax.Substring(bracket + 1).Trim() : "";
                if (syntax == "")
                {
                    // this was the last item (the remainder of the string)
                    si.relative_idx_in_line_.Add(new syntax_info.relative_pos {
                        type = type, start = -1, start_str = null, len = -1, end_str = null
                    });
                    break;
                }

                var start = parse_sub_relative_syntax(ref syntax);
                var end   = parse_sub_relative_syntax(ref syntax);
                si.relative_idx_in_line_.Add(new syntax_info.relative_pos {
                    type = type, start = start.Item1, start_str = start.Item2, len = end.Item1, end_str = end.Item2
                });

                syntax = syntax.Trim();
            }
            return(si);
        }
Пример #23
0
 private bool is_cell_type_ok(info_type type)
 {
     switch (type)
     {
     case info_type.date:
     case info_type.time:
     case info_type.level:
     case info_type.thread:
     case info_type.file:
     case info_type.func:
     case info_type.class_:
     case info_type.view:
     case info_type.line:
         return(false);
     }
     return(true);
 }
Пример #24
0
        private void update_edit_column()
        {
            if (visible_columns_.Count < 1)
            {
                // did not set aliases yet
                return;
            }

            var visible = get_visible_parts().Select(x => x.type).ToList();

            if (edit_column_ == info_type.max || !visible.Contains(edit_column_))
            {
                edit_column_ = visible[0];
            }

            if (!is_editing_)
            {
                return;
            }

            editColumnName.Text = names_[edit_column_];
            foreach (var column in column_to_controls_)
            {
                bool edited = column.Key == edit_column_;
                column.Value.Item1.Font = fonts_.get_font(Font, edited, false, false);
                column.Value.Item2.Font = fonts_.get_font(Font, edited, false, false);
            }
            ++ignore_change_;
            var cur = get_visible_parts().FirstOrDefault(x => x.type == edit_column_);

            isMultiline.Checked = cur.multi_line;
            lineCount.Visible   = cur.multi_line;
            if (cur.multi_line)
            {
                if (cur.auto_resize)
                {
                    lineCount.SelectedIndex = 0;
                }
                else
                {
                    lineCount.SelectedIndex = cur.line_count - 1;
                }
            }
            --ignore_change_;
        }
Пример #25
0
        internal void format(formatted_text text, match_item row, match_item sel, info_type col_type) {
            if (!running || colors_ == null || colors_.Count < 1 || column_ == info_type.max)
                return;
            if (col_type == info_type.line)
                // don't category format the line
                return;

            var row_text = log_view_cell.cell_value_by_type(row, column_);
            var sel_text = log_view_cell.cell_value_by_type(sel, column_);

            category_colors category_col;
            if (colors_.TryGetValue(row_text, out category_col)) {
                var color = row_text == sel_text ? category_col.this_category_bg : category_col.same_category_bg;
                text.bg = color;
                text.update_parts();
            }

        }
Пример #26
0
        public static bool can_be_multi_line(info_type type)
        {
            if (app.inst.force_text_as_multi_line)
            {
                return(true);
            }

            switch (type)
            {
            case info_type.date:
            case info_type.time:
            case info_type.level:
            case info_type.thread:
            case info_type.file:
            case info_type.func:
            case info_type.class_:
            case info_type.view:
            case info_type.line:
                return(false);

            case info_type.ctx1:
            case info_type.ctx2:
            case info_type.ctx3:
            case info_type.ctx4:
            case info_type.ctx5:
            case info_type.ctx6:
            case info_type.ctx7:
            case info_type.ctx8:
            case info_type.ctx9:
            case info_type.ctx10:
            case info_type.ctx11:
            case info_type.ctx12:
            case info_type.ctx13:
            case info_type.ctx14:
            case info_type.ctx15:
            case info_type.msg:
                return(true);

            case info_type.max:
            default:
                Debug.Assert(false);
                return(false);
            }
        }
Пример #27
0
        static private bool has_value_at_column(log_view lv, info_type type, int max_rows_to_check)
        {
            // msg is always shown
            if (type == info_type.msg)
            {
                return(true);
            }
            if (type == info_type.line || type == info_type.view)
            {
                return(true);
            }

            if (max_rows_to_check == 0)
            {
                // before reading anything from the log
                return(false);
            }

            var aliases = lv.filter.log.aliases;

            // 1.5.4+ if the user has already specified clearly that we have this column, we consider it true
            if (aliases.has_column(type))
            {
                return(true);
            }

            int value_count = 0;

            for (int idx = 0; idx < max_rows_to_check; ++idx)
            {
                var i = lv.item_at(idx);
                if (i.line_idx < 0)
                {
                    continue;
                }
                if (log_view_cell.cell_value_by_type(i, type) != "")
                {
                    ++value_count;
                }
            }
            bool has_values = (value_count > 0);

            return(has_values);
        }
Пример #28
0
        public List <filter_line.match_index> match_indexes(line l, info_type type)
        {
            List <filter_line.match_index> indexes = new List <filter_line.match_index>();

            lock (this)
                foreach (var row in rows_)
                {
                    indexes.AddRange(row.match_indexes(l, type));
                }

            indexes.Sort((x, y) => {
                if (x.start != y.start)
                {
                    return(x.start - y.start);
                }
                return(-(x.len - y.len));
            });
            return(indexes);
        }
Пример #29
0
        private void show_sub_item(log_view lv, info_type type, RichTextBox text_ctrl)
        {
            match_item item = lv.sel;
            int        row  = lv.sel_row_idx;

            string txt    = (item as filter.match).line.part(type);
            int    col    = log_view_cell.info_type_to_cell_idx(type);
            var    prints = lv.sel.override_print(lv, txt, col);

            print_info.to_single_enter_char(ref txt, ref prints);

            text_ctrl.Clear();
            text_ctrl.AppendText(txt);

            var full_row = lv.list.GetItem(row);

            text_ctrl.BackColor = drawer_.bg_color(full_row, col);

            int last_idx = 0;

            for (int print_idx = 0; print_idx < prints.Count; ++print_idx)
            {
                int    cur_idx = prints[print_idx].Item1, cur_len = prints[print_idx].Item2;
                string before = txt.Substring(last_idx, cur_idx - last_idx);
                if (before != "")
                {
                    text_ctrl.Select(last_idx, cur_idx - last_idx);
                    text_ctrl.SelectionColor     = drawer_.print_fg_color(full_row, default_print_);
                    text_ctrl.SelectionBackColor = drawer_.bg_color(full_row, col);
                }
                text_ctrl.Select(cur_idx, cur_len);
                text_ctrl.SelectionColor     = drawer_.print_fg_color(full_row, prints[print_idx].Item3);
                text_ctrl.SelectionBackColor = drawer_.print_bg_color(full_row, prints[print_idx].Item3);
                last_idx = cur_idx + cur_len;
            }
            last_idx = prints.Count > 0 ? prints.Last().Item1 + prints.Last().Item2 : 0;
            if (last_idx < txt.Length)
            {
                text_ctrl.Select(last_idx, txt.Length - last_idx);
                text_ctrl.SelectionColor     = drawer_.print_fg_color(full_row, default_print_);
                text_ctrl.SelectionBackColor = drawer_.bg_color(full_row, col);
            }
        }
Пример #30
0
        // #26 - returns the importance of each column (should it be shown in the view by default?)
        //       the idea is to keep just a few in the view, not to clog it, and the rest to show them in the Details pane
        //
        //       I return an integer - the higher it is, the more important the column is
        public static int show_in_view_by_default(info_type type) {
            switch (type) {
            case info_type.msg:     return Int32.MaxValue;

            case info_type.line:    return 100;
            case info_type.view:    return 99;

            case info_type.time:    return 90;
            case info_type.level:   return 89;

            case info_type.thread:  return 87;

            case info_type.file:    return 70;
            case info_type.func:    return 69;
            case info_type.class_:  return 68;

            case info_type.ctx1:    return 60;
            case info_type.ctx2:    return 59;
            case info_type.ctx3:    return 58;

            case info_type.ctx4:    return 57;
            case info_type.ctx5:    return 56;
            case info_type.ctx6:    return 55;
            case info_type.ctx7:    return 54;
            case info_type.ctx8:    return 53;
            case info_type.ctx9:    return 52;
            case info_type.ctx10:   return 51;
            case info_type.ctx11:   return 50;
            case info_type.ctx12:   return 49;
            case info_type.ctx13:   return 48;
            case info_type.ctx14:   return 47;
            case info_type.ctx15:   return 46;

            // 1.7.35+ the idea is that time column should contain everything
            case info_type.date:    return 40;

            case info_type.max:     return -1;
            default:
                Debug.Assert(false);
                return -1;
            }
        }
Пример #31
0
        public List <category_colors> get_colors(info_type type, List <string> possible_values)
        {
            List <category_colors> existing = new List <category_colors>();
            var colors_now = sett_.get(type.ToString()).Split(new [] { color_delim }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var str in colors_now)
            {
                var cur_col = str.Split(new[] { inside_color_delim }, StringSplitOptions.None);
                Debug.Assert(cur_col.Length == 4);
                category_colors cur_colors = new category_colors {
                    name = cur_col[0], bg_color = util.str_to_color(cur_col[1])
                };
                if (cur_col[2] != "")
                {
                    cur_colors.raw_same_category_bg = util.str_to_color(cur_col[2]);
                }
                if (cur_col[3] != "")
                {
                    cur_colors.raw_this_category_bg = util.str_to_color((cur_col[3]));
                }
                existing.Add(cur_colors);
            }


            List <category_colors> result = new List <category_colors>();

            foreach (var value in possible_values)
            {
                var found = existing.FirstOrDefault(x => x.name == value);
                if (found != null)
                {
                    result.Add(found);
                }
                else
                {
                    result.Add(new category_colors {
                        name = value
                    });
                }
            }
            return(result);
        }
Пример #32
0
        public string part(info_type i)
        {
            Debug.Assert(i < info_type.max);

            // 1.8.7+ - just in case we have set the date/time directly in hte constructor, and we didn't parse them from the line itself
            //          note that at this time (1.8+), we have the date/time column formatter, which uses the time directly anyway
            //          so long story short, we should never ask for the time/date as a string here
            if (i == info_type.time && time != DateTime.MinValue && parts[(int)i * 2] < 0)
            {
                return(time.ToString("HH:mm:ss.ffff"));
            }
            if (i == info_type.date && time != DateTime.MinValue && parts[(int)i * 2] < 0)
            {
                return(time.ToString("yyyy/MM/dd"));
            }

            if (parts[(int)i * 2] < 0)
            {
                return("");
            }

            string result = "";
            string msg    = sub_.msg;

            try {
                short start = parts[(int)i * 2], len = parts[(int)i * 2 + 1];
                if (start < msg.Length && start + len <= msg.Length)
                {
                    result = len < 0 ? msg.Substring(start) : msg.Substring(start, len);
                }
            } catch {
                // this can happen when the log has changed or has been re-written, thus, the sub_ has become suddenly empty
            }

            if (app.inst.force_text_as_multi_line)
            {
                result = util.split_into_multiple_fixed_lines(result, 15);
            }

            return(result);
        }
Пример #33
0
        public static bool can_be_category(info_type type)
        {
            switch (type)
            {
            case info_type.max:

            case info_type.date:
            case info_type.time:
            case info_type.view:
            case info_type.line:
            case info_type.msg:
                return(false);

            case info_type.level:
            case info_type.thread:
            case info_type.file:
            case info_type.func:
            case info_type.class_:

            case info_type.ctx1:
            case info_type.ctx2:
            case info_type.ctx3:
            case info_type.ctx4:
            case info_type.ctx5:
            case info_type.ctx6:
            case info_type.ctx7:
            case info_type.ctx8:
            case info_type.ctx9:
            case info_type.ctx10:
            case info_type.ctx11:
            case info_type.ctx12:
            case info_type.ctx13:
            case info_type.ctx14:
            case info_type.ctx15:
                return(true);

            default:
                Debug.Assert(false);
                return(false);
            }
        }
Пример #34
0
        public static bool can_be_multi_line(info_type type) {
            if (app.inst.force_text_as_multi_line)
                return true;

            switch (type) {
            case info_type.date:
            case info_type.time:
            case info_type.level:
            case info_type.thread:
            case info_type.file:
            case info_type.func:
            case info_type.class_:
            case info_type.view:
            case info_type.line:
                return false;

            case info_type.ctx1:
            case info_type.ctx2:
            case info_type.ctx3:
            case info_type.ctx4:
            case info_type.ctx5:
            case info_type.ctx6:
            case info_type.ctx7:
            case info_type.ctx8:
            case info_type.ctx9:
            case info_type.ctx10:
            case info_type.ctx11:
            case info_type.ctx12:
            case info_type.ctx13:
            case info_type.ctx14:
            case info_type.ctx15:
            case info_type.msg:
                return true;

            case info_type.max:
            default:
                Debug.Assert(false);
                return false;
            }
        }
Пример #35
0
        public static bool is_searchable(info_type type) {
            switch (type) {
            case info_type.max:

            case info_type.date:
            case info_type.time:
            case info_type.level:
            case info_type.view:
            case info_type.line:
                return false;

            case info_type.thread:
            case info_type.file:
            case info_type.func:
            case info_type.class_:

            case info_type.ctx1:
            case info_type.ctx2:
            case info_type.ctx3:
            case info_type.ctx4:
            case info_type.ctx5:
            case info_type.ctx6:
            case info_type.ctx7:
            case info_type.ctx8:
            case info_type.ctx9:
            case info_type.ctx10:
            case info_type.ctx11:
            case info_type.ctx12:
            case info_type.ctx13:
            case info_type.ctx14:
            case info_type.ctx15:
            case info_type.msg:
                return true;

            default:
                Debug.Assert(false);
                return false;
            }
        }
Пример #36
0
 public snoop_around_form snoop_for(info_type type)
 {
     Debug.Assert(!disposed_);
     Debug.Assert(info_type_io.is_snoopable(type));
     lock (this) {
         if (!snoops_.ContainsKey(type))
         {
             /*if(unused_.Count > 0) {
              *  var use_now = unused_[0];
              *  unused_.RemoveAt(0);
              *  use_now.clear();
              *  snoops_.Add(type, use_now);
              * } else {*/
             var form = new snoop_around_form();
             form.on_apply = on_apply;
             form.on_snoop = on_snoop;
             snoops_.Add(type, new snoop_form_info {
                 form = form
             });
             //}
         }
         return(snoops_[type].form);
     }
 }
Пример #37
0
        internal void format(formatted_text text, match_item row, match_item sel, info_type col_type)
        {
            if (!running || colors_ == null || colors_.Count < 1 || column_ == info_type.max)
            {
                return;
            }
            if (col_type == info_type.line)
            {
                // don't category format the line
                return;
            }

            var row_text = log_view_cell.cell_value_by_type(row, column_);
            var sel_text = log_view_cell.cell_value_by_type(sel, column_);

            category_colors category_col;

            if (colors_.TryGetValue(row_text, out category_col))
            {
                var color = row_text == sel_text ? category_col.this_category_bg : category_col.same_category_bg;
                text.bg = color;
                text.update_parts();
            }
        }
Пример #38
0
        public List <match_index> match_indexes(line l, info_type type)
        {
            if (part == part_type.font || part == part_type.case_sensitive_info)
            {
                return(empty_);
            }

            // 1.2.6 for now, care about match indexes only for msg column
            if (type != info_type.msg)
            {
                return(empty_);
            }

            // we only care about "positive" matches - those that have "containing", "startswith", regex, etc.
            switch (comparison)
            {
            case comparison_type.does_not_start_with:
            case comparison_type.does_not_contain:
            case comparison_type.contains_none:
                return(empty_);

            case comparison_type.equal:
            case comparison_type.not_equal:
            case comparison_type.starts_with:
            case comparison_type.contains:
            case comparison_type.contains_any:
            case comparison_type.regex:
                break;

            default:
                Debug.Assert(false);
                return(empty_);
            }

            return(case_sensitive ? matches_case_sensitive_with_indexes(l, type) : matches_case_insensitive_with_indexes(l, type));
        }
Пример #39
0
        public List<filter_line.match_index> match_indexes(line l, info_type type) {
            List<filter_line.match_index> indexes = new List<filter_line.match_index>();
            lock (this) 
                foreach ( var row in rows_)
                    indexes.AddRange( row.match_indexes(l, type));

            indexes.Sort((x, y) => {
                if (x.start != y.start)
                    return x.start - y.start;
                return -(x.len - y.len);
            });
            return indexes;
        } 
Пример #40
0
 internal static int info_type_to_cell_idx(info_type type) {
     switch (type) {
     case  info_type.line: return 0;
     case  info_type.view: return 1;
     case  info_type.date: return 2;
     case  info_type.time: return 3;
     case  info_type.level: return 4;
     case  info_type.thread: return 5 ;
     case  info_type.file: return 6;
     case  info_type.func: return 7;
     case  info_type.class_: return 8;
     case  info_type.ctx1: return 9;
     case  info_type.ctx2: return 10;
     case  info_type.ctx3: return 11;
     case  info_type.ctx4: return 12;
     case  info_type.ctx5: return 13;
     case  info_type.ctx6: return 14;
     case  info_type.ctx7: return 15;
     case  info_type.ctx8: return 16;
     case  info_type.ctx9: return 17;
     case  info_type.ctx10: return 18;
     case  info_type.ctx11: return 19;
     case  info_type.ctx12: return 20;
     case  info_type.ctx13: return 21;
     case  info_type.ctx14: return 22;
     case  info_type.ctx15: return 23;
     case  info_type.msg: return 24;
     default: Debug.Assert(false); return 0;
     }
 }
Пример #41
0
 OLVColumn column(info_type type)
 {
     switch (type) {
     case info_type.msg:
         return msgCol;
     case info_type.time:
         return timeCol;
     case info_type.date:
         return dateCol;
     case info_type.level:
         return levelCol;
     case info_type.class_:
         return classCol;
     case info_type.file:
         return fileCol;
     case info_type.func:
         return funcCol;
     case info_type.ctx1:
         return ctx1Col;
     case info_type.ctx2:
         return ctx2Col;
     case info_type.ctx3:
         return ctx3Col;
     case info_type.thread:
         // FIXME have its own column!
         return ctx1Col;
     }
     Debug.Assert(false);
     return msgCol;
 }
Пример #42
0
        public string part(info_type i) {
            Debug.Assert(i < info_type.max);
            if (parts[(int) i * 2] < 0 || parts[(int) i * 2 + 1] <= 0)
                return "";

            string msg = sub_.msg;
            try {
                short start = parts[(int) i * 2], len = parts[(int) i * 2 + 1];
                if ( start < msg.Length && start + len <= msg.Length)
                    return msg.Substring(parts[(int) i * 2], parts[(int) i * 2 + 1]);
            } catch {
            }
            // this can happen when the log has changed or has been re-written, thus, the sub_ has become suddenly empty
            return "";
        }
Пример #43
0
        private void show_sub_item(log_view lv, info_type type, RichTextBox text_ctrl) {
            match_item item = lv.sel;
            int row = lv.sel_row_idx;

            string txt = (item as filter.match).line.part(type);
            int col = log_view_cell.info_type_to_cell_idx(type);
            var prints = lv.sel.override_print(lv, txt, type);
            print_info.to_single_enter_char(ref txt, ref prints);

            text_ctrl.Clear();
            text_ctrl.AppendText(txt);
             
            var full_row = lv.list.GetItem(row);

            text_ctrl.BackColor = drawer_.bg_color(full_row, col);

            int last_idx = 0;
            for (int print_idx = 0; print_idx < prints.Count; ++print_idx) {
                int cur_idx = prints[print_idx].Item1, cur_len = prints[print_idx].Item2;
                string before = txt.Substring(last_idx, cur_idx - last_idx);
                if (before != "") {
                    text_ctrl.Select(last_idx, cur_idx - last_idx);
                    text_ctrl.SelectionColor = drawer_.print_fg_color(full_row, default_print_);
                    text_ctrl.SelectionBackColor = drawer_.bg_color(full_row, col);
                }
                text_ctrl.Select(cur_idx, cur_len);
                text_ctrl.SelectionColor = drawer_.print_fg_color(full_row, prints[print_idx].Item3);
                text_ctrl.SelectionBackColor = drawer_.print_bg_color(full_row, prints[print_idx].Item3);
                last_idx = cur_idx + cur_len;
            }
            last_idx = prints.Count > 0 ? prints.Last().Item1 + prints.Last().Item2 : 0;
            if (last_idx < txt.Length) {
                text_ctrl.Select(last_idx, txt.Length - last_idx);
                text_ctrl.SelectionColor = drawer_.print_fg_color(full_row, default_print_);
                text_ctrl.SelectionBackColor = drawer_.bg_color(full_row, col);
            }
            
        }
Пример #44
0
        internal static string cell_value_by_type(match_item i, info_type type) {
            switch (type) {
            case info_type.msg: return i.msg;

            case info_type.time: return i.time;
            case info_type.date: return i.date;
            case info_type.level: return i.level;
            case info_type.thread: return i.thread;
            case info_type.class_: return i.class_;
            case info_type.file: return i.file;
            case info_type.func: return i.func;

            case info_type.line: return "" + i.line;
            case info_type.view: return i.view;

            case info_type.ctx1: return i.ctx1;
            case info_type.ctx2: return i.ctx2;
            case info_type.ctx3: return i.ctx3;
            case info_type.ctx4: return i.ctx4;
            case info_type.ctx5: return i.ctx5;
            case info_type.ctx6: return i.ctx6;
            case info_type.ctx7: return i.ctx7;
            case info_type.ctx8: return i.ctx8;
            case info_type.ctx9: return i.ctx9;
            case info_type.ctx10: return i.ctx10;
            case info_type.ctx11: return i.ctx11;
            case info_type.ctx12: return i.ctx12;
            case info_type.ctx13: return i.ctx13;
            case info_type.ctx14: return i.ctx14;
            case info_type.ctx15: return i.ctx15;
            }
            Debug.Assert(false);
            return i.msg;
        }
Пример #45
0
 private void edit_column(info_type column) {
     var visible = get_visible_parts();
     Debug.Assert(visible.Select(x => x.type).Contains(column));
     edit_column_ = column;
     update_edit_column();
 }
Пример #46
0
        internal static OLVColumn column(log_view lv, info_type type) {
            switch (type) {
            case info_type.line: return lv.lineCol;
            case info_type.view: return lv.viewCol;

            case info_type.msg: return lv. msgCol;

            case info_type.time: return lv. timeCol;
            case info_type.date: return lv. dateCol;
            case info_type.level: return lv. levelCol;
            case info_type.thread: return lv. threadCol;

            case info_type.file: return lv. fileCol;
            case info_type.func: return lv. funcCol;
            case info_type.class_: return lv. classCol;

            case info_type.ctx1: return lv. ctx1Col;
            case info_type.ctx2: return lv. ctx2Col;
            case info_type.ctx3: return lv. ctx3Col;
            case info_type.ctx4: return lv. ctx4Col;
            case info_type.ctx5: return lv. ctx5Col;
            case info_type.ctx6: return lv. ctx6Col;
            case info_type.ctx7: return lv. ctx7Col;
            case info_type.ctx8: return lv. ctx8Col;
            case info_type.ctx9: return lv. ctx9Col;
            case info_type.ctx10: return lv. ctx10Col;
            case info_type.ctx11: return lv. ctx11Col;
            case info_type.ctx12: return lv. ctx12Col;
            case info_type.ctx13: return lv. ctx13Col;
            case info_type.ctx14: return lv. ctx14Col;
            case info_type.ctx15: return lv. ctx15Col;
            }
            Debug.Assert(false);
            return lv. msgCol;
        }
Пример #47
0
        public static string to_friendly_str(info_type i) {
            switch (i) {
            case info_type.time:
                return "Time";
            case info_type.date:
                return "Date";
            case info_type.level:
                return "Level";
            case info_type.thread:
                return "Thread";
            case info_type.class_:
                return "Class";
            case info_type.file:
                return "File";
            case info_type.func:
                return "Func";
            case info_type.ctx1:
                return "Ctx1";
            case info_type.ctx2:
                return "Ctx2";
            case info_type.ctx3:
                return "Ctx3";
            case info_type.ctx4:
                return "Ctx4";
            case info_type.ctx5:
                return "Ctx5";
            case info_type.ctx6:
                return "Ctx6";
            case info_type.ctx7:
                return "Ctx7";
            case info_type.ctx8:
                return "Ctx8";
            case info_type.ctx9:
                return "Ctx9";
            case info_type.ctx10:
                return "Ctx10";
            case info_type.ctx11:
                return "Ctx11";
            case info_type.ctx12:
                return "Ctx12";
            case info_type.ctx13:
                return "Ctx13";
            case info_type.ctx14:
                return "Ctx14";
            case info_type.ctx15:
                return "Ctx15";
            case info_type.msg:
                return "Message";

            case info_type.view:
                return "View(s)";
            case info_type.line:
                return "Line";
            default:
            case info_type.max:
                Debug.Assert(false);
                return "";
            }
        }
Пример #48
0
 private List<match_index> matches_case_sensitive_with_indexes(line l, info_type type) {
     string line_part = l.part(type);
     return compare_with_indexes(line_part, text, words);
 }
Пример #49
0
 private bool is_cell_type_ok(info_type type) {
     switch (type) {
     case info_type.date:
     case info_type.time:
     case info_type.level:
     case info_type.thread:
     case info_type.file:
     case info_type.func:
     case info_type.class_:
     case info_type.view:
     case info_type.line:
         return false;
     }
     return true;
 }
Пример #50
0
 public Rectangle rect_for_column(info_type col_type) {
     if (column_to_controls_.ContainsKey(col_type)) {
         var rect = column_to_controls_[col_type].Item2.RectangleToScreen(column_to_controls_[col_type].Item2.ClientRectangle);
         return RectangleToClient(rect);
     }
     return Rectangle.Empty;
 }
Пример #51
0
        private void update_edit_column() {
            if (visible_columns_.Count < 1)
                // did not set aliases yet
                return;

            var visible = get_visible_parts().Select(x => x.type).ToList();
            if (edit_column_ == info_type.max || !visible.Contains(edit_column_)) 
                edit_column_ = visible[0];

            if (!is_editing_)
                return;

            editColumnName.Text = names_[edit_column_];
            foreach (var column in column_to_controls_) {
                bool edited = column.Key == edit_column_;
                column.Value.Item1.Font = fonts_.get_font(Font, edited, false, false);
                column.Value.Item2.Font = fonts_.get_font(Font, edited, false, false);
            }
            ++ignore_change_;
            var cur = get_visible_parts().FirstOrDefault(x => x.type == edit_column_);
            isMultiline.Checked = cur.multi_line;
            lineCount.Visible = cur.multi_line;
            if (cur.multi_line) {
                if (cur.auto_resize)
                    lineCount.SelectedIndex = 0;
                else
                    lineCount.SelectedIndex = cur.line_count - 1;
            }
            --ignore_change_;
        }
Пример #52
0
 public List<filter_line.match_index> match_indexes(line l, info_type type) {
     List<filter_line.match_index> indexes = null;
     bool has_match_color = font_.match_fg != util.transparent || font_.match_bg != util.transparent;
     if ( has_match_color)
         foreach (filter_line line in items_) {
             var now = line.match_indexes(l, type);
             if (now.Count > 0) {
                 if ( indexes == null)
                     indexes = new List<filter_line.match_index>();
                 // here, we need to set the match colors
                 foreach (var index in now) {
                     index.fg = font_.match_fg;
                     index.bg = font_.match_bg;
                 }
                 indexes.AddRange(now);
             }
         }
     return indexes ?? empty_;
 } 
Пример #53
0
        private void show_sub_item(log_view lv, info_type type, RichTextBox text_ctrl) {
            match_item item = lv.sel;
            int row = lv.sel_row_idx;

            string txt = (item as filter.match).line.part(type);
            int col_idx = log_view_cell.info_type_to_cell_idx(type);
            var prints = lv.sel.override_print(lv, txt, col_idx, column_formatter_base.format_cell.location_type.details_pane).format_text.to_single_enter_char();
            // ... text has changed
            txt = prints.text;

            text_ctrl.Clear();
            text_ctrl.AppendText(txt);
             
            var full_row = lv.list.GetItem(row);

            text_ctrl.BackColor = drawer_.bg_color(full_row, col_idx, prints);

            var parts = prints.parts(default_print_);
            foreach (var part in parts) {
                text_ctrl.Select(part.start, part.len);
                text_ctrl.SelectionColor = drawer_.print_fg_color(full_row, part);
                text_ctrl.SelectionBackColor = drawer_.print_bg_color(full_row, part);
            }
        }
Пример #54
0
        private List<match_index> compare_with_indexes(string line_part, string text, string[] words, info_type type) {
            List<match_index> indexes = new List<match_index>();
            switch (comparison) {
            case comparison_type.does_not_start_with:
            case comparison_type.does_not_contain:
            case comparison_type.contains_none:
                Debug.Assert(false);
                return empty_;

            case comparison_type.equal:
                if ( line_part == text)
                    indexes.Add(new match_index { start = 0, len = text.Length, type = type });
                break;
            case comparison_type.not_equal:
                if ( line_part != text)
                    indexes.Add(new match_index { start = 0, len = text.Length, type = type });
                break;
            case comparison_type.starts_with:
                if ( line_part.StartsWith(text))
                    indexes.Add(new match_index { start = 0, len = text.Length, type = type });
                break;
            case comparison_type.contains:
                int pos = line_part.IndexOf(text);
                if ( pos >= 0)
                    indexes.Add(new match_index { start = pos, len = text.Length, type = type });
                break;

            case comparison_type.contains_any:
                foreach (string word in words) {
                    int word_pos = line_part.IndexOf(word);
                    if ( word_pos >= 0)
                        indexes.Add(new match_index { start = word_pos, len = word.Length, type = type });
                }
                break;

            case comparison_type.regex:
                var matches = regex_.Match(line_part);
                while (matches.Success) {
                    indexes.Add( new match_index { start = matches.Index, len = matches.Length, type = type } );
                    matches = matches.NextMatch();
                }                    
                break;
            default:
                Debug.Assert(false);
                break;
            }

            return indexes;
        }
Пример #55
0
 private void load_categories_task(info_type col_type) {
     var values = full_log.unique_values(col_type, MAX_CATEGORY_UNIQUE_VALUES + 1);
     categories.async_call(() => {
         if (values.Count > MAX_CATEGORY_UNIQUE_VALUES)
             categories.set_error("Too Many Values!");
         else {
             var colors = category_format().get_colors(col_type, values);
             categories.set_categories(colors);
             foreach ( var view in all_log_views_and_full_log())
                 view.set_category_colors(colors, col_type);
         }
     });
 }
Пример #56
0
        public List< match_index > match_indexes(line l, info_type type) {
            if (part == part_type.font || part == part_type.case_sensitive_info)
                return empty_;

            // 1.2.6 for now, care about match indexes only for msg column
            if (type != info_type.msg)
                return empty_;

            // we only care about "positive" matches - those that have "containing", "startswith", regex, etc.
            switch (comparison) {
            case comparison_type.does_not_start_with:
            case comparison_type.does_not_contain:
            case comparison_type.contains_none:
                return empty_;

            case comparison_type.equal:
            case comparison_type.not_equal:
            case comparison_type.starts_with:
            case comparison_type.contains:
            case comparison_type.contains_any:
            case comparison_type.regex:
                break;
            default:
                Debug.Assert(false);
                return empty_;
            }

            return case_sensitive ? matches_case_sensitive_with_indexes(l, type) : matches_case_insensitive_with_indexes(l, type);
        }
Пример #57
0
 private List<match_index> matches_case_insensitive_with_indexes(line l, info_type type) {
     string line_part = l.part(type).ToLower();
     return compare_with_indexes(line_part, lo_text, lo_words, type);
 }
Пример #58
0
 public bool is_column_searchable(info_type col) {
     if (all_columns)
         return info_type_io.is_searchable(col);
     else
         return col == info_type.msg;
 }
Пример #59
0
        public string part(info_type i) {
            Debug.Assert(i < info_type.max);
            if (parts[(int) i * 2] < 0 || parts[(int) i * 2 + 1] <= 0)
                return "";

            string result = "";
            string msg = sub_.msg;
            try {
                short start = parts[(int) i * 2], len = parts[(int) i * 2 + 1];
                if (start < msg.Length && start + len <= msg.Length)
                    result = msg.Substring(parts[(int) i * 2], parts[(int) i * 2 + 1]);
            } catch {
                // this can happen when the log has changed or has been re-written, thus, the sub_ has become suddenly empty
            }

            if (app.inst.force_text_as_multi_line)
                result = util.split_into_multiple_fixed_lines(result, 15);

            return result;
        }
Пример #60
0
 public List<Tuple<int, int, print_info>> override_print(log_view parent, string text, info_type type) {
     return override_print(parent, text, log_view_cell.info_type_to_cell_idx(type));
 }