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());
}
}
}
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());
}
}
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);
}
}
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());
}
}
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();
}
Aggregations