private void SearchForSubtask() { int i = 0; bool found = false; foreach (char c in Editor_TextBox.Text) { if (c == ':') { string subtaskNum = JSON_Reader.GetSubtaskNum(i, Editor_TextBox.Text); if (subtaskNum.Replace(" ", "").Replace(",", "") == Find_TextBox.Text.Replace(" ", "").Replace(",", "")) { found = true; int startHighlighht = Editor_TextBox.Text.LastIndexOf("\"", i - 2); Editor_TextBox.SelectionStart = i; Editor_TextBox.Select(i, -(i - startHighlighht)); Editor_TextBox.ScrollToCaret(); HideFindButton(); searchSubtask = false; break; } } i++; } if (!found) { ConsoleHandler.append_Force_CanRepeat("That subtask was not found"); } }
private void LintPanel_MouseClick(object sender, MouseEventArgs e) { if (jsonError) { try { string error = JSON_Reader.GetJSON_Error(Editor_TextBox.Text); ConsoleHandler.force_append_Notice(error); //Line number string[] split = error.Split(','); string[] line = split[split.Length - 2].Split(' '); int lineNumber = Int32.Parse(line[line.Length - 1].Replace(".", "").Replace(",", "")); //Position in line string[] pos = split[split.Length - 1].Split(' '); int linePos = Int32.Parse(pos[pos.Length - 1].Replace(".", "").Replace(",", "")); //Scroll to the line above error int index = Editor_TextBox.GetFirstCharIndexFromLine(lineNumber - 3) + linePos; Editor_TextBox.Select(index, 1); Editor_TextBox.ScrollToCaret(); int numChars = (Editor_TextBox.GetFirstCharIndexFromLine(lineNumber - 1)) - (Editor_TextBox.GetFirstCharIndexFromLine(lineNumber - 2)); //highlight line with error index = Editor_TextBox.GetFirstCharIndexFromLine(lineNumber - 2) + linePos; Editor_TextBox.Focus(); Editor_TextBox.Select(index, numChars - 2); } catch { ConsoleHandler.append_CanRepeat("Something went wrong... Unable to find the bad json"); } } }