item_at() приватный Метод

private item_at ( int idx ) : match_item
idx int
Результат match_item
Пример #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
        private void load_surrounding_rows(log_view lv)
        {
            int sel = lv.sel_row_idx;

            if (sel < 0)
            {
                sel = 0;
            }
            // get as many rows as possible, in both directions
            int max_count = Math.Min(app.inst.look_around_find, lv.item_count);
            var surrounding = util.surrounding(sel, max_count, 0, lv.item_count);
            int min = surrounding.Item1, max = surrounding.Item2;

            // at this point, we know the start and end
            for (int idx = min; idx < max; ++idx)
            {
                var           i   = lv.item_at(idx);
                List <string> row = new List <string>();
                foreach (int col_idx in column_indexes_)
                {
                    row.Add(log_view_cell.cell_value(i, col_idx));
                }
                preview_items_.Add(row);
            }

            for (int match_idx = 0; match_idx < preview_items_.Count; ++match_idx)
            {
                matches_.Add(match_idx);
            }
        }
Пример #3
0
        public Color sel_bg_color()
        {
            int row_idx = parent_.sel_row_idx;

            if (row_idx < 0)
            {
                return(drawer_.sel_bg_color(app.inst.bg));
            }
            int        col_idx  = parent_.cur_col_idx;
            match_item i        = parent_.item_at(row_idx);
            var        col_type = log_view_cell.cell_idx_to_type(col_idx);
            var        txt      = log_view_cell.cell_value_by_type(i, col_type);
            var        print    = category_formatted(cache_.override_print(i, txt, row_idx, col_idx), i, col_type);
            var        bg       = i.bg(parent_);

            return(drawer_.sel_bg_color(print.bg != util.transparent ? print.bg : bg));
        }
Пример #4
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);
        }
Пример #5
0
        private void load_surrounding_rows()
        {
            int sel = lv_.sel_row_idx;

            if (sel < 0)
            {
                sel = 0;
            }
            // get as many rows as possible, in both directions
            int max_count = Math.Min(app.inst.look_around_edit_column_formatting, lv_.item_count);
            int min = sel - max_count / 2, max = sel + max_count / 2;

            if (min < 0)
            {
                max += -min;
                min  = 0;
            }
            if (max > lv_.item_count)
            {
                min -= max - lv_.item_count;
                max  = lv_.item_count;
            }
            if (min < 0)
            {
                min = 0;
            }
            if (max > lv_.item_count)
            {
                max = lv_.item_count;
            }
            // at this point, we know the start and end
            List <match_item> preview_items = new List <match_item>();

            for (int idx = min; idx < max; ++idx)
            {
                var i = lv_.item_at(idx);
                preview_items.Add(i);
            }

            list.AddObjects(preview_items);
        }
Пример #6
0
        // returns the overrides, sorted by index in the string to print
        public column_formatter_base.format_cell override_print(log_view parent, string text, int col_idx, column_formatter_base.format_cell.location_type location)
        {
            int    row_idx     = parent.item_index(this);
            int    top_row_idx = parent.top_row_idx;
            string prev_text   = "";

            if (row_idx > 0)
            {
                prev_text = log_view_cell.cell_value(parent.item_at(row_idx - 1), col_idx);
            }

            int  sel_index  = parent.sel_row_idx_ui_thread;
            bool is_bokmark = parent.has_bookmark(line_idx);

            var cell = new column_formatter_base.format_cell(this, parent, col_idx, log_view_cell.cell_idx_to_type(col_idx), new formatted_text(text),
                                                             row_idx, top_row_idx, sel_index, is_bokmark, prev_text, location);

            parent.formatter.format_before(cell);
            var print = override_print_from_all_places(parent, cell.format_text.text, col_idx);

            cell.format_text.add_parts(print);
            parent.formatter.format_after(cell);
            return(cell);
        }
Пример #7
0
        // returns the overrides, sorted by index in the string to print
        public column_formatter_base.format_cell override_print(log_view parent, string text, int col_idx, column_formatter_base.format_cell.location_type location) {
            int row_idx = parent.item_index(this);
            int top_row_idx = parent.top_row_idx;
            string prev_text = "";
            if (row_idx > 0)
                prev_text = log_view_cell.cell_value(parent.item_at(row_idx - 1), col_idx);

            int sel_index = parent.sel_row_idx_ui_thread;
            bool is_bokmark = parent.has_bookmark(line_idx);

            var cell = new column_formatter_base.format_cell(this, parent, col_idx, log_view_cell.cell_idx_to_type(col_idx), new formatted_text(text),
                row_idx, top_row_idx, sel_index, is_bokmark, prev_text, location);
            parent.formatter.format_before(cell);
            var print = override_print_from_all_places(parent, cell.format_text.text, col_idx);
            cell.format_text.add_parts( print);
            parent.formatter.format_after(cell);
            return cell;
        } 
Пример #8
0
        private void load_surrounding_rows(log_view lv) {
            int sel = lv.sel_row_idx;
            if (sel < 0)
                sel = 0;
            // get as many rows as possible, in both directions
            int max_count = Math.Min(MAX_PREVIEW_ROWS, lv.item_count);
            int min = sel - max_count / 2, max = sel + max_count / 2;
            if (min < 0) {
                max += -min;
                min = 0;
            }
            if (max > lv.item_count) {
                min -= max - lv.item_count;
                max = lv.item_count;
            }
            if (min < 0)
                min = 0;
            if (max > lv.item_count)
                max = lv.item_count;
            // at this point, we know the start and end

            // see which columns actuall have useful data
            List< Tuple<int,int>> columns_and_displayidx = new List<Tuple<int,int>>();
            for (int col_idx = 0; col_idx < lv.list.AllColumns.Count; ++col_idx) {
                if ( lv.list.AllColumns[col_idx].Width > 0)
                    if ( lv.visible_columns.Contains(log_view_cell.cell_idx_to_type(col_idx)))
                        columns_and_displayidx.Add( new Tuple<int, int>(col_idx, lv.list.AllColumns[col_idx].DisplayIndex ));
            }
            var columns = columns_and_displayidx.OrderBy(x => x.Item2).Select(x => x.Item1).ToList();

            for (int idx = min; idx < max; ++idx) {
                var i = lv.item_at(idx);
                List<string> row = new List<string>();
                foreach (int col_idx in columns)
                    row.Add(log_view_cell.cell_value(i, col_idx));
                preview_items_.Add(row);
            }

            searchable_columns_.Clear();
            searchable_columns_msg_only_.Clear();
            int preview_col_idx = 0;
            foreach (int col_idx in columns) {
                result.AllColumns[preview_col_idx].Width = lv.list.AllColumns[col_idx].Width;
                result.AllColumns[preview_col_idx].Text = lv.list.AllColumns[col_idx] != lv.msgCol ? lv.list.AllColumns[col_idx].Text : "Message";
                result.AllColumns[preview_col_idx].FillsFreeSpace = lv.list.AllColumns[col_idx].FillsFreeSpace;
                // note: the line column never enters the search
                bool is_searchable = info_type_io.is_searchable(log_view_cell.cell_idx_to_type(col_idx));
                if (is_searchable)
                    searchable_columns_.Add(preview_col_idx);
                if ( lv.msgCol == lv.list.AllColumns[col_idx])
                    searchable_columns_msg_only_.Add(preview_col_idx);

                if (lv.lineCol != lv.list.AllColumns[col_idx])
                    result.AllColumns[preview_col_idx].Renderer = render_;
                ++preview_col_idx;
            }
            for (; preview_col_idx < result.AllColumns.Count; ++preview_col_idx)
                result.AllColumns[preview_col_idx].IsVisible = false;
            result.RebuildColumns();

            for ( int match_idx = 0; match_idx < preview_items_.Count; ++match_idx)
                matches_.Add(match_idx);
        }
Пример #9
0
        private void load_surrounding_rows(log_view lv) {

            int sel = lv.sel_row_idx;
            if (sel < 0)
                sel = 0;
            // get as many rows as possible, in both directions
            int max_count = Math.Min(MAX_PREVIEW_ROWS, lv.item_count);
            int min = sel - max_count / 2, max = sel + max_count / 2;
            if (min < 0) {
                max += -min;
                min = 0;
            }
            if (max > lv.item_count) {
                min -= max - lv.item_count;
                max = lv.item_count;
            }
            if (min < 0)
                min = 0;
            if (max > lv.item_count)
                max = lv.item_count;
            // at this point, we know the start and end
            for (int idx = min; idx < max; ++idx) {
                var i = lv.item_at(idx);
                List<string> row = new List<string>();
                foreach (int col_idx in column_indexes_)
                    row.Add(log_view_cell.cell_value(i, col_idx));
                preview_items_.Add(row);
            }

            for ( int match_idx = 0; match_idx < preview_items_.Count; ++match_idx)
                matches_.Add(match_idx);
        }
Пример #10
0
        private void load_surrounding_rows(log_view lv) {
            int sel = lv.sel_row_idx;
            if (sel < 0)
                sel = 0;
            // get as many rows as possible, in both directions
            int max_count = Math.Min(app.inst.look_around_find, lv.item_count);
            var surrounding = util.surrounding(sel, max_count, 0, lv.item_count);
            int min = surrounding.Item1, max = surrounding.Item2;
            // at this point, we know the start and end
            for (int idx = min; idx < max; ++idx) {
                var i = lv.item_at(idx);
                List<string> row = new List<string>();
                foreach (int col_idx in column_indexes_)
                    row.Add(log_view_cell.cell_value(i, col_idx));
                preview_items_.Add(row);
            }

            for ( int match_idx = 0; match_idx < preview_items_.Count; ++match_idx)
                matches_.Add(match_idx);
        }
Пример #11
0
        private void load_surrounding_rows(log_view lv)
        {
            int sel = lv.sel_row_idx;

            if (sel < 0)
            {
                sel = 0;
            }
            // get as many rows as possible, in both directions
            int max_count = Math.Min(MAX_PREVIEW_ROWS, lv.item_count);
            int min = sel - max_count / 2, max = sel + max_count / 2;

            if (min < 0)
            {
                max += -min;
                min  = 0;
            }
            if (max > lv.item_count)
            {
                min -= max - lv.item_count;
                max  = lv.item_count;
            }
            if (min < 0)
            {
                min = 0;
            }
            if (max > lv.item_count)
            {
                max = lv.item_count;
            }
            // at this point, we know the start and end

            // see which columns actuall have useful data
            List <Tuple <int, int> > columns_and_displayidx = new List <Tuple <int, int> >();

            for (int col_idx = 0; col_idx < lv.list.AllColumns.Count; ++col_idx)
            {
                if (lv.list.AllColumns[col_idx].Width > 0)
                {
                    if (lv.visible_columns.Contains(log_view_cell.cell_idx_to_type(col_idx)))
                    {
                        columns_and_displayidx.Add(new Tuple <int, int>(col_idx, lv.list.AllColumns[col_idx].DisplayIndex));
                    }
                }
            }
            var columns = columns_and_displayidx.OrderBy(x => x.Item2).Select(x => x.Item1).ToList();

            for (int idx = min; idx < max; ++idx)
            {
                var           i   = lv.item_at(idx);
                List <string> row = new List <string>();
                foreach (int col_idx in columns)
                {
                    row.Add(log_view_cell.cell_value(i, col_idx));
                }
                preview_items_.Add(row);
            }

            int preview_col_idx = 0;

            foreach (int col_idx in columns)
            {
                result.AllColumns[preview_col_idx].Width          = lv.list.AllColumns[col_idx].Width;
                result.AllColumns[preview_col_idx].Text           = lv.list.AllColumns[col_idx] != lv.msgCol ? lv.list.AllColumns[col_idx].Text : "Message";
                result.AllColumns[preview_col_idx].FillsFreeSpace = lv.list.AllColumns[col_idx].FillsFreeSpace;
                // note: the line column never enters the search
                if (lv.lineCol == lv.list.AllColumns[col_idx])
                {
                    line_col_ = preview_col_idx;
                }
                else
                {
                    result.AllColumns[preview_col_idx].Renderer = render_;
                }
                ++preview_col_idx;
            }
            for (; preview_col_idx < result.AllColumns.Count; ++preview_col_idx)
            {
                result.AllColumns[preview_col_idx].IsVisible = false;
            }
            result.RebuildColumns();

            for (int match_idx = 0; match_idx < preview_items_.Count; ++match_idx)
            {
                matches_.Add(match_idx);
            }
        }