Ticket #1500: Fix-1500-Console-crashes-on-command-longer-than-term.patch

File Fix-1500-Console-crashes-on-command-longer-than-term.patch, 1.8 KB (added by Cas, 12 years ago)
  • deluge/ui/console/screen.py

    From 1706b0604baa4e4c9c1b274de95868d3e5c96256 Mon Sep 17 00:00:00 2001
    From: Calum Lind <calumlind+deluge@gmail.com>
    Date: Sat, 29 Jan 2011 12:37:19 +0000
    Subject: [PATCH 2/2] Fix #1500 - Console crashes on command longer than terminal width. This error is raised if the cursor is off screen and is supressed with try-except
    
    ---
     deluge/ui/console/screen.py |   16 +++++++++++++---
     1 files changed, 13 insertions(+), 3 deletions(-)
    
    diff --git a/deluge/ui/console/screen.py b/deluge/ui/console/screen.py
    index bf6b531..7ea7cb7 100644
    a b def add_string(self, row, string): 
    250250            if index + 1 == len(parsed): 
    251251                # This is the last string so lets append some " " to it 
    252252                s += " " * (self.cols - (col + len(s)) - 1) 
    253             self.stdscr.addstr(row, col, s, color) 
     253            try: 
     254                self.stdscr.addstr(row, col, s, color) 
     255            except curses.error: 
     256                pass 
     257 
    254258            col += len(s) 
    255259 
    256260    def refresh(self): 
    def refresh(self): 
    287291        self.add_string(self.rows - 1, self.input) 
    288292 
    289293        # Move the cursor 
    290         self.stdscr.move(self.rows - 1, self.input_cursor) 
     294        try: 
     295            self.stdscr.move(self.rows - 1, self.input_cursor) 
     296        except curses.error: 
     297            pass 
    291298        self.stdscr.redrawwin() 
    292299        self.stdscr.refresh() 
    293300 
    def _doRead(self): 
    426433 
    427434        # Update the input string on the screen 
    428435        self.add_string(self.rows - 1, self.input) 
    429         self.stdscr.move(self.rows - 1, self.input_cursor) 
     436        try: 
     437            self.stdscr.move(self.rows - 1, self.input_cursor) 
     438        except curses.error: 
     439            pass 
    430440        self.stdscr.refresh() 
    431441 
    432442    def close(self):