Esempio n. 1
0
        void OnVariableBreakpoint(object sender, EventArgs e)
        {
            if (_menu.Key.VirtualKeyCode != 0)
            {
                return;
            }

            string file = null;

            if (_editor != null)
            {
                file = _editor.FileName;
            }

            BreakpointDialog ui = new BreakpointDialog(2, file, 0);

            if (!ui.Show())
            {
                return;
            }

            string code = "Set-PSBreakpoint -Variable $args[0] -Mode $args[1]";

            if (ui.Script.Length > 0)
            {
                code += " -Script $args[2]";
            }
            if (ui.Action != null)
            {
                code += " -Action $args[3]";
            }
            A.InvokeCode(code, ui.Matter, ui.Mode, ui.Script, ui.Action);
        }
Esempio n. 2
0
        void OnLineBreakpoint(object sender, EventArgs e)
        {
            if (_menu.Key.VirtualKeyCode != 0)
            {
                return;
            }

            string file = null;
            int    line = 0;

            LineBreakpoint bpFound = null;

            if (_editor != null)
            {
                // location
                file = _editor.FileName;
                line = _editor.Caret.Y + 1;

                // find
                foreach (PSObject o in _breakpoints)
                {
                    if (o.BaseObject is LineBreakpoint lbp && lbp.Action == null && line == lbp.Line && Kit.Equals(file, lbp.Script))
                    {
                        bpFound = lbp;
                        break;
                    }
                }

                // found?
                if (bpFound != null)
                {
                    switch (Far.Api.Message("Breakpoint exists",
                                            "Line breakpoint",
                                            MessageOptions.None,
                                            new string[] {
                        "&Remove",
                        bpFound.Enabled ? "&Disable" : "&Enable",
                        "&Modify",
                        "&Add",
                        "&Cancel"
                    }))
                    {
                    case 0:
                        A.RemoveBreakpoint(bpFound);
                        return;

                    case 1:
                        if (bpFound.Enabled)
                        {
                            A.DisableBreakpoint(bpFound);
                        }
                        else
                        {
                            A.InvokeCode("Enable-PSBreakpoint -Breakpoint $args[0]", bpFound);
                        }
                        return;

                    case 2:
                        break;

                    case 3:
                        bpFound = null;
                        break;

                    default:
                        return;
                    }
                }
            }

            // go
            BreakpointDialog ui = new BreakpointDialog(0, file, line);

            if (!ui.Show())
            {
                return;
            }

            // remove old
            if (bpFound != null)
            {
                A.RemoveBreakpoint(bpFound);
            }

            // set new
            A.SetBreakpoint(ui.Script, int.Parse(ui.Matter, null), ui.Action);
        }
Esempio n. 3
0
        void OnCommandBreakpoint(object sender, EventArgs e)
        {
            if (_menu.Key.VirtualKeyCode != 0)
                return;

            string file = null;
            if (_editor != null)
                file = _editor.FileName;

            BreakpointDialog ui = new BreakpointDialog(1, file, 0);
            if (!ui.Show())
                return;

            string code = "Set-PSBreakpoint -Command $args[0]";
            if (ui.Script.Length > 0)
                code += " -Script $args[1]";
            if (ui.Action != null)
                code += " -Action $args[2]";
            A.InvokeCode(code, ui.Matter, ui.Script, ui.Action);
        }
Esempio n. 4
0
        void OnLineBreakpoint(object sender, EventArgs e)
        {
            if (_menu.Key.VirtualKeyCode != 0)
                return;

            string file = null;
            int line = 0;

            LineBreakpoint bpFound = null;
            if (_editor != null)
            {
                // location
                file = _editor.FileName;
                line = _editor.Caret.Y + 1;

                // find
                foreach (PSObject o in _breakpoints)
                {
                    LineBreakpoint lbp = o.BaseObject as LineBreakpoint;
                    if (lbp != null && lbp.Action == null && line == lbp.Line && Kit.Equals(file, lbp.Script))
                    {
                        bpFound = lbp;
                        break;
                    }
                }

                // found?
                if (bpFound != null)
                {
                    switch (Far.Api.Message("Breakpoint exists",
                        "Line breakpoint",
                        MessageOptions.None,
                        new string[] {
                            "&Remove",
                            bpFound.Enabled ? "&Disable" : "&Enable",
                            "&Modify",
                            "&Add",
                            "&Cancel"
                        }))
                    {
                        case 0:
                            A.RemoveBreakpoint(bpFound);
                            return;
                        case 1:
                            if (bpFound.Enabled)
                                A.DisableBreakpoint(bpFound);
                            else
                                A.InvokeCode("Enable-PSBreakpoint -Breakpoint $args[0]", bpFound);
                            return;
                        case 2:
                            break;
                        case 3:
                            bpFound = null;
                            break;
                        default:
                            return;
                    }
                }
            }

            // go
            BreakpointDialog ui = new BreakpointDialog(0, file, line);
            if (!ui.Show())
                return;

            // remove old
            if (bpFound != null)
                A.RemoveBreakpoint(bpFound);

            // set new
            A.SetBreakpoint(ui.Script, int.Parse(ui.Matter, null), ui.Action);
        }