From 576fa44f9e42fca887d8ddcb709673151f7ed6e4 Mon Sep 17 00:00:00 2001 From: acheronfail Date: Thu, 15 Nov 2018 19:49:24 +1100 Subject: [PATCH] feat: add ability to customize status bar text --- RustEnhanced.sublime-settings | 9 +++++++++ SyntaxCheckPlugin.py | 24 +++++++++++++++++------- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/RustEnhanced.sublime-settings b/RustEnhanced.sublime-settings index 32b13dcf..220a33b3 100644 --- a/RustEnhanced.sublime-settings +++ b/RustEnhanced.sublime-settings @@ -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": { diff --git a/SyntaxCheckPlugin.py b/SyntaxCheckPlugin.py index f42ddd91..c4ba43d9 100755 --- a/SyntaxCheckPlugin.py +++ b/SyntaxCheckPlugin.py @@ -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