public PatternEditor() { InitializeComponent(); AddHandler(Keyboard.KeyDownEvent, (System.Windows.Input.KeyEventHandler)HandleKeyDownEvent); // Add the keywords to the list. m_syntaxRichTextBox.Settings.Keywords.Add("function"); m_syntaxRichTextBox.Settings.Keywords.Add("if"); m_syntaxRichTextBox.Settings.Keywords.Add("then"); m_syntaxRichTextBox.Settings.Keywords.Add("else"); m_syntaxRichTextBox.Settings.Keywords.Add("elseif"); m_syntaxRichTextBox.Settings.Keywords.Add("end"); // Set the comment identifier. // For Lua this is two minus-signs after each other (--). // For C++ code we would set this property to "//". m_syntaxRichTextBox.Settings.Comment = "--"; // Set the colors that will be used. m_syntaxRichTextBox.Settings.KeywordColor = System.Drawing.Color.Blue; m_syntaxRichTextBox.Settings.CommentColor = System.Drawing.Color.Green; m_syntaxRichTextBox.Settings.StringColor = System.Drawing.Color.Gray; m_syntaxRichTextBox.Settings.IntegerColor = System.Drawing.Color.Red; // Let's not process strings and integers. m_syntaxRichTextBox.Settings.EnableStrings = true; m_syntaxRichTextBox.Settings.EnableIntegers = true; // Let's make the settings we just set valid by compiling // the keywords to a regular expression. m_syntaxRichTextBox.CompileKeywords(); m_syntaxRichTextBox.Font = new System.Drawing.Font("Courier New", 10); m_syntaxRichTextBox.Text = PSMC.Properties.Settings.Default.CustomModelPattern; m_syntaxRichTextBox.Invalidated += m_syntaxRichTextBox_TextChanged; m_syntaxRichTextBox.PreviewKeyDown += m_syntaxRichTextBox_TextChanged; this.wfh.Child = m_syntaxRichTextBox; m_syntaxRichTextBox.ProcessAllLines(); }
public void pintar(SyntaxRichTextBox syntaxRichTextBox1) { string[] pala = new string[] { "char", "float", "double", "short", "int", "long", "and", "as", "assert", "break", "class", "continue", "def", "del", "elif", "else", "except", "exec", "finally", "for", "from", "global", "if", "import", "in", "is", "lambda", "not", "or", "pass", "try", "while", "with", "yield", "print", "include", "std", "cout", "endl", "main", "void", "input", }; foreach (var item in pala) { syntaxRichTextBox1.Settings.Keywords.Add(item); } syntaxRichTextBox1.Settings.Comment = "//"; syntaxRichTextBox1.Settings.KeywordColor = Color.Blue; syntaxRichTextBox1.Settings.CommentColor = Color.Green; syntaxRichTextBox1.Settings.StringColor = Color.Orange; syntaxRichTextBox1.Settings.IntegerColor = Color.Red; syntaxRichTextBox1.Settings.EnableIntegers = false; syntaxRichTextBox1.Settings.EnableStrings = true; syntaxRichTextBox1.CompileKeywords(); syntaxRichTextBox1.ProcessAllLines(); }
private void addFile(string extension) { SaveFileDialog sfd = new SaveFileDialog(); sfd.InitialDirectory = global::Web_Builder.Form1.path; sfd.Filter = extension; if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK) { editingFiles.AddLast(sfd.FileName); File.Create(sfd.FileName); tabControl1.TabPages.Add(sfd.FileName.Substring(global::Web_Builder.Form1.path.Length)); rtf = new SyntaxRichTextBox(); rtf.Settings.Comment = "<!--"; rtf.Settings.CommentColor = Color.Green; rtf.Settings.IntegerColor = Color.Blue; rtf.Settings.StringColor = Color.Red; rtf.Settings.EnableComments = true; rtf.Settings.EnableIntegers = true; rtf.Settings.EnableStrings = true; rtf.Settings.Keywords.Add("DOCTYPE"); rtf.Settings.Keywords.Add("html"); rtf.Settings.Keywords.Add("title"); rtf.Settings.Keywords.Add("style"); rtf.Settings.Keywords.Add("script"); rtf.Settings.Keywords.Add("link"); rtf.Settings.Keywords.Add("body"); rtf.Settings.Keywords.Add("head"); rtf.Settings.Keywords.Add("center"); rtf.Settings.Keywords.Add("h1"); rtf.Settings.Keywords.Add("h2"); rtf.Settings.Keywords.Add("h3"); rtf.Settings.Keywords.Add("h4"); rtf.Settings.Keywords.Add("h5"); rtf.Settings.Keywords.Add("h6"); rtf.Settings.Keywords.Add("h7"); rtf.Settings.Keywords.Add("p"); rtf.Settings.Keywords.Add("form"); rtf.Settings.Keywords.Add("a"); rtf.Settings.KeywordColor = Color.Blue; rtf.ProcessAllLines(); rtf.Parent = tabControl1.TabPages[tabControl1.TabPages.Count - 1]; rtf.Dock = System.Windows.Forms.DockStyle.Fill; rtf.Font = new System.Drawing.Font("Lucida Console", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); rtf.Location = new System.Drawing.Point(3, 3); rtf.Name = "rtf"; rtf.Size = new System.Drawing.Size(666, 211); rtf.TabIndex = 0; rtf.KeyDown += new System.Windows.Forms.KeyEventHandler(this.richTextBox1_KeyDown); rtf.KeyUp += new System.Windows.Forms.KeyEventHandler(this.richTextBox1_KeyUp); rtf.TextChanged += new System.EventHandler(this.syntaxRichTextBox1_TextChanged); } }
public async static void addTab(TabControl parent, string filePath) { // if tab already openned the file if (editorMap.ContainsKey(filePath)) { return; } // create new tab int lastOffs = filePath.LastIndexOf("\\"); TabPage tabPage = new TabPage(filePath.Substring(lastOffs + 1)); tabPage.Tag = filePath; SyntaxRichTextBox editor = new SyntaxRichTextBox(); editor.Dock = DockStyle.Fill; editor.AcceptsTab = true; try { using (StreamReader sr = new StreamReader(filePath)) { String line = await sr.ReadToEndAsync(); editor.Text = line; } } catch (Exception e) { return; } // colorize the existing text editor.ProcessAllLines(); editorMap.Add(filePath, editor); tabPage.Controls.Add(editor); parent.TabPages.Add(tabPage); }
private void syntaxRichTextBox1_TextChanged(object sender, EventArgs e) { rtf.ProcessAllLines(); }