示例#1
0
			public static void SetColor(ushort ccolor, Curses.Color color)
			{
				SetColor(ccolor, color.R, color.G, color.B);
			}
示例#2
0
 public void Draw(int attribute, string str, int x, int y, int w, int h, out int endx, out int endy)
 {
     using (Curses.Attribute(attribute)) {
         Draw(str, x, y, w, h, out endx, out endy);
     }
 }
示例#3
0
 public void Draw(string str, int x, int y, int w, int h, out int endx, out int endy, params int[] attributes)
 {
     using (Curses.Attribute(attributes)) {
         Draw(str, x, y, w, h, out endx, out endy);
     }
 }
示例#4
0
 public void Fill(int attribute, char c, int x, int y, int w, int h, int startx, int starty)
 {
     Curses.Attribute(attribute, () => Fill(c, x, y, w, h, startx, starty));
 }
示例#5
0
 public void Fill(int attribute, string str, char ch, int x, int y, int w, int h)
 {
     Curses.Attribute(attribute, () => Fill(str, ch, x, y, w, h));
 }
示例#6
0
 public CursesAttribute(int attribute)
 {
     Attribute = attribute;
     Curses.AttributeOn(Attribute);
 }
示例#7
0
 public void Dispose()
 {
     Curses.AttributeOff(Attribute);
 }
示例#8
0
            public static void GetPair(short index, out ushort foreground, out ushort background)
            {
                int r = Curses.pair_content(index, out foreground, out background);

                Ensure(r);
            }
示例#9
0
 public static void GetColor(ushort color, out short r, out short g, out short b)
 {
     Curses.color_content(color, out r, out g, out b);
 }
示例#10
0
 public static void SetColor(ushort color, short r, short g, short b)
 {
     Curses.init_color(color, r, g, b);
 }
示例#11
0
 public static void Finish()
 {
     Curses.attron(ColorPair.From(-1, -1).Attribute);
 }
示例#12
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);
        }