コード例 #1
0
ファイル: Curses.cs プロジェクト: txdv/LibuvSharp.Terminal
			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);
        }