Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
npcole committed May 16, 2014
1 parent d043cfd commit e0e89ac
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
2 changes: 1 addition & 1 deletion TESTING-BufferPager.py
Expand Up @@ -10,7 +10,7 @@ def main(self):
F.wStatus1.value = "Status Line "
F.wStatus2.value = "Second Status Line "
F.wMain.editable = False
F.wMain.autowrap = True
F.wMain.autowrap = False

#F.wMain.buffer([str(r) for r in range(100)], scroll_if_editing=True)
#with open("/Users/nicholas/Downloads/pg2600.txt", 'r') as war_and_peace:
Expand Down
10 changes: 9 additions & 1 deletion build/lib/npyscreen/wgmultiline.py
Expand Up @@ -647,6 +647,14 @@ def _wrap_message_lines(self, message_lines, line_length):
lines.append('')
return lines

def resize(self):
super(Pager, self).resize()
#self.values = [str(self.width), str(self._my_widgets[0].width),]
if self.autowrap:
self.setValuesWrap(list(self.values))
if self.center:
self.centerValues()

def setValuesWrap(self, lines):
if self.autowrap and (lines == self._values_cache_for_wrapping):
return False
Expand All @@ -658,7 +666,7 @@ def setValuesWrap(self, lines):
self._values_cache_for_wrapping = self.values

def centerValues(self):
self.values = [ l.center(self.width-1) for l in self.values ]
self.values = [ l.strip().center(self.width-1) for l in self.values ]

def update(self, clear=True):
#we look this up a lot. Let's have it here.
Expand Down
10 changes: 8 additions & 2 deletions build/lib/npyscreen/wgwidget.py
Expand Up @@ -43,8 +43,14 @@ def handle_input(self, _input):
if _input in self.handlers:
self.handlers[_input](_input)
return True
if curses.ascii.unctrl(_input) in self.handlers:
self.handlers[curses.ascii.unctrl(_input)](_input)

try:
_unctrl_input = curses.ascii.unctrl(_input)
except TypeError:
_unctrl_input = None

if _unctrl_input and (_unctrl_input in self.handlers):
self.handlers[_unctrl_input](_input)
return True


Expand Down
10 changes: 9 additions & 1 deletion npyscreen/wgmultiline.py
Expand Up @@ -647,6 +647,14 @@ def _wrap_message_lines(self, message_lines, line_length):
lines.append('')
return lines

def resize(self):
super(Pager, self).resize()
#self.values = [str(self.width), str(self._my_widgets[0].width),]
if self.autowrap:
self.setValuesWrap(list(self.values))
if self.center:
self.centerValues()

def setValuesWrap(self, lines):
if self.autowrap and (lines == self._values_cache_for_wrapping):
return False
Expand All @@ -658,7 +666,7 @@ def setValuesWrap(self, lines):
self._values_cache_for_wrapping = self.values

def centerValues(self):
self.values = [ l.center(self.width-1) for l in self.values ]
self.values = [ l.strip().center(self.width-1) for l in self.values ]

def update(self, clear=True):
#we look this up a lot. Let's have it here.
Expand Down

0 comments on commit e0e89ac

Please sign in to comment.