mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Bug 264147 - CDT Editor in Column/Block Edit Mode
This commit is contained in:
parent
cbe4c97b64
commit
f0af376bb5
1 changed files with 74 additions and 34 deletions
|
@ -588,10 +588,12 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
|
||||||
final Point selection = sourceViewer.getSelectedRange();
|
final Point selection = sourceViewer.getSelectedRange();
|
||||||
final int offset = selection.x;
|
final int offset = selection.x;
|
||||||
final int length = selection.y;
|
final int length = selection.y;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
IRegion startLine = document.getLineInformationOfOffset(offset);
|
IRegion startLine = document.getLineInformationOfOffset(offset);
|
||||||
IRegion endLine = document.getLineInformationOfOffset(offset + length);
|
IRegion endLine = document.getLineInformationOfOffset(offset + length);
|
||||||
|
if (startLine != endLine && isBlockSelectionModeEnabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ITypedRegion partition = TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, offset, true);
|
ITypedRegion partition = TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, offset, true);
|
||||||
if (!IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType())
|
if (!IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType())
|
||||||
|
@ -649,7 +651,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
|
||||||
|
|
||||||
final char character = event.character;
|
final char character = event.character;
|
||||||
final char closingCharacter = getPeerCharacter(character);
|
final char closingCharacter = getPeerCharacter(character);
|
||||||
final StringBuffer buffer = new StringBuffer();
|
final StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append(character);
|
buffer.append(character);
|
||||||
buffer.append(closingCharacter);
|
buffer.append(closingCharacter);
|
||||||
if (closingCharacter == '>' && nextToken != Symbols.TokenEOF
|
if (closingCharacter == '>' && nextToken != Symbols.TokenEOF
|
||||||
|
@ -814,10 +816,16 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int next = findNextPosition(position);
|
int next = findNextPosition(position);
|
||||||
if (next != BreakIterator.DONE) {
|
try {
|
||||||
setCaretPosition(next);
|
if (isBlockSelectionModeEnabled() && document.getLineOfOffset(next) != document.getLineOfOffset(position)) {
|
||||||
getTextWidget().showSelection();
|
super.run(); // may navigate into virtual white space
|
||||||
fireSelectionChanged();
|
} else if (next != BreakIterator.DONE) {
|
||||||
|
setCaretPosition(next);
|
||||||
|
getTextWidget().showSelection();
|
||||||
|
fireSelectionChanged();
|
||||||
|
}
|
||||||
|
} catch (BadLocationException x) {
|
||||||
|
// ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -892,20 +900,33 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
|
||||||
return;
|
return;
|
||||||
|
|
||||||
final ISourceViewer viewer = getSourceViewer();
|
final ISourceViewer viewer = getSourceViewer();
|
||||||
final int caret, length;
|
StyledText text= viewer.getTextWidget();
|
||||||
Point selection = viewer.getSelectedRange();
|
Point widgetSelection= text.getSelection();
|
||||||
if (selection.y != 0) {
|
if (isBlockSelectionModeEnabled() && widgetSelection.y != widgetSelection.x) {
|
||||||
caret = selection.x;
|
final int caret= text.getCaretOffset();
|
||||||
length = selection.y;
|
final int offset= modelOffset2WidgetOffset(viewer, position);
|
||||||
} else {
|
|
||||||
caret = widgetOffset2ModelOffset(viewer, viewer.getTextWidget().getCaretOffset());
|
|
||||||
length = position - caret;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
if (caret == widgetSelection.x)
|
||||||
viewer.getDocument().replace(caret, length, ""); //$NON-NLS-1$
|
text.setSelectionRange(widgetSelection.y, offset - widgetSelection.y);
|
||||||
} catch (BadLocationException exception) {
|
else
|
||||||
// Should not happen
|
text.setSelectionRange(widgetSelection.x, offset - widgetSelection.x);
|
||||||
|
text.invokeAction(ST.DELETE_NEXT);
|
||||||
|
} else {
|
||||||
|
Point selection= viewer.getSelectedRange();
|
||||||
|
final int caret, length;
|
||||||
|
if (selection.y != 0) {
|
||||||
|
caret= selection.x;
|
||||||
|
length= selection.y;
|
||||||
|
} else {
|
||||||
|
caret= widgetOffset2ModelOffset(viewer, text.getCaretOffset());
|
||||||
|
length= position - caret;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
viewer.getDocument().replace(caret, length, ""); //$NON-NLS-1$
|
||||||
|
} catch (BadLocationException exception) {
|
||||||
|
// Should not happen
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -999,10 +1020,16 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int previous = findPreviousPosition(position);
|
int previous = findPreviousPosition(position);
|
||||||
if (previous != BreakIterator.DONE) {
|
try {
|
||||||
setCaretPosition(previous);
|
if (isBlockSelectionModeEnabled() && document.getLineOfOffset(previous) != document.getLineOfOffset(position)) {
|
||||||
getTextWidget().showSelection();
|
super.run(); // may navigate into virtual white space
|
||||||
fireSelectionChanged();
|
} else if (previous != BreakIterator.DONE) {
|
||||||
|
setCaretPosition(previous);
|
||||||
|
getTextWidget().showSelection();
|
||||||
|
fireSelectionChanged();
|
||||||
|
}
|
||||||
|
} catch (BadLocationException x) {
|
||||||
|
// ignore - getLineOfOffset failed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1078,18 +1105,31 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
|
||||||
|
|
||||||
final int length;
|
final int length;
|
||||||
final ISourceViewer viewer = getSourceViewer();
|
final ISourceViewer viewer = getSourceViewer();
|
||||||
Point selection = viewer.getSelectedRange();
|
StyledText text= viewer.getTextWidget();
|
||||||
if (selection.y != 0) {
|
Point widgetSelection= text.getSelection();
|
||||||
position = selection.x;
|
if (isBlockSelectionModeEnabled() && widgetSelection.y != widgetSelection.x) {
|
||||||
length = selection.y;
|
final int caret= text.getCaretOffset();
|
||||||
} else {
|
final int offset= modelOffset2WidgetOffset(viewer, position);
|
||||||
length = widgetOffset2ModelOffset(viewer, viewer.getTextWidget().getCaretOffset()) - position;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
if (caret == widgetSelection.x)
|
||||||
viewer.getDocument().replace(position, length, ""); //$NON-NLS-1$
|
text.setSelectionRange(widgetSelection.y, offset - widgetSelection.y);
|
||||||
} catch (BadLocationException exception) {
|
else
|
||||||
// Should not happen
|
text.setSelectionRange(widgetSelection.x, offset - widgetSelection.x);
|
||||||
|
text.invokeAction(ST.DELETE_PREVIOUS);
|
||||||
|
} else {
|
||||||
|
Point selection= viewer.getSelectedRange();
|
||||||
|
if (selection.y != 0) {
|
||||||
|
position= selection.x;
|
||||||
|
length= selection.y;
|
||||||
|
} else {
|
||||||
|
length= widgetOffset2ModelOffset(viewer, text.getCaretOffset()) - position;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
viewer.getDocument().replace(position, length, ""); //$NON-NLS-1$
|
||||||
|
} catch (BadLocationException exception) {
|
||||||
|
// Should not happen
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue