/// <summary> /// Initializes the runtime. The boolean flag /// indicates whether we are forcing color to be off. /// </summary> public static void Init(bool disable_color) { if (inited) return; inited = true; empty_container = new Container (0, 0, Application.Cols, Application.Lines); try { main_window = Curses.initscr (); } catch (Exception e){ Console.WriteLine ("Curses failed to initialize, the exception is: " + e); throw new Exception ("Application.Init failed"); } Curses.raw (); Curses.noecho (); //Curses.nonl (); Window.Standard.keypad (true); #if BREAK_UTF8_RENDERING Curses.Event old = 0; MouseEventsAvailable = Curses.console_sharp_mouse_mask ( Curses.Event.Button1Clicked | Curses.Event.Button1DoubleClicked, out old); #endif UsingColor = false; if (!disable_color) UsingColor = Curses.has_colors (); Curses.start_color (); Curses.use_default_colors (); if (UsingColor){ ColorNormal = MakeColor (Curses.COLOR_WHITE, Curses.COLOR_BLUE); ColorFocus = MakeColor (Curses.COLOR_BLACK, Curses.COLOR_CYAN); ColorHotNormal = Curses.A_BOLD | MakeColor (Curses.COLOR_YELLOW, Curses.COLOR_BLUE); ColorHotFocus = Curses.A_BOLD | MakeColor (Curses.COLOR_YELLOW, Curses.COLOR_CYAN); ColorMenu = Curses.A_BOLD | MakeColor (Curses.COLOR_WHITE, Curses.COLOR_CYAN); ColorMenuHot = Curses.A_BOLD | MakeColor (Curses.COLOR_YELLOW, Curses.COLOR_CYAN); ColorMenuSelected = Curses.A_BOLD | MakeColor (Curses.COLOR_WHITE, Curses.COLOR_BLACK); ColorMenuHotSelected = Curses.A_BOLD | MakeColor (Curses.COLOR_YELLOW, Curses.COLOR_BLACK); ColorMarked = ColorHotNormal; ColorMarkedSelected = ColorHotFocus; ColorDialogNormal = MakeColor (Curses.COLOR_BLACK, Curses.COLOR_WHITE); ColorDialogFocus = MakeColor (Curses.COLOR_BLACK, Curses.COLOR_CYAN); ColorDialogHotNormal = MakeColor (Curses.COLOR_BLUE, Curses.COLOR_WHITE); ColorDialogHotFocus = MakeColor (Curses.COLOR_BLUE, Curses.COLOR_CYAN); ColorError = Curses.A_BOLD | MakeColor (Curses.COLOR_WHITE, Curses.COLOR_RED); ColorErrorFocus = MakeColor (Curses.COLOR_BLACK, Curses.COLOR_WHITE); ColorErrorHot = Curses.A_BOLD | MakeColor (Curses.COLOR_YELLOW, Curses.COLOR_RED); ColorErrorHotFocus = ColorErrorHot; } else { ColorNormal = Curses.A_NORMAL; ColorFocus = Curses.A_REVERSE; ColorHotNormal = Curses.A_BOLD; ColorHotFocus = Curses.A_REVERSE | Curses.A_BOLD; ColorMenu = Curses.A_REVERSE; ColorMenuHot = Curses.A_NORMAL; ColorMenuSelected = Curses.A_BOLD; ColorMenuHotSelected = Curses.A_NORMAL; ColorMarked = Curses.A_BOLD; ColorMarkedSelected = Curses.A_REVERSE | Curses.A_BOLD; ColorDialogNormal = Curses.A_REVERSE; ColorDialogFocus = Curses.A_NORMAL; ColorDialogHotNormal = Curses.A_BOLD; ColorDialogHotFocus = Curses.A_NORMAL; ColorError = Curses.A_BOLD; } ColorBasic = MakeColor (-1, -1); mainloop = new MainLoop (); mainloop.AddWatch (0, MainLoop.Condition.PollIn, x => { Container top = toplevels.Count > 0 ? toplevels [toplevels.Count-1] : null; if (top != null) ProcessChar (top); return true; }); }
public void EnterNestedBreakState() { MainLoop loop = new MainLoop (interpreter); main_loop_stack.Push (loop); Report.Debug (DebugFlags.CLI, "{0} enter nested break state", loop); nested_break_state_event.Set (); }