public TerminalWidget() { terminal = new Terminal(); terminalInputOutputSource = new TerminalIOSource(terminal); IO = new DetachableIO(terminalInputOutputSource); IO.BeforeWrite += b => { // we do not check if previous byte was '\r', because it should not cause any problem to // send it twice if (ModifyLineEndings && b == '\n') { IO.Write((byte)'\r'); } }; terminal.InnerMargin = new WidgetSpacing(5, 5, 5, 5); terminal.Cursor.Enabled = true; terminal.ContextMenu = CreatePopupMenu(); var fontFile = typeof(TerminalWidget).Assembly.FromResourceToTemporaryFile("RobotoMono-Regular.ttf"); Xwt.Drawing.Font.RegisterFontFromFile(fontFile); terminal.CurrentFont = Xwt.Drawing.Font.FromName("Roboto Mono").WithSize(10); var encoder = new TermSharp.Vt100.Encoder(x => { terminal.ClearSelection(); terminal.MoveScrollbarToEnd(); terminalInputOutputSource.HandleInput(x); }); terminal.KeyPressed += (s, a) => { a.Handled = true; var modifiers = a.Modifiers; if (!Misc.IsOnOsX) { modifiers &= ~(ModifierKeys.Command); } if (modifiers == ModifierKeys.Shift) { if (a.Key == Key.PageUp) { terminal.PageUp(); return; } if (a.Key == Key.PageDown) { terminal.PageDown(); return; } } encoder.Feed(a.Key, modifiers); }; Content = terminal; }
public TerminalWidget() { terminal = new Terminal(); terminalInputOutputSource = new TerminalIOSource(terminal); IO = new DetachableIO(terminalInputOutputSource); IO.BeforeWrite += b => { // we do not check if previous byte was '\r', because it should not cause any problem to // send it twice if(ModifyLineEndings && b == '\n') { IO.Write((byte)'\r'); } }; terminal.InnerMargin = new WidgetSpacing(5, 5, 5, 5); terminal.Cursor.Enabled = true; terminal.ContextMenu = CreatePopupMenu(); var fontFile = typeof(TerminalWidget).Assembly.FromResourceToTemporaryFile("RobotoMono-Regular.ttf"); Xwt.Drawing.Font.RegisterFontFromFile(fontFile); terminal.CurrentFont = Xwt.Drawing.Font.FromName("Roboto Mono").WithSize(10); var encoder = new TermSharp.Vt100.Encoder(x => { terminal.ClearSelection(); terminal.MoveScrollbarToEnd(); terminalInputOutputSource.HandleInput(x); }); terminal.KeyPressed += (s, a) => { a.Handled = true; var modifiers = a.Modifiers; if(!Misc.IsOnOsX) { modifiers &= ~(ModifierKeys.Command); } if(modifiers == ModifierKeys.Shift) { if(a.Key == Key.PageUp) { terminal.PageUp(); return; } if(a.Key == Key.PageDown) { terminal.PageDown(); return; } } encoder.Feed(a.Key, modifiers); }; Content = terminal; }
public void BindAnalyzer(DetachableIO io) { this.io = io; io.ByteRead += UART.WriteChar; Task.Run(() => { RepeatHistory(); UART.CharReceived += b => { lock (history) { io.Write(b); } }; }); }