Skip to content

Commit 0e32b72

Browse files
Jeangowhyrchl
andauthored
Support horizontal/vertical fraction for auto_zoom_on_focus (#173)
Co-authored-by: Rafał Chłodnicki <[email protected]>
1 parent d0cd911 commit 0e32b72

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
*.pyc
22
*.cache
33
*.sublime-project
4+
*.sublime-workspace
45
*.hgignore
56
*.hgtags
67
*.DS_Store
8+
pyrightconfig.json
79
package-metadata.json

Origami.sublime-settings

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717

1818
// Automatically zoom the active pane.
1919
// Set it to `true` for the default zoom, or to a user-definable
20-
// fraction of the screen, such as "0.75".
20+
// fraction of the screen, such as "0.75", or "[0.5, 0.6]" for
21+
// horizontal and vertical correspondingly.
2122
"auto_zoom_on_focus": false,
2223

2324
// Automatically close a pane once you've closed the last file in it.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ In the keybindings you can change a `mode` which specifies which separation line
5252
Automation
5353
----------
5454

55-
You can have Origami automatically zoom the active pane by setting `auto_zoom_on_focus` in your Origami user preferences. Set it to `true` for the default zoom, or set it to a user-definable fraction of the screen, such as `0.75`.
55+
You can have Origami automatically zoom the active pane by setting `auto_zoom_on_focus` in your Origami user preferences. Set it to `true` for the default zoom, or set it to a user-definable fraction of the screen, such as `0.75`, or `[0.5, 0.6]` for horizontal and vertical correspondingly.
5656

5757
Origami can also automatically close a pane for you once you've closed the last file in it. Just set `auto_close_empty_panes` to true in the Origami preferences.
5858

origami.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -310,10 +310,18 @@ def _on_resize_panes(self, orientation, cells, relevant_index, orig_data, text):
310310
self.window.set_layout(layout)
311311

312312
def zoom_pane(self, fraction):
313-
if fraction is None:
314-
fraction = .9
313+
fraction_horizontal = fraction_vertical = .9
314+
315+
if isinstance(fraction, float) or isinstance(fraction, int):
316+
fraction_horizontal = fraction_vertical = fraction
317+
elif isinstance(fraction, list) and len(fraction) == 2:
318+
if isinstance(fraction[0], float) or isinstance(fraction[0], int):
319+
fraction_horizontal = fraction[0]
320+
if isinstance(fraction[1], float) or isinstance(fraction[1], int):
321+
fraction_vertical = fraction[1]
315322

316-
fraction = min(1, max(0, fraction))
323+
fraction_horizontal = min(1, max(0, fraction_horizontal))
324+
fraction_vertical = min(1, max(0, fraction_vertical))
317325

318326
window = self.window
319327
rows, cols, cells = self.get_layout()
@@ -324,7 +332,7 @@ def zoom_pane(self, fraction):
324332

325333
# TODO: the sizes of the unzoomed panes are calculated incorrectly if the
326334
# unzoomed panes have a split that overlaps the zoomed pane.
327-
current_col_width = 1 if num_cols == 1 else fraction
335+
current_col_width = 1 if num_cols == 1 else fraction_horizontal
328336
other_col_width = 0 if num_cols == 1 else (1 - current_col_width) / (num_cols - 1)
329337

330338
cols = [0.0]
@@ -334,7 +342,7 @@ def zoom_pane(self, fraction):
334342
current_row = current_cell[1]
335343
num_rows = len(rows) - 1
336344

337-
current_row_height = 1 if num_rows == 1 else fraction
345+
current_row_height = 1 if num_rows == 1 else fraction_vertical
338346
other_row_height = 0 if num_rows == 1 else (1 - current_row_height) / (num_rows - 1)
339347
rows = [0.0]
340348
for i in range(num_rows):

0 commit comments

Comments
 (0)