diff options
author | Yifei Feng <yifeif@google.com> | 2018-05-24 19:12:26 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-05-24 19:15:01 -0700 |
commit | b59833c3fd91511b33255369016868e4ae6cda2e (patch) | |
tree | ecbd70cfd3abb5d934f6eb4b7280a35e8589f5cf /tensorflow/python/debug | |
parent | 2b99d9cbc7166efedaff9eee11744348da30fc8a (diff) |
Merge changes from github.
Revert #18413. Too many internal test failures due to the name scope change caused by this change.
Revert #18192. Cannot use re2::StringPiece internally. Need alternative for set call. Will pull and clean this up in a separate change.
PiperOrigin-RevId: 197991247
Diffstat (limited to 'tensorflow/python/debug')
-rw-r--r-- | tensorflow/python/debug/cli/curses_ui.py | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/tensorflow/python/debug/cli/curses_ui.py b/tensorflow/python/debug/cli/curses_ui.py index f66cefb427..7b87972d69 100644 --- a/tensorflow/python/debug/cli/curses_ui.py +++ b/tensorflow/python/debug/cli/curses_ui.py @@ -190,8 +190,6 @@ class ScrollBar(object): return layout def get_click_command(self, mouse_y): - # TODO(cais): Support continuous scrolling when the mouse button is held - # down. if self._output_num_rows <= 1: return None elif mouse_y == self._min_y: @@ -271,6 +269,10 @@ class CursesUI(base_ui.BaseUI): _UI_WAIT_MESSAGE = "Processing..." + # The delay (in ms) between each update of the scroll bar when the mouse + # button is held down on the scroll bar. Controls how fast the screen scrolls. + _MOUSE_SCROLL_DELAY_MS = 100 + _single_instance_lock = threading.Lock() def __init__(self, on_ui_exit=None, config=None): @@ -855,7 +857,30 @@ class CursesUI(base_ui.BaseUI): except curses.error: mouse_event_type = None - if mouse_event_type == curses.BUTTON1_RELEASED: + if mouse_event_type == curses.BUTTON1_PRESSED: + # Logic for held mouse-triggered scrolling. + if mouse_x >= self._max_x - 2: + # Disable blocking on checking for user input. + self._command_window.nodelay(True) + + # Loop while mouse button is pressed. + while mouse_event_type == curses.BUTTON1_PRESSED: + # Sleep for a bit. + curses.napms(self._MOUSE_SCROLL_DELAY_MS) + scroll_command = self._scroll_bar.get_click_command(mouse_y) + if scroll_command in (_SCROLL_UP_A_LINE, _SCROLL_DOWN_A_LINE): + self._scroll_output(scroll_command) + + # Check to see if different mouse event is in queue. + self._command_window.getch() + try: + _, _, _, _, mouse_event_type = self._screen_getmouse() + except curses.error: + pass + + self._command_window.nodelay(False) + return x + elif mouse_event_type == curses.BUTTON1_RELEASED: # Logic for mouse-triggered scrolling. if mouse_x >= self._max_x - 2: scroll_command = self._scroll_bar.get_click_command(mouse_y) @@ -1677,4 +1702,7 @@ class CursesUI(base_ui.BaseUI): self._redraw_output() def _screen_set_mousemask(self): - curses.mousemask(self._mouse_enabled) + if self._mouse_enabled: + curses.mousemask(curses.BUTTON1_RELEASED | curses.BUTTON1_PRESSED) + else: + curses.mousemask(0) |