public static string ReplRead(string prompt, bool lispCompletion, bool symbolCompletion, bool crlf) { try { if (Console.IsInputRedirected) { var s = Console.ReadLine(); if (s == null) { Runtime.Exit(); } return(s); } else { var s = ReplReadImp(prompt, lispCompletion, symbolCompletion, crlf); return(s); } } catch (Exception ex) { Console.Clear(); Console.WriteLine(Runtime.GetDiagnostics(ex)); Console.WriteLine("Temporarily lost control due to console display changes. Input aborted."); Console.Write("Press ENTER to continue."); Console.ReadLine(); return(""); } }
public static void RunGuiMode(CommandLineOptions options) { Runtime.ProgramFeature = "kiezellisp-gui"; Runtime.Repl = false; Runtime.ScriptName = options.ScriptName; Runtime.UserArguments = options.UserArguments; try { Runtime.Reset(); Runtime.RestartLoadFiles(0); Runtime.Run(options.ScriptName, Symbols.LoadPrintKeyword, false, Symbols.LoadVerboseKeyword, false); Runtime.Exit(); } catch (Exception ex) { Runtime.PrintTrace(Runtime.GetDiagnostics(ex)); } }
public static void ReadEvalPrintLoop(string commandOptionArgument = null, bool initialized = false, bool debugging = false) { if (!initialized) { state = new Stack <ThreadContextState>(); state.Push(Runtime.SaveStackAndFrame()); } while (true) { try { if (!initialized) { initialized = true; Reset(-1); } if (string.IsNullOrWhiteSpace(commandOptionArgument)) { var command = ReadCommand(debugging); EvalPrintCommand(command, debugging); } else { var scriptFile = commandOptionArgument; commandOptionArgument = ""; Runtime.Run(scriptFile, Symbols.LoadPrintKeyword, false, Symbols.LoadVerboseKeyword, false); if (!Runtime.Repl) { Runtime.Exit(); } } } catch (ContinueFromBreakpointException) { if (debugging) { throw; } } catch (AbortingDebuggerException) { if (debugging) { throw; } } catch (AbortedDebuggerException) { } catch (InterruptException) { // Effect of Ctrl+D Runtime.PrintStream(GetConsoleErr(), "error", "Interrupt.\n"); } catch (Exception ex) { //ClearKeyboardBuffer(); ex = Runtime.UnwindException(ex); LastException = ex; Runtime.PrintStream(GetConsoleErr(), "error", ex.Message + "\n"); state.Push(Runtime.SaveStackAndFrame()); } } }