Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix line number alignment in SMT interface #3559

Merged
merged 3 commits into from
Feb 23, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 12 additions & 43 deletions key.ui/src/main/java/de/uka/ilkd/key/gui/smt/InformationWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@
import java.awt.*;
import java.util.Collection;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.Element;

import de.uka.ilkd.key.gui.configuration.Config;
import de.uka.ilkd.key.gui.sourceview.TextLineNumber;
import de.uka.ilkd.key.smt.SMTSolver;
import de.uka.ilkd.key.smt.model.Model;
import de.uka.ilkd.key.smt.solvertypes.SolverTypes;

import org.key_project.util.java.StringUtil;


/**
* The information window is used to present detailed information about the execution of a solver.
Expand Down Expand Up @@ -125,48 +121,21 @@ private Component createModelTab() {
}

private Component newTab(Information information) {
final JTextArea lines = new JTextArea("1");
final JTextArea content = new JTextArea();
content.setFont(UIManager.getFont(Config.KEY_FONT_SEQUENT_VIEW));
lines.setBackground(Color.LIGHT_GRAY);
lines.setEditable(false);
final JTextPane content = new JTextPane();
Font font = UIManager.getFont(Config.KEY_FONT_SEQUENT_VIEW);
content.setFont(font);
content.setEditable(false);

content.getDocument().addDocumentListener(new DocumentListener() {
public String getText() {
int caretPosition = content.getDocument().getLength();
Element root = content.getDocument().getDefaultRootElement();
StringBuilder text = new StringBuilder("1" + StringUtil.NEW_LINE);
for (int i = 2; i < root.getElementIndex(caretPosition) + 2; i++) {
text.append(i).append(StringUtil.NEW_LINE);
}
return text.toString();
}

@Override
public void changedUpdate(DocumentEvent de) {
lines.setText(getText());
}

@Override
public void insertUpdate(DocumentEvent de) {
lines.setText(getText());
}

@Override
public void removeUpdate(DocumentEvent de) {
lines.setText(getText());
}

});
content.setText(information.content);
JScrollPane pane = new JScrollPane();
pane.getViewport().add(content);
pane.setRowHeaderView(lines);
pane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

JPanel nowrap = new JPanel(new BorderLayout());
nowrap.add(content);
JScrollPane scrPreview = new JScrollPane();
scrPreview.setViewportView(nowrap);

return pane;
TextLineNumber lineNumbers = new TextLineNumber(content, 1);
scrPreview.setRowHeaderView(lineNumbers);

return scrPreview;
}


Expand Down
Loading