private void ShowChar(Graphics CurGraphics, Char CurChar, Int32 Y, Int32 X, CharAttribStruct CurAttribs)
        {
            if (CurChar == '\0')
            {
                return;
            }

            Color CurFGColor = Color.White;
            Color CurBGColor = Color.Black;

            this.AssignColors(CurAttribs, ref CurFGColor, ref CurBGColor);

            if ((CurBGColor != this.BackColor && (this.Modes.Flags & uc_Mode.LightBackground) == 0) ||
                (CurBGColor != this.ForeColor && (this.Modes.Flags & uc_Mode.LightBackground) > 0))
            {
                // Erase the current Character underneath the cursor postion
                this.EraseBuffer.Clear(CurBGColor);

                // paint a rectangle over the cursor position in the character's BGColor
                CurGraphics.DrawImageUnscaled(this.EraseBitmap, X, Y);
            }

            if (CurAttribs.IsUnderscored)
            {
                CurGraphics.DrawLine(new Pen(CurFGColor, 1), X, Y + this.UnderlinePos, X + this.CharSize.Width,
                                     Y + this.UnderlinePos);
            }

            if (CurAttribs.IsDECSG &&
                (CurChar == 'l' ||
                 CurChar == 'q' ||
                 CurChar == 'w' ||
                 CurChar == 'k' ||
                 CurChar == 'x' ||
                 CurChar == 't' ||
                 CurChar == 'n' ||
                 CurChar == 'u' ||
                 CurChar == 'm' ||
                 CurChar == 'v' ||
                 CurChar == 'j' ||
                 CurChar == '`'))
            {
                this.ShowSpecialChar(CurGraphics, CurChar, Y, X, CurFGColor, CurBGColor);
                return;
            }

            CurGraphics.DrawString(
                CurChar.ToString(),
                this.Font,
                new SolidBrush(CurFGColor),
                X - this.DrawStringOffset.X,
                Y - this.DrawStringOffset.Y);
        }
Exemplo n.º 2
0
 public uc_CaretAttribs(
     Point p1,
     uc_Chars.Sets p2,
     uc_Chars.Sets p3,
     uc_Chars.Sets p4,
     uc_Chars.Sets p5,
     CharAttribStruct p6)
 {
     this.Pos     = p1;
     this.G0Set   = p2;
     this.G1Set   = p3;
     this.G2Set   = p4;
     this.G3Set   = p5;
     this.Attribs = p6;
 }
Exemplo n.º 3
0
 public uc_CaretAttribs(
     Point p1,
     uc_Chars.Sets p2,
     uc_Chars.Sets p3,
     uc_Chars.Sets p4,
     uc_Chars.Sets p5,
     CharAttribStruct p6)
 {
     this.Pos = p1;
     this.G0Set = p2;
     this.G1Set = p3;
     this.G2Set = p4;
     this.G3Set = p5;
     this.Attribs = p6;
 }
Exemplo n.º 4
0
        private void ShowCaret(Graphics CurGraphics)
        {
            Int32 X = this.Caret.Pos.X;
            Int32 Y = this.Caret.Pos.Y;

            if (this.Caret.IsOff == true)
            {
                return;
            }

            // paint a rectangle over the cursor position
            CurGraphics.DrawImageUnscaled(this.Caret.Bitmap, X * (Int32)this.CharSize.Width, Y * (Int32)this.CharSize.Height);

            // if we don't have a char to redraw then leave
            if (this.CharGrid[Y][X] == '\0')
            {
                return;
            }

            CharAttribStruct CurAttribs = new CharAttribStruct();

            CurAttribs.UseAltColor = true;

            CurAttribs.GL = this.AttribGrid[Y][X].GL;
            CurAttribs.GR = this.AttribGrid[Y][X].GR;
            CurAttribs.GS = this.AttribGrid[Y][X].GS;

            if (this.AttribGrid[Y][X].UseAltBGColor == false)
            {
                CurAttribs.AltColor = this.BackColor;
            }
            else if (this.AttribGrid[Y][X].UseAltBGColor == true)
            {
                CurAttribs.AltColor = this.AttribGrid[Y][X].AltBGColor;
            }

            CurAttribs.IsUnderscored = this.AttribGrid[Y][X].IsUnderscored;
            CurAttribs.IsDECSG       = this.AttribGrid[Y][X].IsDECSG;

            // redispay the current char in the background colour
            this.ShowChar(
                CurGraphics,
                this.CharGrid[Y][X],
                Caret.Pos.Y * this.CharSize.Height,
                Caret.Pos.X * this.CharSize.Width,
                CurAttribs);
        }
Exemplo n.º 5
0
        private void AssignColors(CharAttribStruct CurAttribs, ref Color CurFGColor, ref Color CurBGColor)
        {
            CurFGColor = this.ForeColor;
            CurBGColor = this.BackColor;

            if (CurAttribs.IsBlinking == true)
            {
                CurFGColor = this.BlinkColor;
            }

            // bold takes precedence over the blink color
            if (CurAttribs.IsBold == true)
            {
                CurFGColor = this.BoldColor;
            }

            if (CurAttribs.UseAltColor == true)
            {
                CurFGColor = CurAttribs.AltColor;
            }

            // alternate color takes precedence over the bold color
            if (CurAttribs.UseAltBGColor == true)
            {
                CurBGColor = CurAttribs.AltBGColor;
            }

            if (CurAttribs.IsInverse == true)
            {
                Color TmpColor = CurBGColor;

                CurBGColor = CurFGColor;
                CurFGColor = TmpColor;
            }

            // If light background is on and we're not using alt colors
            // reverse the colors
            if ((this.Modes.Flags & uc_Mode.LightBackground) > 0 &&
                CurAttribs.UseAltColor == false && CurAttribs.UseAltBGColor == false)
            {
                Color TmpColor = CurBGColor;
                CurBGColor = CurFGColor;
                CurFGColor = TmpColor;
            }
        }
        private void AssignColors(CharAttribStruct CurAttribs, ref Color CurFGColor, ref Color CurBGColor)
        {
            CurFGColor = this.ForeColor;
            CurBGColor = this.BackColor;

            if (CurAttribs.IsBlinking == true)
            {
                CurFGColor = this.BlinkColor;
            }

            // bold takes precedence over the blink color
            if (CurAttribs.IsBold == true)
            {
                CurFGColor = this.BoldColor;
            }

            if (CurAttribs.UseAltColor == true)
            {
                CurFGColor = CurAttribs.AltColor;
            }

            // alternate color takes precedence over the bold color
            if (CurAttribs.UseAltBGColor == true)
            {
                CurBGColor = CurAttribs.AltBGColor;
            }

            if (CurAttribs.IsInverse == true)
            {
                Color TmpColor = CurBGColor;

                CurBGColor = CurFGColor;
                CurFGColor = TmpColor;
            }

            // If light background is on and we're not using alt colors
            // reverse the colors
            if ((this.Modes.Flags & uc_Mode.LightBackground) > 0 &&
                CurAttribs.UseAltColor == false && CurAttribs.UseAltBGColor == false)
            {
                Color TmpColor = CurBGColor;
                CurBGColor = CurFGColor;
                CurFGColor = TmpColor;
            }
        }
Exemplo n.º 7
0
 internal void ReplaceValues(int rowIndex, string newChars, CharAttribStruct[] newAttributes)
 {
     this.Characters[rowIndex] = newChars;
     this.Attributes[rowIndex] = newAttributes;
 }
Exemplo n.º 8
0
 internal void Insert(int index, string line, CharAttribStruct[] lineAttributes)
 {
     this.Characters.Insert(index, line);
     this.Attributes.Insert(index, lineAttributes);
 }
Exemplo n.º 9
0
 internal void Add(string line, CharAttribStruct[] lineAttributes)
 {
     this.Characters.Add(line);
     this.Attributes.Add(lineAttributes);
 }
Exemplo n.º 10
0
        private void ShowChar(System.Drawing.Graphics CurGraphics, System.Char CurChar, System.Int32 Y, System.Int32 X, CharAttribStruct CurAttribs)
        {
            if (CurChar == '\0')
            {
                return;
            }

            System.Drawing.Color CurFGColor = System.Drawing.Color.White;
            System.Drawing.Color CurBGColor = System.Drawing.Color.Black;

            this.AssignColors (CurAttribs, ref CurFGColor, ref CurBGColor);

            if ((CurBGColor != this.BackColor && (this.Modes.Flags & uc_Mode.LightBackground) == 0) ||
                (CurBGColor != this.FGColor   && (this.Modes.Flags & uc_Mode.LightBackground) > 0))
            {

                // Erase the current Character underneath the cursor postion
                this.EraseBuffer.Clear (CurBGColor);

                // paint a rectangle over the cursor position in the character's BGColor
                CurGraphics.DrawImageUnscaled (
                    this.EraseBitmap,
                    X,
                    Y);
            }

            if (CurAttribs.IsUnderscored)
            {
                CurGraphics.DrawLine (new System.Drawing.Pen (CurFGColor, 1),
                    X,                       Y + this.UnderlinePos,
                    X + this.CharSize.Width, Y + this.UnderlinePos);
            }

            if ((CurAttribs.IsDECSG == true) &&
                (CurChar == 'l' ||
                CurChar == 'q' ||
                CurChar == 'w' ||
                CurChar == 'k' ||
                CurChar == 'x' ||
                CurChar == 't' ||
                CurChar == 'n' ||
                CurChar == 'u' ||
                CurChar == 'm' ||
                CurChar == 'v' ||
                CurChar == 'j' ||
                CurChar == '`'))
            {
                this.ShowSpecialChar (
                    CurGraphics,
                    CurChar,
                    Y,
                    X,
                    CurFGColor,
                    CurBGColor);

                return;
            }

            CurGraphics.DrawString (
                CurChar.ToString (),
                this.Font,
                new System.Drawing.SolidBrush (CurFGColor),
                X - this.DrawStringOffset.X,
                Y - this.DrawStringOffset.Y);
        }
Exemplo n.º 11
0
        private void ShowCaret(System.Drawing.Graphics CurGraphics)
        {
            System.Int32 X = this.Caret.Pos.X;
            System.Int32 Y = this.Caret.Pos.Y;

            if (this.Caret.IsOff == true)
            {
                return;
            }

            // paint a rectangle over the cursor position
            CurGraphics.DrawImageUnscaled (
                this.Caret.Bitmap,
                X * (int) this.CharSize.Width,
                Y * (int) this.CharSize.Height);

            // if we don't have a char to redraw then leave
            if (this.CharGrid[Y][X] == '\0')
            {
                return;
            }

            CharAttribStruct CurAttribs = new CharAttribStruct ();

            CurAttribs.UseAltColor = true;

            CurAttribs.GL = this.AttribGrid[Y][X].GL;
            CurAttribs.GR = this.AttribGrid[Y][X].GR;
            CurAttribs.GS = this.AttribGrid[Y][X].GS;

            if (this.AttribGrid[Y][X].UseAltBGColor == false)
            {
                CurAttribs.AltColor = this.BackColor;
            }
            else if (this.AttribGrid[Y][X].UseAltBGColor == true)
            {
                CurAttribs.AltColor = this.AttribGrid[Y][X].AltBGColor;
            }

            CurAttribs.IsUnderscored = this.AttribGrid[Y][X].IsUnderscored;
            CurAttribs.IsDECSG       = this.AttribGrid[Y][X].IsDECSG;

            // redispay the current char in the background colour
            this.ShowChar (
                CurGraphics,
                this.CharGrid[Y][X],
                Caret.Pos.Y * this.CharSize.Height,
                Caret.Pos.X * this.CharSize.Width,
                CurAttribs);
        }
Exemplo n.º 12
0
        private void CommandRouter(object Sender, ParserEventArgs e)
        {
            switch (e.Action)
            {
                case Actions.Print:
                    this.PrintChar (e.CurChar);
                    //System.Console.Write ("{0}", e.CurChar);
                    break;

                case Actions.Execute:
                    this.ExecuteChar (e.CurChar);
                    break;

                case Actions.Dispatch:
                    break;

                default:
                    break;
            }

            System.Int32 Param = 0;

            System.Int32 Inc = 1; // increment

            switch (e.CurSequence)
            {
                case "":
                    break;

                case "\x1b" + "7": //DECSC Save Cursor position and attributes
                    this.SavedCarets.Add (new uc_CaretAttribs (
                        this.Caret.Pos,
                        this.G0.Set,
                        this.G1.Set,
                        this.G2.Set,
                        this.G3.Set,
                        this.CharAttribs));

                    break;

                case "\x1b" + "8": //DECRC Restore Cursor position and attributes
                    this.Caret.Pos   = ((uc_CaretAttribs) this.SavedCarets[this.SavedCarets.Count - 1]).Pos;
                    this.CharAttribs = ((uc_CaretAttribs) this.SavedCarets[this.SavedCarets.Count - 1]).Attribs;

                    this.G0.Set = ((uc_CaretAttribs) this.SavedCarets[this.SavedCarets.Count - 1]).G0Set;
                    this.G1.Set = ((uc_CaretAttribs) this.SavedCarets[this.SavedCarets.Count - 1]).G1Set;
                    this.G2.Set = ((uc_CaretAttribs) this.SavedCarets[this.SavedCarets.Count - 1]).G2Set;
                    this.G3.Set = ((uc_CaretAttribs) this.SavedCarets[this.SavedCarets.Count - 1]).G3Set;

                    this.SavedCarets.RemoveAt (this.SavedCarets.Count - 1);

                    break;

                case "\x1b~": //LS1R Locking Shift G1 -> GR
                    this.CharAttribs.GR = G1;
                    break;

                case "\x1bn": //LS2 Locking Shift G2 -> GL
                    this.CharAttribs.GL = G2;
                    break;

                case "\x1b}": //LS2R Locking Shift G2 -> GR
                    this.CharAttribs.GR = G2;
                    break;

                case "\x1bo": //LS3 Locking Shift G3 -> GL
                    this.CharAttribs.GL = G3;
                    break;

                case "\x1b|": //LS3R Locking Shift G3 -> GR
                    this.CharAttribs.GR = G3;
                    break;

                case "\x1b#8": //DECALN
                    e.CurParams.Elements.Add ("1");
                    e.CurParams.Elements.Add (this._rows.ToString ());
                    this.SetScrollRegion (e.CurParams);

                    // put E's on the entire screen
                    for (int y = 0; y < this._rows; y++)
                    {
                        this.CaretToAbs (y, 0);

                        for (int x = 0; x < this._cols; x++)
                        {
                            this.PrintChar ('E');
                        }
                    }
                    break;

                case "\x1b=": // Keypad to Application mode
                    this.Modes.Flags = this.Modes.Flags | uc_Mode.KeypadAppln;
                    break;

                case "\x1b>": // Keypad to Numeric mode
                    this.Modes.Flags = this.Modes.Flags ^ uc_Mode.KeypadAppln;
                    break;

                case "\x1b[B": // CUD

                    if (e.CurParams.Count () > 0)
                    {
                        Inc = System.Convert.ToInt32 (e.CurParams.Elements[0]);
                    }

                    if (Inc == 0) Inc = 1;

                    this.CaretToAbs (this.Caret.Pos.Y + Inc, this.Caret.Pos.X);
                    break;

                case "\x1b[A": // CUU

                    if (e.CurParams.Count () > 0)
                    {
                        Inc = System.Convert.ToInt32 (e.CurParams.Elements[0]);
                    }

                    if (Inc == 0) Inc = 1;

                    this.CaretToAbs (this.Caret.Pos.Y - Inc, this.Caret.Pos.X);
                    break;

                case "\x1b[C": // CUF

                    if (e.CurParams.Count () > 0)
                    {
                        Inc = System.Convert.ToInt32 (e.CurParams.Elements[0]);
                    }

                    if (Inc == 0) Inc = 1;

                    this.CaretToAbs (this.Caret.Pos.Y, this.Caret.Pos.X + Inc);
                    break;

                case "\x1b[D": // CUB

                    if (e.CurParams.Count () > 0)
                    {
                        Inc = System.Convert.ToInt32 (e.CurParams.Elements[0]);
                    }

                    if (Inc == 0) Inc = 1;

                    this.CaretToAbs (this.Caret.Pos.Y, this.Caret.Pos.X - Inc);
                    break;

                case "\x1b[H": // CUP
                case "\x1b[f": // HVP

                    System.Int32 X = 0;
                    System.Int32 Y = 0;

                    if (e.CurParams.Count () > 0)
                    {
                        Y = System.Convert.ToInt32 (e.CurParams.Elements[0]) - 1;
                    }

                    if (e.CurParams.Count () > 1)
                    {
                        X = System.Convert.ToInt32 (e.CurParams.Elements[1]) - 1;
                    }

                    this.CaretToRel (Y, X);
                    break;

                case "\x1b[J":

                    if (e.CurParams.Count () > 0)
                    {
                        Param = System.Convert.ToInt32 (e.CurParams.Elements[0]);
                    }

                    this.ClearDown (Param);
                    break;

                case "\x1b[K":

                    if (e.CurParams.Count () > 0)
                    {
                        Param = System.Convert.ToInt32 (e.CurParams.Elements[0]);
                    }

                    this.ClearRight (Param);
                    break;

                case "\x1b[L": // INSERT LINE
                    this.InsertLine (e.CurParams);
                    break;

                case "\x1b[M": // DELETE LINE
                    this.DeleteLine (e.CurParams);
                    break;

                case "\x1bN": // SS2 Single Shift (G2 -> GL)
                    this.CharAttribs.GS = this.G2;
                    break;

                case "\x1bO": // SS3 Single Shift (G3 -> GL)
                    this.CharAttribs.GS = this.G3;
                    //System.Console.WriteLine ("SS3: GS = {0}", this.CharAttribs.GS);
                    break;

                case "\x1b[m":
                    this.SetCharAttribs (e.CurParams);
                    break;

                case "\x1b[?h":
                    this.SetqmhMode (e.CurParams);
                    break;

                case "\x1b[?l":
                    this.SetqmlMode (e.CurParams);
                    break;

                case "\x1b[c": // DA Device Attributes
                    //                    this.DispatchMessage (this, "\x1b[?64;1;2;6;7;8;9c");
                    this.DispatchMessage (this, "\x1b[?6c");
                    break;

                case "\x1b[g":
                    this.ClearTabs (e.CurParams);
                    break;

                case "\x1b[h":
                    this.SethMode (e.CurParams);
                    break;

                case "\x1b[l":
                    this.SetlMode (e.CurParams);
                    break;

                case "\x1b[r": // DECSTBM Set Top and Bottom Margins
                    this.SetScrollRegion (e.CurParams);
                    break;

                case "\x1b[t": // DECSLPP Set Lines Per Page

                    if (e.CurParams.Count () > 0)
                    {
                        Param = System.Convert.ToInt32 (e.CurParams.Elements[0]);
                    }

                    if (Param > 0) this.SetSize (Param, this._cols);

                    break;

                case "\x1b" + "D": // IND

                    if (e.CurParams.Count () > 0)
                    {
                        Param = System.Convert.ToInt32 (e.CurParams.Elements[0]);
                    }

                    this.Index (Param);
                    break;

                case "\x1b" + "E": // NEL
                    this.LineFeed ();
                    this.CarriageReturn ();
                    break;

                case "\x1bH": // HTS
                    this.TabSet ();
                    break;

                case "\x1bM": // RI
                    if (e.CurParams.Count () > 0)
                    {
                        Param = System.Convert.ToInt32 (e.CurParams.Elements[0]);
                    }

                    this.ReverseIndex (Param);
                    break;

                default:
                    //System.Console.Write ("unsupported VT sequence {0} happened\n", e.CurSequence);
                    break;

            }

            if (e.CurSequence.StartsWith ("\x1b("))
            {
                this.SelectCharSet (ref this.G0.Set, e.CurSequence.Substring (2));
            }
            else if (e.CurSequence.StartsWith ("\x1b-") ||
                e.CurSequence.StartsWith ("\x1b)"))
            {
                this.SelectCharSet (ref this.G1.Set, e.CurSequence.Substring (2));
            }
            else if (e.CurSequence.StartsWith ("\x1b.") ||
                e.CurSequence.StartsWith ("\x1b*"))
            {
                this.SelectCharSet (ref this.G2.Set, e.CurSequence.Substring (2));
            }
            else if (e.CurSequence.StartsWith ("\x1b/") ||
                e.CurSequence.StartsWith ("\x1b+"))
            {
                this.SelectCharSet (ref this.G3.Set, e.CurSequence.Substring (2));
            }
        }