//takes a character and creates a TermChar private TermChar CreateTermChar(char c) { TermChar tc = new TermChar(); tc.Char = c.ToString(); tc.AnsiGraphic = this.currentGraphic.CurrentGraphicCfg; return(tc); }
public object Clone() { TermChar rtnVal = new TermChar(); rtnVal.Char = this.c; if (this.graphic != null) { rtnVal.graphic = (TermAnsiGraphic)this.graphic.Clone(); } return(rtnVal); }
//set the termchar at the current position private void SetValue(TermChar termChar) { CircularBufferCounter temp = this._head; try { temp += this.carat.Row; this.buffer[temp.Value, this.carat.Col] = termChar; } catch (Exception ex) { //should not get here unless something if wrong with the CB counters } }
private void SetColor(TermChar tc) { try { if ((tc.AnsiGraphic.Fcolor) > 0) { this._fColor = this._pallet[tc.AnsiGraphic.Fcolor]; } if ((tc.AnsiGraphic.Bcolor) > 0) { this._bColor = this._pallet[tc.AnsiGraphic.Bcolor]; } } catch (Exception ex) { } }
//should be the last thing called after commands are entered private void DrawScreen(Graphics g) { TermChar cur; PointF pt; g.Clear(this._bgColor); lock (this.grid) { for (int i = 0; i <= this.grid.Count; ++i) { //TODO: change to TextRender for (int j = 0; j < this.grid.MaxColCount; ++j) { if (this.grid.GetValue(i, j).Char != "\0") { cur = (TermChar)this.grid.GetValue(i, j); pt = CalcDrawPoint(i, j); SetColor(cur); g.FillRectangle(this._bColor, pt.X, pt.Y, this.charSize.Width, this.charSize.Height); } } for (int j = 0; j < this.grid.MaxColCount; ++j) { if (this.grid.GetValue(i, j).Char != "\0") { cur = (TermChar)this.grid.GetValue(i, j).Clone(); pt = CalcDrawPoint(i, j); SetColor(cur); g.DrawString(cur.Char, this._font, this._fColor, pt); } } } if (!caratVis) { return; } TermChar carat = this.grid.Carat; SetColor(carat); g.DrawString(carat.Char, this._font, this._fColor, CalcDrawPoint(this.grid.Carat.Row, this.grid.Carat.Col)); } }
//TODO: removable internal void DoGridDebugDump() { Console.WriteLine("Start dump..."); int cnt = grid.Count; for (int i = 0; i <= grid.Count; ++i) { for (int j = 0; j < grid.MaxColCount; ++j) { TermChar c = grid.GetValue(i, j); if (c.Char == '\0'.ToString()) { Console.Write(Encoding.ASCII.GetString(new byte[] { 157 })); } Console.Write(c.Char); Console.Write("-"); } Console.Write("\r\n"); } Console.WriteLine("End"); }