https://github.com/migueldeicaza/XtermSharp/blob/master/XtermSharp/Terminal.cs#L683
public int MatchColor (int r1, int g1, int b1)
{
throw new NotImplementedException ();
}
The code in InputHandler.cs looks right:
} else if (p == 38) {
// fg color 256
if (pars [i + 1] == 2) {
i += 2;
fg = terminal.MatchColor (
pars [i] & 0xff,
pars [i + 1] & 0xff,
pars [i + 2] & 0xff);
if (fg == -1)
fg = 0x1ff;
i += 2;
} else if (pars [i + 1] == 5) {
i += 2;
p = pars [i] & 0xff;
fg = p;
}
} else if (p == 48) {
But without MatchColor implemented, 24bit color is not implemented. The spec is:
ESC[ 38;2;⟨r⟩;⟨g⟩;⟨b⟩ m Select RGB foreground color
ESC[ 48;2;⟨r⟩;⟨g⟩;⟨b⟩ m Select RGB background color
I tried a naïve try:
public int MatchColor (int r1, int g1, int b1)
{
return (int)System.Drawing.Color.FromArgb(r1,g1, b1).ToArgb();
}
I obviously don't know what I'm doing because this always returns 255 even though in the debugger I see my values for r1, g1, and b1 being passed in.
What is the value of the the int fg and int bg supposed to hold?
I built this too to help:
public class XtermCharAttribute {
public int Attribute { get; set; }
public static XtermCharAttribute FromAttribute(int attribute) {
return new XtermCharAttribute(attribute);
}
public XtermCharAttribute(int attribute) {
Attribute = attribute;
}
public bool Bold => ((FLAGS)(Attribute >> 18)).HasFlag(FLAGS.BOLD);
public bool Italic => ((FLAGS)(Attribute >> 18)).HasFlag(FLAGS.ITALIC);
public bool Underline => ((FLAGS)(Attribute >> 18)).HasFlag(FLAGS.UNDERLINE);
public System.Drawing.Color FgColor => System.Drawing.Color.FromArgb((Attribute >> 9) & 0x1ff);
public System.Drawing.Color BgColor => System.Drawing.Color.FromArgb(Attribute & 0x1ff);
}
What am I doing wrong/missing?
https://github.com/migueldeicaza/XtermSharp/blob/master/XtermSharp/Terminal.cs#L683
The code in
InputHandler.cslooks right:But without
MatchColorimplemented, 24bit color is not implemented. The spec is:I tried a naïve try:
I obviously don't know what I'm doing because this always returns 255 even though in the debugger I see my values for
r1,g1, andb1being passed in.What is the value of the the
int fgandint bgsupposed to hold?I built this too to help:
What am I doing wrong/missing?