Wrap #18

Merged
merged 10 commits into from Aug 10, 2011

Conversation

Projects
None yet
2 participants
Collaborator

asmeurer commented Aug 7, 2011

Enable wrapping of variables in the variables view

I also added an option for this, which made it easier for me to debug.
I haven't added it to the prefs yet.

TODO:

  • Add the option to the prefs.
  • Allow to turn on wrapping on a per-variable basis ('w' will turn this
    on and off in the variables, view, and there will also be an option
    in the variable inspection options window).
  • Right now, wrapped lines beyond the first line are indented two
    spaces. This is the same as what digging into a variable looks like,
    which make it confusing (granted, digging in still indents further,
    but it's harder to follow). I think variables that are sub variables
    should have some kind of character preceding them, like:
    varname: [1, 2, 3]
    + 0: 1
    + 1: 2
    + 2: 3
  • When variables are not wrapped, there should be an ellipses at the
    end. When unicode is supported, we can use , otherwise, we use ...

So this is not complete yet, though what is here is finished, so you can push this in if you want, or wait for me to finish the rest (which may very well be in a few hours).

This relies on pull #17, as that was making it difficult for me to work with pudb the way I wanted.

asmeurer added some commits Aug 7, 2011

@asmeurer asmeurer Fix bug in modules viewer caused by move from AttrWrap to AttrMap
The bug occurred when you tried to load a module.
0b91f29
@asmeurer asmeurer Enable wrapping of variables in the variables view
I also added an option for this, which made it easier for me to debug.
I haven't added it to the prefs yet.

TODO:

- Add the option to the prefs.

- Allow to turn on wrapping on a per-variable basis ('w' will turn this
  on and off in the variables,   view, and there will also be an option
  in the variable inspection options window).

- Right now, wrapped lines beyond the first line are indented two
  spaces.  This is the same as what digging into a variable looks like,
  which make it confusing (granted, digging in still indents further,
  but it's harder to follow).  I think variables that are sub variables
  should have some kind of character preceding them, like:

    varname: [1, 2, 3]
    + 0: 1
    + 1: 2
    + 2: 3

- When variables are not wrapped, there should be an ellipses at the
  end.  When unicode is supported, we can use …, otherwise, we use ...
8acd47d
Collaborator

asmeurer commented Aug 7, 2011

See also my comments on the mailing list.

asmeurer added some commits Aug 7, 2011

@asmeurer asmeurer Add variable wrapping to the prefs 4b0852f
@asmeurer asmeurer Remove 200 character limit on strings in the variables view
If someone wants to limit the length of the string, he should write a
custom stringifier to do it.
bf78b4a
@asmeurer asmeurer Fix * shortcut for displaying of private members in expanded vars view bbd9ef9
@asmeurer asmeurer Add w shortcut for toggling wrapping in the variables view cab1568
@asmeurer asmeurer Fix a bug where boolean settings set to True were set to "True" 2c56263
@asmeurer asmeurer Add a checkbox for wrapping to the Variable Inspection Options window b752666
@asmeurer asmeurer Print ellipsis at the end of an overlong unwrapped variable
This was supposed to use the unicode ellipsis (…) when possible, but
this does not work.  The behavior is very strange.  If you replace the
last character with …, it puts a ?.  If you replace the second to last
character, it replaces that *and* the last character with a ?.  If you
replace the third to last character, it works.  Therefore, for now, we
always just use ... (three dots) regardless of the console encoding.
e2507fb

inducer commented on e2507fb Aug 7, 2011

I like what you have. I didn't see any ellipses, and I'm not sure they're needed. Wrapping at word boundaries would be wicked nice, though. :)

Owner

asmeurer replied Aug 8, 2011

You didn't see any ellipses? That must be a bug. Note that it is only on when wrapping is off.

Also, note that I've disabled entirely the unicode ellipsis until I can figure it out (the if False line above).

@asmeurer asmeurer Make "| " the prefix before nested variables
I've factored this out into a single variable so that it's easy to
change to something else if you don't like it.
0f14175
Collaborator

asmeurer commented Aug 8, 2011

I went ahead and pushed a commit that recursively puts | before each nested variable. I made it easy to change or revert if you don't like it (indeed, the wrapping logic is completely agnostic to even the length of the prefix, so you can modify it however you like on a line by line basis if you want).

This is all I am going to do for this. Wrapping on word boundaries would be very difficult. Doing the normal wrapping was already hard enough, as you can see from the rather contorted logic in _get_text (this is mostly due to indenting of additional lines). Also, you have to get the attr variable exactly correct, or else it won't work at all. This would be more difficult if you wrapped at word boundaries, as the total length of the text would no longer be the same as the sum of the lengths of the lines (plus padding).

So if you want to give it a shot, go for it. I personally don't really use strings of text very often. My use case is SymPy variables, which have very long string representations, but don't exactly have "word boundaries".

Also, I should point out that not wrapping at word boundaries has advantages. You can see exactly what the string is, including spaces. If you wrap at word boundaries, you lose this information. Therefore, if you do decide to add it, you should add an option to disable it.

inducer merged commit 0f14175 into inducer:master Aug 10, 2011

Owner

inducer commented Aug 10, 2011

Thanks!

Collaborator

asmeurer commented Aug 11, 2011

Thanks!

Thank you for writing this awesome debugger. This has been a fun experience.

By the way, if we ever get unicode working, there's a nicer unicode symbol than |, which is . This fills the whole vertical space. It's what SymPy uses to pretty print lists, tuples, and large parentheses:

In [8]: [sin(1/x)/x, x]
Out[8]: 
⎡   ⎛1⎞   ⎤
⎢sin⎜─⎟   ⎥
⎢   ⎝x⎠   ⎥
⎢──────, x⎥
⎣  x      ⎦
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment