The Window classes defined in both src/viewer/size_window.py and src/viewer/cursor_const.py accept user input to determine the size of the drawable area. If no input is given curses.LINES and curses.COLS are used instead.
If the user unwittingly provides a size input which is larger than the available area and tries to draw into that area, the curses raises an error. Example (assuming 15 lines are actually available):
$ python3 cursor_const.py 16 log.txt 20 15
Traceback (most recent call last):
File "/Users/diyartaskiran/*/SDXPY/src/viewer/cursor_const.py", line 36, in <module>
curses.wrapper(lambda stdscr: main(stdscr, size, lines))
File "/Users/diyartaskiran/anaconda3/envs/softwareconstruction/lib/python3.11/curses/__init__.py", line 94, in wrapper
return func(stdscr, *args, **kwds)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/diyartaskiran/*/SDXPY/src/viewer/cursor_const.py", line 36, in <lambda>
curses.wrapper(lambda stdscr: main(stdscr, size, lines))
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/diyartaskiran/*/SDXPY/src/viewer/cursor_const.py", line 28, in main
window.draw(lines)
File "/Users/diyartaskiran/*/SDXPY/src/viewer/cursor_const.py", line 23, in draw
self._screen.addstr(y, 0, line[:self._size[COL]])
_curses.error: addwstr() returned ERR
In both classes, this is easily changed by accepting at mostcurses.LINES and curses.COLS as window size.
Note: this issue may also extend into the Window classes defined in src/undo, but I have not been able to look into that yet.
The
Window
classes defined in bothsrc/viewer/size_window.py
andsrc/viewer/cursor_const.py
accept user input to determine the size of the drawable area. If no input is givencurses.LINES
andcurses.COLS
are used instead.If the user unwittingly provides a size input which is larger than the available area and tries to draw into that area, the
curses
raises an error. Example (assuming 15 lines are actually available):In both classes, this is easily changed by accepting at most
curses.LINES
andcurses.COLS
as window size.Note: this issue may also extend into the
Window
classes defined insrc/undo
, but I have not been able to look into that yet.