Skip to content

Commit

Permalink
Merge pull request #215 from monkape/width_limits
Browse files Browse the repository at this point in the history
add settings to control min and max terminal width
  • Loading branch information
randy3k authored Jun 8, 2020
2 parents 0800dbf + 614b83a commit e255f18
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Terminus.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@
// decreasing this value may improve performance
"scrollback_history_size": 10000,

// set a minimum or maximum terminal width in characters
"min_columns": 20,
"max_columns": 500,

// Windows and Linux only
// use ctrl+c to copy
// use ctrl+v to paste (use ctrl+alt+v to send ctrl+v instead)
Expand Down
8 changes: 8 additions & 0 deletions terminus/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,14 @@ def run(self, _, **kwargs):
# view_settings.set("caret_style", "blink")
view_settings.set("scroll_past_end", True)
view_settings.set("color_scheme", "Terminus.hidden-color-scheme")

max_columns = terminus_settings.get("max_columns")
if max_columns:
rulers = view_settings.get("rulers", [])
if max_columns not in rulers:
rulers.append(max_columns)
view_settings.set("rulers", rulers)

# search
if "file_regex" in kwargs:
view_settings.set("result_file_regex", kwargs["file_regex"])
Expand Down
10 changes: 8 additions & 2 deletions terminus/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,15 @@ def view_size(view):
if pixel_per_line == 0 or pixel_per_char == 0:
return (0, 0)

settings = sublime.load_settings("Terminus.sublime-settings")
min_columns = settings.get("min_columns", 20)
max_columns = settings.get("max_columns", 500)

nb_columns = int(pixel_width / pixel_per_char) - 3
if nb_columns < 1:
nb_columns = 1
if nb_columns < min_columns:
nb_columns = min_columns
elif nb_columns > max_columns:
nb_columns = max_columns

nb_rows = int(pixel_height / pixel_per_line)
if nb_rows < 1:
Expand Down

0 comments on commit e255f18

Please sign in to comment.