void OnViewConsoleInput(object sender, ConsoleInputEventArgs e)
 {
     if (!DebuggingService.IsDebugging)
     {
         view.WriteOutput("Debug session not started.");
     }
     else if (DebuggingService.IsRunning)
     {
         view.WriteOutput("The expression can't be evaluated while the application is running.");
     }
     else
     {
         EvaluationOptions ops = EvaluationOptions.DefaultOptions;
         ops.AllowMethodEvaluation = true;
         ops.AllowTargetInvoke     = true;
         ops.EvaluationTimeout     = 20000;
         var              ff   = DebuggingService.CurrentFrame;
         string           tt   = e.Text;
         ValidationResult vres = ff.ValidateExpression(tt, ops);
         if (!vres)
         {
             view.WriteOutput(vres.Message);
             view.Prompt(true);
             return;
         }
         ObjectValue val = DebuggingService.CurrentFrame.GetExpressionValue(e.Text, ops);
         if (val.IsEvaluating)
         {
             WaitForCompleted(val);
             return;
         }
         PrintValue(val);
     }
     view.Prompt(true);
 }
Exemple #2
0
        void OnConsoleInput(object sender, ConsoleInputEventArgs e)
        {
            if (string.IsNullOrEmpty(e.Text))
            {
                WritePrompt();
                return;
            }

            if (expression == null)
            {
                expression = e.Text;
            }
            else
            {
                expression += "\n" + e.Text;
            }

            Task.Run(() => {
                try {
                    IsStopButtonEnabled = true;

                    using (var consoleOutputWriter = ConsoleOutputTextWriter.Create(logTextWriter)) {
                        expression = Evaluate(expression);
                    }
                } finally {
                    WritePrompt();
                    IsStopButtonEnabled = false;
                }
            }).Ignore();
        }
Exemple #3
0
        private void ProcessTempInput(ConsoleInputEventArgs eventArgs)
        {
            // TODO: Proper commands

            if (eventArgs.Message != null && eventArgs.Message.Trim() == "shutdown")
            {
                EntryPoint.Exit(true, -1, 5000, true);
            }
        }
Exemple #4
0
        internal static void EvaluateText(string text)
        {
            Runtime.AssertMainThread();

            Pad pad = IdeApp.Workbench.GetPad <CSharpInteractivePad> ();

            pad.BringToFront();

            var input = new ConsoleInputEventArgs(text);

            Instance.OnConsoleInput(Instance.view, input);
        }
 void HandleConsoleInput(object sender, ConsoleInputEventArgs e)
 {
     if (isPrompting)
     {
         isPrompting = false;
         session     = null;
         SendCommand("", "");
     }
     else
     {
         SendCommand("", e.Text);
     }
 }
Exemple #6
0
        void OnViewConsoleInput(object sender, ConsoleInputEventArgs e)
        {
            if (!DebuggingService.IsDebugging)
            {
                view.WriteOutput(GettextCatalog.GetString("Debug session not started."));
                FinishPrinting();
            }
            else if (DebuggingService.IsRunning || DebuggingService.CurrentFrame == null)
            {
                view.WriteOutput(GettextCatalog.GetString("The expression can't be evaluated while the application is running."));
                FinishPrinting();
            }
            else
            {
                var frame      = DebuggingService.CurrentFrame;
                var ops        = GetEvaluationOptions(false);
                var expression = e.Text;

                var vres = frame.ValidateExpression(expression, ops);
                if (!vres)
                {
                    view.WriteOutput(vres.Message);
                    FinishPrinting();
                    return;
                }

                var val = frame.GetExpressionValue(expression, ops);
                if (val.IsEvaluating)
                {
                    WaitForCompleted(val, frame.DebuggerSession);
                    DebuggingService.NotifyVariableChanged();
                    return;
                }

                DebuggingService.NotifyVariableChanged();
                PrintValue(val);
            }
        }
Exemple #7
0
 private static void interpreter_OnConsoleInput(object sender, ConsoleInputEventArgs e)
 {
     interpreter.Input = Console.ReadLine();
 }
 void OnConsoleInput(object sender, ConsoleInputEventArgs e)
 {
     viewModel.ProcessUserInput(e.Text);
 }
Exemple #9
0
        void OnViewConsoleInput(object sender, ConsoleInputEventArgs e)
        {
            var view = sender as ReplView;
            if (view == null)
            {
                throw new InvalidCastException ("View doesn't seem to be a ReplView");
            }
            var session = replSessions [view];

            if (session == null)
            {
                view.WriteOutput ("Not connected.");
                view.Prompt (true);
                return;
            }
            else
            {
                session.Repl.evaluate (e.Text).ContinueWith (task =>
                {
                    var result = task.Result;
                    switch (result.Type)
                    {
                        case ResultType.FAILED:
                            Gtk.Application.Invoke (delegate
                            {
                                view.WriteOutput (result.ResultMessage);
                                view.Prompt (false);
                            });
                            break;
                        case ResultType.NEED_MORE_INPUT:
                            Gtk.Application.Invoke (delegate
                            {
                                view.Prompt (false, true);
                            });
                            break;
                        case ResultType.SUCCESS_NO_OUTPUT:
                            Gtk.Application.Invoke (delegate
                            {
                                view.Prompt (false);
                            });
                            break;
                        case ResultType.SUCCESS_WITH_OUTPUT:
                            Gtk.Application.Invoke (delegate
                            {
                                view.WriteOutput (result.ResultMessage);
                                view.Prompt (true);
                            });

                            break;
                        default:
                            throw new Exception ("Unexpected state! Contact developers.");
                            break;
                    }
                });
            }
        }
Exemple #10
0
 protected virtual void OnConsoleInput(ConsoleInputEventArgs e)
 {
     EventHandler<ConsoleInputEventArgs> handler = ConsoleInput;
     if (handler != null)
         handler(this, e);
 }
 void Input_InputGiven(object sender, ConsoleInputEventArgs e)
 {
     string Command = e.Message;
     if (Command.Length < 1) return;
     if (Input.CommandMatch("help", Command, false, false, false, false))
     {
         Console.WriteLine("Input: Core help: (/[command] or [lua])\n" +
             "  Page Up/Down, Ctrl+Up/Down, and Alt+Up/Down are used to scroll through\n" +
             "  reload - Reloads scripts and commands\n" +
             "  /help - Commands help\n" +
             "  help() - LUA help");
     }
     else if (Input.CommandMatch("reload", Command))
     {
         WraithMod.Lua.Initialize();
         WraithMod.Commands.Initialize();
         WraithMod.LoadBanlist();
     }
     else if (Command[0] == Input.CommandSymbol)
     {
         try
         {
             WraithMod.Commands.RunCommand(Command);
         }
         catch
         {
             Console.WriteLine(MessageType.Error, "Input: Unknown error running command: {0}", Command);
         }
     }
     else if (Command.Trim() != "")
     {
         ParameterizedThreadStart pts = new ParameterizedThreadStart(WraithMod.Lua.RunString);
         Thread t = new Thread(pts);
         Lua.ScriptThreads.Add(t);
         t.Start(Command);
     }
     /*if (Input.CommandMatch("help", e.Message, false, false, false, false))
     {
         Console.WriteLine("Input: Core help: (/[command] or [lua])\n" +
             "  reload - Reloads scripts and commands\n" +
             "  /help - Commands help\n" +
             "  help() - LUA help");
     }
     else if (Input.CommandMatch("reload", e.Message))
     {
         Lua.Initialize();
         Commands.Initialize();
         LoadBanlist();
     }
     else if (e.Message[0] == Input.CommandSymbol)
     {
         try
         {
             Commands.RunCommand(e.Message);
         }
         catch
         {
             Console.WriteLine(MessageType.Error, "Input: Unknown error running command: {0}", e.Message);
         }
     }
     else if (e.Message.Trim() != "")
     {
         ParameterizedThreadStart pts = new ParameterizedThreadStart(Lua.RunString);
         Thread t = new Thread(pts);
         t.Start(e.Message);
     }*/
 }