Created
August 20, 2016 13:45
-
-
Save Arc0re/5a79160cd85c007b981046054e03a177 to your computer and use it in GitHub Desktop.
Sublime Text 3 plugin to display total line count of a file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sublime, sublime_plugin, time | |
last_change = time.time() | |
update_interval = 1.5 # s | |
class DisplayLineCount(sublime_plugin.EventListener): | |
def update_line_count(self, view): | |
line_count = view.rowcol(view.size())[0] + 1 | |
view.set_status("line_count", "{0} lines".format(line_count)) | |
def on_modified(self, view): | |
global last_change | |
current_change = time.time() | |
# Check if we haven't embedded the change in the last update | |
if current_change > last_change + update_interval: | |
last_change = current_change | |
sublime.set_timeout(lambda: self.update_line_count(view), | |
int(update_interval * 1000)) | |
on_post_save_async = update_line_count | |
on_modified_async = update_line_count | |
on_activated_async = update_line_count |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment