tolstoyevsky / gits

Web-based terminal emulator
Apache License 2.0
7 stars 0 forks source link

Current implementation of `cub1` does much more than it's supposed to do #72

Closed eugulixes closed 7 years ago

eugulixes commented 7 years ago

According to the specification[1], cub1 moves the cursor left by 1 position. However, the current implementation of the capability moves the cursor one line up. Moreover, it has a bug: cub1 moves the cursor one line up when the cursor is not at the left-most position.

[1] http://pubs.opengroup.org/onlinepubs/7908799/xcurses/terminfo.html

dshil commented 7 years ago

ping @eugulixes,

Moreover, it has a bug: cub1 moves the cursor one line up when the cursor is not at the left-most position.

Could you please specify this moment. I think that the existing implementation doesn't have this bag.

self._cur_x = max(0, self._cur_x - 1) 
if self._cur_x == self._left_most: # we scroll up only when the cursor reaches the left most position
eugulixes commented 7 years ago

@dshil, this is the way how _cap_cub1 looked like

     def _cap_cub1(self):
         """Moves the cursor left by 1 position.

         Usually the method acts as a handler for a Backspace key-press.
         """
         self._cur_x = max(0, self._cur_x - 1)

         if self._cur_x == self._left_most:
             self._cur_x = self._right_most
             self._cur_y = max(0, self._cur_y - 1)
             self._eol = True

For example, _cur_x is 1 before calling _cap_cub1. Then, after calling _cap_cub1