Lines 105-110
Link Here
|
105 |
import org.netbeans.api.editor.caret.CaretInfo; |
105 |
import org.netbeans.api.editor.caret.CaretInfo; |
106 |
import org.netbeans.api.editor.EditorActionRegistration; |
106 |
import org.netbeans.api.editor.EditorActionRegistration; |
107 |
import org.netbeans.api.editor.EditorActionRegistrations; |
107 |
import org.netbeans.api.editor.EditorActionRegistrations; |
|
|
108 |
import org.netbeans.api.editor.EditorUtilities; |
108 |
import org.netbeans.api.editor.caret.EditorCaret; |
109 |
import org.netbeans.api.editor.caret.EditorCaret; |
109 |
import org.netbeans.api.editor.mimelookup.MimeLookup; |
110 |
import org.netbeans.api.editor.mimelookup.MimeLookup; |
110 |
import org.netbeans.api.editor.mimelookup.MimePath; |
111 |
import org.netbeans.api.editor.mimelookup.MimePath; |
Lines 1170-1180
Link Here
|
1170 |
boolean alreadyBeeped = false; |
1171 |
boolean alreadyBeeped = false; |
1171 |
DocumentUtilities.setTypingModification(doc, true); |
1172 |
DocumentUtilities.setTypingModification(doc, true); |
1172 |
try { |
1173 |
try { |
1173 |
// Store current state of caret(s) for undo |
1174 |
EditorUtilities.addCaretUndoableEdit(doc, caret); |
1174 |
UndoableEdit caretUndoEdit = CaretUndo.createCaretUndoEdit(caret, doc, false); |
|
|
1175 |
if (caretUndoEdit != null) { |
1176 |
doc.addUndoableEdit(caretUndoEdit); |
1177 |
} |
1178 |
for (CaretInfo c : carets) { |
1175 |
for (CaretInfo c : carets) { |
1179 |
if (c.isSelection()) { // valid selection |
1176 |
if (c.isSelection()) { // valid selection |
1180 |
int p0 = Math.min(c.getDot(), c.getMark()); |
1177 |
int p0 = Math.min(c.getDot(), c.getMark()); |
Lines 1231-1241
Link Here
|
1231 |
} |
1228 |
} |
1232 |
} |
1229 |
} |
1233 |
} |
1230 |
} |
1234 |
// Store current state of caret(s) for redo |
1231 |
EditorUtilities.addCaretUndoableEdit(doc, caret); |
1235 |
UndoableEdit caretRedoEdit = CaretUndo.createCaretUndoEdit(caret, doc, true); |
|
|
1236 |
if (caretRedoEdit != null) { |
1237 |
doc.addUndoableEdit(caretRedoEdit); |
1238 |
} |
1239 |
|
1232 |
|
1240 |
} finally { |
1233 |
} finally { |
1241 |
DocumentUtilities.setTypingModification(doc, false); |
1234 |
DocumentUtilities.setTypingModification(doc, false); |
Lines 1262-1272
Link Here
|
1262 |
doc.runAtomicAsUser(new Runnable() { |
1255 |
doc.runAtomicAsUser(new Runnable() { |
1263 |
public void run() { |
1256 |
public void run() { |
1264 |
boolean alreadyBeeped = false; |
1257 |
boolean alreadyBeeped = false; |
1265 |
// Store current state of caret(s) for undo |
1258 |
EditorUtilities.addCaretUndoableEdit(doc, caret); |
1266 |
UndoableEdit caretUndoEdit = CaretUndo.createCaretUndoEdit(caret, doc, false); |
|
|
1267 |
if (caretUndoEdit != null) { |
1268 |
doc.addUndoableEdit(caretUndoEdit); |
1269 |
} |
1270 |
if (target.getCaret().isSelectionVisible() && caret.getDot() != caret.getMark()) { // valid selection |
1259 |
if (target.getCaret().isSelectionVisible() && caret.getDot() != caret.getMark()) { // valid selection |
1271 |
EditorUI editorUI = Utilities.getEditorUI(target); |
1260 |
EditorUI editorUI = Utilities.getEditorUI(target); |
1272 |
Boolean overwriteMode = (Boolean) editorUI.getProperty(EditorUI.OVERWRITE_MODE_PROPERTY); |
1261 |
Boolean overwriteMode = (Boolean) editorUI.getProperty(EditorUI.OVERWRITE_MODE_PROPERTY); |
Lines 1296-1306
Link Here
|
1296 |
target.getToolkit().beep(); |
1285 |
target.getToolkit().beep(); |
1297 |
} |
1286 |
} |
1298 |
} |
1287 |
} |
1299 |
// Store current state of caret(s) for redo |
1288 |
EditorUtilities.addCaretUndoableEdit(doc, caret); |
1300 |
UndoableEdit caretRedoEdit = CaretUndo.createCaretUndoEdit(caret, doc, true); |
|
|
1301 |
if (caretRedoEdit != null) { |
1302 |
doc.addUndoableEdit(caretRedoEdit); |
1303 |
} |
1304 |
} |
1289 |
} |
1305 |
}); |
1290 |
}); |
1306 |
|
1291 |
|
Lines 2021-2031
Link Here
|
2021 |
public void run() { |
2006 |
public void run() { |
2022 |
boolean alreadyBeeped = false; |
2007 |
boolean alreadyBeeped = false; |
2023 |
DocumentUtilities.setTypingModification(doc, true); |
2008 |
DocumentUtilities.setTypingModification(doc, true); |
2024 |
// Store current state of caret(s) for undo |
2009 |
EditorUtilities.addCaretUndoableEdit(doc, caret); |
2025 |
UndoableEdit caretUndoEdit = CaretUndo.createCaretUndoEdit(caret, doc, false); |
|
|
2026 |
if (caretUndoEdit != null) { |
2027 |
doc.addUndoableEdit(caretUndoEdit); |
2028 |
} |
2029 |
try { |
2010 |
try { |
2030 |
for (CaretInfo c : carets) { |
2011 |
for (CaretInfo c : carets) { |
2031 |
if (c.isSelection()) { |
2012 |
if (c.isSelection()) { |
Lines 2068-2078
Link Here
|
2068 |
} |
2049 |
} |
2069 |
} |
2050 |
} |
2070 |
} |
2051 |
} |
2071 |
// Store current state of caret(s) for redo |
2052 |
EditorUtilities.addCaretUndoableEdit(doc, caret); |
2072 |
UndoableEdit caretRedoEdit = CaretUndo.createCaretUndoEdit(caret, doc, true); |
|
|
2073 |
if (caretRedoEdit != null) { |
2074 |
doc.addUndoableEdit(caretRedoEdit); |
2075 |
} |
2076 |
|
2053 |
|
2077 |
} finally { |
2054 |
} finally { |
2078 |
DocumentUtilities.setTypingModification(doc, false); |
2055 |
DocumentUtilities.setTypingModification(doc, false); |
Lines 2093-2103
Link Here
|
2093 |
doc.runAtomicAsUser (new Runnable () { |
2070 |
doc.runAtomicAsUser (new Runnable () { |
2094 |
public void run () { |
2071 |
public void run () { |
2095 |
DocumentUtilities.setTypingModification(doc, true); |
2072 |
DocumentUtilities.setTypingModification(doc, true); |
2096 |
// Store current state of caret(s) for undo |
2073 |
EditorUtilities.addCaretUndoableEdit(doc, caret); |
2097 |
UndoableEdit caretUndoEdit = CaretUndo.createCaretUndoEdit(caret, doc, false); |
|
|
2098 |
if (caretUndoEdit != null) { |
2099 |
doc.addUndoableEdit(caretUndoEdit); |
2100 |
} |
2101 |
try { |
2074 |
try { |
2102 |
List<Position> dotAndMarkPosPairs = new ArrayList<>(2); |
2075 |
List<Position> dotAndMarkPosPairs = new ArrayList<>(2); |
2103 |
dotAndMarkPosPairs.add(doc.createPosition(caret.getDot())); |
2076 |
dotAndMarkPosPairs.add(doc.createPosition(caret.getDot())); |
Lines 2112-2122
Link Here
|
2112 |
} else { |
2085 |
} else { |
2113 |
doc.remove(Math.min(dot, mark), Math.abs(dot - mark)); |
2086 |
doc.remove(Math.min(dot, mark), Math.abs(dot - mark)); |
2114 |
} |
2087 |
} |
2115 |
// Store current state of caret(s) for redo |
2088 |
EditorUtilities.addCaretUndoableEdit(doc, caret); |
2116 |
UndoableEdit caretRedoEdit = CaretUndo.createCaretUndoEdit(caret, doc, true); |
|
|
2117 |
if (caretRedoEdit != null) { |
2118 |
doc.addUndoableEdit(caretRedoEdit); |
2119 |
} |
2120 |
} catch (BadLocationException e) { |
2089 |
} catch (BadLocationException e) { |
2121 |
target.getToolkit().beep(); |
2090 |
target.getToolkit().beep(); |
2122 |
} finally { |
2091 |
} finally { |
Lines 2144-2154
Link Here
|
2144 |
doc.runAtomicAsUser (new Runnable () { |
2113 |
doc.runAtomicAsUser (new Runnable () { |
2145 |
public void run () { |
2114 |
public void run () { |
2146 |
DocumentUtilities.setTypingModification(doc, true); |
2115 |
DocumentUtilities.setTypingModification(doc, true); |
2147 |
// Store current state of caret(s) for undo |
2116 |
EditorUtilities.addCaretUndoableEdit(doc, caret); |
2148 |
UndoableEdit caretUndoEdit = CaretUndo.createCaretUndoEdit(caret, doc, false); |
|
|
2149 |
if (caretUndoEdit != null) { |
2150 |
doc.addUndoableEdit(caretUndoEdit); |
2151 |
} |
2152 |
try { |
2117 |
try { |
2153 |
if (nextChar) { // remove next char |
2118 |
if (nextChar) { // remove next char |
2154 |
doc.remove(dot, 1); |
2119 |
doc.remove(dot, 1); |
Lines 2170-2180
Link Here
|
2170 |
} finally { |
2135 |
} finally { |
2171 |
DocumentUtilities.setTypingModification(doc, false); |
2136 |
DocumentUtilities.setTypingModification(doc, false); |
2172 |
} |
2137 |
} |
2173 |
// Store current state of caret(s) for redo |
2138 |
EditorUtilities.addCaretUndoableEdit(doc, caret); |
2174 |
UndoableEdit caretRedoEdit = CaretUndo.createCaretUndoEdit(caret, doc, true); |
|
|
2175 |
if (caretRedoEdit != null) { |
2176 |
doc.addUndoableEdit(caretRedoEdit); |
2177 |
} |
2178 |
} |
2139 |
} |
2179 |
}); |
2140 |
}); |
2180 |
|
2141 |
|