diff options
author | mathieui <mathieui@mathieui.net> | 2014-04-14 20:56:05 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2014-04-14 20:56:05 +0200 |
commit | 245f5f050cd1b72f365a21c57d3462ed5207e0cc (patch) | |
tree | 5b1c703dc6db66d40859c5b98ffdf8cc854e1d18 /src | |
parent | b884e6d6e2ca7365d6a93482d211892fa141077e (diff) | |
download | poezio-245f5f050cd1b72f365a21c57d3462ed5207e0cc.tar.gz poezio-245f5f050cd1b72f365a21c57d3462ed5207e0cc.tar.bz2 poezio-245f5f050cd1b72f365a21c57d3462ed5207e0cc.tar.xz poezio-245f5f050cd1b72f365a21c57d3462ed5207e0cc.zip |
Fix #2422 (traceback in input) (also #2431)
now the scroll is made with 1/3 of the input size every time instead of
fixed offsets
Diffstat (limited to 'src')
-rw-r--r-- | src/windows.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/windows.py b/src/windows.py index cb1ccefc..81c772f1 100644 --- a/src/windows.py +++ b/src/windows.py @@ -1648,20 +1648,23 @@ class Input(Win): cursor moved and would now be out of the view, we adapt the view_pos so that we can always see our cursor) """ + # start of the input if self.pos == 0: self.view_pos = 0 return + # cursor outside of the screen (left) if self.pos < self.view_pos: - if self.width <= 25: - self.view_pos = self.pos - self.width - else: - self.view_pos = self.pos - 25 - if self.pos >= self.view_pos + self.width - 1: - self.view_pos = self.pos - self.width + 12 + self.view_pos = self.pos - max(1 * self.width // 3, 1) + # cursor outside of the screen (right) + elif self.pos >= self.view_pos + self.width - 1: + self.view_pos = self.pos - max(2 * self.width // 3, 2) + if self.view_pos < 0: self.view_pos = 0 + + assert(self.pos > self.view_pos and - self.pos < self.view_pos + self.width) + self.pos < self.view_pos + max(self.width, 3)) def refresh(self): log.debug('Refresh: %s', self.__class__.__name__) |