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 int offset = selection.x;
|
||||
final int length = selection.y;
|
||||
|
||||
try {
|
||||
IRegion startLine = document.getLineInformationOfOffset(offset);
|
||||
IRegion endLine = document.getLineInformationOfOffset(offset + length);
|
||||
if (startLine != endLine && isBlockSelectionModeEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ITypedRegion partition = TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, offset, true);
|
||||
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 closingCharacter = getPeerCharacter(character);
|
||||
final StringBuffer buffer = new StringBuffer();
|
||||
final StringBuilder buffer = new StringBuilder();
|
||||
buffer.append(character);
|
||||
buffer.append(closingCharacter);
|
||||
if (closingCharacter == '>' && nextToken != Symbols.TokenEOF
|
||||
|
@ -814,11 +816,17 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
|
|||
return;
|
||||
|
||||
int next = findNextPosition(position);
|
||||
if (next != BreakIterator.DONE) {
|
||||
try {
|
||||
if (isBlockSelectionModeEnabled() && document.getLineOfOffset(next) != document.getLineOfOffset(position)) {
|
||||
super.run(); // may navigate into virtual white space
|
||||
} else if (next != BreakIterator.DONE) {
|
||||
setCaretPosition(next);
|
||||
getTextWidget().showSelection();
|
||||
fireSelectionChanged();
|
||||
}
|
||||
} catch (BadLocationException x) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -892,13 +900,25 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
|
|||
return;
|
||||
|
||||
final ISourceViewer viewer = getSourceViewer();
|
||||
final int caret, length;
|
||||
StyledText text= viewer.getTextWidget();
|
||||
Point widgetSelection= text.getSelection();
|
||||
if (isBlockSelectionModeEnabled() && widgetSelection.y != widgetSelection.x) {
|
||||
final int caret= text.getCaretOffset();
|
||||
final int offset= modelOffset2WidgetOffset(viewer, position);
|
||||
|
||||
if (caret == widgetSelection.x)
|
||||
text.setSelectionRange(widgetSelection.y, offset - widgetSelection.y);
|
||||
else
|
||||
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, viewer.getTextWidget().getCaretOffset());
|
||||
caret= widgetOffset2ModelOffset(viewer, text.getCaretOffset());
|
||||
length= position - caret;
|
||||
}
|
||||
|
||||
|
@ -908,6 +928,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
|
|||
// Should not happen
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.internal.ui.editor.CEditor.NextSubWordAction#findNextPosition(int)
|
||||
|
@ -999,11 +1020,17 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
|
|||
return;
|
||||
|
||||
int previous = findPreviousPosition(position);
|
||||
if (previous != BreakIterator.DONE) {
|
||||
try {
|
||||
if (isBlockSelectionModeEnabled() && document.getLineOfOffset(previous) != document.getLineOfOffset(position)) {
|
||||
super.run(); // may navigate into virtual white space
|
||||
} else if (previous != BreakIterator.DONE) {
|
||||
setCaretPosition(previous);
|
||||
getTextWidget().showSelection();
|
||||
fireSelectionChanged();
|
||||
}
|
||||
} catch (BadLocationException x) {
|
||||
// ignore - getLineOfOffset failed
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1078,12 +1105,24 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
|
|||
|
||||
final int length;
|
||||
final ISourceViewer viewer = getSourceViewer();
|
||||
StyledText text= viewer.getTextWidget();
|
||||
Point widgetSelection= text.getSelection();
|
||||
if (isBlockSelectionModeEnabled() && widgetSelection.y != widgetSelection.x) {
|
||||
final int caret= text.getCaretOffset();
|
||||
final int offset= modelOffset2WidgetOffset(viewer, position);
|
||||
|
||||
if (caret == widgetSelection.x)
|
||||
text.setSelectionRange(widgetSelection.y, offset - widgetSelection.y);
|
||||
else
|
||||
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, viewer.getTextWidget().getCaretOffset()) - position;
|
||||
length= widgetOffset2ModelOffset(viewer, text.getCaretOffset()) - position;
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -1092,6 +1131,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
|
|||
// Should not happen
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.cdt.internal.ui.editor.CEditor.PreviousSubWordAction#findPreviousPosition(int)
|
||||
|
|
Loading…
Add table
Reference in a new issue