summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2009-06-02 04:51:23 +0000
committerHisham Muhammad <hisham@gobolinux.org>2009-06-02 04:51:23 +0000
commit6330ff3a0ac6d279132d36cea027ad3f065707b1 (patch)
tree70d894309bb92c9146fc4063e41d68686ffcfafd
parent1371ee28a7e953052e414dfd1641294852aa4458 (diff)
changes for htop 0.8.2
-rw-r--r--AffinityPanel.c2
-rw-r--r--CPUMeter.c8
-rw-r--r--CategoriesPanel.c26
-rw-r--r--ChangeLog3
-rw-r--r--ColumnsPanel.c4
-rw-r--r--FunctionBar.c22
-rw-r--r--FunctionBar.h2
-rw-r--r--Makefile.am4
-rw-r--r--Meter.c13
-rw-r--r--Meter.h13
-rw-r--r--MetersPanel.c1
-rw-r--r--Panel.c63
-rw-r--r--Panel.h4
-rw-r--r--Process.c6
-rw-r--r--RichString.c9
-rw-r--r--RichString.h7
-rw-r--r--ScreenManager.c6
-rw-r--r--SignalsPanel.c2
-rw-r--r--TraceScreen.c14
-rw-r--r--configure.ac4
-rw-r--r--htop.12
-rw-r--r--htop.c65
-rw-r--r--htop.h1
-rw-r--r--plpa-1.1/Makefile.in1
-rw-r--r--plpa-1.1/src/Makefile.in1
25 files changed, 177 insertions, 106 deletions
diff --git a/AffinityPanel.c b/AffinityPanel.c
index 47791ff1..bcd99a32 100644
--- a/AffinityPanel.c
+++ b/AffinityPanel.c
@@ -39,7 +39,7 @@ Panel* AffinityPanel_new(int processorCount, unsigned long mask) {
}
unsigned long AffinityPanel_getAffinity(Panel* this) {
- int size = Panel_getSize(this);
+ int size = Panel_size(this);
unsigned long mask = 0;
for (int i = 0; i < size; i++) {
if (CheckItem_get((CheckItem*)Panel_get(this, i)))
diff --git a/CPUMeter.c b/CPUMeter.c
index bc6af15e..7325bff7 100644
--- a/CPUMeter.c
+++ b/CPUMeter.c
@@ -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);
diff --git a/CategoriesPanel.c b/CategoriesPanel.c
index 8b9d6636..9a8bc196 100644
--- a/CategoriesPanel.c
+++ b/CategoriesPanel.c
@@ -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) {
diff --git a/ChangeLog b/ChangeLog
index 2c9078a6..708b9be4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,9 @@
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)
diff --git a/ColumnsPanel.c b/ColumnsPanel.c
index d52178c4..94a21232 100644
--- a/ColumnsPanel.c
+++ b/ColumnsPanel.c
@@ -30,7 +30,7 @@ static HandlerResult ColumnsPanel_eventHandler(Panel* super, int ch) {
int selected = Panel_getSelectedIndex(super);
HandlerResult result = IGNORED;
- int size = Panel_getSize(super);
+ int size = Panel_size(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_getSize(super);
+ int size = Panel_size(super);
this->settings->changed = true;
// FIXME: this is crappily inefficient
free(this->settings->pl->fields);
diff --git a/FunctionBar.c b/FunctionBar.c
index 1140267b..a66d74c0 100644
--- a/FunctionBar.c
+++ b/FunctionBar.c
@@ -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;
}
diff --git a/FunctionBar.h b/FunctionBar.h
index dfdef606..ae84496b 100644
--- a/FunctionBar.h
+++ b/FunctionBar.h
@@ -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);
diff --git a/Makefile.am b/Makefile.am
index d3fcb43b..a958235b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -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
diff --git a/Meter.c b/Meter.c
index 1436bb22..9c32d353 100644
--- a/Meter.c
+++ b/Meter.c
@@ -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>
diff --git a/Meter.h b/Meter.h
index 86e3489c..fb2ec1ed 100644
--- a/Meter.h
+++ b/Meter.h
@@ -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>
diff --git a/MetersPanel.c b/MetersPanel.c
index 549d8fed..291164fb 100644
--- a/MetersPanel.c
+++ b/MetersPanel.c
@@ -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);
diff --git a/Panel.c b/Panel.c
index 00ff4c69..3ae492e0 100644
--- a/Panel.c
+++ b/Panel.c
@@ -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 = 40;
+ this->scrollHAmount = 20;
else
this->scrollHAmount = 5;
}
@@ -213,7 +213,7 @@ int Panel_getSelectedIndex(Panel* this) {
return this->selected;
}
-int Panel_getSize(Panel* this) {
+int Panel_size(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++;
- break;
+ return 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;
}
- break;
+ return true;
case KEY_RIGHT:
- this->scrollH += this->scrollHAmount;
+ this->scrollH += 5;
this->needsRedraw = true;
- break;
+ return 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;
- break;
+ return true;
case KEY_END:
this->selected = Vector_size(this->items) - 1;
- break;
+ return true;
}
+ return false;
}
diff --git a/Panel.h b/Panel.h
index c0f603a6..ba522b95 100644
--- a/Panel.h
+++ b/Panel.h
@@ -104,12 +104,12 @@ void Panel_moveSelectedDown(Panel* this);
int Panel_getSelectedIndex(Panel* this);
-int Panel_getSize(Panel* this);
+int Panel_size(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
diff --git a/Process.c b/Process.c
index a3b931a6..8f3762cf 100644
--- a/Process.c
+++ b/Process.c
@@ -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 >= (1000 * ONE_M)) {
- len = snprintf(buffer, 10, "%4.2fG ", (float)number / ONE_M);
+ if(number >= (10 * ONE_M)) {
+ len = snprintf(buffer, 10, "%3.1fG ", (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:
diff --git a/RichString.c b/RichString.c
index fbcb17f1..38cb76c5 100644
--- a/RichString.c
+++ b/RichString.c
@@ -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);
}
diff --git a/RichString.h b/RichString.h
index 036a24a4..05991aa4 100644
--- a/RichString.h
+++ b/RichString.h
@@ -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);
diff --git a/ScreenManager.c b/ScreenManager.c
index 5b1713e7..536ff03d 100644
--- a/ScreenManager.c
+++ b/ScreenManager.c
@@ -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_getSize(panelFocus) == 0 && focus > 0)
+ if (Panel_size(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_getSize(panelFocus) == 0 && focus < this->itemCount - 1)
+ if (Panel_size(panelFocus) == 0 && focus < this->itemCount - 1)
goto tryRight;
break;
case KEY_F(10):
diff --git a/SignalsPanel.c b/SignalsPanel.c
index 559e42b9..2d1e967b 100644
--- a/SignalsPanel.c
+++ b/SignalsPanel.c
@@ -23,7 +23,7 @@ typedef struct SignalsPanel_ {
static HandlerResult SignalsPanel_eventHandler(Panel* super, int ch) {
SignalsPanel* this = (SignalsPanel*) super;
- int size = Panel_getSize(super);
+ int size = Panel_size(super);
if (ch <= 255 && isdigit(ch)) {
int signal = ch-48 + this->state;
diff --git a/TraceScreen.c b/TraceScreen.c
index 072c26dd..02e2a85c 100644
--- a/TraceScreen.c
+++ b/TraceScreen.c
@@ -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_getSize(panel)-1), line);
+ Panel_size(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_getSize(panel)-1);
+ Panel_setSelected(panel, Panel_size(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_getSize(panel)-1);
+ Panel_setSelected(panel, Panel_size(panel)-1);
break;
case 'q':
case 27:
diff --git a/configure.ac b/configure.ac
index 979509dd..6da8f9fc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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.))
diff --git a/htop.1 b/htop.1
index a43c2208..b91275e5 100644
--- a/htop.1
+++ b/htop.1
@@ -1,4 +1,4 @@
-.TH "htop" "1" "0.8" "Bartosz Fenski <fenio@o2.pl>" "Utils"
+.TH "htop" "1" "0.8.2" "Bartosz Fenski <fenio@o2.pl>" "Utils"
.SH "NAME"
htop \- interactive process viewer
.SH "SYNTAX"
diff --git a/htop.c b/htop.c
index 9648823a..e04f9350 100644
--- a/htop.c
+++ b/htop.c
@@ -26,6 +26,7 @@ in the source distribution for its full text.
#include "CategoriesPanel.h"
#include "SignalsPanel.h"
#include "TraceScreen.h"
+#include "OpenFilesScreen.h"
#include "AffinityPanel.h"
#include "config.h"
@@ -110,8 +111,8 @@ static void showHelp(ProcessList* pl) {
mvaddstr(13, 0, " Space: tag processes F: cursor follows process");
mvaddstr(14, 0, " U: untag all processes");
mvaddstr(15, 0, " F9 k: kill process/tagged processes P: sort by CPU%");
- mvaddstr(16, 0, " + [ F7: lower priority (+ nice) M: sort by MEM%");
- mvaddstr(17, 0, " - ] F8: higher priority (root only) T: sort by TIME");
+ mvaddstr(16, 0, " - ] F7: higher priority (root only) M: sort by MEM%");
+ mvaddstr(17, 0, " + [ F8: lower priority (+ nice) T: sort by TIME");
#ifdef HAVE_PLPA
if (pl->processorCount > 1)
mvaddstr(18, 0, " a: set CPU affinity F4 I: invert sort order");
@@ -119,7 +120,7 @@ static void showHelp(ProcessList* pl) {
#endif
mvaddstr(18, 0, " F4 I: invert sort order");
mvaddstr(19, 0, " F2 S: setup F6 >: select sort column");
- mvaddstr(20, 0, " F1 h: show this help screen");
+ mvaddstr(20, 0, " F1 h: show this help screen l: list open files with lsof");
mvaddstr(21, 0, " F10 q: quit s: trace syscalls with strace");
attrset(CRT_colors[HELP_BOLD]);
@@ -155,7 +156,7 @@ static char* CategoriesFunctions[10] = {" ", " ", " ", " ",
static void Setup_run(Settings* settings, int headerHeight) {
ScreenManager* scr = ScreenManager_new(0, headerHeight, 0, -1, HORIZONTAL, true);
CategoriesPanel* panelCategories = CategoriesPanel_new(settings, scr);
- ScreenManager_add(scr, (Panel*) panelCategories, FunctionBar_new(10, CategoriesFunctions, NULL, NULL), 16);
+ ScreenManager_add(scr, (Panel*) panelCategories, FunctionBar_new(CategoriesFunctions, NULL, NULL), 16);
CategoriesPanel_makeMetersPage(panelCategories);
Panel* panelFocus;
int ch;
@@ -166,7 +167,7 @@ static void Setup_run(Settings* settings, int headerHeight) {
static bool changePriority(Panel* panel, int delta) {
bool ok = true;
bool anyTagged = false;
- for (int i = 0; i < Panel_getSize(panel); i++) {
+ for (int i = 0; i < Panel_size(panel); i++) {
Process* p = (Process*) Panel_get(panel, i);
if (p->tag) {
ok = Process_setPriority(p, p->nice + delta) && ok;
@@ -188,13 +189,13 @@ static HandlerResult pickWithEnter(Panel* panel, int ch) {
return IGNORED;
}
-static Object* pickFromList(Panel* panel, Panel* list, int x, int y, char** keyLabels, FunctionBar* prevBar) {
+static Object* pickFromVector(Panel* panel, Panel* list, int x, int y, char** keyLabels, FunctionBar* prevBar) {
char* fuKeys[2] = {"Enter", "Esc"};
int fuEvents[2] = {13, 27};
if (!list->eventHandler)
Panel_setEventHandler(list, pickWithEnter);
ScreenManager* scr = ScreenManager_new(0, y, 0, -1, HORIZONTAL, false);
- ScreenManager_add(scr, list, FunctionBar_new(2, keyLabels, fuKeys, fuEvents), x - 1);
+ ScreenManager_add(scr, list, FunctionBar_new(keyLabels, fuKeys, fuEvents), x - 1);
ScreenManager_add(scr, panel, NULL, -1);
Panel* panelFocus;
int ch;
@@ -209,7 +210,7 @@ static Object* pickFromList(Panel* panel, Panel* list, int x, int y, char** keyL
return NULL;
}
-static void addUserToList(int key, void* userCast, void* panelCast) {
+static void addUserToVector(int key, void* userCast, void* panelCast) {
char* user = (char*) userCast;
Panel* panel = (Panel*) panelCast;
Panel_add(panel, (Object*) ListItem_new(user, key));
@@ -274,6 +275,9 @@ int main(int argc, char** argv) {
if (arg == argc - 1) printHelpFlag();
arg++;
setUserOnly(argv[arg], &userOnly, &userId);
+ } else {
+ fprintf(stderr, "Error: unknown flag: %s\n", argv[arg]);
+ exit(1);
}
arg++;
}
@@ -321,14 +325,14 @@ int main(int argc, char** argv) {
}
Panel_setRichHeader(panel, ProcessList_printHeader(pl));
- char* searchFunctions[3] = {"Next ", "Exit ", " Search: "};
- char* searchKeys[3] = {"F3", "Esc", " "};
- int searchEvents[3] = {KEY_F(3), 27, ERR};
- FunctionBar* searchBar = FunctionBar_new(3, searchFunctions, searchKeys, searchEvents);
+ char* searchFunctions[] = {"Next ", "Exit ", " Search: ", NULL};
+ char* searchKeys[] = {"F3", "Esc", " "};
+ int searchEvents[] = {KEY_F(3), 27, ERR};
+ FunctionBar* searchBar = FunctionBar_new(searchFunctions, searchKeys, searchEvents);
- char* defaultFunctions[10] = {"Help ", "Setup ", "Search", "Invert", "Tree ",
- "SortBy", "Nice -", "Nice +", "Kill ", "Quit "};
- FunctionBar* defaultBar = FunctionBar_new(10, defaultFunctions, NULL, NULL);
+ char* defaultFunctions[] = {"Help ", "Setup ", "Search", "Invert", "Tree ",
+ "SortBy", "Nice -", "Nice +", "Kill ", "Quit ", NULL};
+ FunctionBar* defaultBar = FunctionBar_new(defaultFunctions, NULL, NULL);
ProcessList_scan(pl);
usleep(75000);
@@ -512,7 +516,7 @@ int main(int argc, char** argv) {
}
case 'U':
{
- for (int i = 0; i < Panel_getSize(panel); i++) {
+ for (int i = 0; i < Panel_size(panel); i++) {
Process* p = (Process*) Panel_get(panel, i);
p->tag = false;
}
@@ -558,6 +562,17 @@ int main(int argc, char** argv) {
CRT_enableDelay();
break;
}
+ case 'l':
+ {
+ OpenFilesScreen* ts = OpenFilesScreen_new((Process*) Panel_getSelected(panel));
+ OpenFilesScreen_run(ts);
+ OpenFilesScreen_delete(ts);
+ clear();
+ FunctionBar_draw(defaultBar, NULL);
+ refreshTimeout = 0;
+ CRT_enableDelay();
+ break;
+ }
case 'S':
case 'C':
case KEY_F(2):
@@ -581,12 +596,12 @@ int main(int argc, char** argv) {
{
Panel* usersPanel = Panel_new(0, 0, 0, 0, LISTITEM_CLASS, true, ListItem_compare);
Panel_setHeader(usersPanel, "Show processes of:");
- UsersTable_foreach(ut, addUserToList, usersPanel);
+ UsersTable_foreach(ut, addUserToVector, usersPanel);
Vector_sort(usersPanel->items);
ListItem* allUsers = ListItem_new("All users", -1);
Panel_insert(usersPanel, 0, (Object*) allUsers);
- char* fuFunctions[2] = {"Show ", "Cancel "};
- ListItem* picked = (ListItem*) pickFromList(panel, usersPanel, 20, headerHeight, fuFunctions, defaultBar);
+ char* fuFunctions[] = {"Show ", "Cancel ", NULL};
+ ListItem* picked = (ListItem*) pickFromVector(panel, usersPanel, 20, headerHeight, fuFunctions, defaultBar);
if (picked) {
if (picked == allUsers) {
userOnly = false;
@@ -604,15 +619,15 @@ int main(int argc, char** argv) {
killPanel = (Panel*) SignalsPanel_new(0, 0, 0, 0);
}
SignalsPanel_reset((SignalsPanel*) killPanel);
- char* fuFunctions[2] = {"Send ", "Cancel "};
- Signal* signal = (Signal*) pickFromList(panel, killPanel, 15, headerHeight, fuFunctions, defaultBar);
+ char* fuFunctions[] = {"Send ", "Cancel ", NULL};
+ Signal* signal = (Signal*) pickFromVector(panel, killPanel, 15, headerHeight, fuFunctions, defaultBar);
if (signal) {
if (signal->number != 0) {
Panel_setHeader(panel, "Sending...");
Panel_draw(panel, true);
refresh();
bool anyTagged = false;
- for (int i = 0; i < Panel_getSize(panel); i++) {
+ for (int i = 0; i < Panel_size(panel); i++) {
Process* p = (Process*) Panel_get(panel, i);
if (p->tag) {
Process_sendSignal(p, signal->number);
@@ -642,12 +657,12 @@ int main(int argc, char** argv) {
Panel* affinityPanel = AffinityPanel_new(pl->processorCount, curr);
char* fuFunctions[2] = {"Set ", "Cancel "};
- void* set = pickFromList(panel, affinityPanel, 15, headerHeight, fuFunctions, defaultBar);
+ void* set = pickFromVector(panel, affinityPanel, 15, headerHeight, fuFunctions, defaultBar);
if (set) {
unsigned long new = AffinityPanel_getAffinity(affinityPanel);
bool anyTagged = false;
bool ok = true;
- for (int i = 0; i < Panel_getSize(panel); i++) {
+ for (int i = 0; i < Panel_size(panel); i++) {
Process* p = (Process*) Panel_get(panel, i);
if (p->tag) {
ok = Process_setAffinity(p, new) && ok;
@@ -689,7 +704,7 @@ int main(int argc, char** argv) {
Panel_setSelected(sortPanel, i);
free(name);
}
- ListItem* field = (ListItem*) pickFromList(panel, sortPanel, 15, headerHeight, fuFunctions, defaultBar);
+ ListItem* field = (ListItem*) pickFromVector(panel, sortPanel, 15, headerHeight, fuFunctions, defaultBar);
if (field) {
settings->changed = true;
setSortKey(pl, field->key, panel, settings);
diff --git a/htop.h b/htop.h
index f6a0f407..b1c69a28 100644
--- a/htop.h
+++ b/htop.h
@@ -30,6 +30,7 @@ in the source distribution for its full text.
#include "CategoriesPanel.h"
#include "SignalsPanel.h"
#include "TraceScreen.h"
+#include "OpenFilesScreen.h"
#include "AffinityPanel.h"
#include "config.h"
diff --git a/plpa-1.1/Makefile.in b/plpa-1.1/Makefile.in
index a004a6a6..31dae872 100644
--- a/plpa-1.1/Makefile.in
+++ b/plpa-1.1/Makefile.in
@@ -122,6 +122,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
+SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
diff --git a/plpa-1.1/src/Makefile.in b/plpa-1.1/src/Makefile.in
index e7f55f94..8d420b0a 100644
--- a/plpa-1.1/src/Makefile.in
+++ b/plpa-1.1/src/Makefile.in
@@ -157,6 +157,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
+SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@

© 2014-2024 Faster IT GmbH | imprint | privacy policy