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))); 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) { public void setGlobalFontStyle(int style) {
properties.setProperty("global.font.style", String.valueOf(style)); properties.setProperty("global.font.style", String.valueOf(style));
} }

View File

@ -393,15 +393,21 @@ public class FileEditor extends JFrame {
initSearchPanel(); initSearchPanel();
northPanel.add(searchPanel); northPanel.add(searchPanel);
// Menu bar
createMenuBar();
// Text area (editable or read-only) // Text area (editable or read-only)
textArea = new JTextArea(); textArea = new JTextArea();
textArea.setFont(config.getEditorFont()); textArea.setFont(config.getEditorFont());
textArea.setTabSize(4); textArea.setTabSize(4);
textArea.setEditable(!readOnly); textArea.setEditable(!readOnly);
if (config.isEditorLineWrap()) {
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
textArea.setColumns(120);
}
// Menu bar
createMenuBar();
// Undo/Redo support // Undo/Redo support
undoManager = new javax.swing.undo.UndoManager(); undoManager = new javax.swing.undo.UndoManager();
textArea.getDocument().addUndoableEditListener(e -> { textArea.getDocument().addUndoableEditListener(e -> {
@ -664,6 +670,25 @@ public class FileEditor extends JFrame {
private void createViewMenu(JMenuBar menuBar) { private void createViewMenu(JMenuBar menuBar) {
JMenu viewMenu = new JMenu("View"); 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"); JCheckBoxMenuItem hexItem = new JCheckBoxMenuItem("Hex view");
hexItem.setState(hexMode); hexItem.setState(hexMode);
hexItem.addActionListener(e -> { hexItem.addActionListener(e -> {