Well, I only partly agree on that.
I personally don’t use the normal main menu anymore at all and am very happy about the hamburger menu reducing it to the least.
Hence a Command Pallet approach would be my favorite as well.
Based on a suggestion to choose from predefined fonts, I’ve created a POC after the scheme of UI: Select Color Scheme...
- live preview included. Actually, many parts of said command can be re-used. The POC is somewhat more simple atm. without resetting view-specific fonts. The only missing element was an API call which lists available fonts from OS. Instead a "fonts": []
setting is used to quickly switch between fonts as needed.
I find such a simple and quick approach useful especially as switching between light and dark color schemes often requires to change between a “normal” and “light” font variant due to fonts appearing much more bold in dark mode.
Default.sublime-commands
[
{
"caption": "UI: Select Font…",
"command": "select_font"
},
]
select_font.py
import sublime
import sublime_plugin
PREFS_FILE = 'Preferences.sublime-settings'
CURRENT_KIND = (sublime.KIND_ID_COLOR_GREENISH, "âś“", "Current")
class FontInputHandler(sublime_plugin.ListInputHandler):
def __init__(self):
super().__init__()
self.prefs = sublime.load_settings(PREFS_FILE)
self.original = self.prefs.get("font_face", "")
def placeholder(self):
return "Select Font"
def cancel(self):
self.prefs.set('font_face', self.original)
sublime.save_settings(PREFS_FILE)
def confirm(self):
sublime.save_settings(PREFS_FILE)
def preview(self, font_face):
if font_face is None:
return
self.last_previewed = font_face
def update():
# The color scheme to preview has been updated since
# the timeout was created
if font_face != self.last_previewed:
return
if self.prefs.get('font_face') == font_face:
return
self.prefs.set('font_face', font_face)
sublime.set_timeout(update, 250)
def list_items(self):
fonts = self.prefs.get('fonts')
fonts = set(fonts) if isinstance(fonts, list) else set()
fonts.add(self.prefs.get("font_face"))
items = []
selected = -1
for font in sorted(fonts):
kind_info = sublime.KIND_AMBIGUOUS
if self.original and self.original == font:
kind_info = CURRENT_KIND
selected = len(items)
items.append(sublime.ListInputItem(font, font, kind=kind_info))
return (items, selected)
class SelectFontCommand(sublime_plugin.WindowCommand):
def input_description(self):
return "Font:"
def input(self, args):
return FontInputHandler()
def run(self, font_face):
settings = sublime.load_settings(PREFS_FILE)
settings.set('font_face', font_face)
sublime.save_settings(PREFS_FILE)