Skip to content

Commit

Permalink
Show freeze time when output is frozen.
Browse files Browse the repository at this point in the history
  • Loading branch information
ferbncode committed Mar 4, 2018
1 parent de5325a commit 7ed9cbb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
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

0 comments on commit 7ed9cbb

Please sign in to comment.