Ejemplo n.º 1
0
        public Settings()
        {
            RecentFiles       = string.Empty;
            RecentPatternSets = string.Empty;
            Font                        = new Font("Consolas", 8.25f, GraphicsUnit.Point);
            RestoreScreenLoc            = false;             // False so that first runs start in the default window position
            ScreenPosition              = new Point(100, 100);
            WindowSize                  = new Size(640, 480);
            PatternSetDirectory         = Util.ResolveUserDocumentsPath(Application.CompanyName, Application.ProductName);
            ExportFilepath              = null;
            AlternateLineColours        = true;
            LineSelectBackColour        = Color.DarkGreen;
            LineSelectForeColour        = Color.White;
            LineBackColour1             = Color.WhiteSmoke;
            LineBackColour2             = Color.White;
            LineForeColour1             = Color.Black;
            LineForeColour2             = Color.Black;
            FileScrollWidth             = Constants.FileScrollWidthDefault;
            ScrollBarFileRangeColour    = Color.FromArgb(0x80, Color.White);
            ScrollBarCachedRangeColour  = Color.FromArgb(0x40, Color.LightBlue);
            ScrollBarDisplayRangeColour = Color.FromArgb(0x80, Color.SteelBlue);
            BookmarkColour              = Color.Violet;
            RowHeight                   = Constants.RowHeightDefault;
            LoadLastFile                = false;
            LastLoadedFile              = string.Empty;
            OpenAtEnd                   = true;
            FullPathInTitle             = true;
            TabSizeInSpaces             = 4;
            FileChangesAdditive         = true;
            IgnoreBlankLines            = false;
            AlwaysOnTop                 = false;
            FirstRun                    = true;
            ShowTOTD                    = true;
            CheckForUpdates             = false;
            CheckForUpdatesServer       = "http://www.rylogic.co.nz/";
            UseWebProxy                 = false;
            WebProxyHost                = string.Empty;
            WebProxyPort                = Constants.PortNumberWebProxyDefault;
            QuickFilterEnabled          = false;
            HighlightsEnabled           = true;
            FiltersEnabled              = false;
            TransformsEnabled           = false;
            ActionsEnabled              = false;
            TailEnabled                 = true;
            WatchEnabled                = true;
            FileBufSize                 = Constants.FileBufSizeDefault;
            MaxLineLength               = Constants.MaxLineLengthDefault;
            LineCacheCount              = Constants.LineCacheCountDefault;
            Patterns                    = PatternSet.Default();
            RowDelimiter                = string.Empty;             // stored in humanised form, empty means auto detect
            ColDelimiter                = string.Empty;             // stored in humanised form, empty means auto detect
            ColumnCount                 = 2;
            Encoding                    = string.Empty;             // empty means auto detect
            OutputFilepathHistory       = new string[0];
            LogProgramOutputHistory     = new LaunchApp[0];
            NetworkConnectionHistory    = new NetConn[0];
            SerialConnectionHistory     = new SerialConn[0];
            PipeConnectionHistory       = new PipeConn[0];
            AndroidLogcat               = new AndroidLogcat();

            AutoSaveOnChanges = true;
        }
Ejemplo n.º 2
0
        /// <summary>Create a default collection of patterns</summary>
        public static PatternSet Default()
        {
            var ps = new PatternSet();

            #region Highlights
            {
                ps.Highlights.Add(new Highlight
                {
                    Expr        = @"(Error:)|(E/)",
                    PatnType    = EPattern.RegularExpression,
                    ForeColour  = Color.FromArgb(0xff, 0xff, 0xff, 0xff),
                    BackColour  = Color.FromArgb(0xff, 0x8b, 0x00, 0x00),
                    IgnoreCase  = false,
                    Invert      = false,
                    WholeLine   = false,
                    BinaryMatch = true,
                    Active      = true,
                });
                ps.Highlights.Add(new Highlight
                {
                    Expr        = @"(Warn:)|(W/)",
                    PatnType    = EPattern.RegularExpression,
                    ForeColour  = Color.FromArgb(0xff, 0x00, 0x00, 0x00),
                    BackColour  = Color.FromArgb(0xff, 0xff, 0xff, 0x00),
                    IgnoreCase  = false,
                    Invert      = false,
                    WholeLine   = false,
                    BinaryMatch = true,
                    Active      = true,
                });
                ps.Highlights.Add(new Highlight
                {
                    Expr        = @"(Info:)|(I/)",
                    PatnType    = EPattern.RegularExpression,
                    ForeColour  = Color.FromArgb(0xff, 0x00, 0x00, 0x00),
                    BackColour  = Color.FromArgb(0xff, 0xc4, 0xff, 0xff),
                    IgnoreCase  = false,
                    Invert      = false,
                    WholeLine   = false,
                    BinaryMatch = true,
                    Active      = true,
                });
                ps.Highlights.Add(new Highlight
                {
                    Expr        = @"#",
                    PatnType    = EPattern.Substring,
                    ForeColour  = Color.FromArgb(0xff, 0x00, 0x00, 0x00),
                    BackColour  = Color.FromArgb(0xff, 0xc4, 0xff, 0xc7),
                    IgnoreCase  = false,
                    Invert      = false,
                    WholeLine   = false,
                    BinaryMatch = true,
                    Active      = true,
                });
                ps.Highlights.Add(new Highlight
                {
                    Expr        = @"\w+\.txt",
                    Active      = true,
                    PatnType    = EPattern.RegularExpression,
                    IgnoreCase  = false,
                    Invert      = false,
                    WholeLine   = false,
                    ForeColour  = Color.FromArgb(0xFF, 0x2A, 0x00, 0xFF),
                    BackColour  = Color.FromArgb(0xFF, 0xB3, 0xCD, 0xF2),
                    BinaryMatch = false,
                });
            }
            #endregion
            #region Filters
            {
                ps.Filters.Add(new Filter
                {
                    Expr       = @"##",
                    Active     = true,
                    PatnType   = EPattern.Substring,
                    IgnoreCase = false,
                    Invert     = false,
                    WholeLine  = false,
                    IfMatch    = EIfMatch.Reject
                });
            }
            #endregion
            #region Transforms
            {
            }
            #endregion
            #region Actions
            {
                ps.Actions.Add(new ClkAction
                {
                    Expr             = @"\w+\.txt",
                    Active           = true,
                    PatnType         = EPattern.RegularExpression,
                    IgnoreCase       = false,
                    Invert           = false,
                    WholeLine        = false,
                    Executable       = @"C:\windows\notepad.exe",
                    Arguments        = @"{FilePath}",
                    WorkingDirectory = string.Empty
                });
            }
            #endregion
            return(ps);
        }
Ejemplo n.º 3
0
        /// <summary>Performs an export from the command line</summary>
        public static void ExportToFile(StartupOptions startup_options)
        {
            string tmp_settings_path = Path.Combine(Path.GetTempPath(), "rylog_settings_" + Guid.NewGuid() + ".xml");

            try
            {
                // Copy the settings to a tmp file so that we don't trash the normal settings
                if (Path_.FileExists(startup_options.SettingsPath))
                {
                    File.Copy(startup_options.SettingsPath, tmp_settings_path);
                }
                else
                {
                    new Settings().Save(tmp_settings_path);
                }
                startup_options.SettingsPath = tmp_settings_path;

                // Load an instance of the app and the options.
                var m = new Main(startup_options);

                // Override settings passed on the command line
                if (startup_options.RowDelim != null)
                {
                    m.Settings.RowDelimiter = startup_options.RowDelim;
                }
                if (startup_options.ColDelim != null)
                {
                    m.Settings.ColDelimiter = startup_options.ColDelim;
                }
                if (startup_options.PatternSetFilepath != null)
                {
                    // Specifying a pattern set implies the filters and transforms should be enabled
                    m.Settings.Patterns          = PatternSet.Load(startup_options.PatternSetFilepath);
                    m.Settings.FiltersEnabled    = true;
                    m.Settings.TransformsEnabled = true;
                }

                // Do the export
                using (var outp = new StreamWriter(new FileStream(startup_options.ExportPath, FileMode.Create, FileAccess.Write, FileShare.Read)))
                {
                    try
                    {
                        var d = new BLIData(m, new SingleFile(startup_options.FileToLoad));
                        using (d.file)
                        {
                            var rng           = new[] { new RangeI(0, long.MaxValue) };
                            var row_delimiter = Misc.Robitise(m.Settings.RowDelimiter);
                            var col_delimiter = Misc.Robitise(m.Settings.ColDelimiter);

                            if (startup_options.NoGUI)
                            {
                                using (var done = new ManualResetEvent(false))
                                {
                                    ThreadPool.QueueUserWorkItem(x =>
                                    {
                                        d.progress = (c, l) => true;
                                        DoExport(d, rng, row_delimiter, col_delimiter, outp);
                                        done.Set();
                                    });

                                    done.WaitOne();
                                    if (!startup_options.Silent)
                                    {
                                        Console.WriteLine("Export completed successfully.");
                                    }
                                }
                            }
                            else
                            {
                                if (m.DoExportWithProgress(d, rng, row_delimiter, col_delimiter, outp))
                                {
                                    if (!startup_options.Silent)
                                    {
                                        Console.WriteLine("Export completed successfully.");
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Environment.ExitCode = 1;
                        if (!startup_options.Silent)
                        {
                            Console.WriteLine($"Export failed.\r\n{ex.Message}");
                        }
                    }
                }
            }
            finally
            {
                if (Path_.FileExists(tmp_settings_path))
                {
                    File.Delete(tmp_settings_path);
                }
            }
        }
Ejemplo n.º 4
0
 public PatternSetUI(PatternSet set)
 {
     InitializeComponent();
     m_tree.ShowRoot = false;
     Set             = set;
 }