コード例 #1
0
        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;
            }
        }
コード例 #2
0
ファイル: RichText.cs プロジェクト: xamarin-forks/Praeclarum
        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(' ');
            }
        }
コード例 #3
0
        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;
            }
        }
コード例 #4
0
 public UnderlineColorAttribute(UnderlineColor u, Color color) => Handle = Libui.uiNewUnderlineColorAttribute(u, color.R, color.G, color.B, color.A);
コード例 #5
0
        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;
            }
        }
コード例 #6
0
        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;
            }
        }
コード例 #7
0
ファイル: LibuiEx.cs プロジェクト: masums/tcdfx
 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);
コード例 #8
0
ファイル: LibuiEx.cs プロジェクト: masums/tcdfx
 internal static IntPtr NewUnderlineColorAttribute(UnderlineColor u, double r, double g, double b, double a) => Libui.LoadFunction <Signatures.uiNewUnderlineColorAttribute>()(u, r, g, b, a);
コード例 #9
0
 public UnderlineFormat(UnderlineStyle style, UnderlineColor color)
 {
     m_style = style;
     m_color = color;
 }
コード例 #10
0
 public static IntPtr uiNewUnderlineColorAttribute(UnderlineColor u, double r, double g, double b, double a) => FunctionLoader.LoadLibuiFunc <uiNewUnderlineColorAttribute_t>("uiNewUnderlineColorAttribute")(u, r, g, b, a);
コード例 #11
0
 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);