Example #1
0
 public static bool Equals(ColorType ct1,ColorType ct2)
 {
     return ct1.Color == ct2.Color;
 }
Example #2
0
 internal static void Init(Runtime.CommandLineOptions options, TerminalMainProgram mainProgram)
 {
     Width = options.Width;
     Height = options.Height;
     DefaultForeColor = new ColorType(options.ForeColor);
     DefaultBackColor = new ColorType(options.BackColor);
     History = new TerminalHistory();
     TerminalWindow = new TerminalMainForm(options.FontName, options.FontSize, Width, Height, mainProgram);
     WindowList = new List<Window>();
     StdScr = ReplWindow.CreateReplWindow(Width, Height, options.BufferHeight);
     Register(StdScr);
     RefreshAll();
     TerminalWindow.Show();
     TerminalWindow.Activate();
     Application.Run(TerminalWindow);
     //Runtime.Quit();
 }
Example #3
0
 void PaintString(Graphics g, string text, int x, int y, int w, ColorType fg,ColorType bg, int attr )
 {
     //            if (y == 0 && w==2)
     //            {
     //                int n = 37;
     //            }
     var xx = x * charWidth;
     var yy = y * lineHeight;
     var ww = w * charWidth;
     var hh = 1 * lineHeight;
     var bounds3 = new Rectangle(xx, yy, ww, hh);
     //var bounds1 = (RectangleF)bounds3;
     int fontIndex = attr & TerminalAttribute.FontMask;
     bool reverse = (attr & TerminalAttribute.Reverse) != 0;
     if (reverse)
     {
         g.FillRectangle(new SolidBrush(fg), xx, yy, ww, hh);
         //g.DrawString(text, Font, new SolidBrush(bg), bounds1);
         TextRenderer.DrawText(g, text, Fonts[fontIndex], bounds3, bg, fg, flags);
     }
     else
     {
         g.FillRectangle(new SolidBrush(bg), xx, yy, ww, hh);
         //g.DrawString(text, Font, new SolidBrush(fg), bounds1);
         TextRenderer.DrawText(g, text, Fonts[fontIndex], bounds3, fg, bg, flags);
     }
 }
Example #4
0
 internal void Set(int col, int row, char ch, ColorType fg, ColorType bg, int attr)
 {
     Buffer.Set(BufferLeft + col, BufferTop + row, ch, fg, bg, attr);
 }
Example #5
0
 internal void Get(int col, int row, out char ch, out ColorType fg, out ColorType bg, out int attr)
 {
     Buffer.Get(BufferLeft + col, BufferTop + row, out ch, out fg, out bg, out attr);
 }
        public override void Write(string value)
        {
            var beg = value.IndexOf("!{");
            if (beg == -1)
            {
                WriteString(value);
                return;
            }

            var end = value.IndexOf("}", beg);
            if (end == -1)
            {
                end = value.Length;
            }

            if (!savedOrig)
            {
                fgOrig = window.ForeColor;
                attrOrig = window.Attr;
                savedOrig = true;
            }

            var head = value.Substring(0, beg);
            var middle = value.Substring(beg + 2, end - beg - 2);
            var tail = value.Substring(end + (end < value.Length ? 1 : 0));

            WriteString(head);

            var parts = StringExtensions.Split(middle);

            foreach (var part in parts)
            {
                if (part.StartsWith("+"))
                {
                    var word = part.Substring(1);
                    switch (word)
                    {
                        case "normal":
                            case "bold":
                            case "italic":
                            case "underline":
                            case "strikeout":
                            case "strike-out":
                            case "reverse":
                        {
                            window.AttrOn(word);
                            break;
                        }
                            default:
                        {
                            window.ForeColor = new ColorType(word);
                            break;
                        }
                    }
                }
                else if (part.StartsWith("-"))
                {
                    var word = part.Substring(1);
                    switch (word)
                    {
                        case "normal":
                            case "bold":
                            case "italic":
                            case "underline":
                            case "strikeout":
                            case "strike-out":
                            case "reverse":
                        {
                            window.AttrOff(word);
                            break;
                        }
                            default:
                        {
                            window.ForeColor = fgOrig;
                            break;
                        }
                    }
                }
                else
                {
                    var word = part;
                    switch (word)
                    {
                        case "normal":
                            case "bold":
                            case "italic":
                            case "underline":
                            case "strikeout":
                            case "strike-out":
                            case "reverse":
                        {
                            window.AttrSet(word);
                            break;
                        }
                            default:
                        {
                            window.ForeColor = new ColorType(word);
                            break;
                        }
                    }
                }

            }

            Write(tail);

            //Application.DoEvents();
        }
        public override void Write(string value)
        {
            var beg = value.IndexOf("!{");

            if (beg == -1)
            {
                WriteString(value);
                return;
            }

            var end = value.IndexOf("}", beg);

            if (end == -1)
            {
                end = value.Length;
            }

            if (!savedOrig)
            {
                fgOrig    = window.ForeColor;
                attrOrig  = window.Attr;
                savedOrig = true;
            }

            var head   = value.Substring(0, beg);
            var middle = value.Substring(beg + 2, end - beg - 2);
            var tail   = value.Substring(end + (end < value.Length ? 1 : 0));

            WriteString(head);

            var parts = StringExtensions.Split(middle);

            foreach (var part in parts)
            {
                if (part.StartsWith("+"))
                {
                    var word = part.Substring(1);
                    switch (word)
                    {
                    case "normal":
                    case "bold":
                    case "italic":
                    case "underline":
                    case "strikeout":
                    case "strike-out":
                    case "reverse":
                    {
                        window.AttrOn(word);
                        break;
                    }

                    default:
                    {
                        window.ForeColor = new ColorType(word);
                        break;
                    }
                    }
                }
                else if (part.StartsWith("-"))
                {
                    var word = part.Substring(1);
                    switch (word)
                    {
                    case "normal":
                    case "bold":
                    case "italic":
                    case "underline":
                    case "strikeout":
                    case "strike-out":
                    case "reverse":
                    {
                        window.AttrOff(word);
                        break;
                    }

                    default:
                    {
                        window.ForeColor = fgOrig;
                        break;
                    }
                    }
                }
                else
                {
                    var word = part;
                    switch (word)
                    {
                    case "normal":
                    case "bold":
                    case "italic":
                    case "underline":
                    case "strikeout":
                    case "strike-out":
                    case "reverse":
                    {
                        window.AttrSet(word);
                        break;
                    }

                    default:
                    {
                        window.ForeColor = new ColorType(word);
                        break;
                    }
                    }
                }
            }

            Write(tail);

            //Application.DoEvents();
        }
Example #8
0
 public void Set(int col, int row, char ch, ColorType fg, ColorType bg, int style)
 {
     var pos = row * Width + col;
     if (ch != (char)0)
     {
         Data[pos] = ch;
     }
     Fg[pos] = fg;
     Bg[pos] = bg;
     Attr[pos] = style;
 }
Example #9
0
 public void Get(int col, int row, out char ch, out ColorType fg, out ColorType bg, out int attr)
 {
     var pos = row * Width + col;
     ch = Data[pos];
     fg = Fg[pos];
     bg = Bg[pos];
     attr = Attr[pos];
 }
Example #10
0
        public void ClearRect(int x, int y, int w, int h, ColorType foreColor,ColorType backColor)
        {
            var pos = y * Width + x;

            for (int r=0; r<h; ++r)
            {
                for (int c=0; c<w; ++c)
                {
                    Data[pos + c] = ' ';
                    Fg[pos + c] = foreColor;
                    Bg[pos + c] = backColor;
                    Attr[pos + c] = 0;
                }
                pos += Width;
            }
        }