author | Alberto Bertogli
<albertito@blitiri.com.ar> 2011-11-16 21:05:57 UTC |
committer | Alberto Bertogli
<albertito@blitiri.com.ar> 2011-11-16 21:05:57 UTC |
parent | 7a2c90b3364e29b22e6bfbf2dc519257a44be2c9 |
msn | +14 | -6 |
diff --git a/msn b/msn index 2f50535..9a07a76 100755 --- a/msn +++ b/msn @@ -576,14 +576,21 @@ except: # doing this without using a C module. it's based on 'struct winsize', # but as we only use the first 4 bytes, we don't ask for more; then we # unpack the two shorts into (lenght, width) -try: - import struct - winsize = fcntl.ioctl(stdinfd, termios.TIOCGWINSZ, ' ' * 10) - winsize = struct.unpack('hh', winsize[:4]) -except: - winsize = (24, 80) +winsize = (24, 80) screenwidth = winsize[1] +def update_winsize(signo = -1, frame = None): + global winsize, screenwidth + try: + import struct + winsize = fcntl.ioctl(stdinfd, termios.TIOCGWINSZ, ' ' * 10) + winsize = struct.unpack('hh', winsize[:4]) + except: + screenwidth = winsize[1] + +update_winsize() + + # input buffer, where all the characters written by the user are stored in inbuf = '' @@ -881,6 +888,7 @@ def redraw_cli(): """Redraws the current prompt line, including user input; it first clears the line, either automatically or up to 'lenght' chars.""" global inbuf, screenwidth + update_winsize() clear_line() print_prompt() lenght = screenwidth - 7 # we subsctract the prompt lenght + 1