// these are the settings that are to be saved in the context static public log_settings_string get_context_dependent_settings(text_reader reader, log_settings_string_readonly settings) { log_settings_string result; if (reader is file_text_reader) result = settings.sub(new []{ settings.syntax.get(), settings.aliases, settings.description_template }); else result = new log_settings_string( settings.ToString()); result.is_open_first_time.reset(); result.apply_column_positions_to_me.reset(); result.column_positions.reset(); result.available_columns.reset(); return result; }
public static bool is_single_line(string file, log_settings_string_readonly sett) { string[] lines = util.read_beginning_of_file(file, 16834).Split('\n'); for (int index = 0; index < lines.Length; index++) { lines[index] = lines[index].Replace("\r", ""); } int empty_lines = 0; string separator = sett.part_separator; if (separator == "") { separator = ":"; } int contains_separator = 0; foreach (string line in lines) { if (line == "") { ++empty_lines; } else if (line.Contains(separator)) { ++contains_separator; } } // at least 3 entries if (empty_lines > 3) { if (contains_separator + empty_lines == lines.Length) { return(true); } } return(false); }
public static bool is_single_line(string file, log_settings_string_readonly sett) { string[] lines = util.read_beginning_of_file(file, 16834).Split( '\n' ); for (int index = 0; index < lines.Length; index++) lines[index] = lines[index].Replace("\r", ""); int empty_lines = 0; string separator = sett.part_separator; if (separator == "") separator = ":"; int contains_separator = 0; foreach ( string line in lines) if (line == "") ++empty_lines; else if (line.Contains(separator)) ++contains_separator; // at least 3 entries if ( empty_lines > 3) if (contains_separator + empty_lines == lines.Length) return true; return false; }
private ui_context settings_to_context(log_settings_string_readonly log_settings) { string context_name = log_settings.context; if (context_name != "") { var existing = contexts_.FirstOrDefault(x => x.name == context_name); if (existing != null) // 1.5.6+ - we now keep the context in the settings return existing; } // old way of forcing file to have a context (pre 1.5.6) string file = log_settings.type == log_type.file ? log_settings.name : ""; if ( file != "" && app.inst.forced_file_to_context.ContainsKey(file)) { string forced = app.inst.forced_file_to_context[file]; var context_from_forced = contexts_.FirstOrDefault(x => x.name == forced); if (context_from_forced != null) // return it, only if we have a specific Template for it return context_from_forced; } if (file != "") { string from_header = log_to.file_to_context(file); if (from_header != null) { // ... case-insensitive search (easier for user) var context_from_header = contexts_.FirstOrDefault(x => x.name.ToLower() == from_header.ToLower()); if (context_from_header != null) // return it, only if we have a specific Template for it return context_from_header; } // 1.1.25+ - match the context that matches the name completely string name_no_ext = util.filename_no_ext(file); var found = contexts_.FirstOrDefault(x => x.name == name_no_ext); if (found != null) return found; } var default_ = contexts_.FirstOrDefault(x => x.name == "Default"); return default_ ?? contexts_[0]; }
protected log_parser_base(log_settings_string_readonly sett) { sett_ = sett; sett_.on_changed += on_settings_changed; on_updated_settings(); }
// these are the settings that are to be saved per-log static public log_settings_string get_log_dependent_settings(text_reader reader, log_settings_string_readonly settings) { return(new log_settings_string(settings.ToString())); }
// these are the settings that are to be saved in the context static public log_settings_string get_context_dependent_settings(text_reader reader, log_settings_string_readonly settings) { log_settings_string result; if (reader is file_text_reader) { result = settings.sub(new [] { settings.syntax.get(), settings.aliases, settings.description_template }); } else { result = new log_settings_string(settings.ToString()); } result.is_open_first_time.reset(); result.apply_column_positions_to_me.reset(); result.column_positions.reset(); result.available_columns.reset(); return(result); }
// these are the settings that are to be saved per-log static public log_settings_string get_log_dependent_settings(text_reader reader, log_settings_string_readonly settings) { return new log_settings_string( settings.ToString()); }
public void merge_settings(log_settings_string_readonly other_sett, bool edited_syntax_now) { if ( edited_syntax_now) if ( default_settings_.syntax == "") default_settings_.syntax .set(other_sett.syntax); default_settings_.aliases.set(other_sett.aliases); default_settings_.description_template.set(other_sett.description_template); }
// these are the settings that are to be saved in the context static public log_settings_string get_context_dependent_settings(text_reader reader, log_settings_string_readonly settings) { if (reader is file_text_reader) return settings.sub(new []{ settings.syntax.get(), settings.aliases, settings.description_template }); return new log_settings_string( settings.ToString()); }