Skip to content

Commit

Permalink
Unindent everything one notch
Browse files Browse the repository at this point in the history
Not fully correct, but since PID 1 has only one parent indenting it
doesn't add much information, but does use up space, so let's just not.
  • Loading branch information
walles committed Apr 2, 2024
1 parent 4ed7125 commit 889a0f3
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions px/px_terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,13 @@ def to_screen_lines(
mem_width = len(headings[5])
for proc in procs:
pid_width = max(pid_width, len(str(proc.pid)))
command_width = max(command_width, len(proc.command) + proc.level * 2)

# Unindent PIDs 0 and 1. Not fully correct, but since PID 1 has only one
# parent indenting it doesn't add much information, but does use up
# space, so let's just not.
level = max(proc.level - 1, 0)

command_width = max(command_width, len(proc.command) + level * 2)
username_width = max(username_width, len(proc.username))
cpu_width = max(cpu_width, len(proc.cpu_percent_s))

Expand Down Expand Up @@ -456,7 +462,11 @@ def to_screen_lines(

indent = ""
if sort_order == px_sort_order.SortOrder.AGGREGATED_CPU:
indent = " " * proc.level * 2
# Unindent PIDs 0 and 1. Not fully correct, but since PID 1 has only
# one parent indenting it doesn't add much information, but does use
# up space, so let's not.
level = max(proc.level - 1, 0)
indent = " " * level * 2

columns = [
str(proc.pid),
Expand Down

0 comments on commit 889a0f3

Please sign in to comment.