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
b10821aa
Commit
b10821aa
authored
Aug 04, 2006
by
Hisham Muhammad
Browse files
--sort-key flag in the command-line, overriding the
saved setting in .htoprc for the session. (thanks to Rodolfo Borges)
parent
bf44e233
Changes
6
Hide whitespace changes
Inline
Side-by-side
ChangeLog
View file @
b10821aa
What's new in version 0.6.4
* --sort-key flag in the command-line, overriding the
saved setting in .htoprc for the session.
(thanks to Rodolfo Borges)
What's new in version 0.6.3
* Performance improvements: uses much less CPU than the
...
...
ColumnsPanel.c
View file @
b10821aa
...
...
@@ -44,6 +44,15 @@ void ColumnsPanel_delete(Object* object) {
free
(
this
);
}
int
ColumnsPanel_fieldNameToIndex
(
const
char
*
name
)
{
for
(
int
j
=
1
;
j
<=
LAST_PROCESSFIELD
;
j
++
)
{
if
(
String_eq
(
name
,
Process_fieldNames
[
j
]))
{
return
j
;
}
}
return
0
;
}
void
ColumnsPanel_update
(
Panel
*
super
)
{
ColumnsPanel
*
this
=
(
ColumnsPanel
*
)
super
;
int
size
=
Panel_getSize
(
super
);
...
...
@@ -53,12 +62,9 @@ void ColumnsPanel_update(Panel* super) {
this
->
settings
->
pl
->
fields
=
(
ProcessField
*
)
malloc
(
sizeof
(
ProcessField
)
*
(
size
+
1
));
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
char
*
text
=
((
ListItem
*
)
Panel_get
(
super
,
i
))
->
value
;
for
(
int
j
=
1
;
j
<=
LAST_PROCESSFIELD
;
j
++
)
{
if
(
String_eq
(
text
,
Process_fieldNames
[
j
]))
{
this
->
settings
->
pl
->
fields
[
i
]
=
j
;
break
;
}
}
int
j
=
ColumnsPanel_fieldNameToIndex
(
text
);
if
(
j
>
0
)
this
->
settings
->
pl
->
fields
[
i
]
=
j
;
}
this
->
settings
->
pl
->
fields
[
size
]
=
0
;
}
...
...
@@ -83,7 +89,7 @@ HandlerResult ColumnsPanel_eventHandler(Panel* super, int ch) {
case
']'
:
case
'+'
:
{
if
(
selected
<
size
-
2
)
if
(
selected
<
size
-
2
)
Panel_moveSelectedDown
(
super
);
result
=
HANDLED
;
break
;
...
...
ColumnsPanel.h
View file @
b10821aa
...
...
@@ -24,6 +24,8 @@ ColumnsPanel* ColumnsPanel_new(Settings* settings, ScreenManager* scr);
void
ColumnsPanel_delete
(
Object
*
object
);
int
ColumnsPanel_fieldNameToIndex
(
const
char
*
name
);
void
ColumnsPanel_update
(
Panel
*
super
);
HandlerResult
ColumnsPanel_eventHandler
(
Panel
*
super
,
int
ch
);
...
...
String.c
View file @
b10821aa
...
...
@@ -96,7 +96,7 @@ void String_printPointer(void* p) {
printf
(
"%p"
,
p
);
}
inline
int
String_eq
(
char
*
s1
,
char
*
s2
)
{
inline
int
String_eq
(
const
char
*
s1
,
const
char
*
s2
)
{
if
(
s1
==
NULL
||
s2
==
NULL
)
{
if
(
s1
==
NULL
&&
s2
==
NULL
)
return
1
;
...
...
String.h
View file @
b10821aa
...
...
@@ -39,7 +39,7 @@ void String_printInt(int i);
void
String_printPointer
(
void
*
p
);
inline
int
String_eq
(
char
*
s1
,
char
*
s2
);
inline
int
String_eq
(
const
char
*
s1
,
const
char
*
s2
);
char
**
String_split
(
char
*
s
,
char
sep
);
...
...
htop.c
View file @
b10821aa
...
...
@@ -46,6 +46,7 @@ void printHelpFlag() {
printf
(
"Released under the GNU GPL.
\n\n
"
);
printf
(
"-d DELAY Delay between updates, in tenths of seconds
\n\n
"
);
printf
(
"-u USERNAME Show only processes of a given user
\n\n
"
);
printf
(
"--sort-key COLUMN Sort by this column (use --sort-key help for a column list)
\n\n
"
);
printf
(
"Press F1 inside htop for online help.
\n
"
);
printf
(
"See the man page for full information.
\n\n
"
);
exit
(
0
);
...
...
@@ -194,12 +195,25 @@ int main(int argc, char** argv) {
int
delay
=
-
1
;
bool
userOnly
=
false
;
uid_t
userId
=
0
;
int
sortKey
=
0
;
if
(
argc
>
0
)
{
if
(
String_eq
(
argv
[
1
],
"--help"
))
{
printHelpFlag
();
}
else
if
(
String_eq
(
argv
[
1
],
"--version"
))
{
printVersionFlag
();
}
else
if
(
String_eq
(
argv
[
1
],
"--sort-key"
))
{
if
(
argc
<
2
)
printHelpFlag
();
if
(
String_eq
(
argv
[
2
],
"help"
))
{
for
(
int
j
=
1
;
j
<
LAST_PROCESSFIELD
;
j
++
)
printf
(
"%s
\n
"
,
Process_fieldNames
[
j
]);
exit
(
0
);
}
sortKey
=
ColumnsPanel_fieldNameToIndex
(
argv
[
2
]);
if
(
sortKey
==
-
1
)
{
fprintf
(
stderr
,
"Error: invalid column
\"
%s
\"
.
\n
"
,
argv
[
2
]);
exit
(
1
);
}
}
else
if
(
String_eq
(
argv
[
1
],
"-d"
))
{
if
(
argc
<
2
)
printHelpFlag
();
sscanf
(
argv
[
2
],
"%d"
,
&
delay
);
...
...
@@ -237,6 +251,10 @@ int main(int argc, char** argv) {
Header
*
header
=
Header_new
(
pl
);
settings
=
Settings_new
(
pl
,
header
);
if
(
sortKey
>
0
)
{
pl
->
sortKey
=
sortKey
;
pl
->
treeView
=
false
;
}
int
headerHeight
=
Header_calculateHeight
(
header
);
// FIXME: move delay code to settings
...
...
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