use of com.google.security.zynamics.zylib.gui.zygraph.realizers.IZyEditableObject in project binnavi by google.
the class CTabKeyBehavior method updateCaret.
@Override
protected void updateCaret() {
if (!isAltPressed() && !isCtrlPressed()) {
int caretX = getCaretEndPosX();
int caretY = getCaretMousePressedY();
ZyLineContent lineContent = getLineContent(caretY);
final IZyEditableObject editObject = lineContent.getLineFragmentObjectAt(caretX);
final List<IZyEditableObject> editObjects = lineContent.getLineFragmentObjectList();
IZyEditableObject nextEditObject = null;
if (!isShiftPressed()) {
if (editObject != null) {
if (!isComment(caretX, caretY)) {
final int editObjectIndex = lineContent.getLineFragmentObjectList().indexOf(editObject);
if (editObjectIndex < (editObjects.size() - 1)) {
nextEditObject = editObjects.get(editObjectIndex + 1);
}
}
} else {
for (final IZyEditableObject obj : editObjects) {
if (obj.getStart() > caretX) {
nextEditObject = obj;
break;
}
}
}
int tempY = caretY;
if (isComment(caretX, caretY)) {
final int lastCommentLine = getLabelContent().getLastLineIndexOfModelAt(tempY);
final int noneCommentLine = getLabelContent().getNonPureCommentLineIndexOfModelAt(tempY);
if (noneCommentLine != -1) {
if (tempY < noneCommentLine) {
tempY = noneCommentLine - 1;
} else {
tempY = lastCommentLine;
}
} else {
tempY = getLabelContent().getLineCount() - 1;
}
}
if (nextEditObject == null) {
boolean first = true;
while (((nextEditObject == null) && (tempY != caretY)) || first) {
first = false;
tempY = tempY == (getLabelContent().getLineCount() - 1) ? 0 : ++tempY;
final ZyLineContent nextLineContent = getLineContent(tempY);
final List<IZyEditableObject> nextEditObjects = nextLineContent.getLineFragmentObjectList();
if (nextEditObjects.size() > 0) {
nextEditObject = nextEditObjects.get(0);
}
}
}
if (nextEditObject != null) {
caretX = nextEditObject.getStart();
if (nextEditObject.isCommentDelimiter()) {
caretX = nextEditObject.getEnd();
}
caretY = tempY;
setCaret(caretX, caretX, caretY, caretX, caretX, caretY);
}
} else {
if (editObject != null) {
if (!isComment(caretX, caretY)) {
final int editObjectIndex = lineContent.getLineFragmentObjectList().indexOf(editObject);
if (editObjectIndex < 1) {
nextEditObject = editObjects.get(editObjectIndex - 1);
}
}
} else {
for (int index = editObjects.size() - 1; index >= 0; --index) {
final IZyEditableObject obj = editObjects.get(index);
if (obj.getEnd() < caretX) {
nextEditObject = obj;
break;
}
}
}
int tempY = caretY;
if (isComment(caretX, caretY)) {
final int firstCommentLine = getLabelContent().getFirstLineIndexOfModelAt(tempY);
final int noneCommentLine = getLabelContent().getNonPureCommentLineIndexOfModelAt(tempY);
if (noneCommentLine != -1) {
if (tempY < noneCommentLine) {
tempY = firstCommentLine;
} else {
tempY = noneCommentLine;
}
}
}
if (nextEditObject == null) {
boolean first = true;
while (((nextEditObject == null) && (tempY != caretY)) || first) {
first = false;
tempY = tempY == 0 ? getLabelContent().getLineCount() - 1 : --tempY;
final ZyLineContent nextLineContent = getLineContent(tempY);
final List<IZyEditableObject> nextEditObjects = nextLineContent.getLineFragmentObjectList();
if (nextEditObjects.size() > 0) {
nextEditObject = nextEditObjects.get(nextEditObjects.size() - 1);
}
}
}
if (nextEditObject != null) {
caretX = nextEditObject.getStart();
if (nextEditObject.isCommentDelimiter()) {
caretX = nextEditObject.getEnd();
}
caretY = tempY;
if (isComment(caretX, caretY)) {
final int firstCommentLine = getLabelContent().getFirstLineIndexOfModelAt(tempY);
final int noneCommentLine = getLabelContent().getNonPureCommentLineIndexOfModelAt(tempY);
if ((caretY <= noneCommentLine) || (noneCommentLine < 0)) {
caretY = firstCommentLine;
} else {
caretY = noneCommentLine;
}
lineContent = getLineContent(caretY);
nextEditObject = lineContent.getLineFragmentObjectAt(caretX);
if ((nextEditObject != null) && nextEditObject.isCommentDelimiter()) {
caretX = nextEditObject.getEnd();
}
}
setCaret(caretX, caretX, caretY, caretX, caretX, caretY);
}
}
}
}
use of com.google.security.zynamics.zylib.gui.zygraph.realizers.IZyEditableObject in project binnavi by google.
the class CCutKeyBehavior 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());
}
}
use of com.google.security.zynamics.zylib.gui.zygraph.realizers.IZyEditableObject in project binnavi by google.
the class CDelKeyBehavior method initUndoHistory.
@Override
protected void initUndoHistory() {
final int x = getCaretEndPosX();
final int y = getCaretMouseReleasedY();
final ZyLineContent lineContent = getLineContent(y);
final IZyEditableObject lineFragmentObject = lineContent.getLineFragmentObjectAt(x);
m_editableObject = lineContent.getLineObject();
if (lineFragmentObject != null) {
String text = lineContent.getText().substring(lineFragmentObject.getStart(), lineFragmentObject.getEnd());
m_isAboveComment = isAboveLineComment(y);
m_isBehindComment = isBehindLineComment(x, y);
m_isLabelComment = isLabelComment(y);
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());
}
}
use of com.google.security.zynamics.zylib.gui.zygraph.realizers.IZyEditableObject in project binnavi by google.
the class CInsertKeyBehavior method initUndoHistory.
@Override
protected void initUndoHistory() {
if (isPaste()) {
final int x = getCaretEndPosX();
final int y = getCaretMouseReleasedY();
final ZyLineContent lineContent = getLineContent(y);
IZyEditableObject lineFragmentObject = lineContent.getLineFragmentObjectAt(x);
boolean isNewBehindLineComment = false;
String text = "";
m_isAboveComment = isAboveLineComment(y);
m_isLabelComment = isLabelComment(y);
if ((x == lineContent.getText().length()) && !isComment(x, y)) {
m_isBehindComment = true;
isNewBehindLineComment = true;
lineFragmentObject = lineContent.getLineObject();
} else {
m_isBehindComment = isBehindLineComment(x, y);
}
m_editableObject = lineFragmentObject;
if (lineFragmentObject != null) {
if (!isNewBehindLineComment) {
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());
}
}
}
use of com.google.security.zynamics.zylib.gui.zygraph.realizers.IZyEditableObject in project binnavi by google.
the class ZyCodeNodeBuilder method buildContent.
/**
* Builds the visible content of a code node.
*
* @param node The code node that provides the raw data.
* @param graphSettings Provides settings that influence node formatting.
* @param modifier Calculates the address strings. This argument can be null.
*
* @return The content that was built from the information from the raw node.
*/
public static ZyLabelContent buildContent(final INaviCodeNode node, final ZyGraphViewSettings graphSettings, final INodeModifier modifier) {
Preconditions.checkNotNull(node, "IE00897: Node argument can not be null");
final ZyLabelContent content = new ZyLabelContent(new IZyEditableObject() {
@Override
public int getEnd() {
throw new IllegalStateException();
}
@Override
public int getLength() {
throw new IllegalStateException();
}
@Override
public Object getPersistentModel() {
throw new IllegalStateException();
}
@Override
public int getStart() {
throw new IllegalStateException();
}
@Override
public boolean isCommentDelimiter() {
throw new IllegalStateException();
}
@Override
public boolean isPlaceholder() {
throw new IllegalStateException();
}
@Override
public boolean update(final String newContent) {
throw new IllegalStateException();
}
@Override
public boolean updateComment(final String newContent, final ECommentPlacement placement) {
throw new IllegalStateException();
}
}, true, false);
buildContent(content, node, graphSettings, modifier);
return content;
}
Aggregations