/// <summary> /// Set Error marker on code for Java. returns True on success False otherwise. /// </summary> public static bool SetJavaCodeError(FastColoredTextBox code, Range message, bool focus = false) { try { //split data in parts separated by ':' string data = message.Text; string[] part = data.Split(new char[] { ':' }); //usually row and col is on first two parts int row = int.Parse(part[0]) - 1; // <-- throws exception on failure //check if rest of the data is not empty string rest = string.Join(" ", part, 1, part.Length - 1); if (rest.Trim().Length == 0) { return(false); } //get line by row number string line = code.Lines[row].TrimEnd(); //get last of the message Place stop = new Place(line.Length, row); //we need to move start point where first non-space character found int col = 0; while (col < line.Length && line[col] == ' ') { ++col; } Place start = new Place(col, row); //get range from start to stop Range range = code.GetRange(start, stop); //show zigzag lines under the errors range.SetStyle(HighlightSyntax.LineErrorStyle); //focus current and exit if (focus) { code.ExpandBlock(row); code.Selection = range; code.DoRangeVisible(range, true); } // add hints if (Properties.Settings.Default.EditorShowHints) { Hint hdat = code.AddHint(range, data, focus, true, true); hdat.Tag = message; hdat.BorderColor = Color.LightBlue; hdat.BackColor = Color.AliceBlue; hdat.BackColor2 = Color.PowderBlue; } return(true); } catch { return(false); } }
/// <summary> /// Set Error marker on code for Java. returns True on success False otherwise. /// </summary> public static bool SetJavaCodeError(FastColoredTextBox code, Range message, bool focus = false) { try { //split data in parts separated by ':' string data = message.Text; string[] part = data.Split(new char[] { ':' }); //usually row and col is on first two parts int row = int.Parse(part[0]) - 1; // <-- throws exception on failure //check if rest of the data is not empty string rest = string.Join(" ", part, 1, part.Length - 1); if (rest.Trim().Length == 0) return false; //get line by row number string line = code.Lines[row].TrimEnd(); //get last of the message Place stop = new Place(line.Length, row); //we need to move start point where first non-space character found int col = 0; while (col < line.Length && line[col] == ' ') ++col; Place start = new Place(col, row); //get range from start to stop Range range = code.GetRange(start, stop); //show zigzag lines under the errors range.SetStyle(HighlightSyntax.LineErrorStyle); //focus current and exit if (focus) { code.ExpandBlock(row); code.Selection = range; code.DoRangeVisible(range, true); } // add hints if (Properties.Settings.Default.EditorShowHints) { Hint hdat = code.AddHint(range, data, focus, true, true); hdat.Tag = message; hdat.BorderColor = Color.LightBlue; hdat.BackColor = Color.AliceBlue; hdat.BackColor2 = Color.PowderBlue; } return true; } catch { return false; } }
/// <summary> /// Set Error marker on code for C/C++. returns True on success False otherwise. /// </summary> public static bool SetCPPCodeError(FastColoredTextBox code, Range message, bool focus = false) { try { //split data in parts separated by ':' string data = message.Text; string[] part = data.Split(new char[] { ':' }); //usually row and col is on first two parts int row, col; row = int.Parse(part[0]) - 1; // <-- throws exception on failure col = int.Parse(part[1]) - 1; // <-- throws exception on failure //get the type of message : there can be one and only one of these types bool error = Regex.IsMatch(data, " error:.*"); //check for error data type bool warn = Regex.IsMatch(data, " warning:.*"); //check for warning data type bool note = Regex.IsMatch(data, " note:.*"); //check for note data type if (!(error || warn || note)) { return(false); //for c++ do not proceed if not valid type } //get line by row number string line = code.Lines[row]; //get start the message Place start = new Place(col, row); //we need to cover the next word after start while (col < line.Length && char.IsLetterOrDigit(line[col])) { ++col; } //if no word of number is selected select all non-space chars instead if (start.iChar == col) { while (col < line.Length && ' ' != line[col]) { ++col; } } //now we found our stop position Place stop = new Place(col, row); //get range from start to stop Range range = code.GetRange(start, stop); //show zigzag lines under the errors if (error) { range.SetStyle(HighlightSyntax.LineErrorStyle); } else if (warn) { range.SetStyle(HighlightSyntax.LineWarningStyle); } else if (note) { range.SetStyle(HighlightSyntax.LineNoteStyle); } //focus current and exit if (focus && error) { code.ExpandBlock(row); code.Selection = range; code.DoRangeVisible(range, true); } // add hints if (Properties.Settings.Default.EditorShowHints && error) { Hint hdat = code.AddHint(range, data, focus, true, true); hdat.Tag = message; hdat.BackColor = Color.AliceBlue; hdat.BackColor2 = Color.LightSkyBlue; } return(true); } catch { return(false); } }
/// <summary> /// Set Error marker on code for C/C++. returns True on success False otherwise. /// </summary> public static bool SetCPPCodeError(FastColoredTextBox code, Range message, bool focus = false) { try { //split data in parts separated by ':' string data = message.Text; string[] part = data.Split(new char[] { ':' }); //usually row and col is on first two parts int row, col; row = int.Parse(part[0]) - 1; // <-- throws exception on failure col = int.Parse(part[1]) - 1; // <-- throws exception on failure //get the type of message : there can be one and only one of these types bool error = Regex.IsMatch(data, " error:.*"); //check for error data type bool warn = Regex.IsMatch(data, " warning:.*"); //check for warning data type bool note = Regex.IsMatch(data, " note:.*"); //check for note data type if (!(error || warn || note)) return false; //for c++ do not proceed if not valid type //get line by row number string line = code.Lines[row]; //get start the message Place start = new Place(col, row); //we need to cover the next word after start while (col < line.Length && char.IsLetterOrDigit(line[col])) ++col; //if no word of number is selected select all non-space chars instead if (start.iChar == col) { while (col < line.Length && ' ' != line[col]) ++col; } //now we found our stop position Place stop = new Place(col, row); //get range from start to stop Range range = code.GetRange(start, stop); //show zigzag lines under the errors if (error) range.SetStyle(HighlightSyntax.LineErrorStyle); else if (warn) range.SetStyle(HighlightSyntax.LineWarningStyle); else if (note) range.SetStyle(HighlightSyntax.LineNoteStyle); //focus current and exit if (focus && error) { code.ExpandBlock(row); code.Selection = range; code.DoRangeVisible(range, true); } // add hints if (Properties.Settings.Default.EditorShowHints && error) { Hint hdat = code.AddHint(range, data, focus, true, true); hdat.Tag = message; hdat.BackColor = Color.AliceBlue; hdat.BackColor2 = Color.LightSkyBlue; } return true; } catch { return false; } }