Search in sources :

Example 1 with SelectionCapable

use of org.exbin.deltahex.capability.SelectionCapable 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);
    }
}
Also used : CodeAreaUtils(org.exbin.deltahex.CodeAreaUtils) SelectionRange(org.exbin.deltahex.SelectionRange) BinaryData(org.exbin.utils.binary_data.BinaryData) SelectionCapable(org.exbin.deltahex.capability.SelectionCapable)

Example 2 with SelectionCapable

use of org.exbin.deltahex.capability.SelectionCapable 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());
    }
}
Also used : DefaultCodeAreaCaret(org.exbin.deltahex.swing.basic.DefaultCodeAreaCaret) SelectionRange(org.exbin.deltahex.SelectionRange) SelectionCapable(org.exbin.deltahex.capability.SelectionCapable)

Example 3 with SelectionCapable

use of org.exbin.deltahex.capability.SelectionCapable 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();
    }
}
Also used : SelectionRange(org.exbin.deltahex.SelectionRange) SelectionCapable(org.exbin.deltahex.capability.SelectionCapable)

Example 4 with SelectionCapable

use of org.exbin.deltahex.capability.SelectionCapable 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());
}
Also used : SelectionRange(org.exbin.deltahex.SelectionRange) SelectionCapable(org.exbin.deltahex.capability.SelectionCapable)

Example 5 with SelectionCapable

use of org.exbin.deltahex.capability.SelectionCapable 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);
    }
}
Also used : CodeAreaUtils(org.exbin.deltahex.CodeAreaUtils) CodeCharactersCase(org.exbin.deltahex.CodeCharactersCase) SelectionRange(org.exbin.deltahex.SelectionRange) CodeTypeCapable(org.exbin.deltahex.capability.CodeTypeCapable) CodeType(org.exbin.deltahex.CodeType) CodeCharactersCaseCapable(org.exbin.deltahex.capability.CodeCharactersCaseCapable) BinaryData(org.exbin.utils.binary_data.BinaryData) SelectionCapable(org.exbin.deltahex.capability.SelectionCapable)

Aggregations

SelectionRange (org.exbin.deltahex.SelectionRange)10 SelectionCapable (org.exbin.deltahex.capability.SelectionCapable)10 BinaryData (org.exbin.utils.binary_data.BinaryData)5 CodeAreaUtils (org.exbin.deltahex.CodeAreaUtils)4 EditableBinaryData (org.exbin.utils.binary_data.EditableBinaryData)3 CodeCharactersCase (org.exbin.deltahex.CodeCharactersCase)2 CodeType (org.exbin.deltahex.CodeType)2 CodeCharactersCaseCapable (org.exbin.deltahex.capability.CodeCharactersCaseCapable)2 CodeTypeCapable (org.exbin.deltahex.capability.CodeTypeCapable)2 Clipboard (java.awt.datatransfer.Clipboard)1 FlavorEvent (java.awt.datatransfer.FlavorEvent)1 FlavorListener (java.awt.datatransfer.FlavorListener)1 CaretMovedListener (org.exbin.deltahex.CaretMovedListener)1 CaretPosition (org.exbin.deltahex.CaretPosition)1 EditationMode (org.exbin.deltahex.EditationMode)1 EditationModeChangedListener (org.exbin.deltahex.EditationModeChangedListener)1 SelectionChangedListener (org.exbin.deltahex.SelectionChangedListener)1 CaretCapable (org.exbin.deltahex.capability.CaretCapable)1 EditationModeCapable (org.exbin.deltahex.capability.EditationModeCapable)1 BinaryDataCommand (org.exbin.deltahex.operation.BinaryDataCommand)1