MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _scroll_output

Method _scroll_output

tensorflow/python/debug/cli/curses_ui.py:1316–1391  ·  view source on GitHub ↗

Scroll the output pad. Args: direction: _SCROLL_REFRESH, _SCROLL_UP, _SCROLL_DOWN, _SCROLL_UP_A_LINE, _SCROLL_DOWN_A_LINE, _SCROLL_HOME, _SCROLL_END, _SCROLL_TO_LINE_INDEX line_index: (int) Specifies the zero-based line index to scroll to. Applicable only if directio

(self, direction, line_index=None)

Source from the content-addressed store, hash-verified

1314 self._max_x - 1)
1315
1316 def _scroll_output(self, direction, line_index=None):
1317 """Scroll the output pad.
1318
1319 Args:
1320 direction: _SCROLL_REFRESH, _SCROLL_UP, _SCROLL_DOWN, _SCROLL_UP_A_LINE,
1321 _SCROLL_DOWN_A_LINE, _SCROLL_HOME, _SCROLL_END, _SCROLL_TO_LINE_INDEX
1322 line_index: (int) Specifies the zero-based line index to scroll to.
1323 Applicable only if direction is _SCROLL_TO_LINE_INDEX.
1324
1325 Raises:
1326 ValueError: On invalid scroll direction.
1327 TypeError: If line_index is not int and direction is
1328 _SCROLL_TO_LINE_INDEX.
1329 """
1330
1331 if not self._output_pad:
1332 # No output pad is present. Do nothing.
1333 return
1334
1335 if direction == _SCROLL_REFRESH:
1336 pass
1337 elif direction == _SCROLL_UP:
1338 # Scroll up.
1339 self._output_pad_row -= int(self._output_num_rows / 3)
1340 if self._output_pad_row < 0:
1341 self._output_pad_row = 0
1342 elif direction == _SCROLL_DOWN:
1343 # Scroll down.
1344 self._output_pad_row += int(self._output_num_rows / 3)
1345 if (self._output_pad_row >
1346 self._output_pad_height - self._output_pad_screen_height - 1):
1347 self._output_pad_row = (
1348 self._output_pad_height - self._output_pad_screen_height - 1)
1349 elif direction == _SCROLL_UP_A_LINE:
1350 # Scroll up a line
1351 if self._output_pad_row - 1 >= 0:
1352 self._output_pad_row -= 1
1353 elif direction == _SCROLL_DOWN_A_LINE:
1354 # Scroll down a line
1355 if self._output_pad_row + 1 < (
1356 self._output_pad_height - self._output_pad_screen_height):
1357 self._output_pad_row += 1
1358 elif direction == _SCROLL_HOME:
1359 # Scroll to top
1360 self._output_pad_row = 0
1361 elif direction == _SCROLL_END:
1362 # Scroll to bottom
1363 self._output_pad_row = (
1364 self._output_pad_height - self._output_pad_screen_height - 1)
1365 elif direction == _SCROLL_TO_LINE_INDEX:
1366 if not isinstance(line_index, int):
1367 raise TypeError("Invalid line_index type (%s) under mode %s" %
1368 (type(line_index), _SCROLL_TO_LINE_INDEX))
1369 self._output_pad_row = line_index
1370 else:
1371 raise ValueError("Unsupported scroll mode: %s" % direction)
1372
1373 self._nav_history.update_scroll_position(self._output_pad_row)

Callers 5

_dispatch_commandMethod · 0.95
_on_textbox_keypressMethod · 0.95
_display_outputMethod · 0.95
_display_candidatesMethod · 0.95

Calls 7

typeFunction · 0.85

Tested by

no test coverage detected