Skip to content

Commit 957a04d

Browse files
Merge #355
355: feat: add ability to customize status bar text r=ehuss a=acheronfail I wanted to be able to customise the status bar text while the syntax check was running. Here's that change! It's "non-breaking", meaning that the text is still this: 👌 ![default](https://user-images.githubusercontent.com/34289614/48541048-d01ad200-e90f-11e8-9052-596072c1ea4c.gif) And it allows you to customise the text like this: 🎉 ![custom-1](https://user-images.githubusercontent.com/34289614/48541059-db6dfd80-e90f-11e8-92ea-d69ce89fe810.gif) 😮 ![custom-2](https://user-images.githubusercontent.com/34289614/48541061-dd37c100-e90f-11e8-8d50-537f51367226.gif) Or even this: ![custom-3](https://user-images.githubusercontent.com/34289614/48541303-72d35080-e910-11e8-94e7-effaa2101e53.gif) (For a good collection of text-based spinners see [`cli-spinners`](https://github.com/sindresorhus/cli-spinners/blob/master/spinners.json)). Co-authored-by: acheronfail <[email protected]>
2 parents de7e026 + 576fa44 commit 957a04d

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

RustEnhanced.sublime-settings

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@
5757
// If `true`, displays diagnostic messages under the cursor in the status bar.
5858
"rust_message_status_bar": false,
5959

60+
// The message to display when the syntax check is running.
61+
"rust_message_status_bar_msg": "Rust check running",
62+
63+
// A list of chars that cycle through in the status bar to indicate progress.
64+
"rust_message_status_bar_chars": [".", "..", "...", ".."],
65+
66+
// How often (ms) should the status bar text be updated when syntax checking.
67+
"rust_message_status_bar_update_delay": 200,
68+
6069
// If your cargo project has several build targets, it's possible to specify mapping of
6170
// source code filenames to the target names to enable syntax checking.
6271
// "projects": {

SyntaxCheckPlugin.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,23 @@ def run(self):
112112
def update_status(self, count=0):
113113
if self.done:
114114
return
115-
num = count % 4
116-
if num == 3:
117-
num = 1
118-
num += 1
119-
msg = 'Rust check running' + '.' * num
120-
self.window.status_message(msg)
121-
sublime.set_timeout(lambda: self.update_status(count + 1), 200)
115+
116+
status_msg = util.get_setting('rust_message_status_bar_msg')
117+
status_chars = util.get_setting('rust_message_status_bar_chars')
118+
status_update_delay = util.get_setting('rust_message_status_bar_update_delay')
119+
120+
try:
121+
status_chars_len = len(status_chars)
122+
num = count % status_chars_len
123+
if num == status_chars_len - 1:
124+
num = -1
125+
num += 1
126+
127+
self.window.status_message(status_msg + status_chars[num])
128+
sublime.set_timeout(lambda: self.update_status(count + 1), status_update_delay)
129+
except Exception as e:
130+
self.window.status_message('Error setting status text!')
131+
log.critical(self.window, "An error occurred setting status text: " + str(e))
122132

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

0 commit comments

Comments
 (0)