Lines 78-83
Link Here
|
78 |
import java.io.IOException; |
78 |
import java.io.IOException; |
79 |
import java.util.ArrayList; |
79 |
import java.util.ArrayList; |
80 |
import java.util.List; |
80 |
import java.util.List; |
|
|
81 |
import java.util.concurrent.Callable; |
81 |
import java.util.logging.Level; |
82 |
import java.util.logging.Level; |
82 |
import java.util.logging.Logger; |
83 |
import java.util.logging.Logger; |
83 |
import java.util.prefs.PreferenceChangeEvent; |
84 |
import java.util.prefs.PreferenceChangeEvent; |
Lines 1510-1546
Link Here
|
1510 |
// Disable drag which would otherwise occur when mouse would be over text |
1506 |
// Disable drag which would otherwise occur when mouse would be over text |
1511 |
c.setDragEnabled(false); |
1507 |
c.setDragEnabled(false); |
1512 |
// Check possible fold expansion |
1508 |
// Check possible fold expansion |
1513 |
FoldHierarchy hierarchy = FoldHierarchy.get(c); |
1509 |
try { |
1514 |
Document doc = c.getDocument(); |
1510 |
// hack, to get knowledge of possible expansion. Editor depends on Folding, so it's not really possible |
1515 |
if (doc instanceof AbstractDocument) { |
1511 |
// to have Folding depend on BaseCaret (= a cycle). If BaseCaret moves to editor.lib2, this contract |
1516 |
AbstractDocument adoc = (AbstractDocument) doc; |
1512 |
// can be formalized as an interface. |
1517 |
adoc.readLock(); |
1513 |
Callable<Boolean> cc = (Callable<Boolean>)c.getClientProperty("org.netbeans.api.fold.expander"); |
1518 |
try { |
1514 |
if (cc == null || !cc.call()) { |
1519 |
hierarchy.lock(); |
1515 |
if (selectWordAction == null) { |
1520 |
try { |
1516 |
selectWordAction = ((BaseKit) c.getUI().getEditorKit( |
1521 |
Fold collapsed = FoldUtilities.findCollapsedFold( |
1517 |
c)).getActionByName(BaseKit.selectWordAction); |
1522 |
hierarchy, offset, offset); |
|
|
1523 |
if (collapsed != null && collapsed.getStartOffset() <= offset |
1524 |
&& collapsed.getEndOffset() >= offset) { |
1525 |
hierarchy.expand(collapsed); |
1526 |
} else { |
1527 |
if (selectWordAction == null) { |
1528 |
selectWordAction = ((BaseKit) c.getUI().getEditorKit( |
1529 |
c)).getActionByName(BaseKit.selectWordAction); |
1530 |
} |
1531 |
if (selectWordAction != null) { |
1532 |
selectWordAction.actionPerformed(null); |
1533 |
} |
1534 |
// Select word action selects forward i.e. dot > mark |
1535 |
minSelectionStartOffset = getMark(); |
1536 |
minSelectionEndOffset = getDot(); |
1537 |
} |
1538 |
} finally { |
1539 |
hierarchy.unlock(); |
1540 |
} |
1518 |
} |
1541 |
} finally { |
1519 |
if (selectWordAction != null) { |
1542 |
adoc.readUnlock(); |
1520 |
selectWordAction.actionPerformed(null); |
|
|
1521 |
} |
1522 |
// Select word action selects forward i.e. dot > mark |
1523 |
minSelectionStartOffset = getMark(); |
1524 |
minSelectionEndOffset = getDot(); |
1543 |
} |
1525 |
} |
|
|
1526 |
} catch (Exception ex) { |
1527 |
Exceptions.printStackTrace(ex); |
1544 |
} |
1528 |
} |
1545 |
break; |
1529 |
break; |
1546 |
|
1530 |
|
Lines 2304-2308
Link Here
|
2304 |
DRAG_SELECTION // Drag is being done (text selection existed at the mouse press) |
2238 |
DRAG_SELECTION // Drag is being done (text selection existed at the mouse press) |
2305 |
|
2239 |
|
2306 |
} |
2240 |
} |
2307 |
|
2241 |
|
|
|
2242 |
/** |
2243 |
* Refreshes caret display on the screen. |
2244 |
* Some height or view changes may result in the caret going off the screen. In some cases, this is not desirable, |
2245 |
* as the user's work may be interrupted by e.g. an automatic refresh. This method repositions the view so the |
2246 |
* caret remains visible. |
2247 |
* <p/> |
2248 |
* The method has two modes: it can reposition the view just if it originally displayed the caret and the caret became |
2249 |
* invisible, and it can scroll the caret into view unconditionally. |
2250 |
* @param retainInView true to scroll only if the caret was visible. False to refresh regardless of visibility. |
2251 |
*/ |
2252 |
public void refresh(boolean retainInView) { |
2253 |
Rectangle b = caretBounds; |
2254 |
updateAfterFoldHierarchyChange = b != null; |
2255 |
boolean wasInView = b != null && component.getVisibleRect().intersects(b); |
2256 |
update(!retainInView || wasInView); |
2257 |
} |
2258 |
|
2308 |
} |
2259 |
} |