Extended statusbar API that allows (dynamic) popups #15

Open
FichteFoll opened this Issue Apr 26, 2013 · 4 comments

Comments

Projects
None yet
4 participants
Owner

FichteFoll commented Apr 26, 2013

I'd certainly love to be able to modify the items in the statusbar's bottom right (like the current Syntax or Tab Width). Furthermore having your own menu there would allow so much configuration e.g. line endings, the layout or rulers.

This would probably be achieved best by having some kind of View -> Statusbar menu where all the available status bar items can be checked and unchecked which would only leave those you want.

Plugins can register a statusbar menu themselves by calling a sublime.set_statusbar_item or similar method with either a list of dicts or a file name parameter. The file name here would point to a .sublime-menu file and is the more legacy option here which would allow to be overridden by the user completely.
But considering moving to the future I'd suggest supplying an identifier and a list of dicts to this method with the dict containing similar or identical information like the menu files do (command, caption, accelerators) but this would allow runtime modification by calling the method again with the same identifier but with a different dict.

Example as follows:

import sublime

status_id = "status_test"

def plugin_loaded():
    data = [
        dict(caption="New File", command="new_file"),
        dict(caption="Checked?", command="checked_or_unchecked", checkbox=True),
        dict(caption="Remove this menu", command="remove_test_menu")
    ]
    sublime.set_statusbar_item(status_id, data, text="Test this menu")


class RemoveTestMenuCommand(sublime_plugin.ApplicationCommand):
    def run(self):
        sublime.set_statusbar_item(status_id, None)  # removes the item


class CheckedOrUncheckedCommand(sublime_plugin.ApplicationCommand):
    _checked = False

    def is_checked(self):
        return self._checked

    def run(self):
        self._checked = not self._checked
        # Only modify the text
        # I recommend `Ellipsis` or `...` as default parameter here to not collide with `None`
        sublime.set_statusbar_item(status_id, text="Item has been %schecked" % ("" if self._checked else "un"))
Contributor

BoundInCode commented Apr 26, 2013

+1. I would at least like to see some better organization in the status bar, especially when linting plugins take up so much room. Some dividers and styling wouldn't hurt. Not high on my list of priorities but would definitely be a welcome addition.

+1. Not wanting to create a new issue, let me add, as a way to improve the statusbar readability, that long messages (save with different encoding, for example) shouldn't push the right elements out of view. Messages should be truncated or show up in a new line if the statusbar height allows (theme dependent).

Contributor

keith-hall commented Apr 3, 2017

@megadr01d you may want to move that comment to #1642 now that there is a separate issue for it

@keith-hall Thanks for the heads-up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment