import sublime
import sublime_plugin
class EventListener(sublime_plugin.EventListener):
# reference counter of pending debounce timers
refs = 0
def on_load(self, view):
window = sublime.active_window()
if window:
self.refs += 1
window.set_status_bar_visible(True)
def on_time():
self.refs -= 1
if not self.refs:
self.hide_statusbar_by_scroll_position(view)
# sublime.set_timeout(on_time, 5000)
on_activated = on_load
def on_post_text_command(self, view, command_name, args):
"""Check whether to hide or show status bar after cursor movement."""
if command_name in ('scroll_lines', 'move', 'move_to'):
self.hide_statusbar_by_scroll_position(view)
""" does this trigger the status bar to hide when it goes past half way? """
def hide_statusbar_by_scroll_position(self, view):
cur_row, _ = view.rowcol(view.visible_region().end())
last_row, _ = view.rowcol(view.size())
relative_position = cur_row / (last_row + 1) # avoid division by 0
sublime.active_window().set_status_bar_visible(relative_position < 0.5)
After commenting out
sublime.set_timeout(on_time, 5000)
It doesn’t want to hide anymore, even when I scroll, is there a way to keep it from hiding until I change lines instead of closing after 5 seconds?
Ideally say there are 40 lines in a file once I scroll to either line 20 or higher in then I want it to hide, I hope that’s possible.
Thank you.