context: public partial class ackterm
  {
      private partial class TermWindow : System.Windows.Forms.Form
      {
          private class uc_TabStops
          {
              public System.Boolean[] Columns;
  
              public uc_TabStops ()
              {
                  //prntSome.printSome("uc_TabStops");
                  Columns = new System.Boolean[256];
  
                  Columns[8]   = true;
                  Columns[16]  = true;
                  Columns[24]  = true;
                  Columns[32]  = true;
                  Columns[40]  = true;
                  Columns[48]  = true;
                  Columns[56]  = true;
                  Columns[64]  = true;
                  Columns[72]  = true;
                  Columns[80]  = true;
                  Columns[88]  = true;
                  Columns[96]  = true;
                  Columns[104] = true;
                  Columns[112] = true;
                  Columns[120] = true;
                  Columns[128] = true;
              }
          };
  
          private class uc_CaretAttribs
          {
              public System.Drawing.Point Pos;
              public uc_Chars.Sets        G0Set;
              public uc_Chars.Sets        G1Set;
              public uc_Chars.Sets        G2Set;
              public uc_Chars.Sets        G3Set;
              public CharAttribs          Attribs;
  
              public uc_CaretAttribs (
                  System.Drawing.Point p1,
                  uc_Chars.Sets        p2,
                  uc_Chars.Sets        p3,
                  uc_Chars.Sets        p4,
                  uc_Chars.Sets        p5,
                  CharAttribs          p6)
              {
                  //prntSome.printSome("uc_CaretAttribs");
                  this.Pos     = p1;
                  this.G0Set   = p2;
                  this.G1Set   = p3;
                  this.G2Set   = p4;
                  this.G3Set   = p5;
                  this.Attribs = p6;
              }
          }
  
          private void CarriageReturn () 
          {
              //prntSome.printSome("CarriageReturn");
              this.CaretToAbs (this.Caret.Pos.Y, 0);
          }
  
          private void Tab () 
          {
              //prntSome.printSome("Tab");
              for (System.Int32 i = 0; i < this.TabStops.Columns.Length; i++)
              {
                  if (i > this.Caret.Pos.X && this.TabStops.Columns[i]  == true)
                  {
                      this.CaretToAbs (this.Caret.Pos.Y, i);
                      return;
                  }
              }
  
              this.CaretToAbs (this.Caret.Pos.Y, this.Columns -1);
              return;
          }
  
          public void TabSet ()
          {
              //prntSome.printSome("TabSet");
              this.TabStops.Columns[this.Caret.Pos.X] = true;
          }
  
          public void ClearTabs (uc_Params CurParams) // TBC 
          {
              //prntSome.printSome("ClearTabs");
              System.Int32 Param = 0;
  
              if (CurParams.Count () > 0)
              {
                  Param = System.Convert.ToInt32 (CurParams.Elements[0]);
              }
  
              switch (Param)
              {
                  case 0: // Current Position
                      this.TabStops.Columns[this.Caret.Pos.X] = false;
                      break;
  
                  case 3: // All Tabs
                      for (int i = 0; i < this.TabStops.Columns.Length; i++)
                      {
                          this.TabStops.Columns[i] = false;
                      }
                      break;
  
                  default:
                      break;
              }
          }
  
          private void ReverseLineFeed ()
          {
              //prntSome.printSome("ReverseLineFeed");
              // if we're at the top of the scroll region (top margin)
              if (this.Caret.Pos.Y == this.TopMargin)
              {
                  // we need to add a new line at the top of the screen margin
                  // so shift all the rows in the scroll region down in the array and
                  // insert a new row at the top
                  
                  int i;
  
     
                  for (i = this.BottomMargin; i > this.TopMargin; i--)
                  {
                      this.CharGrid[i]   = this.CharGrid[i - 1];
                      this.AttribGrid[i] = this.AttribGrid[i - 1];
                  }
  
                  this.CharGrid[this.TopMargin] = new System.Char[this.Columns];
  
                  this.AttribGrid[this.TopMargin] = new CharAttribs[this.Columns];
              }
  
              this.CaretUp ();
          }
  
          private void InsertLine (uc_Params CurParams)
          {
              //prntSome.printSome("InsertLine");
              // if we're not in the scroll region then bail
              if (this.Caret.Pos.Y < this.TopMargin ||
                  this.Caret.Pos.Y > this.BottomMargin)
              {
                  return;
              }
  
              System.Int32 NbrOff = 1;
  
              if (CurParams.Count () > 0)
              {
                  NbrOff = System.Convert.ToInt32 (CurParams.Elements[0]);
              }
  
              while (NbrOff > 0)
              { 
  
                  // Shift all the rows from the current row to the bottom margin down one place
                  for (int i = this.BottomMargin; i > this.Caret.Pos.Y; i--)
                  {
                      this.CharGrid[i]   = this.CharGrid[i - 1];
                      this.AttribGrid[i] = this.AttribGrid[i - 1];
                  }
  
                  this.CharGrid[this.Caret.Pos.Y]   = new System.Char[this.Columns];
                  this.AttribGrid[this.Caret.Pos.Y] = new CharAttribs[this.Columns];
  
                  NbrOff--;
              }
  
          }
  
          private void DeleteLine (uc_Params CurParams)
          {
              //prntSome.printSome("DeleteLine");
              // if we're not in the scroll region then bail
              if (this.Caret.Pos.Y < this.TopMargin ||
                  this.Caret.Pos.Y > this.BottomMargin)
              {
                  return;
              }
  
              System.Int32 NbrOff = 1;
  
              if (CurParams.Count () > 0)
              {
                  NbrOff = System.Convert.ToInt32 (CurParams.Elements[0]);
              }
  
              while (NbrOff > 0)
              { 
  
                  // Shift all the rows from below the current row to the bottom margin up one place
                  for (int i = this.Caret.Pos.Y; i < this.BottomMargin; i++)
                  {
                      this.CharGrid[i]   = this.CharGrid[i + 1];
                      this.AttribGrid[i] = this.AttribGrid[i + 1];
                  }
  
                  this.CharGrid[this.BottomMargin]   = new System.Char[this.Columns];
                  this.AttribGrid[this.BottomMargin] = new CharAttribs[this.Columns];
  
                  NbrOff--;
              }
          }
  
          private void LineFeed ()
          {
              //prntSome.printSome("LineFeed");
              if (this.Caret.Pos.Y == this.BottomMargin || this.Caret.Pos.Y == this.Rows - 1)
              {
                  // we need to add a new line so shift all the rows up in the array and
                  // insert a new row at the bottom
                  
                  int i;
                  
                  for (i = this.TopMargin; i < this.BottomMargin; i++)
                  {
                      this.CharGrid[i]   = this.CharGrid[i + 1];
                      this.AttribGrid[i] = this.AttribGrid[i + 1];
                  }
  
                  this.CharGrid[i]   = new System.Char[this.Columns];
                  this.AttribGrid[i] = new CharAttribs[this.Columns];
  
              }
  
              this.CaretDown ();
          }
  
          private void Index (System.Int32 Param)
          {
              //prntSome.printSome("Index");
              if (Param == 0) Param = 1;
  
              for (int i = 0; i < Param; i++)
              {
                  this.LineFeed ();
              }
          }
  
          private void ReverseIndex (System.Int32 Param)
          {
              //prntSome.printSome("ReverseIndex");
  
gt:             if (Param == 0) Param = 1;