Guest User

Untitled

a guest
Jan 20th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. import sublime
  2. import sublime_plugin
  3.  
  4. # This is a modified version of the Default/font.py file that ships with
  5. # sublime, which includes versions of the increase and decrease font size
  6. # commands that limit the size the font can be at each extreme.
  7.  
  8. # This includes an event listener that catches any attempt to use the
  9. # "standard" font commands and rewrites the command to use these ones instead.
  10.  
  11. min_font_size = 14
  12. max_font_size = 26
  13.  
  14. class IncreaseFontSizeLimitCommand(sublime_plugin.ApplicationCommand):
  15. def run(self):
  16. s = sublime.load_settings("Preferences.sublime-settings")
  17. current = s.get("font_size", 10)
  18.  
  19. if current >= 36:
  20. current += 4
  21. elif current >= 24:
  22. current += 2
  23. else:
  24. current += 1
  25.  
  26. if current > max_font_size:
  27. current = max_font_size
  28. s.set("font_size", current)
  29.  
  30. sublime.save_settings("Preferences.sublime-settings")
  31.  
  32.  
  33. class DecreaseFontSizeLimitCommand(sublime_plugin.ApplicationCommand):
  34. def run(self):
  35. s = sublime.load_settings("Preferences.sublime-settings")
  36. current = s.get("font_size", 10)
  37. # current -= 1
  38.  
  39. if current >= 40:
  40. current -= 4
  41. elif current >= 26:
  42. current -= 2
  43. else:
  44. current -= 1
  45.  
  46. if current < min_font_size:
  47. current = min_font_size
  48. s.set("font_size", current)
  49.  
  50. sublime.save_settings("Preferences.sublime-settings")
  51.  
  52.  
  53. class FontEventListener(sublime_plugin.EventListener):
  54. def on_window_command(self, window, command, args):
  55. if command == "increase_font_size":
  56. return ("increase_font_size_limit", args)
  57. elif command == "decrease_font_size":
  58. return ("decrease_font_size_limit", args)
Add Comment
Please, Sign In to add comment