From d0e56912638b2a90bb960574ceb5c0bbbf415aca Mon Sep 17 00:00:00 2001 From: hut Date: Mon, 17 May 2010 18:52:51 +0200 Subject: utf: partial fix of console width overflow handling --- ranger/gui/widgets/console.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ranger/gui/widgets/console.py b/ranger/gui/widgets/console.py index 48116187..3bb41482 100644 --- a/ranger/gui/widgets/console.py +++ b/ranger/gui/widgets/console.py @@ -99,8 +99,9 @@ class Console(Widget): self.win.erase() self.addstr(0, 0, self.prompt) - overflow = -self.wid + len(self.prompt) + len(self.line) + 1 + overflow = -self.wid + len(self.prompt) + uwid(self.line) + 1 if overflow > 0: + #XXX: cut uft-char-wise, consider width self.addstr(self.line[overflow:]) else: self.addstr(self.line) @@ -223,6 +224,7 @@ class Console(Widget): def move(self, **keywords): direction = Direction(keywords) if direction.horizontal(): + # Ensure that the pointer is moved utf-char-wise uc = uchars(self.line) upos = len(uchars(self.line[:self.pos])) newupos = direction.move( @@ -268,6 +270,7 @@ class Console(Widget): if not self.line: self.close() return + # Delete utf-char-wise uc = uchars(self.line) upos = len(uchars(self.line[:self.pos])) + mod left_part = ''.join(uc[:upos]) -- cgit 1.4.1-2-gfad0