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
Show 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
What's new in version 0.6.3
* Performance improvements: uses much less CPU than the
* Performance improvements: uses much less CPU than the
...
...
ColumnsPanel.c
View file @
b10821aa
...
@@ -44,6 +44,15 @@ void ColumnsPanel_delete(Object* object) {
...
@@ -44,6 +44,15 @@ void ColumnsPanel_delete(Object* object) {
free
(
this
);
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
)
{
void
ColumnsPanel_update
(
Panel
*
super
)
{
ColumnsPanel
*
this
=
(
ColumnsPanel
*
)
super
;
ColumnsPanel
*
this
=
(
ColumnsPanel
*
)
super
;
int
size
=
Panel_getSize
(
super
);
int
size
=
Panel_getSize
(
super
);
...
@@ -53,12 +62,9 @@ void ColumnsPanel_update(Panel* super) {
...
@@ -53,12 +62,9 @@ void ColumnsPanel_update(Panel* super) {
this
->
settings
->
pl
->
fields
=
(
ProcessField
*
)
malloc
(
sizeof
(
ProcessField
)
*
(
size
+
1
));
this
->
settings
->
pl
->
fields
=
(
ProcessField
*
)
malloc
(
sizeof
(
ProcessField
)
*
(
size
+
1
));
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
char
*
text
=
((
ListItem
*
)
Panel_get
(
super
,
i
))
->
value
;
char
*
text
=
((
ListItem
*
)
Panel_get
(
super
,
i
))
->
value
;
for
(
int
j
=
1
;
j
<=
LAST_PROCESSFIELD
;
j
++
)
{
int
j
=
ColumnsPanel_fieldNameToIndex
(
text
);
if
(
String_eq
(
text
,
Process_fieldNames
[
j
]))
{
if
(
j
>
0
)
this
->
settings
->
pl
->
fields
[
i
]
=
j
;
this
->
settings
->
pl
->
fields
[
i
]
=
j
;
break
;
}
}
}
}
this
->
settings
->
pl
->
fields
[
size
]
=
0
;
this
->
settings
->
pl
->
fields
[
size
]
=
0
;
}
}
...
...
ColumnsPanel.h
View file @
b10821aa
...
@@ -24,6 +24,8 @@ ColumnsPanel* ColumnsPanel_new(Settings* settings, ScreenManager* scr);
...
@@ -24,6 +24,8 @@ ColumnsPanel* ColumnsPanel_new(Settings* settings, ScreenManager* scr);
void
ColumnsPanel_delete
(
Object
*
object
);
void
ColumnsPanel_delete
(
Object
*
object
);
int
ColumnsPanel_fieldNameToIndex
(
const
char
*
name
);
void
ColumnsPanel_update
(
Panel
*
super
);
void
ColumnsPanel_update
(
Panel
*
super
);
HandlerResult
ColumnsPanel_eventHandler
(
Panel
*
super
,
int
ch
);
HandlerResult
ColumnsPanel_eventHandler
(
Panel
*
super
,
int
ch
);
...
...
String.c
View file @
b10821aa
...
@@ -96,7 +96,7 @@ void String_printPointer(void* p) {
...
@@ -96,7 +96,7 @@ void String_printPointer(void* p) {
printf
(
"%p"
,
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
)
{
if
(
s1
==
NULL
&&
s2
==
NULL
)
if
(
s1
==
NULL
&&
s2
==
NULL
)
return
1
;
return
1
;
...
...
String.h
View file @
b10821aa
...
@@ -39,7 +39,7 @@ void String_printInt(int i);
...
@@ -39,7 +39,7 @@ void String_printInt(int i);
void
String_printPointer
(
void
*
p
);
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
);
char
**
String_split
(
char
*
s
,
char
sep
);
...
...
htop.c
View file @
b10821aa
...
@@ -46,6 +46,7 @@ void printHelpFlag() {
...
@@ -46,6 +46,7 @@ void printHelpFlag() {
printf
(
"Released under the GNU GPL.
\n\n
"
);
printf
(
"Released under the GNU GPL.
\n\n
"
);
printf
(
"-d DELAY Delay between updates, in tenths of seconds
\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
(
"-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
(
"Press F1 inside htop for online help.
\n
"
);
printf
(
"See the man page for full information.
\n\n
"
);
printf
(
"See the man page for full information.
\n\n
"
);
exit
(
0
);
exit
(
0
);
...
@@ -194,12 +195,25 @@ int main(int argc, char** argv) {
...
@@ -194,12 +195,25 @@ int main(int argc, char** argv) {
int
delay
=
-
1
;
int
delay
=
-
1
;
bool
userOnly
=
false
;
bool
userOnly
=
false
;
uid_t
userId
=
0
;
uid_t
userId
=
0
;
int
sortKey
=
0
;
if
(
argc
>
0
)
{
if
(
argc
>
0
)
{
if
(
String_eq
(
argv
[
1
],
"--help"
))
{
if
(
String_eq
(
argv
[
1
],
"--help"
))
{
printHelpFlag
();
printHelpFlag
();
}
else
if
(
String_eq
(
argv
[
1
],
"--version"
))
{
}
else
if
(
String_eq
(
argv
[
1
],
"--version"
))
{
printVersionFlag
();
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"
))
{
}
else
if
(
String_eq
(
argv
[
1
],
"-d"
))
{
if
(
argc
<
2
)
printHelpFlag
();
if
(
argc
<
2
)
printHelpFlag
();
sscanf
(
argv
[
2
],
"%d"
,
&
delay
);
sscanf
(
argv
[
2
],
"%d"
,
&
delay
);
...
@@ -237,6 +251,10 @@ int main(int argc, char** argv) {
...
@@ -237,6 +251,10 @@ int main(int argc, char** argv) {
Header
*
header
=
Header_new
(
pl
);
Header
*
header
=
Header_new
(
pl
);
settings
=
Settings_new
(
pl
,
header
);
settings
=
Settings_new
(
pl
,
header
);
if
(
sortKey
>
0
)
{
pl
->
sortKey
=
sortKey
;
pl
->
treeView
=
false
;
}
int
headerHeight
=
Header_calculateHeight
(
header
);
int
headerHeight
=
Header_calculateHeight
(
header
);
// FIXME: move delay code to settings
// 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