mirror of
https://github.com/mitb-archive/filebot
synced 2024-11-10 11:25:04 -05:00
Dynamically resize the code editor depending on how many lines the current format expression has
This commit is contained in:
parent
7a91e60858
commit
d0a3b76c84
@ -205,7 +205,7 @@ public class FormatDialog extends JDialog {
|
||||
editorScrollPane.setBackground(new JTextField().getBackground());
|
||||
editorScrollPane.setBorder(new JTextField().getBorder());
|
||||
|
||||
content.add(editorScrollPane, "w 120px:min(pref, 420px), h pref!, growx, wrap 4px, id editor");
|
||||
content.add(editorScrollPane, "w 120px:min(pref, 420px), h pref, growx, wrap 4px, id editor");
|
||||
content.add(createImageButton(changeSampleAction), "sg action, w 25!, h 19!, pos n editor.y2+2 editor.x2 n");
|
||||
content.add(createImageButton(selectFolderAction), "sg action, w 25!, h 19!, pos n editor.y2+2 editor.x2-(27*1) n");
|
||||
content.add(createImageButton(showRecentAction), "sg action, w 25!, h 19!, pos n editor.y2+2 editor.x2-(27*2) n");
|
||||
@ -343,6 +343,16 @@ public class FormatDialog extends JDialog {
|
||||
checkFormatInBackground();
|
||||
}));
|
||||
|
||||
// dynamically resize the code editor depending on how many lines the current format expression has
|
||||
editor.getDocument().addDocumentListener(new LazyDocumentListener(0, evt -> {
|
||||
int r1 = editor.getRows();
|
||||
int r2 = (int) editor.getText().chars().filter(c -> c == '\n').count() + 1;
|
||||
if (r1 != r2) {
|
||||
editor.setRows(r2);
|
||||
getWindow(editor).revalidate();
|
||||
}
|
||||
}));
|
||||
|
||||
return editor;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user