aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/python/debug
diff options
context:
space:
mode:
authorGravatar Shanqing Cai <cais@google.com>2018-03-20 08:08:48 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-03-20 08:16:41 -0700
commit222c2b858fb1722f9aaf45e780b08e505e845665 (patch)
treebb006e5e165167c7ba89fe1a841f06ea111a38fe /tensorflow/python/debug
parenta40c8024f9beec346c2c1d98e9238c5d48ea0dca (diff)
tfdbg: Curses CLI: Fill line-end whitespace with default color pair
to prevent spurious color pairs from appearing in certain text terminal environments. RELNOTES: Bug fix: tfdbg curses CLI: fix spurious background colors in some text terminals. PiperOrigin-RevId: 189742433
Diffstat (limited to 'tensorflow/python/debug')
-rw-r--r--tensorflow/python/debug/cli/curses_ui.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tensorflow/python/debug/cli/curses_ui.py b/tensorflow/python/debug/cli/curses_ui.py
index bb52f90512..f66cefb427 100644
--- a/tensorflow/python/debug/cli/curses_ui.py
+++ b/tensorflow/python/debug/cli/curses_ui.py
@@ -1185,6 +1185,22 @@ class CursesUI(base_ui.BaseUI):
self._main_menu = None
self._main_menu_pad = None
+ def _pad_line_end_with_whitespace(self, pad, row, line_end_x):
+ """Pad the whitespace at the end of a line with the default color pair.
+
+ Prevents spurious color pairs from appearing at the end of the lines in
+ certain text terimnals.
+
+ Args:
+ pad: The curses pad object to operate on.
+ row: (`int`) row index.
+ line_end_x: (`int`) column index of the end of the line (beginning of
+ the whitespace).
+ """
+ if line_end_x < self._max_x - 2:
+ pad.addstr(row, line_end_x, " " * (self._max_x - 3 - line_end_x),
+ self._default_color_pair)
+
def _screen_add_line_to_output_pad(self, pad, row, txt, color_segments=None):
"""Render a line in a text pad.
@@ -1208,6 +1224,7 @@ class CursesUI(base_ui.BaseUI):
if not color_segments:
pad.addstr(row, 0, txt, self._default_color_pair)
+ self._pad_line_end_with_whitespace(pad, row, len(txt))
return
if not isinstance(color_segments, list):
@@ -1248,6 +1265,8 @@ class CursesUI(base_ui.BaseUI):
for segment, color_pair in zip(all_segments, all_color_pairs):
if segment[1] < self._max_x:
pad.addstr(row, segment[0], txt[segment[0]:segment[1]], color_pair)
+ if all_segments:
+ self._pad_line_end_with_whitespace(pad, row, all_segments[-1][1])
def _screen_scroll_output_pad(self, pad, viewport_top, viewport_left,
screen_location_top, screen_location_left,