public void Start() { Application.UseSystemConsole = true; Application.Init(); Application.MainLoop.AddIdle(OnMainLoopIdle); var top = Application.Top; var topFrame = top.Frame; _logWindow = new Window("Debugger Log") { X = 0, Y = 1, Width = Dim.Fill(), Height = Dim.Fill() - 3, CanFocus = false }; // _logView = new Filler( // new Rect(0, 0, 200, 200) // ); _textView = new LogView() { X = 0, Y = 0, Width = Dim.Fill(), Height = Dim.Fill(), CanFocus = false }; _logWindow.Add(_textView); _scrollBar = new ScrollBarView(_textView, true); _scrollBar.ChangedPosition += () => { _textView.TopRow = _scrollBar.Position; if (_textView.TopRow != _scrollBar.Position) { _scrollBar.Position = _textView.TopRow; } _textView.SetNeedsDisplay(); }; _scrollBar.OtherScrollBarView.ChangedPosition += () => { _textView.LeftColumn = _scrollBar.OtherScrollBarView.Position; if (_textView.LeftColumn != _scrollBar.OtherScrollBarView.Position) { _scrollBar.OtherScrollBarView.Position = _textView.LeftColumn; } _textView.SetNeedsDisplay(); }; _textView.DrawContent += (e) => { _scrollBar.Size = _textView.Lines - 1; _scrollBar.Position = _textView.TopRow; _scrollBar.OtherScrollBarView.Size = _textView.Maxlength; _scrollBar.OtherScrollBarView.Position = _textView.LeftColumn; _scrollBar.LayoutSubviews(); _scrollBar.Refresh(); }; var commandBar = new View() { X = 0, Y = Pos.AnchorEnd(3), Width = Dim.Fill(), Height = 2 }; var commandBarText = new Label("Enter debugger commands") { X = 0, Y = 0, Width = Dim.Fill(), Height = 1 }; var commandLabel = new Label(">") { X = 0, Y = 1, Width = 1, Height = 1 }; var commandText = new CommandField { X = 1, Y = 1, Width = Dim.Fill(), Height = 1, CanFocus = true, TabIndex = 0, }; commandText.CommandEntered += (s, e) => { _parser?.Parse(e); commandBar.SetFocus(); }; commandBar.Add(commandBarText, commandLabel, commandText); _menuBar = new MenuBar( new MenuBarItem[] { new MenuBarItem("_File", new MenuItem [] { new MenuItem("_Save", "Save program", SaveFile), new MenuItem("_Open", "Open program", OpenFile), new MenuItem("_Quit", "", () => { if (Quit()) { top.Running = false; } }) }), new MenuBarItem("_Debug", new MenuItem [] { new MenuItem("_Continue", "", null), new MenuItem("_Pause", "", null), new MenuItem("_Step", "", null) }) }); _statusBar = new StatusBar() { ColorScheme = Colors.TopLevel, Visible = true, Items = new StatusItem[] { _runMode, _A, _X, _Y, _PC, _SP, _C, _Z, _I, _D, _B, _B2, _V, _N } }; top.Add(_logWindow); top.Add(commandBar); top.Add(_menuBar); top.Add(_statusBar); Application.Run(); commandBar.SetFocus(); }
public override void Init(Toplevel top, ColorScheme colorScheme) { Application.Init(); Top = top; if (Top == null) { Top = Application.Top; } Win = new Window(_fileName ?? "Untitled") { X = 0, Y = 1, Width = Dim.Fill(), Height = Dim.Fill(), ColorScheme = colorScheme, }; Top.Add(Win); _textView = new TextView() { X = 0, Y = 0, Width = Dim.Fill(), Height = Dim.Fill(), BottomOffset = 1, RightOffset = 1 }; CreateDemoFile(_fileName); LoadFile(); Win.Add(_textView); var menu = new MenuBar(new MenuBarItem [] { new MenuBarItem("_File", new MenuItem [] { new MenuItem("_New", "", () => New()), new MenuItem("_Open", "", () => Open()), new MenuItem("_Save", "", () => Save()), new MenuItem("_Save As", "", () => SaveAs()), new MenuItem("_Close", "", () => CloseFile()), null, new MenuItem("_Quit", "", () => Quit()), }), new MenuBarItem("_Edit", new MenuItem [] { new MenuItem("_Copy", "", () => Copy(), null, null, Key.CtrlMask | Key.C), new MenuItem("C_ut", "", () => Cut(), null, null, Key.CtrlMask | Key.W), new MenuItem("_Paste", "", () => Paste(), null, null, Key.CtrlMask | Key.Y), null, new MenuItem("_Find", "", () => Find(), null, null, Key.CtrlMask | Key.S), new MenuItem("Find _Next", "", () => FindNext(), null, null, Key.CtrlMask | Key.ShiftMask | Key.S), new MenuItem("Find P_revious", "", () => FindPrevious(), null, null, Key.CtrlMask | Key.ShiftMask | Key.AltMask | Key.S), new MenuItem("_Replace", "", () => Replace(), null, null, Key.CtrlMask | Key.R), new MenuItem("Replace Ne_xt", "", () => ReplaceNext(), null, null, Key.CtrlMask | Key.ShiftMask | Key.R), new MenuItem("Replace Pre_vious", "", () => ReplacePrevious(), null, null, Key.CtrlMask | Key.ShiftMask | Key.AltMask | Key.R), new MenuItem("Replace _All", "", () => ReplaceAll(), null, null, Key.CtrlMask | Key.ShiftMask | Key.AltMask | Key.A), null, new MenuItem("_Select All", "", () => SelectAll(), null, null, Key.CtrlMask | Key.T) }), new MenuBarItem("_ScrollBarView", CreateKeepChecked()), new MenuBarItem("_Cursor", new MenuItem [] { new MenuItem("_Invisible", "", () => SetCursor(CursorVisibility.Invisible)), new MenuItem("_Box", "", () => SetCursor(CursorVisibility.Box)), new MenuItem("_Underline", "", () => SetCursor(CursorVisibility.Underline)), new MenuItem("", "", () => {}, () => { return(false); }), new MenuItem("xTerm :", "", () => {}, () => { return(false); }), new MenuItem("", "", () => {}, () => { return(false); }), new MenuItem(" _Default", "", () => SetCursor(CursorVisibility.Default)), new MenuItem(" _Vertical", "", () => SetCursor(CursorVisibility.Vertical)), new MenuItem(" V_ertical Fix", "", () => SetCursor(CursorVisibility.VerticalFix)), new MenuItem(" B_ox Fix", "", () => SetCursor(CursorVisibility.BoxFix)), new MenuItem(" U_nderline Fix", "", () => SetCursor(CursorVisibility.UnderlineFix)) }), new MenuBarItem("Forma_t", new MenuItem [] { CreateWrapChecked(), CreateAutocomplete(), CreateAllowsTabChecked() }), new MenuBarItem("_Responder", new MenuItem [] { CreateCanFocusChecked(), CreateEnabledChecked(), CreateVisibleChecked() }), }); Top.Add(menu); var statusBar = new StatusBar(new StatusItem [] { new StatusItem(Key.F2, "~F2~ Open", () => Open()), new StatusItem(Key.F3, "~F3~ Save", () => Save()), new StatusItem(Key.F4, "~F4~ Save As", () => SaveAs()), new StatusItem(Key.CtrlMask | Key.Q, "~^Q~ Quit", () => Quit()), new StatusItem(Key.Null, $"OS Clipboard IsSupported : {Clipboard.IsSupported}", null) }); Top.Add(statusBar); _scrollBar = new ScrollBarView(_textView, true); _scrollBar.ChangedPosition += () => { _textView.TopRow = _scrollBar.Position; if (_textView.TopRow != _scrollBar.Position) { _scrollBar.Position = _textView.TopRow; } _textView.SetNeedsDisplay(); }; _scrollBar.OtherScrollBarView.ChangedPosition += () => { _textView.LeftColumn = _scrollBar.OtherScrollBarView.Position; if (_textView.LeftColumn != _scrollBar.OtherScrollBarView.Position) { _scrollBar.OtherScrollBarView.Position = _textView.LeftColumn; } _textView.SetNeedsDisplay(); }; _scrollBar.VisibleChanged += () => { if (_scrollBar.Visible && _textView.RightOffset == 0) { _textView.RightOffset = 1; } else if (!_scrollBar.Visible && _textView.RightOffset == 1) { _textView.RightOffset = 0; } }; _scrollBar.OtherScrollBarView.VisibleChanged += () => { if (_scrollBar.OtherScrollBarView.Visible && _textView.BottomOffset == 0) { _textView.BottomOffset = 1; } else if (!_scrollBar.OtherScrollBarView.Visible && _textView.BottomOffset == 1) { _textView.BottomOffset = 0; } }; _textView.DrawContent += (e) => { _scrollBar.Size = _textView.Lines; _scrollBar.Position = _textView.TopRow; if (_scrollBar.OtherScrollBarView != null) { _scrollBar.OtherScrollBarView.Size = _textView.Maxlength; _scrollBar.OtherScrollBarView.Position = _textView.LeftColumn; } _scrollBar.LayoutSubviews(); _scrollBar.Refresh(); }; Win.KeyPress += (e) => { if (winDialog != null && (e.KeyEvent.Key == Key.Esc || e.KeyEvent.Key == (Key.Q | Key.CtrlMask))) { DisposeWinDialog(); } else if (e.KeyEvent.Key == (Key.Q | Key.CtrlMask)) { Quit(); e.Handled = true; } }; }
public override void Init(Toplevel top, ColorScheme colorScheme) { Application.Init(); Top = top; if (Top == null) { Top = Application.Top; } Win = new Window(_fileName ?? "Untitled") { X = 0, Y = 1, Width = Dim.Fill(), Height = Dim.Fill(), ColorScheme = colorScheme, }; Top.Add(Win); _textView = new TextView() { X = 0, Y = 0, Width = Dim.Fill(), Height = Dim.Fill(), BottomOffset = 1, RightOffset = 1 }; CreateDemoFile(_fileName); LoadFile(); Win.Add(_textView); var menu = new MenuBar(new MenuBarItem [] { new MenuBarItem("_File", new MenuItem [] { new MenuItem("_New", "", () => New()), new MenuItem("_Open", "", () => Open()), new MenuItem("_Save", "", () => Save()), new MenuItem("_Save As", "", () => SaveAs()), new MenuItem("_Close", "", () => CloseFile()), null, new MenuItem("_Quit", "", () => Quit()), }), new MenuBarItem("_Edit", new MenuItem [] { new MenuItem("_Copy", "", () => Copy(), null, null, Key.CtrlMask | Key.C), new MenuItem("C_ut", "", () => Cut(), null, null, Key.CtrlMask | Key.W), new MenuItem("_Paste", "", () => Paste(), null, null, Key.CtrlMask | Key.Y), null, new MenuItem("_Find", "", () => Find(), null, null, Key.CtrlMask | Key.S), new MenuItem("Find _Next", "", () => FindNext(), null, null, Key.CtrlMask | Key.ShiftMask | Key.S), new MenuItem("Find P_revious", "", () => FindPrevious(), null, null, Key.CtrlMask | Key.ShiftMask | Key.AltMask | Key.S), new MenuItem("_Replace", "", () => Replace(), null, null, Key.CtrlMask | Key.R), new MenuItem("Replace Ne_xt", "", () => ReplaceNext(), null, null, Key.CtrlMask | Key.ShiftMask | Key.R), new MenuItem("Replace Pre_vious", "", () => ReplacePrevious(), null, null, Key.CtrlMask | Key.ShiftMask | Key.AltMask | Key.R), new MenuItem("Replace _All", "", () => ReplaceAll(), null, null, Key.CtrlMask | Key.ShiftMask | Key.AltMask | Key.A), null, new MenuItem("_Select All", "", () => SelectAll(), null, null, Key.CtrlMask | Key.T) }), new MenuBarItem("_ScrollBarView", CreateKeepChecked()), new MenuBarItem("_Cursor", CreateCursorRadio()), new MenuBarItem("Forma_t", new MenuItem [] { CreateWrapChecked(), CreateAutocomplete(), CreateAllowsTabChecked() }), new MenuBarItem("_Responder", new MenuItem [] { CreateCanFocusChecked(), CreateEnabledChecked(), CreateVisibleChecked() }), new MenuBarItem("Conte_xtMenu", new MenuItem [] { miForceMinimumPosToZero = new MenuItem("ForceMinimumPosTo_Zero", "", () => { miForceMinimumPosToZero.Checked = forceMinimumPosToZero = !forceMinimumPosToZero; _textView.ContextMenu.ForceMinimumPosToZero = forceMinimumPosToZero; }) { CheckType = MenuItemCheckStyle.Checked, Checked = forceMinimumPosToZero }, new MenuBarItem("_Languages", GetSupportedCultures()) }) }); Top.Add(menu); var statusBar = new StatusBar(new StatusItem [] { new StatusItem(Key.F2, "~F2~ Open", () => Open()), new StatusItem(Key.F3, "~F3~ Save", () => Save()), new StatusItem(Key.F4, "~F4~ Save As", () => SaveAs()), new StatusItem(Key.CtrlMask | Key.Q, "~^Q~ Quit", () => Quit()), new StatusItem(Key.Null, $"OS Clipboard IsSupported : {Clipboard.IsSupported}", null) }); Top.Add(statusBar); _scrollBar = new ScrollBarView(_textView, true); _scrollBar.ChangedPosition += () => { _textView.TopRow = _scrollBar.Position; if (_textView.TopRow != _scrollBar.Position) { _scrollBar.Position = _textView.TopRow; } _textView.SetNeedsDisplay(); }; _scrollBar.OtherScrollBarView.ChangedPosition += () => { _textView.LeftColumn = _scrollBar.OtherScrollBarView.Position; if (_textView.LeftColumn != _scrollBar.OtherScrollBarView.Position) { _scrollBar.OtherScrollBarView.Position = _textView.LeftColumn; } _textView.SetNeedsDisplay(); }; _scrollBar.VisibleChanged += () => { if (_scrollBar.Visible && _textView.RightOffset == 0) { _textView.RightOffset = 1; } else if (!_scrollBar.Visible && _textView.RightOffset == 1) { _textView.RightOffset = 0; } }; _scrollBar.OtherScrollBarView.VisibleChanged += () => { if (_scrollBar.OtherScrollBarView.Visible && _textView.BottomOffset == 0) { _textView.BottomOffset = 1; } else if (!_scrollBar.OtherScrollBarView.Visible && _textView.BottomOffset == 1) { _textView.BottomOffset = 0; } }; _textView.DrawContent += (e) => { _scrollBar.Size = _textView.Lines; _scrollBar.Position = _textView.TopRow; if (_scrollBar.OtherScrollBarView != null) { _scrollBar.OtherScrollBarView.Size = _textView.Maxlength; _scrollBar.OtherScrollBarView.Position = _textView.LeftColumn; } _scrollBar.LayoutSubviews(); _scrollBar.Refresh(); }; Win.KeyPress += (e) => { var keys = ShortcutHelper.GetModifiersKey(e.KeyEvent); if (winDialog != null && (e.KeyEvent.Key == Key.Esc || e.KeyEvent.Key == (Key.Q | Key.CtrlMask))) { DisposeWinDialog(); } else if (e.KeyEvent.Key == (Key.Q | Key.CtrlMask)) { Quit(); e.Handled = true; } else if (winDialog != null && keys == (Key.Tab | Key.CtrlMask)) { if (_tabView.SelectedTab == _tabView.Tabs.ElementAt(_tabView.Tabs.Count - 1)) { _tabView.SelectedTab = _tabView.Tabs.ElementAt(0); } else { _tabView.SwitchTabBy(1); } e.Handled = true; } else if (winDialog != null && keys == (Key.Tab | Key.CtrlMask | Key.ShiftMask)) { if (_tabView.SelectedTab == _tabView.Tabs.ElementAt(0)) { _tabView.SelectedTab = _tabView.Tabs.ElementAt(_tabView.Tabs.Count - 1); } else { _tabView.SwitchTabBy(-1); } e.Handled = true; } }; Top.Closed += (_) => Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US"); }
public override void Init(Toplevel top, ColorScheme colorScheme) { Application.Init(); Top = top; if (Top == null) { Top = Application.Top; } var menu = new MenuBar(new MenuBarItem [] { new MenuBarItem("_File", new MenuItem [] { new MenuItem("_New", "", () => New()), new MenuItem("_Open", "", () => Open()), new MenuItem("_Save", "", () => Save()), null, new MenuItem("_Quit", "", () => Quit()), }), new MenuBarItem("_Edit", new MenuItem [] { new MenuItem("_Copy", "", () => Copy()), new MenuItem("C_ut", "", () => Cut()), new MenuItem("_Paste", "", () => Paste()) }), new MenuBarItem("_ScrollBarView", CreateKeepChecked()) }); Top.Add(menu); var statusBar = new StatusBar(new StatusItem [] { new StatusItem(Key.F2, "~F2~ Open", () => Open()), new StatusItem(Key.F3, "~F3~ Save", () => Save()), new StatusItem(Key.CtrlMask | Key.Q, "~^Q~ Quit", () => Quit()), }); Top.Add(statusBar); CreateDemoFile(_fileName); Win = new Window(_fileName ?? "Untitled") { X = 0, Y = 1, Width = Dim.Fill(), Height = Dim.Fill(), ColorScheme = colorScheme, }; Top.Add(Win); _textView = new TextView() { X = 0, Y = 0, Width = Dim.Fill(), Height = Dim.Fill(), }; LoadFile(); Win.Add(_textView); _scrollBar = new ScrollBarView(_textView, true); _scrollBar.ChangedPosition += () => { _textView.TopRow = _scrollBar.Position; if (_textView.TopRow != _scrollBar.Position) { _scrollBar.Position = _textView.TopRow; } _textView.SetNeedsDisplay(); }; _scrollBar.OtherScrollBarView.ChangedPosition += () => { _textView.LeftColumn = _scrollBar.OtherScrollBarView.Position; if (_textView.LeftColumn != _scrollBar.OtherScrollBarView.Position) { _scrollBar.OtherScrollBarView.Position = _textView.LeftColumn; } _textView.SetNeedsDisplay(); }; _textView.DrawContent += (e) => { _scrollBar.Size = _textView.Lines - 1; _scrollBar.Position = _textView.TopRow; _scrollBar.OtherScrollBarView.Size = _textView.Maxlength; _scrollBar.OtherScrollBarView.Position = _textView.LeftColumn; _scrollBar.LayoutSubviews(); _scrollBar.Refresh(); }; }
public override void Init(Toplevel top, ColorScheme colorScheme) { Application.Init(); Top = top; if (Top == null) { Top = Application.Top; } var menu = new MenuBar(new MenuBarItem [] { new MenuBarItem("_File", new MenuItem [] { new MenuItem("_New", "", () => New()), new MenuItem("_Open", "", () => Open()), new MenuItem("_Save", "", () => Save()), new MenuItem("_Save As", "", () => SaveAs()), null, new MenuItem("_Quit", "", () => Quit()), }), new MenuBarItem("_Edit", new MenuItem [] { new MenuItem("_Copy", "", () => Copy(), null, null, Key.CtrlMask | Key.C), new MenuItem("C_ut", "", () => Cut(), null, null, Key.CtrlMask | Key.W), new MenuItem("_Paste", "", () => Paste(), null, null, Key.CtrlMask | Key.Y) }), new MenuBarItem("_ScrollBarView", CreateKeepChecked()), new MenuBarItem("_Cursor", new MenuItem [] { new MenuItem("_Invisible", "", () => SetCursor(CursorVisibility.Invisible)), new MenuItem("_Box", "", () => SetCursor(CursorVisibility.Box)), new MenuItem("_Underline", "", () => SetCursor(CursorVisibility.Underline)), new MenuItem("", "", () => {}, () => { return(false); }), new MenuItem("xTerm :", "", () => {}, () => { return(false); }), new MenuItem("", "", () => {}, () => { return(false); }), new MenuItem(" _Default", "", () => SetCursor(CursorVisibility.Default)), new MenuItem(" _Vertical", "", () => SetCursor(CursorVisibility.Vertical)), new MenuItem(" V_ertical Fix", "", () => SetCursor(CursorVisibility.VerticalFix)), new MenuItem(" B_ox Fix", "", () => SetCursor(CursorVisibility.BoxFix)), new MenuItem(" U_nderline Fix", "", () => SetCursor(CursorVisibility.UnderlineFix)) }), new MenuBarItem("Forma_t", CreateWrapChecked()) }); Top.Add(menu); var statusBar = new StatusBar(new StatusItem [] { new StatusItem(Key.F2, "~F2~ Open", () => Open()), new StatusItem(Key.F3, "~F3~ Save", () => Save()), new StatusItem(Key.CtrlMask | Key.Q, "~^Q~ Quit", () => Quit()), }); Top.Add(statusBar); CreateDemoFile(_fileName); Win = new Window(_fileName ?? "Untitled") { X = 0, Y = 1, Width = Dim.Fill(), Height = Dim.Fill(), ColorScheme = colorScheme, }; Top.Add(Win); _textView = new TextView() { X = 0, Y = 0, Width = Dim.Fill(), Height = Dim.Fill(), BottomOffset = 1, RightOffset = 1 }; LoadFile(); Win.Add(_textView); _scrollBar = new ScrollBarView(_textView, true); _scrollBar.ChangedPosition += () => { _textView.TopRow = _scrollBar.Position; if (_textView.TopRow != _scrollBar.Position) { _scrollBar.Position = _textView.TopRow; } _textView.SetNeedsDisplay(); }; _scrollBar.OtherScrollBarView.ChangedPosition += () => { _textView.LeftColumn = _scrollBar.OtherScrollBarView.Position; if (_textView.LeftColumn != _scrollBar.OtherScrollBarView.Position) { _scrollBar.OtherScrollBarView.Position = _textView.LeftColumn; } _textView.SetNeedsDisplay(); }; _textView.DrawContent += (e) => { _scrollBar.Size = _textView.Lines; _scrollBar.Position = _textView.TopRow; if (_scrollBar.OtherScrollBarView != null) { _scrollBar.OtherScrollBarView.Size = _textView.Maxlength; _scrollBar.OtherScrollBarView.Position = _textView.LeftColumn; } _scrollBar.LayoutSubviews(); _scrollBar.Refresh(); }; }