Search in sources :

Example 6 with ZyLineContent

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

the class CCharKeyBehavior method updateUndoHistory.

@Override
protected void updateUndoHistory() {
    if (m_editableObject != null) {
        // There was an editable object that has been changed
        final int x = getCaretEndPosX();
        final int y = getCaretMouseReleasedY();
        final ZyLineContent lineContent = getLineContent(y);
        final IZyEditableObject editableObject = lineContent.getLineFragmentObjectAt(x);
        if (editableObject != null) {
            String text = lineContent.getText().substring(editableObject.getStart(), editableObject.getEnd());
            if (isComment(x, y)) {
                text = getMultiLineComment(y);
            }
            udpateUndolist(getLabelContent(), lineContent.getLineObject().getPersistentModel(), 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)

Example 7 with ZyLineContent

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

the class CCharKeyBehavior method initUndoHistory.

@Override
protected void initUndoHistory() {
    final int x = getCaretEndPosX();
    final int y = getCaretMouseReleasedY();
    final ZyLineContent lineContent = getLineContent(y);
    IZyEditableObject editableObject = lineContent.getLineFragmentObjectAt(x);
    m_isAboveComment = isAboveLineComment(y);
    m_isBehindComment = isBehindLineComment(x, y);
    m_isLabelComment = isLabelComment(y);
    boolean isNewBehindLineComment = false;
    if ((x == lineContent.getText().length()) && !isComment(x, y)) {
        // a new behind line comment will be created
        m_isBehindComment = true;
        isNewBehindLineComment = true;
        editableObject = lineContent.getLineObject();
    }
    m_editableObject = editableObject;
    String text = "";
    if (editableObject != null) {
        if (!isNewBehindLineComment) {
            text = lineContent.getText().substring(editableObject.getStart(), editableObject.getEnd());
            if (isComment(x, y)) {
                text = getMultiLineComment(y);
            }
        }
        udpateUndolist(getLabelContent(), lineContent.getLineObject().getPersistentModel(), 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)

Example 8 with ZyLineContent

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

the class CCursorKeyBehavior method handleNotShiftAndCtrl.

protected void handleNotShiftAndCtrl(final int xdelta, final int ydelta) {
    final ZyLabelContent labelContent = getLabelContent();
    int caretStartPos_X = getCaretStartPosX();
    int mousePressed_X = getCaretMousePressedX();
    final int mousePressed_Y = getCaretMousePressedY();
    int caretEndPos_X = getCaretEndPosX();
    int mouseReleased_X = getCaretMouseReleasedX();
    final int mouseReleased_Y = getCaretMouseReleasedY();
    if (xdelta != 0) {
        final ZyLineContent lineContent = labelContent.getLineContent(mouseReleased_Y);
        final String s = lineContent.getText() + " ";
        if (xdelta > 0) {
            final boolean firstIsSpace = s.charAt(caretEndPos_X) == ' ';
            int endindex = 0;
            for (int i = caretEndPos_X; i < s.length(); ++i) {
                endindex = i;
                if (firstIsSpace) {
                    if (s.charAt(i) != ' ') {
                        break;
                    }
                } else {
                    if (s.charAt(i) == ' ') {
                        break;
                    }
                }
            }
            if ((lineContent.getText().endsWith("\n") || lineContent.getText().endsWith("\r")) && (lineContent.getText().length() == endindex)) {
                endindex -= 1;
            }
            caretStartPos_X = endindex;
            mousePressed_X = endindex;
            mouseReleased_X = endindex;
            caretEndPos_X = endindex;
        } else if (xdelta < 0) {
            if (caretEndPos_X == 0) {
                return;
            }
            final boolean firstIsSpace = s.charAt(caretEndPos_X - 1) == ' ';
            int startindex = caretEndPos_X - 1;
            for (int i = caretEndPos_X - 1; i >= 0; --i) {
                if (firstIsSpace) {
                    if (s.charAt(i) != ' ') {
                        break;
                    }
                } else {
                    if (s.charAt(i) == ' ') {
                        break;
                    }
                }
                startindex = i;
            }
            caretStartPos_X = startindex;
            mousePressed_X = startindex;
            mouseReleased_X = startindex;
            caretEndPos_X = startindex;
        }
        mouseReleased_X = correctMouseReleasedX(mouseReleased_X, mouseReleased_Y, mousePressed_Y);
        setCaret(caretStartPos_X, mousePressed_X, mousePressed_Y, caretEndPos_X, mouseReleased_X, mouseReleased_Y);
    } else if (ydelta != 0) {
        handleNotShiftAndNotCtrl(0, ydelta);
    }
}
Also used : ZyLabelContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent) ZyLineContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent)

Example 9 with ZyLineContent

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

the class ClipboardCopier method copyToClipboard.

/**
   * Copies the text content of a node to the clip board.
   * 
   * @param node The node to copy to the clip board.
   */
public static void copyToClipboard(final ZyGraphNode<?> node) {
    Preconditions.checkNotNull(node, "Error: Node argument can not be null");
    final IZyNodeRealizer realizer = node.getRealizer();
    final ZyLabelContent content = realizer.getNodeContent();
    if (content.isSelectable()) {
        final ZyLabelContent zyContent = content;
        final StringBuilder textBuilder = new StringBuilder();
        for (final ZyLineContent zyLineContent : zyContent) {
            textBuilder.append(zyLineContent.getText());
            //$NON-NLS-1$
            textBuilder.append("\n");
        }
        ClipboardHelpers.copyToClipboard(textBuilder.toString());
    }
}
Also used : ZyLabelContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent) IZyNodeRealizer(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.IZyNodeRealizer) ZyLineContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent)

Example 10 with ZyLineContent

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

the class CAbstractKeyBehavior method getMultiLineComment.

protected String getMultiLineComment(final int lineYPos) {
    final StringBuilder commentText = new StringBuilder();
    final int nonCommentLine = m_labelContent.getNonPureCommentLineIndexOfModelAt(lineYPos);
    final int firstModelLine = m_labelContent.getFirstLineIndexOfModelAt(lineYPos);
    final int lastModelLine = m_labelContent.getLastLineIndexOfModelAt(lineYPos);
    int startIndex = isAboveLineComment(lineYPos) ? firstModelLine : nonCommentLine;
    int endIndex = isAboveLineComment(lineYPos) ? nonCommentLine - 1 : lastModelLine;
    if (nonCommentLine < 0) {
        startIndex = firstModelLine;
        endIndex = lastModelLine;
    }
    for (int index = startIndex; index <= endIndex; ++index) {
        final ZyLineContent curLineContent = m_labelContent.getLineContent(index);
        final String lineText = getSingleLineCommentText(curLineContent);
        commentText.append(lineText);
    }
    return commentText.toString();
}
Also used : ZyLineContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent) Point(java.awt.Point)

Aggregations

ZyLineContent (com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent)56 IZyEditableObject (com.google.security.zynamics.zylib.gui.zygraph.realizers.IZyEditableObject)24 Point (java.awt.Point)15 GraphSearcher (com.google.security.zynamics.binnavi.yfileswrap.Gui.GraphWindows.Searchers.Text.Model.GraphSearcher)8 NaviEdge (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviEdge)8 NaviNode (com.google.security.zynamics.binnavi.yfileswrap.zygraph.NaviNode)8 ZyNormalNodeRealizer (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.ZyNormalNodeRealizer)8 Test (org.junit.Test)8 ZyLabelContent (com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent)5 CStyleRunData (com.google.security.zynamics.zylib.gui.zygraph.realizers.CStyleRunData)3 IZyNodeRealizer (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.realizers.IZyNodeRealizer)3 INaviFunction (com.google.security.zynamics.binnavi.disassembly.INaviFunction)2 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)2 ArrayList (java.util.ArrayList)2 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)1 MaybeNullException (com.google.security.zynamics.binnavi.Exceptions.MaybeNullException)1 IComment (com.google.security.zynamics.binnavi.Gui.GraphWindows.CommentDialogs.Interfaces.IComment)1 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)1 DefaultAddressConverter (com.google.security.zynamics.binnavi.debug.debugger.DefaultAddressConverter)1 IDebugger (com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger)1