Пример #1
0
 public void Draw(Color foreground, Color background, string str, int x, int y, int w, int h, out int endx, out int endy, params int[] attributes)
 {
     Draw(ColorPair.From(foreground, background, attributes), str, x, y, w, h, out endx, out endy);
 }
Пример #2
0
 public void Draw(Color foreground, string str, int x, int y, int w, int h, params int[] attributes)
 {
     Draw(ColorPair.From(foreground, attributes), str, x, y, w, h);
 }
Пример #3
0
 public void Draw(Color foreground, Color background, string str, int x, int y, params int[] attributes)
 {
     Draw(ColorPair.From(foreground, background, attributes), str, x, y);
 }
Пример #4
0
 public void Fill(Color foreground, Color background, string str, char ch, int x, int y, int w, int h, params int[] attributes)
 {
     Fill(ColorPair.From(foreground, background, attributes), str, ch, x, y, w, h);
 }
Пример #5
0
 public void Draw(Color foreground, string str, params int[] attributes)
 {
     Draw(ColorPair.From(foreground, attributes), str);
 }
Пример #6
0
 public static ColorPair From(Color foreground, Color background)
 {
     return(ColorPair.From(ConvertBasic(foreground), ConvertBasic(background)));
 }
Пример #7
0
 public static int From(int foreground, int background, params int[] attributes)
 {
     return(Accumulate(ColorPair.From(foreground, background).Attribute, attributes));
 }
Пример #8
0
 public static CursesAttribute Attribute(System.Drawing.Color foreground, System.Drawing.Color background, params int[] attributes)
 {
     return(Attribute(ColorPair.From(foreground, background, attributes)));
 }
Пример #9
0
 public static void Finish()
 {
     Curses.attron(ColorPair.From(-1, -1).Attribute);
 }
Пример #10
0
        public static int Each(string str, Func <char, bool> callback)
        {
            int n = 0;

            DrawStringMode mode = DrawStringMode.Normal;

            string fg = string.Empty;
            string bg = string.Empty;

            foreach (char c in str)
            {
                switch (mode)
                {
                case DrawStringMode.Normal:
                    if (c == '\x0000')
                    {
                        mode = DrawStringMode.ForegroundColor;
                    }
                    else
                    {
                        if (!callback(c))
                        {
                            return(n);
                        }
                        n++;
                    }
                    break;

                case DrawStringMode.ForegroundColor:
                    if (char.IsNumber(c))
                    {
                        fg += c;
                    }
                    else if (c == ',')
                    {
                        mode = DrawStringMode.Background;
                    }
                    else if (c == ' ')
                    {
                        ushort foreground = ushort.MaxValue;
                        if (fg != string.Empty)
                        {
                            foreground = ushort.Parse(fg);
                        }
                        Curses.attron(ColorPair.From(foreground, ushort.MaxValue).Attribute);
                        fg   = string.Empty;
                        mode = DrawStringMode.Normal;
                    }
                    else
                    {
                        throw new Exception("Malformed color string");
                    }
                    break;

                case DrawStringMode.Background:
                    if (char.IsNumber(c))
                    {
                        bg += c;
                    }
                    else if (c == ' ')
                    {
                        Curses.attron(ColorPair.From(ushort.Parse(fg), ushort.Parse(bg)).Attribute);
                        fg   = string.Empty;
                        bg   = string.Empty;
                        mode = DrawStringMode.Normal;
                    }
                    else
                    {
                        throw new Exception("Malformed color string");
                    }
                    break;
                }
            }
            return(n);
        }