Esempio n. 1
0
 /**
  * Write a specific Python prompt into the given position. The position is nearly always the end
  * of the document.
  *
  * @param pos where to insert the prompt
  * @param prompt String with the prompt to insert
  */
 public void insertPrompt(final int pos, final String prompt) {
   try {
     super.insertString(pos, prompt, pythonPromptAttr);
   } catch (final Exception ex) {
     ex.printStackTrace();
   }
 }
Esempio n. 2
0
  /**
   * Insert a single character into the document. If the character is contained within the
   * delimiters the previous word, supposed to be complete then, is checked against the ones to be
   * syntax highlighted by checkText()
   *
   * @param offs location within the document where to insert the character
   * @param str the character to insert
   */
  public void insertChar(final int offs, final String str) {
    if (offs < 0) {
      return;
    }

    try {
      super.insertString(offs, str, normal);
    } catch (final Exception ex) {
      ex.printStackTrace();
    }
  }
Esempio n. 3
0
  /**
   * Insert a line in the text element containing the passed position skipping a number of character
   * from the beginning of the element. The function of the skipping of characters is to "jump" over
   * the prompt in the beginning of a line.
   *
   * @param pos the position from which to retrieve the element that contains it
   * @param skip how many characters are skipped from the beginning of the element when inserting
   *     the string
   * @param line the line to insert
   */
  public void setCurrentLine(final int pos, final int skip, final String line) {
    final Element element = getParagraphElement(pos);

    final int start = element.getStartOffset();
    final int end = element.getEndOffset();

    try {
      remove(start + skip, end - (start + skip + 1));
      super.insertString(start + skip, line, normal);
    } catch (final BadLocationException e) {
      System.out.println("Bad location!");
      e.printStackTrace();
    }
  }