added wrap to viewer
This commit is contained in:
parent
f8f138d98d
commit
8d7d039a6a
@ -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));
|
||||
}
|
||||
|
||||
@ -393,15 +393,21 @@ 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();
|
||||
textArea.getDocument().addUndoableEditListener(e -> {
|
||||
@ -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 -> {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user