| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,7 +16,7 @@ public void invalidate() { | |||
| 16 | 16 | } | |
| 17 | 17 | ||
| 18 | 18 | public int findMatchingBracket(final String text, final int pos) { | |
| 19 | - if (pos < 0 || pos > text.length()) | ||
| 19 | + if (pos < 0 || pos >= text.length()) | ||
| 20 | 20 | return -1; | |
| 21 | 21 | ||
| 22 | 22 | final char alpha = text.charAt(pos); | |
@@ -51,7 +51,7 @@ public int findMatchingBracket(final String text, final int pos) { | |||
| 51 | 51 | return -1; | |
| 52 | 52 | } | |
| 53 | 53 | ||
| 54 | - if (offsets == null) | ||
| 54 | + if (offsets == null || offsets.get(offsets.size()-1) >= text.length()) | ||
| 55 | 55 | parse(text); | |
| 56 | 56 | ||
| 57 | 57 | // find this bracket | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -755,6 +755,9 @@ public int xToOffset(int line, int x) { | |||
| 755 | 755 | // ", i = " + i + | |
| 756 | 756 | // ", length = " + length + | |
| 757 | 757 | // ", array len = " + segmentArray.length); | |
| 758 | + if (segmentOffset + offset + i >= segmentArray.length) { | ||
| 759 | + return segmentArray.length - segmentOffset - 1; | ||
| 760 | + } | ||
| 758 | 761 | char c = segmentArray[segmentOffset + offset + i]; | |
| 759 | 762 | int charWidth; | |
| 760 | 763 | if (c == '\t') { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -155,15 +155,10 @@ protected void done() { | |||
| 155 | 155 | /** Find out which error/warning the user has clicked and scroll to it */ | |
| 156 | 156 | private void scrollToMarkerAt(final int y) { | |
| 157 | 157 | try { | |
| 158 | - new SwingWorker() { | ||
| 159 | - protected Object doInBackground() throws Exception { | ||
| 160 | - LineMarker m = findClosestMarker(y); | ||
| 161 | - if (m != null) { | ||
| 162 | - editor.getErrorChecker().scrollToErrorLine(m.getProblem()); | ||
| 163 | - } | ||
| 164 | - return null; | ||
| 165 | - } | ||
| 166 | - }.execute(); | ||
| 158 | + LineMarker m = findClosestMarker(y); | ||
| 159 | + if (m != null) { | ||
| 160 | + editor.getErrorChecker().scrollToErrorLine(m.getProblem()); | ||
| 161 | + } | ||
| 167 | 162 | } catch (Exception ex) { | |
| 168 | 163 | ex.printStackTrace(); | |
| 169 | 164 | } | |
@@ -181,21 +176,16 @@ public JToolTip createToolTip() { | |||
| 181 | 176 | /** Show tooltip on hover. */ | |
| 182 | 177 | private void showMarkerHover(final int y) { | |
| 183 | 178 | try { | |
| 184 | - new SwingWorker() { | ||
| 185 | - protected Object doInBackground() throws Exception { | ||
| 186 | - LineMarker m = findClosestMarker(y); | ||
| 187 | - if (m != null) { | ||
| 188 | - Problem p = m.getProblem(); | ||
| 179 | + LineMarker m = findClosestMarker(y); | ||
| 180 | + if (m != null) { | ||
| 181 | + Problem p = m.getProblem(); | ||
| 189 | 182 | // String kind = p.isError() ? | |
| 190 | 183 | // Language.text("editor.status.error") : | |
| 191 | 184 | // Language.text("editor.status.warning"); | |
| 192 | 185 | // setToolTipText(kind + ": " + p.getMessage()); | |
| 193 | - editor.statusToolTip(MarkerColumn.this, p.getMessage(), p.isError()); | ||
| 194 | - setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); | ||
| 195 | - } | ||
| 196 | - return null; | ||
| 197 | - } | ||
| 198 | - }.execute(); | ||
| 186 | + editor.statusToolTip(MarkerColumn.this, p.getMessage(), p.isError()); | ||
| 187 | + setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); | ||
| 188 | + } | ||
| 199 | 189 | } catch (Exception ex) { | |
| 200 | 190 | ex.printStackTrace(); | |
| 201 | 191 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -26,6 +26,7 @@ | |||
| 26 | 26 | import java.awt.Color; | |
| 27 | 27 | import java.awt.Cursor; | |
| 28 | 28 | import java.awt.Font; | |
| 29 | + import java.awt.FontMetrics; | ||
| 29 | 30 | import java.awt.Graphics; | |
| 30 | 31 | import java.awt.Graphics2D; | |
| 31 | 32 | import java.awt.Point; | |
@@ -114,39 +115,6 @@ public void mousePressed(MouseEvent event) { | |||
| 114 | 115 | } | |
| 115 | 116 | }); | |
| 116 | 117 | ||
| 117 | - addMouseMotionListener(new MouseMotionAdapter() { | ||
| 118 | - @Override | ||
| 119 | - public void mouseMoved(final MouseEvent evt) { | ||
| 120 | - int line = textArea.yToLine(evt.getY()); | ||
| 121 | - int x = evt.getX(); | ||
| 122 | - | ||
| 123 | - LineMarker marker = getJavaEditor().findError(line); | ||
| 124 | - if (marker != null) { | ||
| 125 | - Problem problem = marker.getProblem(); | ||
| 126 | - | ||
| 127 | - int lineOffset = textArea.getLineStartOffset(problem.getLineNumber()); | ||
| 128 | - | ||
| 129 | - int lineStart = textArea.getLineStartOffset(line); | ||
| 130 | - int lineEnd = textArea.getLineStopOffset(line); | ||
| 131 | - | ||
| 132 | - int errorStart = lineOffset + problem.getPDELineStartOffset(); | ||
| 133 | - int errorEnd = lineOffset + problem.getPDELineStopOffset() + 1; | ||
| 134 | - | ||
| 135 | - int startOffset = Math.max(errorStart, lineStart) - lineStart; | ||
| 136 | - int stopOffset = Math.min(errorEnd, lineEnd) - lineStart; | ||
| 137 | - | ||
| 138 | - if (x >= getJavaTextArea().offsetToX(line, startOffset) && | ||
| 139 | - x <= getJavaTextArea().offsetToX(line, stopOffset)) { | ||
| 140 | - //setToolTipText(problem.getMessage()); | ||
| 141 | - getJavaEditor().statusToolTip(JavaTextAreaPainter.this, | ||
| 142 | - problem.getMessage(), | ||
| 143 | - problem.isError()); | ||
| 144 | - evt.consume(); | ||
| 145 | - } | ||
| 146 | - } | ||
| 147 | - } | ||
| 148 | - }); | ||
| 149 | - | ||
| 150 | 118 | // TweakMode code | |
| 151 | 119 | tweakMode = false; | |
| 152 | 120 | cursorType = Cursor.DEFAULT_CURSOR; | |
@@ -476,6 +444,42 @@ public void setMode(Mode mode) { | |||
| 476 | 444 | } | |
| 477 | 445 | ||
| 478 | 446 | ||
| 447 | + @Override | ||
| 448 | + public String getToolTipText(MouseEvent evt) { | ||
| 449 | + int line = evt.getY() / getFontMetrics().getHeight() + textArea.getFirstLine(); | ||
| 450 | + if (line >= 0 || line < textArea.getLineCount()) { | ||
| 451 | + LineMarker marker = getJavaEditor().findError(line); | ||
| 452 | + if (marker != null) { | ||
| 453 | + Problem problem = marker.getProblem(); | ||
| 454 | + | ||
| 455 | + int lineOffset = textArea.getLineStartOffset(problem.getLineNumber()); | ||
| 456 | + | ||
| 457 | + int lineStart = textArea.getLineStartOffset(line); | ||
| 458 | + int lineEnd = textArea.getLineStopOffset(line); | ||
| 459 | + | ||
| 460 | + int errorStart = lineOffset + problem.getPDELineStartOffset(); | ||
| 461 | + int errorEnd = lineOffset + problem.getPDELineStopOffset() + 1; | ||
| 462 | + | ||
| 463 | + int startOffset = Math.max(errorStart, lineStart) - lineStart; | ||
| 464 | + int stopOffset = Math.min(errorEnd, lineEnd) - lineStart; | ||
| 465 | + | ||
| 466 | + int x = evt.getX(); | ||
| 467 | + | ||
| 468 | + if (x >= getJavaTextArea().offsetToX(line, startOffset) && | ||
| 469 | + x <= getJavaTextArea().offsetToX(line, stopOffset)) { | ||
| 470 | + getJavaEditor().statusToolTip(JavaTextAreaPainter.this, | ||
| 471 | + problem.getMessage(), | ||
| 472 | + problem.isError()); | ||
| 473 | + return super.getToolTipText(evt); | ||
| 474 | + } | ||
| 475 | + } | ||
| 476 | + } | ||
| 477 | + setToolTipText(null); | ||
| 478 | + return super.getToolTipText(evt); | ||
| 479 | + } | ||
| 480 | + | ||
| 481 | + | ||
| 482 | + /* | ||
| 479 | 483 | @Override | |
| 480 | 484 | public String getToolTipText(MouseEvent event) { | |
| 481 | 485 | if (!getJavaEditor().hasJavaTabs()) { | |
@@ -564,6 +568,7 @@ public String getToolTipText(MouseEvent event) { | |||
| 564 | 568 | // setToolTipText(null); | |
| 565 | 569 | return super.getToolTipText(event); | |
| 566 | 570 | } | |
| 571 | + */ | ||
| 567 | 572 | ||
| 568 | 573 | ||
| 569 | 574 | // TweakMode code | |
| Back | FazBrowse Home | New Git URL |
0 commit comments