Sublime Forum

How to keep showing `Building` on the status bar

#1

Usually, I build project with taking about 30 seconds to finish, but I do not keep the output build panel open, then, I would like to know the build process has finished, when the Building message disappears from the status bar.

Currently, the Building message only appears for a few seconds and when the build has finished, it is showed back Finished building for a few seconds again.

Can the Building message keep showing until the build is finished?

This way I do not have to open the Console to check it because once the message disappears, it means the build process has finished.

Related threads:



0 Likes

#2

I did this patch, If someone know some improvement, feel free to share it

--- a/exec.py
+++ b/exec.py
@@ -323,7 +323,10 @@ class ExecCommand(sublime_plugin.WindowCommand, ProcessListener):
                 if not isinstance(cmd, str):
                     cmd_string = " ".join(cmd)
                 print("Running " + cmd_string)
-            sublime.status_message("Building")
+
+            for view in self.window.views():
+                view.set_status("output_exec_window%s" % self.window.id(), "Building...")
 
         show_panel_on_build = view_settings.get("show_panel_on_build", True)
         if show_panel_on_build:

@@ -439,7 +442,11 @@ class ExecCommand(sublime_plugin.WindowCommand, ProcessListener):
         if proc != self.proc:
             return
 
+        for view in self.window.views():
+            view.erase_status("output_exec_window%s" % self.window.id())
+
         errs = self.output_view.find_all_results()
0 Likes

#3

In reading your question I would have suggested a similar patch. Depending on your use case, you may want to also extend the event listener to apply the setting to newly opened tabs or loaded views as well, but that’s about the only thing I can think to add.

1 Like

#4

Thanks for sharing. I would not apply these extension to new tabs because I almost never open new tabs on this project. It is a Latex Project, so I mostly spend my time on the same files.

LatexTools has these features built-in for Latex, but I am not using LatexTools to build because I am building my document remotely (in a virtual machine running on my own computer), not on my local machine/host.

I am doing this because Latex on Linux build my whole project in ~60 seconds, while on my host machine (Windows 10), it build the project in ~120 seconds.

I use this script to do the remote build: (Makefile)

0 Likes

#5

I just created an alternate solution based on the Package Control’s one:

diff --git a/exec.py b/exec.py
index 353b8cb..f4b91ad 100644
--- a/exec.py
+++ b/exec.py
 
+class ThreadProgress():
+    """
+    Animates an indicator, [=   ], in the status area while a thread runs
+
+    Based on Package Control
+    https://github.com/wbond/package_control/blob/db53090bd0920ca2c58ef27f0361a4d7b096df0e/package_control/thread_progress.py
+
+    :param thread:
+        The thread to track for activity
+
+    :param message:
+        The message to display next to the activity indicator
+
+    :param success_message:
+        The message to display once the thread is complete
+    """
+    windows = {}
+    running = False
+
+    def __init__(self, message, success_message):
+        self.status_name = "output_build_view_"
+        self.message = message
+        self.success_message = success_message
+        self.addend = 1
+        self.size = 12
+        self.last_view = None
+        self.window = sublime.active_window()
+        self.windows[self.window.id()] = self
+        self.index = 0
+        if not self.running:
+            self.is_alive = True
+            self.running = True
+            sublime.set_timeout(lambda: self.run(), 100)
+
+    @classmethod
+    def stop(cls):
+        window_id = sublime.active_window().id()
+        if window_id in cls.windows:
+            progress = cls.windows[window_id]
+            progress.is_alive = False
+            del cls.windows[window_id]
+
+    def run(self):
+        active_view = self.window.active_view()
+        active_window_id = '%s%s' % ( self.status_name, self.window.id() )
+
+        if self.last_view is not None and active_view != self.last_view:
+            self.last_view.erase_status(active_window_id)
+            self.last_view = None
+
+        if not self.is_alive:
+            def cleanup():
+                active_view.erase_status(active_window_id)
+
+            active_view.set_status(active_window_id, self.success_message)
+            sublime.set_timeout(cleanup, 10000)
+
+            ThreadProgress.running = False
+            return
+
+        before = self.index % self.size
+        after = (self.size - 1) - before
+
+        active_view.set_status(active_window_id, '%s [%s=%s]' % (self.message, ' ' * before, ' ' * after))
+        if self.last_view is None:
+            self.last_view = active_view
+
+        if not after:
+            self.addend = -1
+
+        if not before:
+            self.addend = 1
+
+        self.index += self.addend
+        sublime.set_timeout(lambda: self.run(), 100)
+
+
 class ExecCommand(sublime_plugin.WindowCommand, ProcessListener):
     BLOCK_SIZE = 2**14
     text_queue = collections.deque()
@@ -325,8 +402,7 @@ class ExecCommand(sublime_plugin.WindowCommand, ProcessListener):
                 print("Running " + cmd_string)
 
-            for view in self.window.views():
-                view.set_status("output_exec_window%s" % self.window.id(), "Building...")
+            ThreadProgress("Building...", "Successfully Build the Project!")
 
         show_panel_on_build = view_settings.get("show_panel_on_build", True)
         if show_panel_on_build:
@@ -442,9 +518,7 @@ class ExecCommand(sublime_plugin.WindowCommand, ProcessListener):
         if proc != self.proc:
             return
 
-        for view in self.window.views():
-            view.erase_status("output_exec_window%s" % self.window.id())
-
+        ThreadProgress.stop()
         errs = self.output_view.find_all_results()
 
         if len(errs) == 0:
0 Likes

#6

FYI, we’re probably adding an implementation to sublime_lib. It’s largely modeled after the Package Control implementation.

2 Likes