[ create a new paste ] login | about

Link: http://codepad.org/5kbNCQRB    [ raw code | fork ]

C++, pasted on May 18:
public string keywords = ("uses|var|array|of|BEGIN|FOR|For|to|do|Begin|end|END|IF|then");
        public string keywords2 = ("0|1|2|3|4|5|6|7|8|9");
        public void updatekeyword()
        {
            string UserAddKeyWord = txtGetText.Text;
            keywords = string.Concat(keywords, UserAddKeyWord);            
        }
        private void rtbPascal_TextChanged(object sender, EventArgs e)
        {
            highlight();

        }
        private void highlight()
        {
            updatekeyword();
            Regex rex1 = new Regex(keywords);
            int StartPoint = rtbPascal.SelectionStart;
            foreach (Match KeywordMatch in rex1.Matches(rtbPascal.Text))
            {
                rtbPascal.Select(KeywordMatch.Index, KeywordMatch.Length);
                rtbPascal.SelectionColor = Color.Blue;
                rtbPascal.SelectionStart = StartPoint;
                rtbPascal.SelectionColor = Color.Black;
            }
            Regex rex2 = new Regex(keywords2);
            foreach (Match KeywordMatch2 in rex2.Matches(rtbPascal.Text))
            {
                rtbPascal.Select(KeywordMatch2.Index, KeywordMatch2.Length);
                rtbPascal.SelectionColor = Color.Orange;
                rtbPascal.SelectionStart = StartPoint;
                rtbPascal.SelectionColor = Color.Black;
            }

        }


Create a new paste based on this one


Comments: