Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show time when output was frozen. #99

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pg_view/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def poll_keys(screen, output):
flags.display_units = flags.display_units is False
if c == ord('f'):
flags.freeze = flags.freeze is False
output.freeze_time = time.localtime() if flags.freeze else None
if c == ord('s'):
flags.filter_aux = flags.filter_aux is False
if c == ord('h'):
Expand Down
16 changes: 16 additions & 0 deletions pg_view/models/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def __init__(self, screen):
self.output_order = []
self.show_help = False
self.is_color_supported = True
self.freeze_time = None

self._init_display()

Expand Down Expand Up @@ -119,6 +120,7 @@ def refresh(self):
self.help()
# show clock if possible
self.show_clock()
self.show_freeze_time()
self.show_help_bar()
self.screen.refresh()
self.output_order = []
Expand Down Expand Up @@ -186,6 +188,20 @@ def show_clock(self):
clock_str = time.strftime(self.CLOCK_FORMAT, time.localtime())
self.screen.addnstr(0, self.screen_x - clock_str_len, clock_str, clock_str_len)

def show_freeze_time(self):
if not self.freeze_time:
return
freeze_time_len = len("Frozen at: ") + len(self.CLOCK_FORMAT)
clean = True
for pos in range(0, freeze_time_len):
x = self.screen.inch(1, self.screen_x - freeze_time_len - 1 + pos) & 255
if x != ord(' '):
clean = False
break
if clean:
freeze_time_str = "Frozen at: " + time.strftime(self.CLOCK_FORMAT, self.freeze_time)
self.screen.addnstr(1, self.screen_x - freeze_time_len, freeze_time_str, freeze_time_len)

def _status_to_color(self, status, highlight):
if status == COLSTATUS.cs_critical:
return self.COLOR_CRITICAL
Expand Down