added wrap to viewer

This commit is contained in:
Radek Davidek 2026-04-24 16:54:46 +02:00
parent f8f138d98d
commit 8d7d039a6a
2 changed files with 36 additions and 3 deletions

View File

@ -451,6 +451,14 @@ public class AppConfig {
return Integer.parseInt(properties.getProperty("global.font.style", String.valueOf(Font.PLAIN)));
}
public boolean isEditorLineWrap() {
return Boolean.parseBoolean(properties.getProperty("editor.lineWrap", "true"));
}
public void setEditorLineWrap(boolean wrap) {
properties.setProperty("editor.lineWrap", String.valueOf(wrap));
}
public void setGlobalFontStyle(int style) {
properties.setProperty("global.font.style", String.valueOf(style));
}

View File

@ -393,14 +393,20 @@ public class FileEditor extends JFrame {
initSearchPanel();
northPanel.add(searchPanel);
// Menu bar
createMenuBar();
// Text area (editable or read-only)
textArea = new JTextArea();
textArea.setFont(config.getEditorFont());
textArea.setTabSize(4);
textArea.setEditable(!readOnly);
if (config.isEditorLineWrap()) {
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
textArea.setColumns(120);
}
// Menu bar
createMenuBar();
// Undo/Redo support
undoManager = new javax.swing.undo.UndoManager();
@ -664,6 +670,25 @@ public class FileEditor extends JFrame {
private void createViewMenu(JMenuBar menuBar) {
JMenu viewMenu = new JMenu("View");
JCheckBoxMenuItem wrapItem = new JCheckBoxMenuItem("Wrap");
wrapItem.setState(textArea.getLineWrap());
wrapItem.addActionListener(e -> {
boolean wrap = wrapItem.getState();
textArea.setLineWrap(wrap);
textArea.setWrapStyleWord(wrap);
if (wrap) {
textArea.setColumns(120);
}
if (config != null) {
config.setEditorLineWrap(wrap);
config.saveConfig();
}
textArea.revalidate();
});
viewMenu.add(wrapItem);
viewMenu.addSeparator();
JCheckBoxMenuItem hexItem = new JCheckBoxMenuItem("Hex view");
hexItem.setState(hexMode);
hexItem.addActionListener(e -> {