pudb
pudb copied to clipboard
Display the source file name
When I don't know which file I am looking at, I use "L" to see the file name. Pudb could display the name in the title of the source pane.
That's a whole row of characters down the tube though. I appreciate every row not occupied by UI, especially on size-constrained displays. Plus I'm not that often disoriented about where I am, but then I'm mostly debugging my own code. I could see it as an option, maybe.
I wasn't going to use a new row, I would add it to the very top row, which has a lot of space left.
The top row seems pretty full if you have a smaller terminal (isn't the default on most systems 80 characters wide?). The row the says "command line" is pretty empty, though.
Agree that the top row is pretty full. That "command line" line should probably be removed (rather than cluttered up more).
Then again, if you run PuDB fullscreen (like I do and I'm guessing @nedbat does) there is plenty of room at the top. So it could be added there, but only visible for people willing to make their terminals wide enough.
That'd be good, but it's a little nontrivial to achieve in Urwid. (i.e. you're writing a custom Widget at that point)
This might be controversial, but I don't think the top line needs as much help as it offers. "PuDB - ?:help" would be enough.
I could go along with that.
I mean only visible in the sense of what it already does now (truncate the top line).
Oh nevermind, it doesn't truncate. I misremembered.
I agree with @nedbat about preferring the top line to only have the "? - help" tip, and to include the current file name/path. I would suggest by default it display N chars from the end of the abspath of the current filename, where N is determined by an algorithm fed by a $COLUMNS from the shell, plus sidebar_width from the current pudb.conf settings. I prefer this solution to peer into the stack window for current filename.
That's a whole row of characters down the tube though
Even as an option would be great - jumping around in large codebases I frequently have to open the L dialog just to see where I am, would be great if that could be seen at a glance
Having an option for this would be amazing. Anyone who's navigating up and down the stack will appreciate this. This is especially useful if you're trying to debug inheritance problems in a large code base.
"L" does not work in the Stack so you have to go back and forth between the stack and the main window to see which file you're looking at.
This is fantastic idea and love the filename being displayed!
I am experimenting with this and at a glance it looks quite easy.
The content of the top row is in this caption variable. We can get the current filename from DebuggerUI.source_code_provider.get_source_identifier() if I'm not mistaken.
From there other things like dynamic caption length computed from $COLUMNS, this feature being optional,... can be done quickly.
If it doesn't cost vertical real estate (which can be precious in row-constrained terminals), I'm OK with having this added.
I got it to display the full path to current source file. However, if the path is too long to be displayed in 1 row, it will wrap automatically, creating more rows. If we somehow have enough more space (by resizing the window, for example), a Ctrl-L will redraw it into 1 row.

What do we want to do?
The wrapping is kind of what I wanted to avoid. urwid.Text has a wrap="ellipsis" mode, which may help enforce the single-line requirement. It'll probably clip the most interesting part though (the actual filename). Maybe we can start by only showing the filename? AFAICT, a better solution would require us to write a custom widget.
I just tried all the wrap options of urwid.Text and none looks promising.
I think we can:
- show only the filename
- show as much of the full path as possible on 1 line("/.../dirA/subdir/foo.py"). This will help providing more context. We can start from root or from an arbitrary dir ("dirA/subdir/foo.py" instead)
- have a config in the config file for this
none looks promising.
Why? Can you explain?
show only the filename
I think this with ellipsis clipping would be my preferred "cheap" solution.
show as much of the full path as possible on 1 line
How would we know?
have a config in the config file for this
Nah. This is a solvable problem. We don't need to involve the user.
none looks promising.
Why? Can you explain?
show only the filename
I think this with
ellipsisclipping would be my preferred "cheap" solution.show as much of the full path as possible on 1 line
How would we know?
have a config in the config file for this
Nah. This is a solvable problem. We don't need to involve the user.
- In the wrap options:
spaceandanywill wrap.clipandellipsiswon't wrap but will cut out the ending, which is what we actually want. - Like above.
- I think we can calculate this based on current available horizontal space. A quick google shows shutil.get_terminal_size()
- My reason is that in most(or many) cases, people are working with enough screen space to display full path. So we can have a default and still let users decide based on their use cases.
Point 3 and 4 may be because of my overthinking though. Just let me know what we decide.
Edit: In point 2, do you mean show the filename and ellipsis the path to parent dir?
I updated the PR so that: if there is enough width: display the full path, else display the longest possible path.
If the terminal size changes, PuDB will update the path automatically.
I agree this. Without this functionality, I have to use ctrl + x then manually print __file__ to see the full path of current file- -
You can just use Shift + L, too.
- show as much of the full path as possible on 1 line("/.../dirA/subdir/foo.py"). This will help providing more context. We can start from root or from an arbitrary dir ("dirA/subdir/foo.py" instead)
good idea imo.
and I think we'd not display it in the title of the source pane, because it will overwrite the help information especially ?:help, I used to learn pudb by pressing ?
another option is to display the filename (with as much of the full path as possible) at the line between the source pane and command line pane by replacing "Command line: [Ctrl-X]", just like the behavior of cgdb.
It is currently not shown in the main window to save lines. Type [shift-L] to see the complete path, then [right arrow][enter] to go back.