public static void SetColor(ushort ccolor, Curses.Color color) { SetColor(ccolor, color.R, color.G, color.B); }
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); } }
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); } }
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)); }
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)); }
public CursesAttribute(int attribute) { Attribute = attribute; Curses.AttributeOn(Attribute); }
public void Dispose() { Curses.AttributeOff(Attribute); }
public static void GetPair(short index, out ushort foreground, out ushort background) { int r = Curses.pair_content(index, out foreground, out background); Ensure(r); }
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); }
public static void SetColor(ushort color, short r, short g, short b) { Curses.init_color(color, r, g, b); }
public static void Finish() { Curses.attron(ColorPair.From(-1, -1).Attribute); }
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); }