Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resize #7

Merged
merged 4 commits into from
Jul 28, 2011
Merged

Resize #7

merged 4 commits into from
Jul 28, 2011

Conversation

asmeurer
Copy link
Collaborator

This lets you resize the height of the variables, stack, and breakpoints lists. See the commit messages for more details, but basically you just enter the one you want to resize and press [ to make it grow and ] to make it shrink.

lists

For now, you do it by selecting the list you want to grow/shrink and
pressing [ to grow and ] to shrink, but this can easily be changed.
This uses proportional growing/shrinking, just like the vertical -/+
does, i.e., [ multiplies the weight by 1.25 and ] divides the weight by
1.25.  This perhaps should be changed, as it feels a little awkward,
though the "weight" part of it is hard-coded into urwin, and changing
that would not be easy. On the other hand, this isn't too hard to get
used to, and it's pretty easy to get the sizes you want.

All sizes are saved in the configuration file and reloaded in future
uses.  So technically, a picky user could set any weight he wants to
suit his needs.
@asmeurer
Copy link
Collaborator Author

Hold on, there's a bug where it fails if you shrink one of the lists down to 0 columns.

@inducer inducer merged commit ab6139d into inducer:master Jul 28, 2011
@inducer
Copy link
Owner

inducer commented Jul 28, 2011

Cleaned up, merged. Thanks!

@asmeurer
Copy link
Collaborator Author

This shouldn't have been merged. There is an issue. You can make one of the boxes so small so that you can't see anything in it, and then if you select it and press down arrow, it fails.

Oh, and you forgot to mention the new theme in the release notes.

@asmeurer
Copy link
Collaborator Author

I'm not sure how to fix it. get_item_rows supposedly shows you how many rows a widget takes up, but sometimes it lies and says 2 when it is really 1, and for some reason, even if I set a limit at 2 it still sometimes gets too small.

Perhaps I should approach this from the other side and make downarrow work even when nothing is visible.

@inducer
Copy link
Owner

inducer commented Jul 28, 2011

Oh well, it's in now. Let's try and fix it.

FWIW, down-arrow works for me even when nothing is visible--i.e. it activates an invisible box. (Urwid 0.9.9.2)

A less-than-elegant fix would be a 'reset sidebar box sizes' button in the prefs.

@asmeurer
Copy link
Collaborator Author

Actually, I'm inclined to say that this is a urwid bug. I have 0.9.9.1. Let me see if upgrading fixes it. Here is the full traceback:

---------------------------------------------------------------------------
ListBoxError                              Traceback (most recent call last)

/Users/aaronmeurer/Documents/pudb/<ipython console> in <module>()

/sw/lib/python2.7/site-packages/IPython/Prompts.pyc in __call__(self, arg)
    518         self.prompt_out.set_colors()
    519 
--> 520     def __call__(self,arg=None):
    521         """Printing with history cache management.
    522 

/sw/lib/python2.7/bdb.pyc in trace_dispatch(self, frame, event, arg)
     48             return self.dispatch_line(frame)
     49         if event == 'call':
---> 50             return self.dispatch_call(frame, arg)
     51         if event == 'return':
     52             return self.dispatch_return(frame, arg)

/sw/lib/python2.7/bdb.pyc in dispatch_call(self, frame, arg)
     77             # No need to trace this function

     78             return # None
---> 79         self.user_call(frame, arg)
     80         if self.quitting: raise BdbQuit
     81         return self.trace_dispatch

/Users/aaronmeurer/Documents/pudb/pudb/debugger.pyc in user_call(self, frame, argument_list)
    211             return
    212         if self.stop_here(frame):
--> 213             self.interaction(frame)
    214 
    215     def user_line(self, frame):

/Users/aaronmeurer/Documents/pudb/pudb/debugger.pyc in interaction(self, frame, exc_tuple)
    200         self.set_frame_index(index)
    201 
--> 202         self.ui.call_with_ui(self.ui.interaction, exc_tuple)
    203 
    204     def get_stack_situation_id(self):

/Users/aaronmeurer/Documents/pudb/pudb/debugger.pyc in call_with_ui(self, f, *args, **kwargs)
   1165         self.show()
   1166         try:
-> 1167             return f(*args, **kwargs)
   1168         finally:
   1169             self.hide()

/Users/aaronmeurer/Documents/pudb/pudb/debugger.pyc in interaction(self, exc_tuple)
   1271 
   1272         self.caption.set_text(caption)
-> 1273         self.event_loop()
   1274 
   1275     def set_current_file(self, fname):

/Users/aaronmeurer/Documents/pudb/pudb/debugger.pyc in event_loop(self, toplevel)
   1233                         self.size = self.screen.get_cols_rows()
   1234                     else:
-> 1235                         toplevel.keypress(self.size, k)
   1236 
   1237             return self.quit_event_loop

/Users/aaronmeurer/Documents/pudb/pudb/ui_tools.pyc in keypress(self, size, key)
     80 
     81     def keypress(self, size, key):
---> 82         result = self._w.keypress(size, key)
     83 
     84         if result is not None:

/sw/lib/python2.7/site-packages/urwid-0.9.9.1-py2.7-macosx-10.6-x86_64.egg/urwid/container.pyc in keypress(self, size, key)
    612         if not self.body.selectable():
    613             return key
--> 614         return self.body.keypress( (maxcol, remaining), key )
    615 
    616 

/sw/lib/python2.7/site-packages/urwid-0.9.9.1-py2.7-macosx-10.6-x86_64.egg/urwid/container.pyc in keypress(self, size, key)
   1331             'cursor page up', 'cursor page down'):
   1332             self.pref_col = None
-> 1333         key = w.keypress( (mc,)+size[1:], key )
   1334 
   1335         if command_map[key] not in ('cursor left', 'cursor right'):

/sw/lib/python2.7/site-packages/urwid-0.9.9.1-py2.7-macosx-10.6-x86_64.egg/urwid/container.pyc in keypress(self, size, key)
    893         if self.focus_item.selectable():
    894             tsize = self.get_item_size(size,i,True,item_rows)
--> 895             key = self.focus_item.keypress( tsize, key )
    896             if command_map[key] not in ('cursor up', 'cursor down'):
    897                 return key

/sw/lib/python2.7/site-packages/urwid-0.9.9.1-py2.7-macosx-10.6-x86_64.egg/urwid/container.pyc in keypress(self, size, key)
    893         if self.focus_item.selectable():
    894             tsize = self.get_item_size(size,i,True,item_rows)
--> 895             key = self.focus_item.keypress( tsize, key )
    896             if command_map[key] not in ('cursor up', 'cursor down'):
    897                 return key

/Users/aaronmeurer/Documents/pudb/pudb/ui_tools.pyc in keypress(self, size, key)
     80 
     81     def keypress(self, size, key):
---> 82         result = self._w.keypress(size, key)
     83 
     84         if result is not None:

/sw/lib/python2.7/site-packages/urwid-0.9.9.1-py2.7-macosx-10.6-x86_64.egg/urwid/listbox.pyc in keypress(self, size, key)
    750 
    751         if command_map[key] == 'cursor down':
--> 752             return self._keypress_down((maxcol, maxrow))
    753 
    754         if command_map[key] == 'cursor page up':

/sw/lib/python2.7/site-packages/urwid-0.9.9.1-py2.7-macosx-10.6-x86_64.egg/urwid/listbox.pyc in _keypress_down(self, size)
    886             if widget is None:
    887                 self.shift_focus((maxcol,maxrow), 
--> 888                     row_offset-rows)
    889                 return
    890             # FIXME: catch this bug in testcase


/sw/lib/python2.7/site-packages/urwid-0.9.9.1-py2.7-macosx-10.6-x86_64.egg/urwid/listbox.pyc in shift_focus(self, size, offset_inset)
    546             tgt_rows = target.rows( (maxcol,), True )
    547             if offset_inset + tgt_rows <= 0:
--> 548                 raise ListBoxError, "Invalid offset_inset: %s, only %s rows in target!" %(`offset_inset`, `tgt_rows`)
    549             self.offset_rows = 0
    550             self.inset_fraction = (-offset_inset,tgt_rows)

ListBoxError: Invalid offset_inset: -1, only 1 rows in target!

You reproduce it by shrinking one of the boxes (say variables) down completely, which requires growing the other boxes, and then selecting that box (v) and pressing down arrow.

By the way, one thing I noticed that we need to do is normalize the weights. They tend to grow very small, and if you resize enough times, they will eventually go to 0 due to floating point precision. But this is trivial to fix, and I will submit a patch for it.

@asmeurer
Copy link
Collaborator Author

Nope, it still does it in urwid 0.9.9.2. Here's a screenshot, so you know what I'm talking about:

If you press down arrow from here (notice that "Variables" is highlighted), it gives the above strack trace.

@asmeurer
Copy link
Collaborator Author

Actually, never mind about normalization. That was only necessary when I tried to use the column size as a limit, not 1/5 < width < 5, which obviously will never get too small or too big :)

@asmeurer
Copy link
Collaborator Author

I just tried the git version of urwid, and the problem does not exist there.

@inducer
Copy link
Owner

inducer commented Jul 29, 2011

So, ok to keep this closed?

@asmeurer
Copy link
Collaborator Author

Yes. This is clearly an urwid bug, and I for one have no problem running the dev version as a work around.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants