public void Clear() { this.buffer = new T[this.maxCount + 1]; this._tail = new CircularBuffer <T> .CircularBufferCounter(maxCount, 0); this._head = new CircularBuffer <T> .CircularBufferCounter(maxCount, 0); }
public void Dispose() { this._tail = null; this._head = null; this.buffer = null; this.currentGraphic = null; this.carat = null; this.encoder = null; }
/// <summary> /// Gets a Value from the row/colo /// </summary> /// <param name="row">The presented row, we handle offseting the values</param> /// <param name="col">The column</param> /// <returns>TermChar</returns> public TermChar GetValue(int row, int col) { //clone the head counter CircularBufferCounter temp = (CircularBufferCounter)this._head.Clone(); //set the row offset, let it handle wrapping temp += row; return(this.buffer[temp.Value, col]); }
public void DoEraseLine() { CircularBufferCounter temp = this._head; temp += this.carat.Row; for (int i = this.carat.Col; i < this._maxCol; ++i) { this.buffer[temp.Value, i].Clear(); } }
/// <summary> /// Resets the grid to default values /// </summary> public void Clear() { this.buffer = new TermChar[this._maxRow, this._maxCol]; InitBuffer(); this._tail = new CircularBufferCounter(this._maxRow, this._maxRow - 1); this._head = new CircularBufferCounter(this._maxRow, 0); currentGraphic = new TermCurrentGraphic((int)ANSI_COLOR.White, (int)ANSI_COLOR.Black_B); this.carat = new TermCarat(0, 0); this.carat.Char = encoder.GetString(carat_b); this.carat.AnsiGraphic = currentGraphic.CurrentGraphicCfg; }
public void DoNewLine() { //check the total count of lines, is it at our max value? if (this.carat.Row == this._maxRow - 1) { this._head += 1; //move the head down this._tail += 1; //move the tail down DoEraseLine(); //clear the new line in case we have stale data; } else { this.carat.IncRow(); } }
//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 } }
public void Add(T item) { //need to find a better way to handle non-nullables if (buffer[this._tail.Next()] == null) { buffer[this._tail.Value] = item; this._tail += 1; } else { buffer[this._head.Value] = default(T); this._head += 1; buffer[this._tail.Value] = item; this._tail += 1; } }