Search in sources :

Example 21 with IZyEditableObject

use of com.google.security.zynamics.zylib.gui.zygraph.realizers.IZyEditableObject in project binnavi by google.

the class CDelKeyBehavior method updateUndoHistory.

@Override
protected void updateUndoHistory() {
    final int x = getCaretEndPosX();
    final int y = getCaretMouseReleasedY();
    final ZyLineContent lineContent = getLineContent(y);
    final IZyEditableObject lineFragmentObject = lineContent.getLineFragmentObjectAt(x);
    String text = "";
    if (lineFragmentObject != null) {
        text = lineContent.getText().substring(lineFragmentObject.getStart(), lineFragmentObject.getEnd());
        if (isComment(x, y)) {
            text = getMultiLineComment(y);
        }
        udpateUndolist(getLabelContent(), lineContent.getLineObject().getPersistentModel(), m_editableObject, text, m_isAboveComment, m_isBehindComment, m_isLabelComment, getCaretStartPosX(), getCaretMousePressedX(), getCaretMousePressedY(), getCaretEndPosX(), getCaretMouseReleasedX(), getCaretMouseReleasedY());
    }
}
Also used : IZyEditableObject(com.google.security.zynamics.zylib.gui.zygraph.realizers.IZyEditableObject) ZyLineContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent) Point(java.awt.Point)

Example 22 with IZyEditableObject

use of com.google.security.zynamics.zylib.gui.zygraph.realizers.IZyEditableObject in project binnavi by google.

the class CDelKeyBehavior method getMultiCommentEndPoint.

private Point getMultiCommentEndPoint(final int lineXPos, final int lineYPos) {
    if (isComment(lineXPos, lineYPos)) {
        final ZyLineContent lineContent = getLineContent(lineYPos);
        int x = lineContent.getLineFragmentObjectList().get(lineContent.getLineFragmentObjectList().size() - 1).getEnd();
        int y = lineYPos;
        for (int index = lineYPos + 1; index <= getLabelContent().getLastLineIndexOfModelAt(lineYPos); ++index) {
            final ZyLineContent nextLineContent = getLineContent(index);
            final int editableObjectSize = nextLineContent.getLineFragmentObjectList().size();
            final IZyEditableObject firstEditableObject = nextLineContent.getLineFragmentObjectAt(0);
            if (firstEditableObject != null) {
                if (firstEditableObject.isCommentDelimiter()) {
                    x = nextLineContent.getLineFragmentObjectAt(editableObjectSize - 1).getEnd();
                    y = index;
                }
            } else {
                // End of above line comment
                break;
            }
        }
        return new Point(x, y);
    }
    return null;
}
Also used : IZyEditableObject(com.google.security.zynamics.zylib.gui.zygraph.realizers.IZyEditableObject) Point(java.awt.Point) ZyLineContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent) Point(java.awt.Point)

Example 23 with IZyEditableObject

use of com.google.security.zynamics.zylib.gui.zygraph.realizers.IZyEditableObject in project binnavi by google.

the class CInsertKeyBehavior method updateUndoHistory.

@Override
protected void updateUndoHistory() {
    if (isPaste()) {
        if (m_editableObject != null) {
            final int x = getCaretEndPosX();
            final int y = getCaretMouseReleasedY();
            final ZyLineContent lineContent = getLineContent(y);
            final IZyEditableObject lineFragmentObject = lineContent.getLineFragmentObjectAt(x);
            if (lineFragmentObject != null) {
                String text = lineContent.getText().substring(lineFragmentObject.getStart(), lineFragmentObject.getEnd());
                if (isComment(x, y)) {
                    text = getMultiLineComment(y);
                }
                udpateUndolist(getLabelContent(), lineContent.getLineObject().getPersistentModel(), lineFragmentObject, text, m_isAboveComment, m_isBehindComment, m_isLabelComment, getCaretStartPosX(), getCaretMousePressedX(), getCaretMousePressedY(), getCaretEndPosX(), getCaretMouseReleasedX(), getCaretMouseReleasedY());
            }
        }
    }
}
Also used : IZyEditableObject(com.google.security.zynamics.zylib.gui.zygraph.realizers.IZyEditableObject) ZyLineContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent) Point(java.awt.Point)

Example 24 with IZyEditableObject

use of com.google.security.zynamics.zylib.gui.zygraph.realizers.IZyEditableObject in project binnavi by google.

the class CAbstractKeyBehavior method getSingleLineCommentText.

private String getSingleLineCommentText(final ZyLineContent lineContent) {
    final StringBuilder commentText = new StringBuilder();
    final String lineText = lineContent.getText();
    boolean hasDelimiter = false;
    for (final IZyEditableObject lineObject : lineContent.getLineFragmentObjectList()) {
        if (lineObject.isCommentDelimiter()) {
            hasDelimiter = true;
            continue;
        }
        if (hasDelimiter) {
            final String subString = lineText.substring(lineObject.getStart(), lineObject.getEnd());
            commentText.append(subString);
        }
    }
    return commentText.toString();
}
Also used : IZyEditableObject(com.google.security.zynamics.zylib.gui.zygraph.realizers.IZyEditableObject)

Example 25 with IZyEditableObject

use of com.google.security.zynamics.zylib.gui.zygraph.realizers.IZyEditableObject in project binnavi by google.

the class CAbstractKeyBehavior method isDeleteableSelection.

protected boolean isDeleteableSelection() {
    final int mouseStartY = Math.min(getCaretMousePressedY(), getCaretMouseReleasedY());
    final int mouseEndY = Math.max(getCaretMousePressedY(), getCaretMouseReleasedY());
    final int caretStartX = Math.min(getCaretStartPosX(), getCaretEndPosX());
    final int caretEndX = Math.max(getCaretStartPosX(), getCaretEndPosX());
    final ZyLineContent firstLineContent = getLineContent(mouseStartY);
    final ZyLineContent lastLineContent = getLineContent(mouseEndY);
    final IZyEditableObject firstEditObject = firstLineContent.getLineFragmentObjectAt(caretStartX);
    final IZyEditableObject lastEditObject = firstLineContent.getLineFragmentObjectAt(caretEndX);
    if (firstLineContent.getLineObject() != lastLineContent.getLineObject()) {
        return false;
    }
    if (isComment(caretStartX, mouseStartY)) {
        if (mouseEndY > mouseStartY) {
            final int noneCommentLine = m_labelContent.getNonPureCommentLineIndexOfModelAt(mouseStartY);
            if (noneCommentLine != -1) {
                if ((mouseStartY < noneCommentLine) && (mouseEndY >= noneCommentLine)) {
                    return false;
                } else if ((mouseStartY >= noneCommentLine) && (mouseEndY < noneCommentLine)) {
                    return false;
                }
            }
        }
    } else {
        if ((firstEditObject != lastEditObject) || ((firstEditObject == null) && (lastEditObject == null))) {
            return false;
        }
    }
    return true;
}
Also used : IZyEditableObject(com.google.security.zynamics.zylib.gui.zygraph.realizers.IZyEditableObject) ZyLineContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent) Point(java.awt.Point)

Aggregations

IZyEditableObject (com.google.security.zynamics.zylib.gui.zygraph.realizers.IZyEditableObject)27 ZyLineContent (com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent)24 Point (java.awt.Point)12 ZyLabelContent (com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent)2 ECommentPlacement (com.google.security.zynamics.zylib.gui.zygraph.realizers.ECommentPlacement)1