use of com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent 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());
}
}
}
}
use of com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent in project binnavi by google.
the class CCodeNodeUpdater method generateContent.
@Override
public void generateContent(final IZyNodeRealizer realizer, final ZyLabelContent content) {
ZyCodeNodeBuilder.buildContent(content, codeNode, graph.getSettings(), nodeModifier);
for (final INaviInstruction instruction : codeNode.getInstructions()) {
final INaviModule module = instruction.getModule();
if ((provider != null) && (provider.getDebugger(module) != null) && graph.getSettings().getDisplaySettings().getShowMemoryAddresses(provider.getDebugger(module))) {
final int line = CCodeNodeHelpers.instructionToLine(codeNode, instruction);
if (line != -1) {
final ZyLineContent lineContent = this.realizer.getNodeContent().getLineContent(line);
// TODO(timkornau) x64
lineContent.setTextColor(0, 8, Color.RED);
}
}
}
// Set highlighting for breakpoints and the instruction pointer.
final INaviInstruction instruction = codeNode.getInstructions().iterator().next();
if (instruction != null) {
final INaviModule module = instruction.getModule();
final IDebugger debugger = provider.getDebugger(module);
if (debugger == null) {
return;
}
final BreakpointManager manager = debugger.getBreakpointManager();
CBreakpointPainter.paintBreakpoints(manager, node, codeNode);
if (debugger.getProcessManager().getActiveThread() != null) {
final RelocatedAddress instructionPointer = debugger.getProcessManager().getActiveThread().getCurrentAddress();
final MemoryModule memoryModule = debugger.getProcessManager().getModule(instructionPointer);
final UnrelocatedAddress unrelocatedIP = new DefaultAddressConverter(memoryModule.getBaseAddress().getAddress(), module.getConfiguration().getFileBase()).memoryToFile(instructionPointer);
CDebuggerPainter.updateSingleNodeDebuggerHighlighting(graph, unrelocatedIP, node);
}
}
}
use of com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent in project binnavi by google.
the class ZyCodeNodeBuilder method insertLines.
/**
* Inserts the previously created lines into the content with consideration for the comments.
*
* @param content The content to which the lines are added.
* @param lines The instruction lines to add to the content.
* @param comments Information about the instruction comments for each line.
* @param maxLineWidth The maximum line width of all instruction lines in characters.
*/
private static void insertLines(final ZyLabelContent content, final List<Pair<String, List<CStyleRunData>>> lines, final HashMap<Pair<String, List<CStyleRunData>>, ArrayList<CommentContainer>> comments, final int maxLineWidth) {
for (final Pair<String, List<CStyleRunData>> lineContent : lines) {
final ArrayList<CommentContainer> instructionComments = comments.get(lineContent);
final StringBuilder lineBuilder = new StringBuilder(lineContent.first());
final List<CStyleRunData> styleRuns = lineContent.second();
if ((instructionComments == null) || instructionComments.isEmpty()) {
final ZyLineContent instructionLine = new ZyLineContent(lineBuilder.toString(), NORMAL_FONT, styleRuns, null);
content.addLineContent(instructionLine);
continue;
}
final String instructionFirstCommentLine = instructionComments.get(0).getCommentingString() != null ? instructionComments.get(0).getCommentingString().get(0) : null;
if (instructionFirstCommentLine != null) {
lineBuilder.append(Strings.repeat(" ", (maxLineWidth - lineBuilder.length()) + 1));
lineBuilder.append(instructionFirstCommentLine);
}
final ZyLineContent instructionLine = new ZyLineContent(lineBuilder.toString(), NORMAL_FONT, styleRuns, null);
if (instructionFirstCommentLine != null) {
instructionLine.setFont(maxLineWidth + 1, instructionFirstCommentLine.length(), ITALIC_FONT);
instructionLine.setTextColor(maxLineWidth + 1, instructionFirstCommentLine.length(), Color.BLACK);
instructionLine.setTextColor(maxLineWidth + 1, instructionComments.get(0).getCommentUserNameLength(), instructionComments.get(0).getCommentColor());
}
content.addLineContent(instructionLine);
boolean firstCommentContainer = true;
for (final CommentContainer commentContainer : instructionComments) {
boolean firstCommentLine = true;
for (final String partialCommentString : commentContainer.getCommentingString()) {
if (firstCommentContainer) {
firstCommentContainer = false;
continue;
}
final ZyLineContent commentLine = new ZyLineContent(Strings.repeat(" ", maxLineWidth + 1) + partialCommentString, ITALIC_FONT, null);
commentLine.setTextColor(Color.BLACK);
if (firstCommentLine) {
firstCommentLine = false;
commentLine.setTextColor(maxLineWidth + 1, commentContainer.getCommentUserNameLength(), commentContainer.getCommentColor());
}
content.addLineContent(commentLine);
}
}
}
}
use of com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent in project binnavi by google.
the class ZyFunctionNodeBuilder method buildNameLine.
/**
* Builds the name line of a function node.
*
* @param node The function node which provides the raw data.
* @param content The node content object where the name line is added.
* @param showFunctionInformation True, to show function information in the node. False, to hide
* it.
*/
private static void buildNameLine(final INaviFunctionNode node, final ZyLabelContent content, final boolean showFunctionInformation) {
final INaviFunction function = node.getFunction();
String informationString = "";
if (function.getBasicBlockCount() > 0) {
final StringBuilder builder = new StringBuilder();
builder.append(" (");
builder.append(function.getBasicBlockCount());
builder.append(" basic block");
if (function.getBasicBlockCount() > 1) {
builder.append('s');
}
if (function.getEdgeCount() > 0) {
builder.append(", ");
builder.append(function.getEdgeCount());
builder.append(" edge");
if (function.getEdgeCount() > 1) {
builder.append('s');
}
}
builder.append(')');
informationString = builder.toString();
}
final ZyLineContent nameLine = new ZyLineContent(function.getName() + informationString, NORMAL_FONT, null);
content.addLineContent(nameLine);
}
use of com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLineContent in project binnavi by google.
the class ZyFunctionNodeBuilder method buildAddressLine.
/**
* Builds the address line of a function node.
*
* @param node The function node which provides the raw data.
* @param content The node content object where the address line is added.
* @param modifier
*/
private static void buildAddressLine(final INaviFunctionNode node, final ZyLabelContent content, final INodeModifier modifier) {
final String module = node.getFunction().getModule().getConfiguration().getName();
final String standardAddress = node.getFunction().getAddress().toHexString();
final String address = modifier == null ? standardAddress : modifier.getAddress(node);
final CStyleRunData styleRun = address.equals(standardAddress) ? new CStyleRunData(0, -1, Color.BLACK) : new CStyleRunData(0, -1, Color.RED);
final ZyLineContent addressLine = new ZyLineContent(module + "::" + address, BOLD_FONT, Lists.newArrayList(styleRun), null);
content.addLineContent(addressLine);
}
Aggregations