private void HighlightTokens() { this.SelectionStart = 0; this.SelectionLength = this.Text.Length; this.SelectionUnderlineColor = UnderlineColor.None; this.SelectionUnderlineStyle = UnderlineStyle.None; LexicalAnalyzer lexer = new LexicalAnalyzer(this.Text); TokenType lastToken = TokenType.Any; for (TokenType tokenType = lexer.MoveNext(); tokenType != TokenType.EndOfFile; tokenType = lexer.MoveNext()) { this.SelectionStart = lexer.CurrentMatch.Index; this.SelectionLength = lexer.CurrentMatch.Length; switch (tokenType) { case TokenType.And: case TokenType.Or: case TokenType.Not: this.SelectionColor = Color.Blue; break; case TokenType.Identity: case TokenType.Role: this.SelectionColor = Color.Navy; break; case TokenType.Word: case TokenType.QuotedString: if (lastToken == TokenType.Identity || lastToken == TokenType.Role) { this.SelectionColor = Color.Navy; } else { this.SelectionColor = Color.Black; } break; default: this.SelectionColor = Color.Black; break; } lastToken = tokenType; } }
public void AppendRtf(StringBuilder r, Dictionary <int, int> colorTable, Dictionary <string, int> fontTable) { var a = false; if (FontName != null && FontName.Length > 0) { var ci = fontTable[FontName]; r.AppendFormat(@"\f{0}", ci); a = true; } if (FontSize > 1) { r.AppendFormat(@"\fs{0}", (int)(2 * FontSize + 0.5f)); a = true; } if (ForegroundColor != null) { var ci = colorTable[ForegroundColor.ToArgb()]; r.AppendFormat(@"\cf{0}", ci); a = true; } if (BackgroundColor != null) { var ci = colorTable[BackgroundColor.ToArgb()]; r.AppendFormat(@"\highlight{0}", ci); a = true; } if (UnderlineStyle != UnderlineStyle.None) { var ci = colorTable[UnderlineColor.ToArgb()]; r.AppendFormat(@"\ulc{0}\ulwave", ci); a = true; } if (!string.IsNullOrEmpty(Link)) { //r.AppendFormat (@"{{{{\field{{\*\fldinst{{HYPERLINK ""{0}"" }}}}{{\fldrslt{{\ul ", Link.Replace ('\"', ' ')); r.Append(@"\ul"); a = true; } if (a) { r.Append(' '); } }
private void ParseText() { try { parsed = true; parser.Parse(this.Text); parseStatus = Resources.ParseSucceededMessageBox; } catch (SyntaxException ex) { parsed = false; parseStatus = string.Format(Resources.Culture, Resources.ParseFailedMessage, ex.Message); int position = ex.Index; if (position < this.Text.Length - 1) { position++; } this.SelectionStart = position; this.SelectionLength = this.Text.Length == 0 ? 0 : this.Text.Length - position - 1; this.SelectionUnderlineStyle = UnderlineStyle.Wave; this.SelectionUnderlineColor = UnderlineColor.Red; } }
public UnderlineColorAttribute(UnderlineColor u, Color color) => Handle = Libui.uiNewUnderlineColorAttribute(u, color.R, color.G, color.B, color.A);
private void ParseText() { try { parsed = true; parser.Parse(this.Text); parseStatus = Resources.ParseSucceededMessageBox; } catch (SyntaxException ex) { parsed = false; parseStatus = string.Format(CultureInfo.CurrentCulture, Resources.ParseFailedMessage, ex.Message); int position = ex.Index; if (position < this.Text.Length - 1) { position++; } this.SelectionStart = position; this.SelectionLength = this.Text.Length == 0 ? 0 : this.Text.Length - position - 1; this.SelectionUnderlineStyle = UnderlineStyle.Wave; this.SelectionUnderlineColor = UnderlineColor.Red; } }
internal static void AttributeGetType(IntPtr a, out UnderlineColor u, out double r, out double g, out double b, out double alpha) => Libui.LoadFunction <Signatures.uiAttributeUnderlineColor>()(a, out u, out r, out g, out b, out alpha);
internal static IntPtr NewUnderlineColorAttribute(UnderlineColor u, double r, double g, double b, double a) => Libui.LoadFunction <Signatures.uiNewUnderlineColorAttribute>()(u, r, g, b, a);
public UnderlineFormat(UnderlineStyle style, UnderlineColor color) { m_style = style; m_color = color; }
public static IntPtr uiNewUnderlineColorAttribute(UnderlineColor u, double r, double g, double b, double a) => FunctionLoader.LoadLibuiFunc <uiNewUnderlineColorAttribute_t>("uiNewUnderlineColorAttribute")(u, r, g, b, a);
public static void uiAttributeUnderlineColor(IntPtr a, out UnderlineColor u, out double r, out double g, out double b, out double alpha) => FunctionLoader.LoadLibuiFunc <uiAttributeUnderlineColor_t>("uiAttributeUnderlineColor")(a, out u, out r, out g, out b, out alpha);