public TerminalEmulator() { this.ScrollbackBuffer = new ScrollBackBuffer(); // set the display options this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer, true); this.Keyboard = new uc_Keyboard(this); this.Parser = new uc_Parser(); this.Caret = new uc_Caret(); this.Modes = new uc_Mode(); this.TabStops = new uc_TabStops(); this.SavedCarets = new ArrayList(); this.Caret.Pos = new Point(0, 0); this.CharSize = new Size(); this.AssignDefaultColors(); this.G0 = new uc_Chars(uc_Chars.Sets.ASCII); this.G1 = new uc_Chars(uc_Chars.Sets.ASCII); this.G2 = new uc_Chars(uc_Chars.Sets.DECSG); this.G3 = new uc_Chars(uc_Chars.Sets.DECSG); this.CharAttribs.GL = this.G0; this.CharAttribs.GR = this.G2; this.CharAttribs.GS = null; this.GetFontInfo(); this.InitializeVerticalScrollBar(); // create the character grid (rows by columns). This is a shadow of what's displayed // Set the window size to match this.SetSize(24, 80); this.Parser.ParserEvent += this.CommandRouter; this.Keyboard.KeyboardEvent += this.DispatchMessage; this.RefreshEvent += this.ShowBuffer; this.CaretOffEvent += this.CaretOff; this.CaretOnEvent += this.CaretOn; this.RxdTextEvent += this.Parser.ParseString; this.FontChanged += this.OnFontChanged; this.MouseWheel += this.OnMouseWheel; this.BeginDrag = new Point(); this.EndDrag = new Point(); // Enable autowrap when reaching the end of columnwidth this.Modes.Flags = this.Modes.Flags | uc_Mode.AutoWrap; this.Cursor = Cursors.IBeam; }
private void UpdateCurrentCharsFromVisibleBuffer(ScrollBackBuffer visiblebuffer) { for (Int32 visibleRowIndex = 0; visibleRowIndex < visiblebuffer.Count; visibleRowIndex++) { char[] lineChars = visiblebuffer.Characters[visibleRowIndex].ToCharArray(); for (Int32 column = 0; column < this._cols; column++) { if (column > visiblebuffer.Characters[visibleRowIndex].Length - 1) { continue; } this.CharGrid[visibleRowIndex][column] = lineChars[column]; this.AttribGrid[visibleRowIndex][column] = visiblebuffer.Attributes[visibleRowIndex][column]; } this.UpdateCommandLineChars(); } }
private void HandleScroll(Object sender, ScrollEventArgs se) { if (!this.Caret.IsOff) { this.TextAtCursor = this.CaptureTextAtCursor(); } if (!UpdateLastVisibleLine(se)) { return; } this.ClearScreenChars(); ScrollBackBuffer visiblebuffer = this.CreateVisiblebuffer(); this.UpdateCurrentCharsFromVisibleBuffer(visiblebuffer); this.Refresh(); }
private ScrollBackBuffer CreateVisiblebuffer() { ScrollBackBuffer visibleBuffer = new ScrollBackBuffer(); int lastLineIndex = this.ScrollbackBuffer.Count - 1 + this.LastVisibleLine; for (Int32 lineIndex = lastLineIndex; lineIndex >= 0; lineIndex--) { visibleBuffer.Insert(0, this.ScrollbackBuffer.Characters[lineIndex], this.ScrollbackBuffer.Attributes[lineIndex]); // don't parse more strings than our display can show); if (visibleBuffer.Count >= this._rows - 1) // rows -1 to leave line for cursor space { break; } } return(visibleBuffer); }
public TerminalEmulator() { this.ScrollbackBuffer = new ScrollBackBuffer(); // set the display options this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer, true); this.Keyboard = new uc_Keyboard(this); this.Parser = new uc_Parser(); this.Caret = new uc_Caret(); this.Modes = new uc_Mode(); this.TabStops = new uc_TabStops(); this.SavedCarets = new ArrayList(); ////this.Name = "ACK-TERM"; ////this.Text = "ACK-TERM"; this.Caret.Pos = new Point(0, 0); this.CharSize = new Size(); this.AssignDefaultColors(); this.G0 = new uc_Chars(uc_Chars.Sets.ASCII); this.G1 = new uc_Chars(uc_Chars.Sets.ASCII); this.G2 = new uc_Chars(uc_Chars.Sets.DECSG); this.G3 = new uc_Chars(uc_Chars.Sets.DECSG); this.CharAttribs.GL = this.G0; this.CharAttribs.GR = this.G2; this.CharAttribs.GS = null; this.GetFontInfo(); // Create and initialize contextmenu ////this.contextMenu1 = new ContextMenu(); ////this.mnuCopy = new MenuItem("Copy"); ////this.mnuPaste = new MenuItem("Paste"); ////this.mnuCopyPaste = new MenuItem("Copy and Paste"); ////this.contextMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { //// this.mnuCopyPaste, //// this.mnuPaste, //// this.mnuCopy //// }); ////this.mnuCopy.Index = 0; ////this.mnuPaste.Index = 1; ////this.mnuCopyPaste.Index = 2; ////this.ContextMenu = this.contextMenu1; ////this.mnuCopy.Click += new System.EventHandler(this.mnuCopy_Click); ////this.mnuPaste.Click += new System.EventHandler(this.mnuPaste_Click); ////this.mnuCopyPaste.Click += new System.EventHandler(this.mnuCopyPaste_Click); this.InitializeVerticalScrollBar(); // create the character grid (rows by columns). This is a shadow of what's displayed // Set the window size to match this.SetSize(24, 80); this.Parser.ParserEvent += this.CommandRouter; this.Keyboard.KeyboardEvent += this.DispatchMessage; this.RefreshEvent += this.ShowBuffer; this.CaretOffEvent += this.CaretOff; this.CaretOnEvent += this.CaretOn; this.RxdTextEvent += this.Parser.ParseString; this.FontChanged += this.OnFontChanged; this.MouseWheel += this.OnMouseWheel; this.BeginDrag = new Point(); this.EndDrag = new Point(); // Enable autowrap when reaching the end of columnwidth this.Modes.Flags = this.Modes.Flags | uc_Mode.AutoWrap; this.Cursor = Cursors.IBeam; }
public TerminalEmulator() { this.ScrollbackBuffer = new ScrollBackBuffer(); // set the display options this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer, true); this.Keyboard = new uc_Keyboard(this); this.Parser = new uc_Parser(); this.Caret = new uc_Caret(); this.Modes = new uc_Mode(); this.TabStops = new uc_TabStops(); this.SavedCarets = new ArrayList(); ////this.Name = "ACK-TERM"; ////this.Text = "ACK-TERM"; this.Caret.Pos = new Point(0, 0); this.CharSize = new Size(); this.AssignDefaultColors(); this.G0 = new uc_Chars(uc_Chars.Sets.ASCII); this.G1 = new uc_Chars(uc_Chars.Sets.ASCII); this.G2 = new uc_Chars(uc_Chars.Sets.DECSG); this.G3 = new uc_Chars(uc_Chars.Sets.DECSG); this.CharAttribs.GL = this.G0; this.CharAttribs.GR = this.G2; this.CharAttribs.GS = null; this.GetFontInfo(); // Create and initialize contextmenu ////this.contextMenu1 = new ContextMenu(); ////this.mnuCopy = new MenuItem("Copy"); ////this.mnuPaste = new MenuItem("Paste"); ////this.mnuCopyPaste = new MenuItem("Copy and Paste"); ////this.contextMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { //// this.mnuCopyPaste, //// this.mnuPaste, //// this.mnuCopy //// }); ////this.mnuCopy.Index = 0; ////this.mnuPaste.Index = 1; ////this.mnuCopyPaste.Index = 2; ////this.ContextMenu = this.contextMenu1; ////this.mnuCopy.Click += new System.EventHandler(this.mnuCopy_Click); ////this.mnuPaste.Click += new System.EventHandler(this.mnuPaste_Click); ////this.mnuCopyPaste.Click += new System.EventHandler(this.mnuCopyPaste_Click); this.InitializeVerticalScrollBar(); // create the character grid (rows by columns). This is a shadow of what's displayed // Set the window size to match this.SetSize(24, 80); this.Parser.ParserEvent += this.CommandRouter; this.Keyboard.KeyboardEvent += this.DispatchMessage; this.RefreshEvent += this.ShowBuffer; this.CaretOffEvent += this.CaretOff; this.CaretOnEvent += this.CaretOn; this.RxdTextEvent += this.Parser.ParseString; this.FontChanged += this.OnFontChanged; this.MouseWheel += this.OnMouseWheel; this.BeginDrag = new Point(); this.EndDrag = new Point(); // Enable autowrap when reaching the end of columnwidth this.Modes.Flags = this.Modes.Flags | uc_Mode.AutoWrap; this.Cursor = Cursors.IBeam; }
private ScrollBackBuffer CreateVisiblebuffer() { ScrollBackBuffer visibleBuffer = new ScrollBackBuffer(); int lastLineIndex = this.ScrollbackBuffer.Count - 1 + this.LastVisibleLine; for (Int32 lineIndex = lastLineIndex; lineIndex >= 0; lineIndex--) { visibleBuffer.Insert(0, this.ScrollbackBuffer.Characters[lineIndex], this.ScrollbackBuffer.Attributes[lineIndex]); // don't parse more strings than our display can show); if (visibleBuffer.Count >= this._rows - 1) // rows -1 to leave line for cursor space break; } return visibleBuffer; }
private void UpdateCurrentCharsFromVisibleBuffer(ScrollBackBuffer visiblebuffer) { for (Int32 visibleRowIndex = 0; visibleRowIndex < visiblebuffer.Count; visibleRowIndex++) { char[] lineChars = visiblebuffer.Characters[visibleRowIndex].ToCharArray(); for (Int32 column = 0; column < this._cols; column++) { if (column > visiblebuffer.Characters[visibleRowIndex].Length - 1) continue; this.CharGrid[visibleRowIndex][column] = lineChars[column]; this.AttribGrid[visibleRowIndex][column] = visiblebuffer.Attributes[visibleRowIndex][column]; } this.UpdateCommandLineChars(); } }