public void OnNewItem(IPoderosaLogItem item) { //カテゴリ分けなどあるかもしれないが... String text = String.Format("[{0}] {1}", item.Category.Name, item.Text); int width = PoderosaLogDocument.DefaultWidth; //width文字ごとに切り取り。日本語文字があるケースは未サポート int offset = 0; while (offset < text.Length) { int next = RuntimeUtil.AdjustIntRange(offset + width, 0, text.Length); GLine line = new GLine(text.Substring(offset, next - offset).ToCharArray(), new GWord(TextDecoration.ClonedDefault(), 0, CharGroup.Hankaku)); line.EOLType = next < text.Length? EOLType.Continue : EOLType.CRLF; Append(line); offset = next; } PoderosaLogViewControl vc = _session.CurrentView; if (vc != null) { if (vc.InvokeRequired) { vc.Invoke(vc.UpdateDocumentDelegate); } else { vc.UpdateDocument(); } } }
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); } }