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

Display the source file name #170

Open
nedbat opened this issue Feb 4, 2016 · 26 comments · May be fixed by #464
Open

Display the source file name #170

nedbat opened this issue Feb 4, 2016 · 26 comments · May be fixed by #464

Comments

@nedbat
Copy link
Contributor

nedbat commented Feb 4, 2016

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.

@inducer
Copy link
Owner

inducer commented Feb 4, 2016

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.

@nedbat
Copy link
Contributor Author

nedbat commented Feb 4, 2016

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.

@asmeurer
Copy link
Collaborator

asmeurer commented Feb 4, 2016

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.

@inducer
Copy link
Owner

inducer commented Feb 4, 2016

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

@asmeurer
Copy link
Collaborator

asmeurer commented Feb 4, 2016

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.

@inducer
Copy link
Owner

inducer commented Feb 4, 2016

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)

@nedbat
Copy link
Contributor Author

nedbat commented Feb 4, 2016

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

@inducer
Copy link
Owner

inducer commented Feb 4, 2016

I could go along with that.

@asmeurer
Copy link
Collaborator

asmeurer commented Feb 4, 2016

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

@asmeurer
Copy link
Collaborator

asmeurer commented Feb 4, 2016

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

@timblaktu
Copy link

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.

@ndevenish
Copy link

ndevenish commented Jun 11, 2019

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

@dkao1978
Copy link

dkao1978 commented Aug 1, 2019

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.

@TimothyBramlett
Copy link

This is fantastic idea and love the filename being displayed!

@qhuy4119
Copy link
Contributor

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.

@inducer
Copy link
Owner

inducer commented Jul 13, 2021

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

@qhuy4119 qhuy4119 linked a pull request Jul 13, 2021 that will close this issue
@qhuy4119
Copy link
Contributor

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?

@inducer
Copy link
Owner

inducer commented Jul 13, 2021

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.

@qhuy4119
Copy link
Contributor

qhuy4119 commented Jul 13, 2021

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

@inducer
Copy link
Owner

inducer commented Jul 13, 2021

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.

@qhuy4119
Copy link
Contributor

qhuy4119 commented Jul 13, 2021

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
Copy link
Contributor

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.

@BIAOXYZ
Copy link

BIAOXYZ commented Sep 21, 2021

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

@inducer
Copy link
Owner

inducer commented Sep 21, 2021

You can just use Shift + L, too.

@guoyejun
Copy link

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

@kwmiebach
Copy link
Contributor

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.

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 a pull request may close this issue.