Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
htop
Commits
4d44c355
Commit
4d44c355
authored
Aug 12, 2015
by
Hisham Muhammad
Browse files
Merge pull request #148 from nckx/display-basename
[PATCH] New setting: "Show program path"
parents
4e135bb6
fc0e4466
Changes
6
Hide whitespace changes
Inline
Side-by-side
Action.c
View file @
4d44c355
...
@@ -211,6 +211,11 @@ static Htop_Reaction actionToggleUserlandThreads(State* st) {
...
@@ -211,6 +211,11 @@ static Htop_Reaction actionToggleUserlandThreads(State* st) {
return
HTOP_RECALCULATE
|
HTOP_SAVE_SETTINGS
;
return
HTOP_RECALCULATE
|
HTOP_SAVE_SETTINGS
;
}
}
static
Htop_Reaction
actionToggleProgramPath
(
State
*
st
)
{
st
->
settings
->
showProgramPath
=
!
st
->
settings
->
showProgramPath
;
return
HTOP_REFRESH
|
HTOP_SAVE_SETTINGS
;
}
static
Htop_Reaction
actionToggleTreeView
(
State
*
st
)
{
static
Htop_Reaction
actionToggleTreeView
(
State
*
st
)
{
st
->
settings
->
treeView
=
!
st
->
settings
->
treeView
;
st
->
settings
->
treeView
=
!
st
->
settings
->
treeView
;
if
(
st
->
settings
->
treeView
)
st
->
settings
->
direction
=
1
;
if
(
st
->
settings
->
treeView
)
st
->
settings
->
direction
=
1
;
...
@@ -501,6 +506,7 @@ void Action_setBindings(Htop_Action* keys) {
...
@@ -501,6 +506,7 @@ void Action_setBindings(Htop_Action* keys) {
keys
[
'P'
]
=
actionSortByCPU
;
keys
[
'P'
]
=
actionSortByCPU
;
keys
[
'H'
]
=
actionToggleUserlandThreads
;
keys
[
'H'
]
=
actionToggleUserlandThreads
;
keys
[
'K'
]
=
actionToggleKernelThreads
;
keys
[
'K'
]
=
actionToggleKernelThreads
;
keys
[
'p'
]
=
actionToggleProgramPath
;
keys
[
't'
]
=
actionToggleTreeView
;
keys
[
't'
]
=
actionToggleTreeView
;
keys
[
KEY_F
(
5
)]
=
actionToggleTreeView
;
keys
[
KEY_F
(
5
)]
=
actionToggleTreeView
;
keys
[
KEY_F
(
4
)]
=
actionIncFilter
;
keys
[
KEY_F
(
4
)]
=
actionIncFilter
;
...
...
DisplayOptionsPanel.c
View file @
4d44c355
...
@@ -87,6 +87,7 @@ DisplayOptionsPanel* DisplayOptionsPanel_new(Settings* settings, ScreenManager*
...
@@ -87,6 +87,7 @@ DisplayOptionsPanel* DisplayOptionsPanel_new(Settings* settings, ScreenManager*
Panel_add
(
super
,
(
Object
*
)
CheckItem_new
(
strdup
(
"Hide userland threads"
),
&
(
settings
->
hideUserlandThreads
),
false
));
Panel_add
(
super
,
(
Object
*
)
CheckItem_new
(
strdup
(
"Hide userland threads"
),
&
(
settings
->
hideUserlandThreads
),
false
));
Panel_add
(
super
,
(
Object
*
)
CheckItem_new
(
strdup
(
"Display threads in a different color"
),
&
(
settings
->
highlightThreads
),
false
));
Panel_add
(
super
,
(
Object
*
)
CheckItem_new
(
strdup
(
"Display threads in a different color"
),
&
(
settings
->
highlightThreads
),
false
));
Panel_add
(
super
,
(
Object
*
)
CheckItem_new
(
strdup
(
"Show custom thread names"
),
&
(
settings
->
showThreadNames
),
false
));
Panel_add
(
super
,
(
Object
*
)
CheckItem_new
(
strdup
(
"Show custom thread names"
),
&
(
settings
->
showThreadNames
),
false
));
Panel_add
(
super
,
(
Object
*
)
CheckItem_new
(
strdup
(
"Show program path"
),
&
(
settings
->
showProgramPath
),
true
));
Panel_add
(
super
,
(
Object
*
)
CheckItem_new
(
strdup
(
"Highlight program
\"
basename
\"
"
),
&
(
settings
->
highlightBaseName
),
false
));
Panel_add
(
super
,
(
Object
*
)
CheckItem_new
(
strdup
(
"Highlight program
\"
basename
\"
"
),
&
(
settings
->
highlightBaseName
),
false
));
Panel_add
(
super
,
(
Object
*
)
CheckItem_new
(
strdup
(
"Highlight large numbers in memory counters"
),
&
(
settings
->
highlightMegabytes
),
false
));
Panel_add
(
super
,
(
Object
*
)
CheckItem_new
(
strdup
(
"Highlight large numbers in memory counters"
),
&
(
settings
->
highlightMegabytes
),
false
));
Panel_add
(
super
,
(
Object
*
)
CheckItem_new
(
strdup
(
"Leave a margin around header"
),
&
(
settings
->
headerMargin
),
false
));
Panel_add
(
super
,
(
Object
*
)
CheckItem_new
(
strdup
(
"Leave a margin around header"
),
&
(
settings
->
headerMargin
),
false
));
...
...
Process.c
View file @
4d44c355
...
@@ -275,25 +275,33 @@ void Process_printTime(RichString* str, unsigned long long totalHundredths) {
...
@@ -275,25 +275,33 @@ void Process_printTime(RichString* str, unsigned long long totalHundredths) {
}
}
static
inline
void
Process_writeCommand
(
Process
*
this
,
int
attr
,
int
baseattr
,
RichString
*
str
)
{
static
inline
void
Process_writeCommand
(
Process
*
this
,
int
attr
,
int
baseattr
,
RichString
*
str
)
{
int
start
=
RichString_size
(
str
);
int
start
=
RichString_size
(
str
),
finish
=
0
;
RichString_append
(
str
,
attr
,
this
->
comm
);
char
*
comm
=
this
->
comm
;
if
(
this
->
settings
->
highlightBaseName
)
{
int
finish
=
RichString_size
(
str
)
-
1
;
if
(
this
->
settings
->
highlightBaseName
||
!
this
->
settings
->
showProgramPath
)
{
if
(
this
->
basenameOffset
!=
-
1
)
int
i
,
basename
=
0
;
finish
=
(
start
+
this
->
basenameOffset
)
-
1
;
for
(
i
=
0
;
i
<
this
->
basenameOffset
;
i
++
)
{
int
colon
=
RichString_findChar
(
str
,
':'
,
start
);
if
(
comm
[
i
]
==
'/'
)
{
if
(
colon
!=
-
1
&&
colon
<
finish
)
{
basename
=
i
+
1
;
finish
=
colon
;
}
else
if
(
comm
[
i
]
==
':'
)
{
}
else
{
finish
=
i
+
1
;
for
(
int
i
=
finish
-
start
;
i
>=
0
;
i
--
)
{
break
;
if
(
this
->
comm
[
i
]
==
'/'
)
{
start
+=
i
+
1
;
break
;
}
}
}
}
}
RichString_setAttrn
(
str
,
baseattr
,
start
,
finish
);
if
(
!
finish
)
{
if
(
this
->
settings
->
showProgramPath
)
start
+=
basename
;
else
comm
+=
basename
;
finish
=
this
->
basenameOffset
-
basename
;
}
finish
+=
start
-
1
;
}
}
RichString_append
(
str
,
attr
,
comm
);
if
(
this
->
settings
->
highlightBaseName
)
RichString_setAttrn
(
str
,
baseattr
,
start
,
finish
);
}
}
void
Process_outputRate
(
RichString
*
str
,
char
*
buffer
,
int
n
,
double
rate
,
int
coloring
)
{
void
Process_outputRate
(
RichString
*
str
,
char
*
buffer
,
int
n
,
double
rate
,
int
coloring
)
{
...
...
Settings.c
View file @
4d44c355
...
@@ -46,6 +46,7 @@ typedef struct Settings_ {
...
@@ -46,6 +46,7 @@ typedef struct Settings_ {
bool countCPUsFromZero;
bool countCPUsFromZero;
bool detailedCPUTime;
bool detailedCPUTime;
bool treeView;
bool treeView;
bool showProgramPath;
bool hideThreads;
bool hideThreads;
bool shadowOtherUsers;
bool shadowOtherUsers;
bool showThreadNames;
bool showThreadNames;
...
@@ -186,6 +187,8 @@ static bool Settings_read(Settings* this, const char* fileName) {
...
@@ -186,6 +187,8 @@ static bool Settings_read(Settings* this, const char* fileName) {
this
->
shadowOtherUsers
=
atoi
(
option
[
1
]);
this
->
shadowOtherUsers
=
atoi
(
option
[
1
]);
}
else
if
(
String_eq
(
option
[
0
],
"show_thread_names"
))
{
}
else
if
(
String_eq
(
option
[
0
],
"show_thread_names"
))
{
this
->
showThreadNames
=
atoi
(
option
[
1
]);
this
->
showThreadNames
=
atoi
(
option
[
1
]);
}
else
if
(
String_eq
(
option
[
0
],
"show_program_path"
))
{
this
->
showProgramPath
=
atoi
(
option
[
1
]);
}
else
if
(
String_eq
(
option
[
0
],
"highlight_base_name"
))
{
}
else
if
(
String_eq
(
option
[
0
],
"highlight_base_name"
))
{
this
->
highlightBaseName
=
atoi
(
option
[
1
]);
this
->
highlightBaseName
=
atoi
(
option
[
1
]);
}
else
if
(
String_eq
(
option
[
0
],
"highlight_megabytes"
))
{
}
else
if
(
String_eq
(
option
[
0
],
"highlight_megabytes"
))
{
...
@@ -272,6 +275,7 @@ bool Settings_write(Settings* this) {
...
@@ -272,6 +275,7 @@ bool Settings_write(Settings* this) {
fprintf
(
fd
,
"hide_userland_threads=%d
\n
"
,
(
int
)
this
->
hideUserlandThreads
);
fprintf
(
fd
,
"hide_userland_threads=%d
\n
"
,
(
int
)
this
->
hideUserlandThreads
);
fprintf
(
fd
,
"shadow_other_users=%d
\n
"
,
(
int
)
this
->
shadowOtherUsers
);
fprintf
(
fd
,
"shadow_other_users=%d
\n
"
,
(
int
)
this
->
shadowOtherUsers
);
fprintf
(
fd
,
"show_thread_names=%d
\n
"
,
(
int
)
this
->
showThreadNames
);
fprintf
(
fd
,
"show_thread_names=%d
\n
"
,
(
int
)
this
->
showThreadNames
);
fprintf
(
fd
,
"show_program_path=%d
\n
"
,
(
int
)
this
->
showProgramPath
);
fprintf
(
fd
,
"highlight_base_name=%d
\n
"
,
(
int
)
this
->
highlightBaseName
);
fprintf
(
fd
,
"highlight_base_name=%d
\n
"
,
(
int
)
this
->
highlightBaseName
);
fprintf
(
fd
,
"highlight_megabytes=%d
\n
"
,
(
int
)
this
->
highlightMegabytes
);
fprintf
(
fd
,
"highlight_megabytes=%d
\n
"
,
(
int
)
this
->
highlightMegabytes
);
fprintf
(
fd
,
"highlight_threads=%d
\n
"
,
(
int
)
this
->
highlightThreads
);
fprintf
(
fd
,
"highlight_threads=%d
\n
"
,
(
int
)
this
->
highlightThreads
);
...
...
Settings.h
View file @
4d44c355
...
@@ -37,6 +37,7 @@ typedef struct Settings_ {
...
@@ -37,6 +37,7 @@ typedef struct Settings_ {
bool
countCPUsFromZero
;
bool
countCPUsFromZero
;
bool
detailedCPUTime
;
bool
detailedCPUTime
;
bool
treeView
;
bool
treeView
;
bool
showProgramPath
;
bool
hideThreads
;
bool
hideThreads
;
bool
shadowOtherUsers
;
bool
shadowOtherUsers
;
bool
showThreadNames
;
bool
showThreadNames
;
...
...
htop.1.in
View file @
4d44c355
...
@@ -151,6 +151,9 @@ Hide user threads: on systems that represent them differently than ordinary
...
@@ -151,6 +151,9 @@ Hide user threads: on systems that represent them differently than ordinary
processes (such as recent NPTL-based systems), this can hide threads from
processes (such as recent NPTL-based systems), this can hide threads from
userspace processes in the process list. (This is a toggle key.)
userspace processes in the process list. (This is a toggle key.)
.TP
.TP
.B p
Show full paths to running programs, where applicable. (This is a toggle key.)
.TP
.B Ctrl-L
.B Ctrl-L
Refresh: redraw screen and recalculate values.
Refresh: redraw screen and recalculate values.
.TP
.TP
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment