diff --git a/pdex/src/processing/mode/experimental/TextArea.java b/pdex/src/processing/mode/experimental/TextArea.java index 87198bf6e..4b3b247d9 100644 --- a/pdex/src/processing/mode/experimental/TextArea.java +++ b/pdex/src/processing/mode/experimental/TextArea.java @@ -43,7 +43,7 @@ import processing.app.syntax.JEditTextArea; import processing.app.syntax.TextAreaDefaults; /** * Customized text area. Adds support for line background colors. - * + * * @author Martin Leopold */ public class TextArea extends JEditTextArea { @@ -119,22 +119,22 @@ public class TextArea extends JEditTextArea { // TweakMode code - prevCompListeners = painter - .getComponentListeners(); - prevMouseListeners = painter.getMouseListeners(); - prevMMotionListeners = painter - .getMouseMotionListeners(); - prevKeyListeners = editor.getKeyListeners(); + prevCompListeners = painter + .getComponentListeners(); + prevMouseListeners = painter.getMouseListeners(); + prevMMotionListeners = painter + .getMouseMotionListeners(); + prevKeyListeners = editor.getKeyListeners(); - interactiveMode = false; - addPrevListeners(); + interactiveMode = false; + addPrevListeners(); } /** * Sets ErrorCheckerService and loads theme for TextArea(XQMode) - * + * * @param ecs * @param mode */ @@ -149,7 +149,7 @@ public class TextArea extends JEditTextArea { * Code completion begins from here. */ public void processKeyEvent(KeyEvent evt) { - if(Base.isMacOS() && evt.isControlDown()) System.out.println("Ctrl down: " + evt); + //if(Base.isMacOS() && evt.isControlDown()) System.out.println("Ctrl down: " + evt); if(evt.getKeyCode() == KeyEvent.VK_ESCAPE){ if(suggestion != null){ if(suggestion.isVisible()){ @@ -164,7 +164,7 @@ public class TextArea extends JEditTextArea { if (suggestion != null) { if (suggestion.isVisible()) { if (suggestion.insertSelection(CompletionPanel.KEYBOARD_COMPLETION)) { - //hideSuggestion(); // Kill it! + //hideSuggestion(); // Kill it! evt.consume(); // Still try to show suggestions after inserting if it's // the case of overloaded methods. See #2755 @@ -175,7 +175,7 @@ public class TextArea extends JEditTextArea { } } } - + if (evt.getID() == KeyEvent.KEY_PRESSED) { switch (evt.getKeyCode()) { case KeyEvent.VK_DOWN: @@ -211,20 +211,20 @@ public class TextArea extends JEditTextArea { super.processKeyEvent(evt); if (editor.hasJavaTabs) return; // code completion disabled if java tabs - + if (evt.getID() == KeyEvent.KEY_TYPED) { char keyChar = evt.getKeyChar(); - if (keyChar == KeyEvent.VK_ENTER || + if (keyChar == KeyEvent.VK_ENTER || keyChar == KeyEvent.VK_ESCAPE || keyChar == KeyEvent.VK_TAB || keyChar == KeyEvent.CHAR_UNDEFINED) { return; } else if (keyChar == ')') { - hideSuggestion(); // See #2741 + hideSuggestion(); // See #2741 return; } - + final KeyEvent evt2 = evt; if (keyChar == ' ') { if (!Base.isMacOS() && ExperimentalMode.ccTriggerEnabled && @@ -286,10 +286,10 @@ public class TextArea extends JEditTextArea { }; worker.execute(); } - + /** * Retrieves the word on which the mouse pointer is present - * @param evt - the MouseEvent which triggered this method + * @param evt - the MouseEvent which triggered this method * @return */ private String fetchPhrase(MouseEvent evt) { @@ -352,16 +352,16 @@ public class TextArea extends JEditTextArea { return word.trim(); } } - + /** * Retrieves the current word typed just before the caret. * Then triggers code completion for that word. - * - * @param evt - the KeyEvent which triggered this method + * + * @param evt - the KeyEvent which triggered this method * @return */ public String fetchPhrase(KeyEvent evt) { - + int off = getCaretPosition(); log2("off " + off); if (off < 0) @@ -380,9 +380,9 @@ public class TextArea extends JEditTextArea { hideSuggestion(); return null; //TODO: Does this check cause problems? Verify. } - + log2(" x char: " + s.charAt(x)); - + if (!(Character.isLetterOrDigit(s.charAt(x)) || s.charAt(x) == '_' || s.charAt(x) == '(' || s.charAt(x) == '.')) { //log("Char before caret isn't a letter/digit/_(. so no predictions"); @@ -398,8 +398,8 @@ public class TextArea extends JEditTextArea { hideSuggestion(); return null; } - - //int xLS = off - getLineStartNonWhiteSpaceOffset(line); + + //int xLS = off - getLineStartNonWhiteSpaceOffset(line); String word = (x < s.length() ? s.charAt(x) : "") + ""; if (s.trim().length() == 1) { @@ -409,7 +409,7 @@ public class TextArea extends JEditTextArea { word = word.trim(); if (word.endsWith(".")) word = word.substring(0, word.length() - 1); - + errorCheckerService.getASTGenerator().preparePredictions(word, line + errorCheckerService.mainClassOffset,0); return word; @@ -483,7 +483,7 @@ public class TextArea extends JEditTextArea { /** * Retrieve the total width of the gutter area. - * + * * @return gutter width in pixels */ protected int getGutterWidth() { @@ -503,7 +503,7 @@ public class TextArea extends JEditTextArea { /** * Retrieve the width of margins applied to the left and right of the gutter * text. - * + * * @return margins in pixels */ protected int getGutterMargins() { @@ -515,7 +515,7 @@ public class TextArea extends JEditTextArea { /** * Set the gutter text of a specific line. - * + * * @param lineIdx * the line index (0-based) * @param text @@ -528,7 +528,7 @@ public class TextArea extends JEditTextArea { /** * Set the gutter text and color of a specific line. - * + * * @param lineIdx * the line index (0-based) * @param text @@ -543,7 +543,7 @@ public class TextArea extends JEditTextArea { /** * Clear the gutter text of a specific line. - * + * * @param lineIdx * the line index (0-based) */ @@ -564,7 +564,7 @@ public class TextArea extends JEditTextArea { /** * Retrieve the gutter text of a specific line. - * + * * @param lineIdx * the line index (0-based) * @return the gutter text @@ -575,7 +575,7 @@ public class TextArea extends JEditTextArea { /** * Retrieve the gutter text color for a specific line. - * + * * @param lineIdx * the line index * @return the gutter text color @@ -586,7 +586,7 @@ public class TextArea extends JEditTextArea { /** * Set the background color of a line. - * + * * @param lineIdx * 0-based line number * @param col @@ -599,7 +599,7 @@ public class TextArea extends JEditTextArea { /** * Clear the background color of a line. - * + * * @param lineIdx * 0-based line number */ @@ -620,7 +620,7 @@ public class TextArea extends JEditTextArea { /** * Get a lines background color. - * + * * @param lineIdx * 0-based line number * @return the color or null if no color was set for the specified line @@ -632,7 +632,7 @@ public class TextArea extends JEditTextArea { /** * Convert a character offset to a horizontal pixel position inside the text * area. Overridden to take gutter width into account. - * + * * @param line * the 0-based line number * @param offset @@ -647,7 +647,7 @@ public class TextArea extends JEditTextArea { /** * Convert a horizontal pixel position to a character offset. Overridden to * take gutter width into account. - * + * * @param line * the 0-based line number * @param x @@ -689,7 +689,7 @@ public class TextArea extends JEditTextArea { } return; } - + if (me.getButton() == MouseEvent.BUTTON3) { if(!editor.hasJavaTabs){ // tooltips, etc disabled for java tabs fetchPhrase(me); @@ -786,7 +786,7 @@ public class TextArea extends JEditTextArea { }); }*/ - + // appears unused, removed when looking to change completion trigger [fry 140801] /* public void showSuggestionLater(final DefaultListModel defListModel, final String word) { @@ -801,8 +801,8 @@ public class TextArea extends JEditTextArea { */ /** - * Calculates location of caret and displays the suggestion popup at the location. - * + * Calculates location of caret and displays the suggestion popup at the location. + * * @param defListModel * @param subWord */ @@ -833,7 +833,7 @@ public class TextArea extends JEditTextArea { location,editor); // else // suggestion.updateList(defListModel, subWord, location, position); -// +// // suggestion.setVisible(true); requestFocusInWindow(); // SwingUtilities.invokeLater(new Runnable() { @@ -858,99 +858,99 @@ public class TextArea extends JEditTextArea { // TweakMode code // save input listeners to stop/start text edit - ComponentListener[] prevCompListeners; - MouseListener[] prevMouseListeners; - MouseMotionListener[] prevMMotionListeners; - KeyListener[] prevKeyListeners; + ComponentListener[] prevCompListeners; + MouseListener[] prevMouseListeners; + MouseMotionListener[] prevMMotionListeners; + KeyListener[] prevKeyListeners; - boolean interactiveMode; + boolean interactiveMode; - /* remove all standard interaction listeners */ - public void removeAllListeners() - { - ComponentListener[] componentListeners = painter - .getComponentListeners(); - MouseListener[] mouseListeners = painter.getMouseListeners(); - MouseMotionListener[] mouseMotionListeners = painter - .getMouseMotionListeners(); - KeyListener[] keyListeners = editor.getKeyListeners(); + /* remove all standard interaction listeners */ + public void removeAllListeners() + { + ComponentListener[] componentListeners = painter + .getComponentListeners(); + MouseListener[] mouseListeners = painter.getMouseListeners(); + MouseMotionListener[] mouseMotionListeners = painter + .getMouseMotionListeners(); + KeyListener[] keyListeners = editor.getKeyListeners(); - for (ComponentListener cl : componentListeners) - painter.removeComponentListener(cl); + for (ComponentListener cl : componentListeners) + painter.removeComponentListener(cl); - for (MouseListener ml : mouseListeners) - painter.removeMouseListener(ml); + for (MouseListener ml : mouseListeners) + painter.removeMouseListener(ml); - for (MouseMotionListener mml : mouseMotionListeners) - painter.removeMouseMotionListener(mml); + for (MouseMotionListener mml : mouseMotionListeners) + painter.removeMouseMotionListener(mml); - for (KeyListener kl : keyListeners) { - editor.removeKeyListener(kl); - } - } + for (KeyListener kl : keyListeners) { + editor.removeKeyListener(kl); + } + } - public void startInteractiveMode() - { - // ignore if we are already in interactiveMode - if (interactiveMode) - return; + public void startInteractiveMode() + { + // ignore if we are already in interactiveMode + if (interactiveMode) + return; - removeAllListeners(); + removeAllListeners(); - // add our private interaction listeners - customPainter.addMouseListener(customPainter); - customPainter.addMouseMotionListener(customPainter); - customPainter.startInterativeMode(); - customPainter.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); - this.editable = false; - this.caretBlinks = false; - this.setCaretVisible(false); - interactiveMode = true; - } + // add our private interaction listeners + customPainter.addMouseListener(customPainter); + customPainter.addMouseMotionListener(customPainter); + customPainter.startInterativeMode(); + customPainter.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); + this.editable = false; + this.caretBlinks = false; + this.setCaretVisible(false); + interactiveMode = true; + } - public void stopInteractiveMode() - { - // ignore if we are not in interactive mode - if (!interactiveMode) - return; + public void stopInteractiveMode() + { + // ignore if we are not in interactive mode + if (!interactiveMode) + return; - removeAllListeners(); - addPrevListeners(); + removeAllListeners(); + addPrevListeners(); - customPainter.stopInteractiveMode(); - customPainter.setCursor(new Cursor(Cursor.TEXT_CURSOR)); - this.editable = true; - this.caretBlinks = true; - this.setCaretVisible(true); + customPainter.stopInteractiveMode(); + customPainter.setCursor(new Cursor(Cursor.TEXT_CURSOR)); + this.editable = true; + this.caretBlinks = true; + this.setCaretVisible(true); - interactiveMode = false; - } + interactiveMode = false; + } - public int getHorizontalScroll() - { - return horizontal.getValue(); - } + public int getHorizontalScroll() + { + return horizontal.getValue(); + } - private void addPrevListeners() - { - // add the original text-edit listeners - for (ComponentListener cl : prevCompListeners) { - customPainter.addComponentListener(cl); - } - for (MouseListener ml : prevMouseListeners) { - customPainter.addMouseListener(ml); - } - for (MouseMotionListener mml : prevMMotionListeners) { - customPainter.addMouseMotionListener(mml); - } - for (KeyListener kl : prevKeyListeners) { - editor.addKeyListener(kl); - } - } + private void addPrevListeners() + { + // add the original text-edit listeners + for (ComponentListener cl : prevCompListeners) { + customPainter.addComponentListener(cl); + } + for (MouseListener ml : prevMouseListeners) { + customPainter.addMouseListener(ml); + } + for (MouseMotionListener mml : prevMMotionListeners) { + customPainter.addMouseMotionListener(mml); + } + for (KeyListener kl : prevKeyListeners) { + editor.addKeyListener(kl); + } + } - public void updateInterface(ArrayList handles[], ArrayList colorBoxes[]) - { - customPainter.updateInterface(handles, colorBoxes); - } + public void updateInterface(ArrayList handles[], ArrayList colorBoxes[]) + { + customPainter.updateInterface(handles, colorBoxes); + } }