use of org.exbin.deltahex.SelectionRange in project deltahex-java by exbin.
the class CodeAreaOperationCommandHandler method copy.
@Override
public void copy() {
SelectionRange selection = ((SelectionCapable) codeArea.getWorker()).getSelection();
if (!selection.isEmpty()) {
long first = selection.getFirst();
long last = selection.getLast();
BinaryData copy = codeArea.getData().copy(first, last - first + 1);
CodeAreaUtils.BinaryDataClipboardData binaryData = new CodeAreaUtils.BinaryDataClipboardData(copy, binaryDataFlavor);
setClipboardContent(binaryData);
}
}
use of org.exbin.deltahex.SelectionRange in project deltahex-java by exbin.
the class CodeAreaOperationCommandHandler method updateSelection.
public void updateSelection(boolean selecting, @Nonnull CaretPosition caretPosition) {
DefaultCodeAreaCaret caret = (DefaultCodeAreaCaret) ((CaretCapable) codeArea.getWorker()).getCaret();
SelectionRange selection = ((SelectionCapable) codeArea.getWorker()).getSelection();
if (selecting) {
((SelectionCapable) codeArea.getWorker()).setSelection(selection.getStart(), caret.getDataPosition());
} else {
((SelectionCapable) codeArea.getWorker()).setSelection(caret.getDataPosition(), caret.getDataPosition());
}
}
use of org.exbin.deltahex.SelectionRange in project deltahex-java by exbin.
the class DefaultCodeAreaCommandHandler method cut.
@Override
public void cut() {
if (!((EditationModeCapable) codeArea.getWorker()).isEditable()) {
return;
}
SelectionRange selection = ((SelectionCapable) codeArea.getWorker()).getSelection();
if (!selection.isEmpty()) {
copy();
deleteSelection();
codeArea.notifyDataChanged();
}
}
use of org.exbin.deltahex.SelectionRange in project deltahex-java by exbin.
the class CodeAreaOperationCommandHandler method clearSelection.
@Override
public void clearSelection() {
SelectionRange selection = ((SelectionCapable) codeArea.getWorker()).getSelection();
((SelectionCapable) codeArea.getWorker()).setSelection(selection.getStart(), selection.getStart());
}
use of org.exbin.deltahex.SelectionRange in project deltahex-java by exbin.
the class CodeAreaOperationCommandHandler method copyAsCode.
@Override
public void copyAsCode() {
SelectionRange selection = ((SelectionCapable) codeArea.getWorker()).getSelection();
if (!selection.isEmpty()) {
long first = selection.getFirst();
long last = selection.getLast();
BinaryData copy = codeArea.getData().copy(first, last - first + 1);
CodeType codeType = ((CodeTypeCapable) codeArea.getWorker()).getCodeType();
CodeCharactersCase charactersCase = ((CodeCharactersCaseCapable) codeArea.getWorker()).getCodeCharactersCase();
CodeAreaUtils.CodeDataClipboardData binaryData = new CodeAreaUtils.CodeDataClipboardData(copy, binaryDataFlavor, codeType, charactersCase);
setClipboardContent(binaryData);
}
}
Aggregations