public void SetSelectionStyles() { textArea.tv.RemoveStyleSet(ssSelection); ssSelection = new StyleSet(textArea.sr.pstyleSelection, 2); Literal styleName = new Literal(textArea.hasFocus() ? "selection.style" : "selection.style.no.focus"); StyleModification smSelection = StyleModification.FromOptions( pdoc.currentMode, styleName, pdoc.options, null); ssSelection.Set(1, smSelection); textArea.tv.AddStyleSet(ssSelection); textArea.tv.RemoveStyleSet(ssCaret); ssCaret = new StyleSet(textArea.sr, 2); StyleModification smCaret = new StyleModification(); Literal litDecoration = new Literal("Decoration"); Literal litCaret = new Literal("Caret"); IDecoration caret = (IDecoration)PrototypeRegistry.FromName(litDecoration, litCaret); Literal caretName = new Literal(textArea.hasFocus() ? "caret.color" : "caret.color.no.focus"); RGBColor caretColor = textArea.hasFocus() ? new RGBColor(0xff, 0, 0) : new RGBColor(0, 0, 0); Literal caretValue = pdoc.options.ModeValue(pdoc.currentMode, caretName); if (caretValue != null) { caretColor = new RGBColor(StyleModification.ColourFromLiteral(caretValue)); } caret.SetFore(caretColor); smCaret.AddDecorationFore(caret); ssCaret.Set(1, smCaret); textArea.tv.AddStyleSet(ssCaret); pdoc.pbuffer.DetachStyles(textArea.sr); pdoc.pbuffer.AttachStyles(textArea.sr, null, 0, false); }