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 path of current source file in header bar #464

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Display path to current source file dynamically based on terminal width
The path to current source file will now be calculated dynamically. If
there is enough space, the full absolute path will be shown. Otherwise,
the longest possible path will be shown by trimming the full absolute
path from the left.

If there is an update to the terminal width, the path will be
recalculated when the user runs the next line of code, however the method (next, step, continue).
NOTICE: Pressing Ctrl-l will redraw the screen with the current path, it doesn't recalculated the path string.
qhuy4119 committed Jul 15, 2021
commit e4af74a7490d52108935f67ab3fa31c2c7c5f1ee
19 changes: 17 additions & 2 deletions pudb/debugger.py
Original file line number Diff line number Diff line change
@@ -2642,8 +2642,23 @@ def interaction(self, exc_tuple, show_exc_dialog=True):
self.current_exc_tuple = exc_tuple

from pudb import VERSION
caption = [(None, "PuDB %s - ?:help - %s" %
(VERSION, self.source_code_provider.get_source_identifier()))]
separator = ' - '
info_string = separator.join(["PuDB %s" % VERSION, "?:help"])

def get_source_filename():
available_width = self.screen.get_cols_rows(
)[0] - (len(info_string) + len(separator))
full_filename = self.source_code_provider.get_source_identifier()
if available_width > len(full_filename):
return full_filename
else:
trim_index = len(full_filename) - available_width
filename = full_filename[trim_index:]
first_dirname_index = filename.find(os.sep)
filename = filename[first_dirname_index + 1:]
return filename

caption = separator.join([info_string, get_source_filename()])

if self.debugger.post_mortem:
if show_exc_dialog and exc_tuple is not None: