Skip to content

Commit

Permalink
feat: add ability to customize status bar text
Browse files Browse the repository at this point in the history
  • Loading branch information
acheronfail committed Nov 15, 2018
1 parent de7e026 commit 576fa44
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
9 changes: 9 additions & 0 deletions RustEnhanced.sublime-settings
Expand Up @@ -57,6 +57,15 @@
// If `true`, displays diagnostic messages under the cursor in the status bar.
"rust_message_status_bar": false,

// The message to display when the syntax check is running.
"rust_message_status_bar_msg": "Rust check running",

// A list of chars that cycle through in the status bar to indicate progress.
"rust_message_status_bar_chars": [".", "..", "...", ".."],

// How often (ms) should the status bar text be updated when syntax checking.
"rust_message_status_bar_update_delay": 200,

// If your cargo project has several build targets, it's possible to specify mapping of
// source code filenames to the target names to enable syntax checking.
// "projects": {
Expand Down
24 changes: 17 additions & 7 deletions SyntaxCheckPlugin.py
Expand Up @@ -112,13 +112,23 @@ def run(self):
def update_status(self, count=0):
if self.done:
return
num = count % 4
if num == 3:
num = 1
num += 1
msg = 'Rust check running' + '.' * num
self.window.status_message(msg)
sublime.set_timeout(lambda: self.update_status(count + 1), 200)

status_msg = util.get_setting('rust_message_status_bar_msg')
status_chars = util.get_setting('rust_message_status_bar_chars')
status_update_delay = util.get_setting('rust_message_status_bar_update_delay')

try:
status_chars_len = len(status_chars)
num = count % status_chars_len
if num == status_chars_len - 1:
num = -1
num += 1

self.window.status_message(status_msg + status_chars[num])
sublime.set_timeout(lambda: self.update_status(count + 1), status_update_delay)
except Exception as e:
self.window.status_message('Error setting status text!')
log.critical(self.window, "An error occurred setting status text: " + str(e))

def get_rustc_messages(self):
"""Top-level entry point for generating messages for the given
Expand Down

0 comments on commit 576fa44

Please sign in to comment.