Beispiel #1
0
 private void RunExternal(string file, int lineNum)
 {
     Logic.RunExternal(file, lineNum);
 }
Beispiel #2
0
        internal void HandleKeyDownOnResults(KeyEventArgs e, int line)
        {
            var supress = true;

            switch (e.KeyCode)
            {
            case Keys.Space:
            {
                var(file, lineNum) = Logic.LookupFileAtLine(line);
                if (file != null)
                {
                    PreviewFile(file, lineNum);
                }
                break;
            }

            case Keys.Enter:
            {
                var(file, lineNum) = Logic.LookupFileAtLine(line);
                if (file != null)
                {
                    EditFile(file, lineNum);
                }
                break;
            }

            case Keys.P:
            {
                var(file, lineNum) = Logic.LookupFileAtLine(line);
                if (file != null)
                {
                    OpenProject(file, lineNum);
                }
                break;
            }

            case Keys.N:
            {
                CreateNote();
                break;
            }

            case Keys.G:
            {
                var(file, lineNum) = Logic.LookupFileAtLine(line);
                if (file != null)
                {
                    GitLog(file);
                }
                break;
            }

            case Keys.R:
            {
                var(file, lineNum) = Logic.LookupFileAtLine(line);
                RunExternal(file, lineNum);
                break;
            }

            case Keys.D:
            {
                var(file, lineNum) = Logic.LookupFileAtLine(line);
                OpenContainingDirectory(file);
                break;
            }

            case Keys.F:
            {
                Ui.searchControl.searchTextBox.Focus();
                break;
            }

            default:
            {
                supress = false;
            }
            break;
            }
            if (supress)
            {
                e.Handled          = true;
                e.SuppressKeyPress = true;
            }
        }
Beispiel #3
0
        public MainFormBehind(MainFormUi ui)
        {
            void SetupScintilla()
            {
                var scintilla = SciUtil.CreateScintilla();

                scintilla.UpdateUI += (o, e) =>
                {
                    if (e.Change == UpdateChange.Selection)
                    {
                        UpdateStatusBar();
                    }
                };
                //sci.ReadOnly = true;
                ui.resultBox = scintilla;
                ui.form.Controls.Add(ui.resultBox);
                ui.resultBox.Dock = DockStyle.Fill;
                ui.searchTextBox.Select();
                ui.tableLayout.Controls.Add(ui.resultBox, 0, 1);
            }

            this.Ui = ui;
            SetupScintilla();
            ui.searchTextBox.KeyDown += (o, e) =>
            {
                if (e.KeyCode == Keys.Enter)
                {
                    SearchStartEvent(ui, e);
                }
            };
            ui.dirSelector.KeyDown += (o, e) =>
            {
                if (e.KeyCode == Keys.Enter)
                {
                    SearchStartEvent(ui, e);
                }
            };

            ui.resultBox.KeyDown += (o, e) =>
            {
                HandleKeyDownOnResults(e, ui.resultBox.CurrentLine);
            };
            ui.resultBox.KeyPress += (o, e) =>
            {
                // prevent PLING sound
                e.Handled = true;
            };
            SciUtil.SetAllText(ui.resultBox, Logic.Tutorial);

            ui.dirSelector.DataSource   = Logic.DirHistory;
            ui.searchTextBox.DataSource = Logic.SearchHistory;
            ui.rgArgsComboBox.Items.AddRange(new[]
            {
                Logic.RgExtraArgs,
                "--files",
                "-m 5 --smart-case",
                "-M 1000",
                "-g *.cs -g *.csproj",
                "--no-ignore",
                "--context 2"
            });
            ui.rgArgsComboBox.TextChanged += (o, e) =>
            {
                Logic.RgExtraArgs = ui.rgArgsComboBox.Text;
                UpdateStatusBar();
            };

            ui.dirSelector.Text = Logic.WorkDir;
            ui.btnAbort.Click  += (o, e) =>
            {
                ui.btnAbort.Visible = false;
                Logic.KillSearch();
            };
            LiveSearchEvents(ui);

            if (Logic.InitialSearchString != null)
            {
                ui.searchTextBox.Text     = Logic.InitialSearchString;
                Logic.InitialSearchString = null;
                Logic.StartSearch(ui);
            }
            UpdateStatusBar();
        }
Beispiel #4
0
 private static void SearchStartEvent(MainFormUi ui, KeyEventArgs e)
 {
     e.SuppressKeyPress = true;
     e.Handled          = true;
     Logic.StartSearch(ui);
 }
Beispiel #5
0
 private void UpdateStatusBar()
 {
     var(file, line)                = Logic.LookupFileAtLine(Ui.resultBox.CurrentLine, relative: true);
     Ui.statusLabel.Text            = $"{file} +{line}";
     Ui.statusLabelCurrentArgs.Text = Logic.RgExtraArgs;
 }