fixed bug

--HG--
branch : pmacs2
This commit is contained in:
moculus 2007-07-29 03:08:42 +00:00
parent e0716c5d2c
commit 966ad5afc8
1 changed files with 16 additions and 9 deletions

View File

@ -382,15 +382,14 @@ class Application(object):
self.error_string = "" self.error_string = ""
self.error_timestamp = None self.error_timestamp = None
def resize_event(self): def resize_event(self):
self.y, self.x = self.stdscr.getmaxyx() (self.y, self.x) = self.stdscr.getmaxyx()
self.resize_slots() self.resize_slots()
def resize_slots(self): def resize_slots(self):
n = len(self.bufferlist.slots) n = len(self.bufferlist.slots)
assert n > 0 assert n > 0
x = self.x - 1 x = self.x - 1
y_sum = self.y - 1 - n y_sum = self.y - 1 - n
# XYZ this method seems broken self.bufferlist.resize(y_sum, x)
self.bufferlist.resize(x, y_sum)
# exit # exit
def exit(self): def exit(self):
@ -459,6 +458,9 @@ class Application(object):
if self.error_timestamp is not None and ERROR_TIMEOUT > 0 and \ if self.error_timestamp is not None and ERROR_TIMEOUT > 0 and \
time.time() - self.error_timestamp > ERROR_TIMEOUT: time.time() - self.error_timestamp > ERROR_TIMEOUT:
self.clear_error() self.clear_error()
(y, x) = self.stdscr.getmaxyx()
if y != self.y or x != self.x:
self.resize_event()
# clear the error line; it might look confusing to the user # clear the error line; it might look confusing to the user
try: try:
@ -477,11 +479,16 @@ class Application(object):
# full screen drawer # full screen drawer
def draw(self): def draw(self):
self.draw_slots() try:
self.draw_input_bar() self.draw_slots()
self.draw_cursor() self.draw_input_bar()
self.win.noutrefresh() self.draw_cursor()
curses.doupdate() self.win.noutrefresh()
curses.doupdate()
except:
# ok, so there was a problem...
# let's see if the screen changed sizes and if so, resize our slots
self.resize_event()
def draw_cursor(self): def draw_cursor(self):
if self.mini_active: if self.mini_active:
@ -526,7 +533,7 @@ class Application(object):
slot = self.bufferlist.slots[i] slot = self.bufferlist.slots[i]
self.draw_slot(i) self.draw_slot(i)
self.draw_status_bar(i) self.draw_status_bar(i)
def highlight_char(self, sy, sx, fg='default', bg='default'): def highlight_char(self, sy, sx, fg='default', bg='default'):
junk = self.win.inch(sy, sx) junk = self.win.inch(sy, sx)
char = junk & 255 char = junk & 255