Skip to content

Commit

Permalink
Fix line number alignment in SMT interface (#3559)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattulbrich authored Feb 23, 2025
2 parents dfc5b50 + a6a93d5 commit ea7e633
Showing 1 changed file with 12 additions and 43 deletions.
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

0 comments on commit ea7e633

Please # to comment.