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
6330ff3a
Commit
6330ff3a
authored
Jun 02, 2009
by
Hisham Muhammad
Browse files
changes for htop 0.8.2
parent
1371ee28
Changes
25
Show whitespace changes
Inline
Side-by-side
AffinityPanel.c
View file @
6330ff3a
...
...
@@ -39,7 +39,7 @@ Panel* AffinityPanel_new(int processorCount, unsigned long mask) {
}
unsigned
long
AffinityPanel_getAffinity
(
Panel
*
this
)
{
int
size
=
Panel_
getS
ize
(
this
);
int
size
=
Panel_
s
ize
(
this
);
unsigned
long
mask
=
0
;
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
if
(
CheckItem_get
((
CheckItem
*
)
Panel_get
(
this
,
i
)))
...
...
CPUMeter.c
View file @
6330ff3a
...
...
@@ -43,6 +43,10 @@ static void CPUMeter_init(Meter* this) {
static
void
CPUMeter_setValues
(
Meter
*
this
,
char
*
buffer
,
int
size
)
{
ProcessList
*
pl
=
this
->
pl
;
int
processor
=
this
->
param
;
if
(
processor
>
this
->
pl
->
processorCount
)
{
snprintf
(
buffer
,
size
,
"absent"
);
return
;
}
double
total
=
(
double
)
pl
->
totalPeriod
[
processor
];
double
cpu
;
this
->
values
[
0
]
=
pl
->
nicePeriod
[
processor
]
/
total
*
100
.
0
;
...
...
@@ -67,6 +71,10 @@ static void CPUMeter_display(Object* cast, RichString* out) {
char
buffer
[
50
];
Meter
*
this
=
(
Meter
*
)
cast
;
RichString_init
(
out
);
if
(
this
->
param
>
this
->
pl
->
processorCount
)
{
RichString_append
(
out
,
CRT_colors
[
METER_TEXT
],
"absent"
);
return
;
}
sprintf
(
buffer
,
"%5.1f%% "
,
this
->
values
[
1
]);
RichString_append
(
out
,
CRT_colors
[
METER_TEXT
],
":"
);
RichString_append
(
out
,
CRT_colors
[
CPU_NORMAL
],
buffer
);
...
...
CategoriesPanel.c
View file @
6330ff3a
...
...
@@ -23,17 +23,17 @@ typedef struct CategoriesPanel_ {
}*/
static
char
*
MetersFunctions
[
10
]
=
{
" "
,
" "
,
" "
,
"Type "
,
" "
,
" "
,
"MoveUp"
,
"MoveDn"
,
"Remove"
,
"Done "
};
static
char
*
MetersFunctions
[]
=
{
" "
,
" "
,
" "
,
"Type "
,
" "
,
" "
,
"MoveUp"
,
"MoveDn"
,
"Remove"
,
"Done "
,
NULL
};
static
char
*
AvailableMetersFunctions
[
10
]
=
{
" "
,
" "
,
" "
,
" "
,
"Add L "
,
"Add R "
,
" "
,
" "
,
" "
,
"Done "
};
static
char
*
AvailableMetersFunctions
[]
=
{
" "
,
" "
,
" "
,
" "
,
"Add L "
,
"Add R "
,
" "
,
" "
,
" "
,
"Done "
,
NULL
};
static
char
*
DisplayOptionsFunctions
[
10
]
=
{
" "
,
" "
,
" "
,
" "
,
" "
,
" "
,
" "
,
" "
,
" "
,
"Done "
};
static
char
*
DisplayOptionsFunctions
[]
=
{
" "
,
" "
,
" "
,
" "
,
" "
,
" "
,
" "
,
" "
,
" "
,
"Done "
,
NULL
};
static
char
*
ColumnsFunctions
[
10
]
=
{
" "
,
" "
,
" "
,
" "
,
" "
,
" "
,
"MoveUp"
,
"MoveDn"
,
"Remove"
,
"Done "
};
static
char
*
ColumnsFunctions
[]
=
{
" "
,
" "
,
" "
,
" "
,
" "
,
" "
,
"MoveUp"
,
"MoveDn"
,
"Remove"
,
"Done "
,
NULL
};
static
char
*
ColorsFunctions
[
10
]
=
{
" "
,
" "
,
" "
,
" "
,
" "
,
" "
,
" "
,
" "
,
" "
,
"Done "
};
static
char
*
ColorsFunctions
[]
=
{
" "
,
" "
,
" "
,
" "
,
" "
,
" "
,
" "
,
" "
,
" "
,
"Done "
,
NULL
};
static
char
*
AvailableColumnsFunctions
[
10
]
=
{
" "
,
" "
,
" "
,
" "
,
"Add "
,
" "
,
" "
,
" "
,
" "
,
"Done "
};
static
char
*
AvailableColumnsFunctions
[]
=
{
" "
,
" "
,
" "
,
" "
,
"Add "
,
" "
,
" "
,
" "
,
" "
,
"Done "
,
NULL
};
static
void
CategoriesPanel_delete
(
Object
*
object
)
{
Panel
*
super
=
(
Panel
*
)
object
;
...
...
@@ -46,26 +46,26 @@ void CategoriesPanel_makeMetersPage(CategoriesPanel* this) {
Panel
*
leftMeters
=
(
Panel
*
)
MetersPanel_new
(
this
->
settings
,
"Left column"
,
this
->
settings
->
header
->
leftMeters
,
this
->
scr
);
Panel
*
rightMeters
=
(
Panel
*
)
MetersPanel_new
(
this
->
settings
,
"Right column"
,
this
->
settings
->
header
->
rightMeters
,
this
->
scr
);
Panel
*
availableMeters
=
(
Panel
*
)
AvailableMetersPanel_new
(
this
->
settings
,
leftMeters
,
rightMeters
,
this
->
scr
);
ScreenManager_add
(
this
->
scr
,
leftMeters
,
FunctionBar_new
(
10
,
MetersFunctions
,
NULL
,
NULL
),
20
);
ScreenManager_add
(
this
->
scr
,
rightMeters
,
FunctionBar_new
(
10
,
MetersFunctions
,
NULL
,
NULL
),
20
);
ScreenManager_add
(
this
->
scr
,
availableMeters
,
FunctionBar_new
(
10
,
AvailableMetersFunctions
,
NULL
,
NULL
),
-
1
);
ScreenManager_add
(
this
->
scr
,
leftMeters
,
FunctionBar_new
(
MetersFunctions
,
NULL
,
NULL
),
20
);
ScreenManager_add
(
this
->
scr
,
rightMeters
,
FunctionBar_new
(
MetersFunctions
,
NULL
,
NULL
),
20
);
ScreenManager_add
(
this
->
scr
,
availableMeters
,
FunctionBar_new
(
AvailableMetersFunctions
,
NULL
,
NULL
),
-
1
);
}
static
void
CategoriesPanel_makeDisplayOptionsPage
(
CategoriesPanel
*
this
)
{
Panel
*
displayOptions
=
(
Panel
*
)
DisplayOptionsPanel_new
(
this
->
settings
,
this
->
scr
);
ScreenManager_add
(
this
->
scr
,
displayOptions
,
FunctionBar_new
(
10
,
DisplayOptionsFunctions
,
NULL
,
NULL
),
-
1
);
ScreenManager_add
(
this
->
scr
,
displayOptions
,
FunctionBar_new
(
DisplayOptionsFunctions
,
NULL
,
NULL
),
-
1
);
}
static
void
CategoriesPanel_makeColorsPage
(
CategoriesPanel
*
this
)
{
Panel
*
colors
=
(
Panel
*
)
ColorsPanel_new
(
this
->
settings
,
this
->
scr
);
ScreenManager_add
(
this
->
scr
,
colors
,
FunctionBar_new
(
10
,
ColorsFunctions
,
NULL
,
NULL
),
-
1
);
ScreenManager_add
(
this
->
scr
,
colors
,
FunctionBar_new
(
ColorsFunctions
,
NULL
,
NULL
),
-
1
);
}
static
void
CategoriesPanel_makeColumnsPage
(
CategoriesPanel
*
this
)
{
Panel
*
columns
=
(
Panel
*
)
ColumnsPanel_new
(
this
->
settings
,
this
->
scr
);
Panel
*
availableColumns
=
(
Panel
*
)
AvailableColumnsPanel_new
(
this
->
settings
,
columns
,
this
->
scr
);
ScreenManager_add
(
this
->
scr
,
columns
,
FunctionBar_new
(
10
,
ColumnsFunctions
,
NULL
,
NULL
),
20
);
ScreenManager_add
(
this
->
scr
,
availableColumns
,
FunctionBar_new
(
10
,
AvailableColumnsFunctions
,
NULL
,
NULL
),
-
1
);
ScreenManager_add
(
this
->
scr
,
columns
,
FunctionBar_new
(
ColumnsFunctions
,
NULL
,
NULL
),
20
);
ScreenManager_add
(
this
->
scr
,
availableColumns
,
FunctionBar_new
(
AvailableColumnsFunctions
,
NULL
,
NULL
),
-
1
);
}
static
HandlerResult
CategoriesPanel_eventHandler
(
Panel
*
super
,
int
ch
)
{
...
...
ChangeLog
View file @
6330ff3a
What's new in version 0.8.2
* Integrated lsof (press 'l')
* Fix display of gigabyte-sized values
(thanks to Andika Triwidada)
* Option to display hostname in the meters area
* Rename VEID to CTID in OpenVZ systems
(thanks to Thorsten Schifferdecker)
...
...
ColumnsPanel.c
View file @
6330ff3a
...
...
@@ -30,7 +30,7 @@ static HandlerResult ColumnsPanel_eventHandler(Panel* super, int ch) {
int
selected
=
Panel_getSelectedIndex
(
super
);
HandlerResult
result
=
IGNORED
;
int
size
=
Panel_
getS
ize
(
super
);
int
size
=
Panel_
s
ize
(
super
);
switch
(
ch
)
{
case
KEY_F
(
7
):
...
...
@@ -95,7 +95,7 @@ int ColumnsPanel_fieldNameToIndex(const char* name) {
void
ColumnsPanel_update
(
Panel
*
super
)
{
ColumnsPanel
*
this
=
(
ColumnsPanel
*
)
super
;
int
size
=
Panel_
getS
ize
(
super
);
int
size
=
Panel_
s
ize
(
super
);
this
->
settings
->
changed
=
true
;
// FIXME: this is crappily inefficient
free
(
this
->
settings
->
pl
->
fields
);
...
...
FunctionBar.c
View file @
6330ff3a
...
...
@@ -36,34 +36,36 @@ char* FUNCTIONBAR_CLASS = "FunctionBar";
#define FUNCTIONBAR_CLASS NULL
#endif
static
char
*
FunctionBar_FKeys
[
10
]
=
{
"F1"
,
"F2"
,
"F3"
,
"F4"
,
"F5"
,
"F6"
,
"F7"
,
"F8"
,
"F9"
,
"F10"
};
static
char
*
FunctionBar_FKeys
[]
=
{
"F1"
,
"F2"
,
"F3"
,
"F4"
,
"F5"
,
"F6"
,
"F7"
,
"F8"
,
"F9"
,
"F10"
,
NULL
};
static
char
*
FunctionBar_FLabels
[
10
]
=
{
" "
,
" "
,
" "
,
" "
,
" "
,
" "
,
" "
,
" "
,
" "
,
" "
};
static
char
*
FunctionBar_FLabels
[]
=
{
" "
,
" "
,
" "
,
" "
,
" "
,
" "
,
" "
,
" "
,
" "
,
" "
,
NULL
};
static
int
FunctionBar_FEvents
[
10
]
=
{
KEY_F
(
1
),
KEY_F
(
2
),
KEY_F
(
3
),
KEY_F
(
4
),
KEY_F
(
5
),
KEY_F
(
6
),
KEY_F
(
7
),
KEY_F
(
8
),
KEY_F
(
9
),
KEY_F
(
10
)};
static
int
FunctionBar_FEvents
[]
=
{
KEY_F
(
1
),
KEY_F
(
2
),
KEY_F
(
3
),
KEY_F
(
4
),
KEY_F
(
5
),
KEY_F
(
6
),
KEY_F
(
7
),
KEY_F
(
8
),
KEY_F
(
9
),
KEY_F
(
10
)};
FunctionBar
*
FunctionBar_new
(
int
size
,
char
**
functions
,
char
**
keys
,
int
*
events
)
{
FunctionBar
*
FunctionBar_new
(
char
**
functions
,
char
**
keys
,
int
*
events
)
{
FunctionBar
*
this
=
malloc
(
sizeof
(
FunctionBar
));
Object_setClass
(
this
,
FUNCTIONBAR_CLASS
);
((
Object
*
)
this
)
->
delete
=
FunctionBar_delete
;
this
->
functions
=
functions
;
this
->
size
=
size
;
if
(
keys
&&
events
)
{
this
->
staticData
=
false
;
this
->
functions
=
malloc
(
sizeof
(
char
*
)
*
size
);
this
->
keys
=
malloc
(
sizeof
(
char
*
)
*
size
);
this
->
events
=
malloc
(
sizeof
(
int
)
*
size
);
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
this
->
functions
=
malloc
(
sizeof
(
char
*
)
*
15
);
this
->
keys
=
malloc
(
sizeof
(
char
*
)
*
15
);
this
->
events
=
malloc
(
sizeof
(
int
)
*
15
);
int
i
=
0
;
while
(
i
<
15
&&
functions
[
i
])
{
this
->
functions
[
i
]
=
String_copy
(
functions
[
i
]);
this
->
keys
[
i
]
=
String_copy
(
keys
[
i
]);
this
->
events
[
i
]
=
events
[
i
];
i
++
;
}
this
->
size
=
i
;
}
else
{
this
->
staticData
=
true
;
this
->
functions
=
functions
?
functions
:
FunctionBar_FLabels
;
this
->
keys
=
FunctionBar_FKeys
;
this
->
events
=
FunctionBar_FEvents
;
assert
((
!
functions
)
||
this
->
size
=
=
10
)
;
this
->
size
=
10
;
}
return
this
;
}
...
...
FunctionBar.h
View file @
6330ff3a
...
...
@@ -37,7 +37,7 @@ extern char* FUNCTIONBAR_CLASS;
#define FUNCTIONBAR_CLASS NULL
#endif
FunctionBar
*
FunctionBar_new
(
int
size
,
char
**
functions
,
char
**
keys
,
int
*
events
);
FunctionBar
*
FunctionBar_new
(
char
**
functions
,
char
**
keys
,
int
*
events
);
void
FunctionBar_delete
(
Object
*
cast
);
...
...
Makefile.am
View file @
6330ff3a
...
...
@@ -22,7 +22,7 @@ LoadAverageMeter.c MemoryMeter.c Meter.c MetersPanel.c Object.c Panel.c \
BatteryMeter.c Process.c ProcessList.c RichString.c ScreenManager.c Settings.c
\
SignalItem.c SignalsPanel.c String.c SwapMeter.c TasksMeter.c TraceScreen.c
\
UptimeMeter.c UsersTable.c Vector.c AvailableColumnsPanel.c AffinityPanel.c
\
HostnameMeter.c
HostnameMeter.c
OpenFilesScreen.c
myhtopheaders
=
AvailableColumnsPanel.h AvailableMetersPanel.h
\
CategoriesPanel.h CheckItem.h ClockMeter.h ColorsPanel.h ColumnsPanel.h
\
...
...
@@ -31,7 +31,7 @@ Hashtable.h Header.h htop.h ListItem.h LoadAverageMeter.h MemoryMeter.h \
BatteryMeter.h Meter.h MetersPanel.h Object.h Panel.h ProcessList.h RichString.h
\
ScreenManager.h Settings.h SignalItem.h SignalsPanel.h String.h
\
SwapMeter.h TasksMeter.h TraceScreen.h UptimeMeter.h UsersTable.h Vector.h
\
Process.h AffinityPanel.h HostnameMeter.h
Process.h AffinityPanel.h HostnameMeter.h
OpenFilesScreen.h
SUFFIXES
=
.h
...
...
Meter.c
View file @
6330ff3a
...
...
@@ -6,19 +6,18 @@ in the source distribution for its full text.
*/
#define _GNU_SOURCE
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <curses.h>
#include <stdarg.h>
#include "RichString.h"
#include "Meter.h"
#include "Object.h"
#include "CRT.h"
#include "ListItem.h"
#include "String.h"
#include "ProcessList.h"
#include "RichString.h"
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include "debug.h"
#include <assert.h>
...
...
Meter.h
View file @
6330ff3a
...
...
@@ -10,18 +10,17 @@ in the source distribution for its full text.
*/
#define _GNU_SOURCE
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <curses.h>
#include <stdarg.h>
#include "RichString.h"
#include "Object.h"
#include "CRT.h"
#include "ListItem.h"
#include "String.h"
#include "ProcessList.h"
#include "RichString.h"
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include "debug.h"
#include <assert.h>
...
...
MetersPanel.c
View file @
6330ff3a
...
...
@@ -79,6 +79,7 @@ static HandlerResult MetersPanel_EventHandler(Panel* super, int ch) {
}
if
(
result
==
HANDLED
)
{
Header
*
header
=
this
->
settings
->
header
;
this
->
settings
->
changed
=
true
;
Header_calculateHeight
(
header
);
Header_draw
(
header
);
ScreenManager_resize
(
this
->
scr
,
this
->
scr
->
x1
,
header
->
height
,
this
->
scr
->
x2
,
this
->
scr
->
y2
);
...
...
Panel.c
View file @
6330ff3a
...
...
@@ -94,9 +94,9 @@ void Panel_init(Panel* this, int x, int y, int w, int h, char* type, bool owner)
this
->
selected
=
0
;
this
->
oldSelected
=
0
;
this
->
needsRedraw
=
true
;
this
->
header
.
len
=
0
;
RichString_prune
(
&
(
this
->
header
))
;
if
(
String_eq
(
CRT_termType
,
"linux"
))
this
->
scrollHAmount
=
4
0
;
this
->
scrollHAmount
=
2
0
;
else
this
->
scrollHAmount
=
5
;
}
...
...
@@ -213,7 +213,7 @@ int Panel_getSelectedIndex(Panel* this) {
return
this
->
selected
;
}
int
Panel_
getS
ize
(
Panel
*
this
)
{
int
Panel_
s
ize
(
Panel
*
this
)
{
assert
(
this
!=
NULL
);
return
Vector_size
(
this
->
items
);
...
...
@@ -326,43 +326,74 @@ void Panel_draw(Panel* this, bool focus) {
move
(
0
,
0
);
}
void
Panel_onKey
(
Panel
*
this
,
int
key
)
{
bool
Panel_onKey
(
Panel
*
this
,
int
key
)
{
assert
(
this
!=
NULL
);
switch
(
key
)
{
case
KEY_DOWN
:
if
(
this
->
selected
+
1
<
Vector_size
(
this
->
items
))
this
->
selected
++
;
b
re
ak
;
re
turn
true
;
case
KEY_UP
:
if
(
this
->
selected
>
0
)
this
->
selected
--
;
break
;
return
true
;
#ifdef KEY_C_DOWN
case
KEY_C_DOWN
:
if
(
this
->
selected
+
1
<
Vector_size
(
this
->
items
))
{
this
->
selected
++
;
if
(
this
->
scrollV
<
Vector_size
(
this
->
items
)
-
this
->
h
)
{
this
->
scrollV
++
;
this
->
needsRedraw
=
true
;
}
}
return
true
;
#endif
#ifdef KEY_C_UP
case
KEY_C_UP
:
if
(
this
->
selected
>
0
)
{
this
->
selected
--
;
if
(
this
->
scrollV
>
0
)
{
this
->
scrollV
--
;
this
->
needsRedraw
=
true
;
}
}
return
true
;
#endif
case
KEY_LEFT
:
if
(
this
->
scrollH
>
0
)
{
this
->
scrollH
-=
this
->
scrollHAmount
;
this
->
scrollH
-=
5
;
this
->
needsRedraw
=
true
;
}
b
re
ak
;
re
turn
true
;
case
KEY_RIGHT
:
this
->
scrollH
+=
this
->
scrollHAmount
;
this
->
scrollH
+=
5
;
this
->
needsRedraw
=
true
;
b
re
ak
;
re
turn
true
;
case
KEY_PPAGE
:
this
->
selected
-=
this
->
h
;
this
->
selected
-=
(
this
->
h
-
1
);
this
->
scrollV
-=
(
this
->
h
-
1
);
if
(
this
->
selected
<
0
)
this
->
selected
=
0
;
break
;
if
(
this
->
scrollV
<
0
)
this
->
scrollV
=
0
;
this
->
needsRedraw
=
true
;
return
true
;
case
KEY_NPAGE
:
this
->
selected
+=
this
->
h
;
this
->
selected
+=
(
this
->
h
-
1
)
;
int
size
=
Vector_size
(
this
->
items
);
if
(
this
->
selected
>=
size
)
this
->
selected
=
size
-
1
;
break
;
this
->
scrollV
+=
(
this
->
h
-
1
);
if
(
this
->
scrollV
>=
MAX
(
0
,
size
-
this
->
h
))
this
->
scrollV
=
MAX
(
0
,
size
-
this
->
h
-
1
);
this
->
needsRedraw
=
true
;
return
true
;
case
KEY_HOME
:
this
->
selected
=
0
;
b
re
ak
;
re
turn
true
;
case
KEY_END
:
this
->
selected
=
Vector_size
(
this
->
items
)
-
1
;
b
re
ak
;
re
turn
true
;
}
return
false
;
}
Panel.h
View file @
6330ff3a
...
...
@@ -104,12 +104,12 @@ void Panel_moveSelectedDown(Panel* this);
int
Panel_getSelectedIndex
(
Panel
*
this
);
int
Panel_
getS
ize
(
Panel
*
this
);
int
Panel_
s
ize
(
Panel
*
this
);
void
Panel_setSelected
(
Panel
*
this
,
int
selected
);
void
Panel_draw
(
Panel
*
this
,
bool
focus
);
void
Panel_onKey
(
Panel
*
this
,
int
key
);
bool
Panel_onKey
(
Panel
*
this
,
int
key
);
#endif
Process.c
View file @
6330ff3a
...
...
@@ -208,8 +208,8 @@ static int Process_getuid = -1;
static
void
Process_printLargeNumber
(
Process
*
this
,
RichString
*
str
,
unsigned
long
number
)
{
char
buffer
[
11
];
int
len
;
if
(
number
>=
(
10
00
*
ONE_M
))
{
len
=
snprintf
(
buffer
,
10
,
"%
4.2
fG "
,
(
float
)
number
/
ONE_M
);
if
(
number
>=
(
10
*
ONE_M
))
{
len
=
snprintf
(
buffer
,
10
,
"%
3.1
fG "
,
(
float
)
number
/
ONE_M
);
RichString_appendn
(
str
,
CRT_colors
[
LARGE_NUMBER
],
buffer
,
len
);
}
else
if
(
number
>=
(
100000
))
{
len
=
snprintf
(
buffer
,
10
,
"%4ldM "
,
number
/
ONE_K
);
...
...
@@ -535,7 +535,7 @@ int Process_compare(const void* v1, const void* v2) {
case
PPID
:
return
(
p1
->
ppid
-
p2
->
ppid
);
case
USER
:
return
strcmp
(
p1
->
user
,
p2
->
user
);
return
strcmp
(
p1
->
user
?
p1
->
user
:
""
,
p2
->
user
?
p2
->
user
:
""
);
case
PRIORITY
:
return
(
p1
->
priority
-
p2
->
priority
);
case
PROCESSOR
:
...
...
RichString.c
View file @
6330ff3a
...
...
@@ -8,13 +8,14 @@
#include <stdlib.h>
#include <string.h>
#include <curses.h>
#include <ctype.h>
#include "debug.h"
#include <assert.h>
#ifdef HAVE_LIBNCURSESW
#include <wchar.h>
#include <curses.h>
#else
#include <ncursesw/curses.h>
#endif
#define RICHSTRING_MAXLEN 300
...
...
@@ -116,6 +117,10 @@ int RichString_findChar(RichString *this, char c, int start) {
#endif
void
RichString_prune
(
RichString
*
this
)
{
this
->
len
=
0
;
}
void
RichString_setAttr
(
RichString
*
this
,
int
attrs
)
{
RichString_setAttrn
(
this
,
attrs
,
0
,
this
->
len
-
1
);
}
...
...
RichString.h
View file @
6330ff3a
...
...
@@ -11,13 +11,14 @@
#include <stdlib.h>
#include <string.h>
#include <curses.h>
#include <ctype.h>
#include "debug.h"
#include <assert.h>
#ifdef HAVE_LIBNCURSESW
#include <wchar.h>
#include <curses.h>
#else
#include <ncursesw/curses.h>
#endif
#define RICHSTRING_MAXLEN 300
...
...
@@ -68,6 +69,8 @@ int RichString_findChar(RichString *this, char c, int start);
#endif
void
RichString_prune
(
RichString
*
this
);
void
RichString_setAttr
(
RichString
*
this
,
int
attrs
);
extern
void
RichString_append
(
RichString
*
this
,
int
attrs
,
char
*
data
);
...
...
ScreenManager.c
View file @
6330ff3a
...
...
@@ -83,7 +83,7 @@ void ScreenManager_add(ScreenManager* this, Panel* item, FunctionBar* fuBar, int
if
(
fuBar
)
Vector_add
(
this
->
fuBars
,
fuBar
);
else
Vector_add
(
this
->
fuBars
,
FunctionBar_new
(
0
,
NULL
,
NULL
,
NULL
));
Vector_add
(
this
->
fuBars
,
FunctionBar_new
(
NULL
,
NULL
,
NULL
));
if
(
!
this
->
fuBar
&&
fuBar
)
this
->
fuBar
=
fuBar
;
item
->
needsRedraw
=
true
;
this
->
itemCount
++
;
...
...
@@ -188,7 +188,7 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
if
(
focus
>
0
)
focus
--
;
panelFocus
=
(
Panel
*
)
Vector_get
(
this
->
items
,
focus
);
if
(
Panel_
getS
ize
(
panelFocus
)
==
0
&&
focus
>
0
)
if
(
Panel_
s
ize
(
panelFocus
)
==
0
&&
focus
>
0
)
goto
tryLeft
;
break
;
case
KEY_RIGHT
:
...
...
@@ -197,7 +197,7 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
if
(
focus
<
this
->
itemCount
-
1
)
focus
++
;
panelFocus
=
(
Panel
*
)
Vector_get
(
this
->
items
,
focus
);
if
(
Panel_
getS
ize
(
panelFocus
)
==
0
&&
focus
<
this
->
itemCount
-
1
)
if
(
Panel_
s
ize
(
panelFocus
)
==
0
&&
focus
<
this
->
itemCount
-
1
)
goto
tryRight
;
break
;
case
KEY_F
(
10
):
...
...
SignalsPanel.c
View file @
6330ff3a
...
...
@@ -23,7 +23,7 @@ typedef struct SignalsPanel_ {
static
HandlerResult
SignalsPanel_eventHandler
(
Panel
*
super
,
int
ch
)
{
SignalsPanel
*
this
=
(
SignalsPanel
*
)
super
;
int
size
=
Panel_
getS
ize
(
super
);
int
size
=
Panel_
s
ize
(
super
);
if
(
ch
<=
255
&&
isdigit
(
ch
))
{
int
signal
=
ch
-
48
+
this
->
state
;
...
...
TraceScreen.c
View file @
6330ff3a
...
...
@@ -32,17 +32,17 @@ typedef struct TraceScreen_ {
}*/
static
char
*
tbFunctions
[
3
]
=
{
"AutoScroll "
,
"Stop Tracing "
,
"Done "
};
static
char
*
tbFunctions
[]
=
{
"AutoScroll "
,
"Stop Tracing "
,
"Done "
,
NULL
};
static
char
*
tbKeys
[
3
]
=
{
"F4"
,
"F5"
,
"Esc"
};
static
char
*
tbKeys
[]
=
{
"F4"
,
"F5"
,
"Esc"
};
static
int
tbEvents
[
3
]
=
{
KEY_F
(
4
),
KEY_F
(
5
),
27
};
static
int
tbEvents
[]
=
{
KEY_F
(
4
),
KEY_F
(
5
),
27
};
TraceScreen
*
TraceScreen_new
(
Process
*
process
)
{
TraceScreen
*
this
=
(
TraceScreen
*
)
malloc
(
sizeof
(
TraceScreen
));
this
->
process
=
process
;
this
->
display
=
Panel_new
(
0
,
1
,
COLS
,
LINES
-
2
,
LISTITEM_CLASS
,
true
,
ListItem_compare
);
this
->
bar
=
FunctionBar_new
(
3
,
tbFunctions
,
tbKeys
,
tbEvents
);
this
->
bar
=
FunctionBar_new
(
tbFunctions
,
tbKeys
,
tbEvents
);
this
->
tracing
=
true
;
return
this
;
}
...
...
@@ -105,7 +105,7 @@ void TraceScreen_run(TraceScreen* this) {
buffer
[
i
]
=
'\0'
;
if
(
contLine
)
{
ListItem_append
((
ListItem
*
)
Panel_get
(
panel
,
Panel_
getS
ize
(
panel
)
-
1
),
line
);
Panel_
s
ize
(
panel
)
-
1
),
line
);
contLine
=
false
;
}
else
{
Panel_add
(
panel
,
(
Object
*
)
ListItem_new
(
line
,
0
));
...
...
@@ -119,7 +119,7 @@ void TraceScreen_run(TraceScreen* this) {
contLine
=
true
;
}
if
(
follow
)
Panel_setSelected
(
panel
,
Panel_
getS
ize
(
panel
)
-
1
);
Panel_setSelected
(
panel
,
Panel_
s
ize
(
panel
)
-
1
);
Panel_draw
(
panel
,
true
);
}
int
ch
=
getch
();
...
...
@@ -146,7 +146,7 @@ void TraceScreen_run(TraceScreen* this) {
case
KEY_F
(
4
):
follow
=
!
follow
;
if
(
follow
)
Panel_setSelected
(
panel
,
Panel_
getS
ize
(
panel
)
-
1
);
Panel_setSelected
(
panel
,
Panel_
s
ize
(
panel
)
-
1
);
break
;
case
'q'
:
case
27
:
...
...
configure.ac
View file @
6330ff3a
...
...
@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.57)
AC_INIT([htop],[0.8.
1
],[loderunner@users.sourceforge.net])
AC_INIT([htop],[0.8.
2
],[loderunner@users.sourceforge.net])
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([htop.c])
AC_CONFIG_HEADER([config.h])
...
...
@@ -88,8 +88,10 @@ fi
AC_ARG_ENABLE(unicode, [AC_HELP_STRING([--enable-unicode], [enable Unicode support])], ,enable_unicode="no")
if test "x$enable_unicode" = xyes; then
AC_CHECK_LIB([ncursesw], [refresh], [], [missing_libraries="$missing_libraries libncursesw"])
AC_CHECK_HEADERS([ncursesw/curses.h],[:],[missing_headers="$missing_headers $ac_header"])
else
AC_CHECK_LIB([ncurses], [refresh], [], [missing_libraries="$missing_libraries libncurses"])
AC_CHECK_HEADERS([curses.h],[:],[missing_headers="$missing_headers $ac_header"])
fi
AC_CHECK_FILE($PROCDIR/stat,,AC_MSG_ERROR(Cannot find /proc/stat. Make sure you have a Linux-compatible /proc filesystem mounted. See the file README for help.))
...
...
Prev
1
2
Next
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