Skip to content

24bit fg/bg color is not implemented and I haz questions... #78

Description

@tig

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is neededup-for-grabsRelatively simple, and could use a volunteer to take on it

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions