[autocomplete] 90/143: More minor parameterized completion updates.
Benjamin Mesing
ben at alioth.debian.org
Sat Oct 19 12:53:23 UTC 2013
This is an automated email from the git hooks/post-receive script.
ben pushed a commit to branch master
in repository autocomplete.
commit d6e31e03331993751fbcfb2a1d03589fa7b2876a
Author: bobbylight <robert at fifesoft.com>
Date: Tue Jun 19 03:35:30 2012 +0000
More minor parameterized completion updates.
---
.../ParameterizedCompletionContext.java | 69 +++++++++++++++---
.../ParameterizedCompletionDescriptionToolTip.java | 75 --------------------
2 files changed, 61 insertions(+), 83 deletions(-)
diff --git a/src/org/fife/ui/autocomplete/ParameterizedCompletionContext.java b/src/org/fife/ui/autocomplete/ParameterizedCompletionContext.java
index 49ecdfc..62e2a5e 100644
--- a/src/org/fife/ui/autocomplete/ParameterizedCompletionContext.java
+++ b/src/org/fife/ui/autocomplete/ParameterizedCompletionContext.java
@@ -116,6 +116,11 @@ class ParameterizedCompletionContext {
private Position defaultEndOffs;
/**
+ * The currently "selected" parameter in the displayed text.
+ */
+ private int lastSelectedParam;
+
+ /**
* A small popup window giving likely choices for parameterized completions.
*/
private ParameterizedCompletionChoicesWindow paramChoicesWindow;
@@ -170,8 +175,6 @@ class ParameterizedCompletionContext {
tip = new ParameterizedCompletionDescriptionToolTip(parentWindow,
this, ac, pc);
- paramChoicesWindow = createParamChoicesWindow();
-
}
@@ -477,7 +480,7 @@ class ParameterizedCompletionContext {
// "+1" is a workaround for Java Highlight issues.
tc.setSelectionStart(currentNext.getStartOffset()+1);
tc.setSelectionEnd(currentNext.getEndOffset());
- tip.updateText(pos);
+ updateToolTipText(pos);
}
@@ -502,7 +505,6 @@ class ParameterizedCompletionContext {
Highlight currentPrev = null;
int pos = 0;
List highlights = getParameterHighlights();
- int lastSelectedParam = tip.getLastSelectedParam();
for (int i=0; i<highlights.size(); i++) {
Highlight h = (Highlight)highlights.get(i);
@@ -524,13 +526,13 @@ class ParameterizedCompletionContext {
// "+1" is a workaround for Java Highlight issues.
tc.setSelectionStart(currentPrev.getStartOffset()+1);
tc.setSelectionEnd(currentPrev.getEndOffset());
- tip.updateText(pos);
+ updateToolTipText(pos);
}
else if (currentPrev!=null && dot>currentPrev.getStartOffset()) {
// "+1" is a workaround for Java Highlight issues.
tc.setSelectionStart(currentPrev.getStartOffset()+1);
tc.setSelectionEnd(currentPrev.getEndOffset());
- tip.updateText(pos);
+ updateToolTipText(pos);
}
else {
tc.setCaretPosition(maxPos.getOffset());
@@ -611,7 +613,6 @@ class ParameterizedCompletionContext {
}
// Toggles visibility, if necessary.
- int lastSelectedParam = tip.getLastSelectedParam();
paramChoicesWindow.setParameter(lastSelectedParam, paramPrefix);
}
@@ -695,6 +696,8 @@ class ParameterizedCompletionContext {
if (visible) {
+ lastSelectedParam = -1;
+
try {
int dot = tc.getCaretPosition();
Rectangle r = tc.modelToView(dot);
@@ -713,6 +716,7 @@ class ParameterizedCompletionContext {
if (paramChoicesWindow==null) {
paramChoicesWindow = createParamChoicesWindow();
}
+ lastSelectedParam = getCurrentParameterIndex();
prepareParamChoicesWindow();
}
@@ -780,6 +784,55 @@ class ParameterizedCompletionContext {
/**
+ * Updates the text in the tool tip to have the current parameter
+ * displayed in bold. The "current parameter" is determined from the
+ * current caret position.
+ *
+ * @return The "prefix" of text in the caret's parameter before the caret.
+ */
+ private String updateToolTipText() {
+
+ JTextComponent tc = ac.getTextComponent();
+ int dot = tc.getSelectionStart();
+ int mark = tc.getSelectionEnd();
+ int index = -1;
+ String paramPrefix = null;
+
+ List paramHighlights = getParameterHighlights();
+ for (int i=0; i<paramHighlights.size(); i++) {
+ Highlight h = (Highlight)paramHighlights.get(i);
+ // "+1" because of param hack - see OutlineHighlightPainter
+ int start = h.getStartOffset()+1;
+ if (dot>=start && dot<=h.getEndOffset()) {
+ try {
+ // All text selected => offer all suggestions, otherwise
+ // use prefix before selection
+ if (dot!=start || mark!=h.getEndOffset()) {
+ paramPrefix = tc.getText(start, dot-start);
+ }
+ } catch (BadLocationException ble) {
+ ble.printStackTrace();
+ }
+ index = i;
+ break;
+ }
+ }
+
+ updateToolTipText(index);
+ return paramPrefix;
+
+ }
+
+
+ private void updateToolTipText(int selectedParam) {
+ if (selectedParam!=lastSelectedParam) {
+ tip.updateText(selectedParam);
+ this.lastSelectedParam = selectedParam;
+ }
+ }
+
+
+ /**
* Updates the <code>LookAndFeel</code> of all popup windows this context
* manages.
*/
@@ -937,7 +990,7 @@ class ParameterizedCompletionContext {
setVisible(false, false);
return;
}
- paramPrefix = tip.updateText();
+ paramPrefix = updateToolTipText();
if (tip.isVisible()) {
prepareParamChoicesWindow();
}
diff --git a/src/org/fife/ui/autocomplete/ParameterizedCompletionDescriptionToolTip.java b/src/org/fife/ui/autocomplete/ParameterizedCompletionDescriptionToolTip.java
index 8d09c17..cfecaf0 100644
--- a/src/org/fife/ui/autocomplete/ParameterizedCompletionDescriptionToolTip.java
+++ b/src/org/fife/ui/autocomplete/ParameterizedCompletionDescriptionToolTip.java
@@ -12,15 +12,11 @@ package org.fife.ui.autocomplete;
import java.awt.BorderLayout;
import java.awt.Rectangle;
import java.awt.Window;
-import java.util.List;
import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JWindow;
import javax.swing.SwingUtilities;
-import javax.swing.text.BadLocationException;
-import javax.swing.text.JTextComponent;
-import javax.swing.text.Highlighter.Highlight;
import org.fife.ui.rsyntaxtextarea.PopupWindowDecorator;
import org.fife.ui.rsyntaxtextarea.RSyntaxUtilities;
@@ -36,21 +32,11 @@ import org.fife.ui.rsyntaxtextarea.RSyntaxUtilities;
class ParameterizedCompletionDescriptionToolTip {
/**
- * The parent context.
- */
- private ParameterizedCompletionContext context;
-
- /**
* The actual tool tip.
*/
private JWindow tooltip;
/**
- * The parent AutoCompletion instance.
- */
- private AutoCompletion ac;
-
- /**
* The label that holds the description.
*/
private JLabel descLabel;
@@ -60,11 +46,6 @@ class ParameterizedCompletionDescriptionToolTip {
*/
private ParameterizedCompletion pc;
- /**
- * The currently "selected" parameter in the displayed text.
- */
- private int lastSelectedParam;
-
/**
* Constructor.
@@ -79,8 +60,6 @@ class ParameterizedCompletionDescriptionToolTip {
tooltip = new JWindow(owner);
- this.context = context;
- this.ac = ac;
this.pc = pc;
descLabel = new JLabel();
@@ -105,7 +84,6 @@ class ParameterizedCompletionDescriptionToolTip {
decorator.decorate(tooltip);
}
- lastSelectedParam = -1;
updateText(0);
tooltip.setFocusableWindowState(false);
@@ -113,11 +91,6 @@ class ParameterizedCompletionDescriptionToolTip {
}
- public int getLastSelectedParam() {
- return lastSelectedParam;
- }
-
-
/**
* Returns whether this tool tip is visible.
*
@@ -178,47 +151,6 @@ class ParameterizedCompletionDescriptionToolTip {
/**
* Updates the text in the tool tip to have the current parameter
- * displayed in bold. The "current parameter" is determined from the
- * current caret position.
- *
- * @return The "prefix" of text in the caret's parameter before the caret.
- */
- public String updateText() {
-
- JTextComponent tc = ac.getTextComponent();
- int dot = tc.getSelectionStart();
- int mark = tc.getSelectionEnd();
- int index = -1;
- String paramPrefix = null;
-
- List paramHighlights = context.getParameterHighlights();
- for (int i=0; i<paramHighlights.size(); i++) {
- Highlight h = (Highlight)paramHighlights.get(i);
- // "+1" because of param hack - see OutlineHighlightPainter
- int start = h.getStartOffset()+1;
- if (dot>=start && dot<=h.getEndOffset()) {
- try {
- // All text selected => offer all suggestions, otherwise
- // use prefix before selection
- if (dot!=start || mark!=h.getEndOffset()) {
- paramPrefix = tc.getText(start, dot-start);
- }
- } catch (BadLocationException ble) {
- ble.printStackTrace();
- }
- index = i;
- break;
- }
- }
-
- updateText(index);
- return paramPrefix;
-
- }
-
-
- /**
- * Updates the text in the tool tip to have the current parameter
* displayed in bold.
*
* @param selectedParam The index of the selected parameter.
@@ -226,13 +158,6 @@ class ParameterizedCompletionDescriptionToolTip {
*/
public boolean updateText(int selectedParam) {
- // Don't redo everything if they're just using the arrow keys to move
- // through each char of a single parameter, for example.
- if (selectedParam==lastSelectedParam) {
- return false;
- }
- lastSelectedParam = selectedParam;
-
StringBuffer sb = new StringBuffer("<html>");
int paramCount = pc.getParamCount();
for (int i=0; i<paramCount; i++) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/autocomplete.git
More information about the pkg-java-commits
mailing list