##// END OF EJS Templates
If running under Python 2.5, ibrowse now properly handles terminal resizing.
walter.doerwald -
Show More
@@ -1,6 +1,6 b''
1 # -*- coding: iso-8859-1 -*-
1 # -*- coding: iso-8859-1 -*-
2
2
3 import curses, textwrap
3 import curses, fcntl, signal, struct, tty, textwrap
4
4
5 import astyle, ipipe
5 import astyle, ipipe
6
6
@@ -864,6 +864,9 b' class ibrowse(ipipe.Display):'
864 # e.g. normal browsing or entering an argument for a command
864 # e.g. normal browsing or entering an argument for a command
865 self.mode = "default"
865 self.mode = "default"
866
866
867 # set by the SIGWINCH signal handler
868 self.resized = False
869
867 def nextstepx(self, step):
870 def nextstepx(self, step):
868 """
871 """
869 Accelerate horizontally.
872 Accelerate horizontally.
@@ -1300,6 +1303,9 b' class ibrowse(ipipe.Display):'
1300
1303
1301 self.enter(_BrowserHelp(self), "default")
1304 self.enter(_BrowserHelp(self), "default")
1302
1305
1306 def sigwinchhandler(self, signal, frame):
1307 self.resized = True
1308
1303 def cmd_hideattr(self):
1309 def cmd_hideattr(self):
1304 level = self.levels[-1]
1310 level = self.levels[-1]
1305 if level.displayattr[0] is None:
1311 if level.displayattr[0] is None:
@@ -1558,6 +1564,20 b' class ibrowse(ipipe.Display):'
1558 # Check keyboard
1564 # Check keyboard
1559 while True:
1565 while True:
1560 c = scr.getch()
1566 c = scr.getch()
1567 if self.resized:
1568 size = fcntl.ioctl(0, tty.TIOCGWINSZ, "12345678")
1569 size = struct.unpack("4H", size)
1570 oldsize = scr.getmaxyx()
1571 scr.erase()
1572 curses.resize_term(size[0], size[1])
1573 newsize = scr.getmaxyx()
1574 scr.erase()
1575 for l in self.levels:
1576 l.mainsizey += newsize[0]-oldsize[0]
1577 l.moveto(l.curx, l.cury, refresh=True)
1578 scr.refresh()
1579 self.resized = False
1580 break # Redisplay
1561 if self.mode in self.prompts:
1581 if self.mode in self.prompts:
1562 if self.prompts[self.mode].handlekey(self, c):
1582 if self.prompts[self.mode].handlekey(self, c):
1563 break # Redisplay
1583 break # Redisplay
@@ -1596,4 +1616,11 b' class ibrowse(ipipe.Display):'
1596 self.scr = None
1616 self.scr = None
1597
1617
1598 def display(self):
1618 def display(self):
1599 return curses.wrapper(self._dodisplay)
1619 if hasattr(curses, "resize_term"):
1620 oldhandler = signal.signal(signal.SIGWINCH, self.sigwinchhandler)
1621 try:
1622 return curses.wrapper(self._dodisplay)
1623 finally:
1624 signal.signal(signal.SIGWINCH, oldhandler)
1625 else:
1626 return curses.wrapper(self._dodisplay)
@@ -1,3 +1,8 b''
1 2006-06-19 Walter Doerwald <walter@livinglogic.de>
2
3 * IPython/Extensions/ibrowse.py: ibrowse now properly handles terminal
4 resizing. This requires Python 2.5 to word.
5
1 2006-06-16 Walter Doerwald <walter@livinglogic.de>
6 2006-06-16 Walter Doerwald <walter@livinglogic.de>
2
7
3 * IPython/Extensions/ibrowse.py: Add two new commands to
8 * IPython/Extensions/ibrowse.py: Add two new commands to
General Comments 0
You need to be logged in to leave comments. Login now