示例#1
0
        protected void ProcessSGR(string param)
        {
            string[] ps = param.Split(';');

            foreach (string cmd in ps)
            {
                TextDecoration dec  = (TextDecoration)_currentdecoration.Clone();
                int            code = ParseSGRCode(cmd);
                if (code >= 30 && code <= 37)
                {
                    //これだと色を変更したとき既に画面にあるものは連動しなくなるが、そこをちゃんとするのは困難である
                    dec.TextColor = _tag.GetCurrentRenderProfile().ESColorSet[code % 10];
                }
                else if (code >= 40 && code <= 47)
                {
                    Color c = _tag.GetCurrentRenderProfile().ESColorSet[code % 10];
                    dec.BackColor = DrawUtil.DarkColor(c);                     //背景色は暗めに
                }
                else
                {
                    switch (code)
                    {
                    case 0:
                        dec = TextDecoration.ClonedDefault();
                        break;

                    case 1:
                    case 5:
                        dec.Bold = true;
                        break;

                    case 4:
                        dec.Underline = true;
                        break;

                    case 7:
                        dec.Inverse();
                        break;

                    case 2:
                        dec = TextDecoration.ClonedDefault();                                 //不明だがSGR 2で終わっている例があった
                        break;

                    case 22:
                    case 25:
                    case 27:
                    case 28:
                        dec = TextDecoration.ClonedDefault();
                        break;

                    case 24:
                        dec.Underline = false;
                        break;

                    case 39:
                        dec.TextColorType = ColorType.DefaultText;
                        break;

                    case 49:
                        dec.BackColorType = ColorType.DefaultBack;
                        break;

                    case 10:
                    case 11:
                    case 12:
                        break;                                 //'konsole'というやつらしい。無視で問題なさそう

                    default:
                        throw new UnknownEscapeSequenceException(String.Format("unknown SGR command {0}", param));
                    }
                }

                _currentdecoration = dec;
                //_manipulator.SetDecoration(dec);
            }
        }