pudb icon indicating copy to clipboard operation
pudb copied to clipboard

Display the source file name

Open nedbat opened this issue 9 years ago • 26 comments

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.

nedbat avatar Feb 04 '16 10:02 nedbat

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.

inducer avatar Feb 04 '16 14:02 inducer

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.

nedbat avatar Feb 04 '16 15:02 nedbat

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.

asmeurer avatar Feb 04 '16 15:02 asmeurer

Agree that the top row is pretty full. That "command line" line should probably be removed (rather than cluttered up more).

inducer avatar Feb 04 '16 16:02 inducer

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.

asmeurer avatar Feb 04 '16 16:02 asmeurer

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)

inducer avatar Feb 04 '16 16:02 inducer

This might be controversial, but I don't think the top line needs as much help as it offers. "PuDB - ?:help" would be enough.

nedbat avatar Feb 04 '16 16:02 nedbat

I could go along with that.

inducer avatar Feb 04 '16 16:02 inducer

I mean only visible in the sense of what it already does now (truncate the top line).

asmeurer avatar Feb 04 '16 16:02 asmeurer

Oh nevermind, it doesn't truncate. I misremembered.

asmeurer avatar Feb 04 '16 16:02 asmeurer

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.

timblaktu avatar Jun 14 '18 18:06 timblaktu

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

ndevenish avatar Jun 11 '19 10:06 ndevenish

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.

dkao1978 avatar Aug 01 '19 19:08 dkao1978

This is fantastic idea and love the filename being displayed!

TimothyBramlett avatar Dec 13 '19 04:12 TimothyBramlett

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.

qhuy4119 avatar Jul 12 '21 12:07 qhuy4119

If it doesn't cost vertical real estate (which can be precious in row-constrained terminals), I'm OK with having this added.

inducer avatar Jul 13 '21 11:07 inducer

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. Screenshot_20210713_195215

What do we want to do?

qhuy4119 avatar Jul 13 '21 13:07 qhuy4119

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.

inducer avatar Jul 13 '21 13:07 inducer

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

qhuy4119 avatar Jul 13 '21 13:07 qhuy4119

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.

inducer avatar Jul 13 '21 13:07 inducer

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.

  1. In the wrap options: space and any will wrap. clip and ellipsis won't wrap but will cut out the ending, which is what we actually want.
  2. Like above.
  3. I think we can calculate this based on current available horizontal space. A quick google shows shutil.get_terminal_size()
  4. 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?

qhuy4119 avatar Jul 13 '21 13:07 qhuy4119

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.

qhuy4119 avatar Jul 15 '21 10:07 qhuy4119

I agree this. Without this functionality, I have to use ctrl + x then manually print __file__ to see the full path of current file- -

BIAOXYZ avatar Sep 21 '21 19:09 BIAOXYZ

You can just use Shift + L, too.

inducer avatar Sep 21 '21 21:09 inducer

  • 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.

guoyejun avatar Mar 26 '23 13:03 guoyejun

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.

kwmiebach avatar Sep 12 '23 02:09 kwmiebach