/// <summary> /// Handles the key uo event of the editor. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void editor_KeyUp(object sender, KeyEventArgs e) { e.SuppressKeyPress = false; e.Handled = false; if (e.KeyData == Keys.Enter) { _parent.Help.displayHelp(); } String currentLine = ControlsUtils.getCurrentLine(_textEditor.Document); StringTokenizer stk = new StringTokenizer(currentLine, "|"); try { if (currentLine.Length == 0) { _parent.Help.displayHelp(); } else if (StringUtil.occurrences(currentLine, "|") >= 2 && stk.CountTokens() >= 1) { _parent.Help.displayHelpForLine(currentLine); } } catch { //thrown when currentLine is null and occurrences is called, nothing to do. } }
/// <summary> /// Updates help for the current line the user clicked on. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void editor_MouseClick(object sender, MouseEventArgs e) { String currentLine = ControlsUtils.getCurrentLine(_textEditor.Document); StringTokenizer stk = new StringTokenizer(currentLine, "|"); try { if (StringUtil.occurrences(currentLine, "|") >= 2 && stk.CountTokens() >= 1) { _parent.Help.displayHelpForLine(currentLine); } else { _parent.Help.displayHelp(); } } catch //catch (ArgumentException ex) //UNUSED Variable { //thrown when currentLine is null and occurrences is called _parent.Help.displayHelp(); } }
/// <summary> /// Displays help for a command which is the first token in the given line. /// </summary> /// <param name="lineFromEditor">a line of text form the swat editor.</param> public void displayHelpForLine(String lineFromEditor) { if (String.IsNullOrEmpty(lineFromEditor)) { displayHelp(); return; } //extract command from line and call displayHelp(commandname) StringTokenizer st = new StringTokenizer(lineFromEditor, "|"); displayHelp(st.NextToken()); }