Example #1
0
        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));
                }
            }
        }
Example #2
0
 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));
     }
 }
Example #3
0
 private void ok_Click(object sender, EventArgs e)
 {
     if (txt.Text != "") {
         sett.set("search_bg", util.color_to_str(bg.BackColor));
         sett.set("search_fg", util.color_to_str(fg.BackColor));
         sett.set("search_text", txt.Text);
         sett.save();
         search_ = new search_for {text = txt.Text, bg = bg.BackColor, fg = fg.BackColor, mark_lines_with_color = mark.Checked};
         DialogResult = DialogResult.OK;
     }
 }
Example #4
0
 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);
     }
 }
Example #5
0
 private void ok_Click(object sender, EventArgs e)
 {
     if (txt.Text != "")
     {
         sett.set("search_bg", util.color_to_str(bg.BackColor));
         sett.set("search_fg", util.color_to_str(fg.BackColor));
         sett.set("search_text", txt.Text);
         sett.save();
         search_ = new search_for {
             text = txt.Text, bg = bg.BackColor, fg = fg.BackColor, mark_lines_with_color = mark.Checked
         };
         DialogResult = DialogResult.OK;
     }
 }
Example #6
0
        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());
                }
            }
        }
Example #7
0
 public static bool matches(IEnumerable <string> cells, search_for search)
 {
     return(cells.Any(cell => matches_cell(cell, search)));
 }
Example #8
0
 public static bool matches(filter.match item, IEnumerable <info_type> cols, search_for search)
 {
     return(matches(item.line, cols, search));
 }