private void redoToolStripMenuItem_Click(object sender, EventArgs e) { TextFeild.Redo(); }
private void selectAllToolStripMenuItem_Click(object sender, EventArgs e) { TextFeild.SelectAll(); }
private void pasteToolStripMenuItem_Click(object sender, EventArgs e) { TextFeild.Paste(); }
private void copyToolStripMenuItem_Click(object sender, EventArgs e) { TextFeild.Copy(); }
private void TextFeild_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Right || e.KeyCode == Keys.Left) { int length_pri = 0, index_pri = 0; Text = TextFeild.Text; indexatstart = index = TextFeild.SelectionStart; if (Text.Contains(Word) && Word != "") { index = 0; while (index_pri != -1) { length_pri = 0; index_pri = 0; length_pri = Word.Length; index_pri = Text.IndexOf(Word, index + length); if (index_pri != -1) { TextFeild.Select(index_pri, length_pri); TextFeild.SelectionBackColor = Color.White; } length = length_pri; index = index_pri; } } length = 0; string selectiontext = ""; if (e.KeyCode == Keys.Right) { indexatstart++; } else if (e.KeyCode == Keys.Left) { indexatstart--; } else if (e.KeyCode == Keys.Up) { index = TextFeild.SelectionStart = indexatstart; index--; if (index < Text.Length) { selectiontext = Text.Substring(index, 1); } while (selectiontext != "\n") { length++; index--; if (index >= 0) { selectiontext = Text.Substring(index, 1); } else { selectiontext = "\n"; } } length++; index--; if (index < Text.Length) { selectiontext = Text.Substring(index, 1); } while (selectiontext != "\n") { index--; if (index >= 0) { selectiontext = Text.Substring(index, 1); } else { selectiontext = "\n"; } } indexatstart = index + length; } else if (e.KeyCode == Keys.Down) { index = TextFeild.SelectionStart = indexatstart; index--; if (index < Text.Length) { selectiontext = Text.Substring(index, 1); } while (selectiontext != "\n") { length++; index--; if (index >= 0) { selectiontext = Text.Substring(index, 1); } else { selectiontext = "\n"; } } index++; if (index < Text.Length) { selectiontext = Text.Substring(index, 1); } while (selectiontext != "\n") { index++; if (index >= 0) { selectiontext = Text.Substring(index, 1); } else { selectiontext = "\n"; } } indexatstart = index + (length + 1); } length = 0; selectiontext = ""; index = TextFeild.SelectionStart = indexatstart; index--; if (index < Text.Length) { selectiontext = Text.Substring(index, 1); } while (selectiontext != " " && selectiontext != "\n") { length++; index--; if (index >= 0) { selectiontext = Text.Substring(index, 1); } else { selectiontext = "\n"; } } index = index + (length); index++; if (index < Text.Length) { selectiontext = Text.Substring(index, 1); } while (selectiontext != " " && selectiontext != "\n") { length++; index++; if (index < Text.Length) { selectiontext = Text.Substring(index, 1); } else { selectiontext = "\n"; } } if (e.KeyCode == Keys.Right) { indexatstart--; } else if (e.KeyCode == Keys.Left) { indexatstart++; } else if (e.KeyCode == Keys.Down) { indexatstart = indexatstart - (length + 1); } else if (e.KeyCode == Keys.Up) { indexatstart = indexatstart + (length + 1); } index = index - length; length_pri = 0; index_pri = 0; if ((index + length) <= Text.Length) { Word = Text.Substring(index, length); } if (Text.Contains(Word) && Word != "") { index = 0; while (index_pri != -1) { length_pri = 0; index_pri = 0; length_pri = Word.Length; index_pri = Text.IndexOf(Word, index + length); if (index_pri != -1) { string nxtchr = ""; if (index_pri + length_pri + 1 < Text.Length) { nxtchr = Text.Substring(index_pri + length_pri, 1); } else { nxtchr = " "; } TextFeild.Select(index_pri, length_pri); if ((nxtchr == " " || nxtchr == "\n") && Text.Substring(index_pri - 1, 1) == " ") { TextFeild.SelectionBackColor = Color.LightGray; } } length = length_pri; index = index_pri; } TextFeild.SelectionStart = indexatstart; TextFeild.SelectionLength = 0; } } else if (e.KeyCode != Keys.Control && e.KeyCode != Keys.Back) { int length_pri = 0, index_pri = 0; Text = TextFeild.Text; indexatstart = index = TextFeild.SelectionStart; if (Text.Contains(Word) && Word != "") { index = 0; while (index_pri != -1) { length_pri = 0; index_pri = 0; length_pri = Word.Length; index_pri = Text.IndexOf(Word, index + length); if (index_pri != -1) { TextFeild.Select(index_pri, length_pri); TextFeild.SelectionBackColor = Color.White; TextFeild.SelectionColor = Color.Black; } length = length_pri; index = index_pri; } } if (e.KeyCode == Keys.Space || e.KeyCode == Keys.Enter) { int nextindex = 0; string Syntaxwords = File.ReadAllText(Filename_Syntaxwords), iterator = "", Word = ""; index = 0; length = 0; while (nextindex < Syntaxwords.Length) { length = 0; if (index < Syntaxwords.Length) { iterator = Syntaxwords.Substring(index, 1); } while (iterator != "\n" && iterator != "\r") { length++; index++; if (index < Syntaxwords.Length) { iterator = Syntaxwords.Substring(index, 1); } else { iterator = "\n"; } } nextindex = index; index -= length; if (index < Syntaxwords.Length) { Word = Syntaxwords.Substring(index, length); } length_pri = 0; index_pri = 0; Text = TextFeild.Text; if (Text.Contains(Word) && Word != "") { index = 0; length = 0; while (index_pri != -1) { length_pri = 0; index_pri = 0; length_pri = Word.Length; index_pri = Text.IndexOf(Word, index + length); if (index_pri != -1) { string nxtchr = ""; if (index_pri + length_pri < Text.Length) { nxtchr = Text.Substring(index_pri + length_pri, 1); } else { nxtchr = " "; } TextFeild.Select(index_pri, length_pri); if ((nxtchr == " " || nxtchr == "\n") && Text.Substring(index_pri - 1, 1) == " ") { TextFeild.SelectionColor = Color.Blue; } } length = length_pri; index = index_pri; } } index = nextindex + 2; } } TextFeild.SelectionStart = indexatstart; TextFeild.SelectionLength = 0; } }
private void TextFeild_MouseClick(object sender, MouseEventArgs e) { int length_pri = 0, index_pri = 0; Text = TextFeild.Text; indexatstart = index = TextFeild.SelectionStart; if (Text.Contains(Word) && Word != "") { index = 0; while (index_pri != -1) { length_pri = 0; index_pri = 0; length_pri = Word.Length; index_pri = Text.IndexOf(Word, index + length); if (index_pri != -1) { TextFeild.Select(index_pri, length_pri); TextFeild.SelectionBackColor = Color.White; } length = length_pri; index = index_pri; } } length = 0; string selectiontext = ""; index = TextFeild.SelectionStart = indexatstart; index--; if (index < Text.Length) { selectiontext = Text.Substring(index, 1); } while (selectiontext != " " && selectiontext != "\n") { length++; index--; if (index >= 0) { selectiontext = Text.Substring(index, 1); } else { selectiontext = "\n"; } } index = index + (length); index++; if (index < Text.Length) { selectiontext = Text.Substring(index, 1); } while (selectiontext != " " && selectiontext != "\n") { length++; index++; if (index < Text.Length) { selectiontext = Text.Substring(index, 1); } else { selectiontext = "\n"; } } index = index - length; length_pri = 0; index_pri = 0; Word = Text.Substring(index, length); if (Text.Contains(Word) && Word != "") { index = 0; while (index_pri != -1) { length_pri = 0; index_pri = 0; length_pri = Word.Length; index_pri = Text.IndexOf(Word, index + length); if (index_pri != -1) { string nxtchr = ""; if (index_pri + length_pri + 1 < Text.Length) { nxtchr = Text.Substring(index_pri + length_pri, 1); } else { nxtchr = " "; } TextFeild.Select(index_pri, length_pri); if ((nxtchr == " " || nxtchr == "\n") && Text.Substring(index_pri - 1, 1) == " ") { TextFeild.SelectionBackColor = Color.LightGray; } } length = length_pri; index = index_pri; } TextFeild.SelectionStart = indexatstart; TextFeild.SelectionLength = 0; } }