Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sublime
- import sublime_plugin
- # This is a modified version of the Default/font.py file that ships with
- # sublime, which includes versions of the increase and decrease font size
- # commands that limit the size the font can be at each extreme.
- # This includes an event listener that catches any attempt to use the
- # "standard" font commands and rewrites the command to use these ones instead.
- min_font_size = 14
- max_font_size = 26
- class IncreaseFontSizeLimitCommand(sublime_plugin.ApplicationCommand):
- def run(self):
- s = sublime.load_settings("Preferences.sublime-settings")
- current = s.get("font_size", 10)
- if current >= 36:
- current += 4
- elif current >= 24:
- current += 2
- else:
- current += 1
- if current > max_font_size:
- current = max_font_size
- s.set("font_size", current)
- sublime.save_settings("Preferences.sublime-settings")
- class DecreaseFontSizeLimitCommand(sublime_plugin.ApplicationCommand):
- def run(self):
- s = sublime.load_settings("Preferences.sublime-settings")
- current = s.get("font_size", 10)
- # current -= 1
- if current >= 40:
- current -= 4
- elif current >= 26:
- current -= 2
- else:
- current -= 1
- if current < min_font_size:
- current = min_font_size
- s.set("font_size", current)
- sublime.save_settings("Preferences.sublime-settings")
- class FontEventListener(sublime_plugin.EventListener):
- def on_window_command(self, window, command, args):
- if command == "increase_font_size":
- return ("increase_font_size_limit", args)
- elif command == "decrease_font_size":
- return ("decrease_font_size_limit", args)
Add Comment
Please, Sign In to add comment