Commit 6330ff3a authored by Hisham Muhammad's avatar Hisham Muhammad
Browse files

changes for htop 0.8.2

parent 1371ee28
...@@ -39,7 +39,7 @@ Panel* AffinityPanel_new(int processorCount, unsigned long mask) { ...@@ -39,7 +39,7 @@ Panel* AffinityPanel_new(int processorCount, unsigned long mask) {
} }
unsigned long AffinityPanel_getAffinity(Panel* this) { unsigned long AffinityPanel_getAffinity(Panel* this) {
int size = Panel_getSize(this); int size = Panel_size(this);
unsigned long mask = 0; unsigned long mask = 0;
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
if (CheckItem_get((CheckItem*)Panel_get(this, i))) if (CheckItem_get((CheckItem*)Panel_get(this, i)))
......
...@@ -43,6 +43,10 @@ static void CPUMeter_init(Meter* this) { ...@@ -43,6 +43,10 @@ static void CPUMeter_init(Meter* this) {
static void CPUMeter_setValues(Meter* this, char* buffer, int size) { static void CPUMeter_setValues(Meter* this, char* buffer, int size) {
ProcessList* pl = this->pl; ProcessList* pl = this->pl;
int processor = this->param; int processor = this->param;
if (processor > this->pl->processorCount) {
snprintf(buffer, size, "absent");
return;
}
double total = (double) pl->totalPeriod[processor]; double total = (double) pl->totalPeriod[processor];
double cpu; double cpu;
this->values[0] = pl->nicePeriod[processor] / total * 100.0; this->values[0] = pl->nicePeriod[processor] / total * 100.0;
...@@ -67,6 +71,10 @@ static void CPUMeter_display(Object* cast, RichString* out) { ...@@ -67,6 +71,10 @@ static void CPUMeter_display(Object* cast, RichString* out) {
char buffer[50]; char buffer[50];
Meter* this = (Meter*)cast; Meter* this = (Meter*)cast;
RichString_init(out); 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]); sprintf(buffer, "%5.1f%% ", this->values[1]);
RichString_append(out, CRT_colors[METER_TEXT], ":"); RichString_append(out, CRT_colors[METER_TEXT], ":");
RichString_append(out, CRT_colors[CPU_NORMAL], buffer); RichString_append(out, CRT_colors[CPU_NORMAL], buffer);
......
...@@ -23,17 +23,17 @@ typedef struct CategoriesPanel_ { ...@@ -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) { static void CategoriesPanel_delete(Object* object) {
Panel* super = (Panel*) object; Panel* super = (Panel*) object;
...@@ -46,26 +46,26 @@ void CategoriesPanel_makeMetersPage(CategoriesPanel* this) { ...@@ -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* 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* 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); 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, leftMeters, FunctionBar_new(MetersFunctions, NULL, NULL), 20);
ScreenManager_add(this->scr, rightMeters, FunctionBar_new(10, MetersFunctions, NULL, NULL), 20); ScreenManager_add(this->scr, rightMeters, FunctionBar_new(MetersFunctions, NULL, NULL), 20);
ScreenManager_add(this->scr, availableMeters, FunctionBar_new(10, AvailableMetersFunctions, NULL, NULL), -1); ScreenManager_add(this->scr, availableMeters, FunctionBar_new(AvailableMetersFunctions, NULL, NULL), -1);
} }
static void CategoriesPanel_makeDisplayOptionsPage(CategoriesPanel* this) { static void CategoriesPanel_makeDisplayOptionsPage(CategoriesPanel* this) {
Panel* displayOptions = (Panel*) DisplayOptionsPanel_new(this->settings, this->scr); 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) { static void CategoriesPanel_makeColorsPage(CategoriesPanel* this) {
Panel* colors = (Panel*) ColorsPanel_new(this->settings, this->scr); 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) { static void CategoriesPanel_makeColumnsPage(CategoriesPanel* this) {
Panel* columns = (Panel*) ColumnsPanel_new(this->settings, this->scr); Panel* columns = (Panel*) ColumnsPanel_new(this->settings, this->scr);
Panel* availableColumns = (Panel*) AvailableColumnsPanel_new(this->settings, columns, 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, columns, FunctionBar_new(ColumnsFunctions, NULL, NULL), 20);
ScreenManager_add(this->scr, availableColumns, FunctionBar_new(10, AvailableColumnsFunctions, NULL, NULL), -1); ScreenManager_add(this->scr, availableColumns, FunctionBar_new(AvailableColumnsFunctions, NULL, NULL), -1);
} }
static HandlerResult CategoriesPanel_eventHandler(Panel* super, int ch) { static HandlerResult CategoriesPanel_eventHandler(Panel* super, int ch) {
......
What's new in version 0.8.2 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 * Option to display hostname in the meters area
* Rename VEID to CTID in OpenVZ systems * Rename VEID to CTID in OpenVZ systems
(thanks to Thorsten Schifferdecker) (thanks to Thorsten Schifferdecker)
......
...@@ -30,7 +30,7 @@ static HandlerResult ColumnsPanel_eventHandler(Panel* super, int ch) { ...@@ -30,7 +30,7 @@ static HandlerResult ColumnsPanel_eventHandler(Panel* super, int ch) {
int selected = Panel_getSelectedIndex(super); int selected = Panel_getSelectedIndex(super);
HandlerResult result = IGNORED; HandlerResult result = IGNORED;
int size = Panel_getSize(super); int size = Panel_size(super);
switch(ch) { switch(ch) {
case KEY_F(7): case KEY_F(7):
...@@ -95,7 +95,7 @@ int ColumnsPanel_fieldNameToIndex(const char* name) { ...@@ -95,7 +95,7 @@ int ColumnsPanel_fieldNameToIndex(const char* name) {
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_size(super);
this->settings->changed = true; this->settings->changed = true;
// FIXME: this is crappily inefficient // FIXME: this is crappily inefficient
free(this->settings->pl->fields); free(this->settings->pl->fields);
......
...@@ -36,34 +36,36 @@ char* FUNCTIONBAR_CLASS = "FunctionBar"; ...@@ -36,34 +36,36 @@ char* FUNCTIONBAR_CLASS = "FunctionBar";
#define FUNCTIONBAR_CLASS NULL #define FUNCTIONBAR_CLASS NULL
#endif #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)); FunctionBar* this = malloc(sizeof(FunctionBar));
Object_setClass(this, FUNCTIONBAR_CLASS); Object_setClass(this, FUNCTIONBAR_CLASS);
((Object*) this)->delete = FunctionBar_delete; ((Object*) this)->delete = FunctionBar_delete;
this->functions = functions; this->functions = functions;
this->size = size;
if (keys && events) { if (keys && events) {
this->staticData = false; this->staticData = false;
this->functions = malloc(sizeof(char*) * size); this->functions = malloc(sizeof(char*) * 15);
this->keys = malloc(sizeof(char*) * size); this->keys = malloc(sizeof(char*) * 15);
this->events = malloc(sizeof(int) * size); this->events = malloc(sizeof(int) * 15);
for (int i = 0; i < size; i++) { int i = 0;
while (i < 15 && functions[i]) {
this->functions[i] = String_copy(functions[i]); this->functions[i] = String_copy(functions[i]);
this->keys[i] = String_copy(keys[i]); this->keys[i] = String_copy(keys[i]);
this->events[i] = events[i]; this->events[i] = events[i];
i++;
} }
this->size = i;
} else { } else {
this->staticData = true; this->staticData = true;
this->functions = functions ? functions : FunctionBar_FLabels; this->functions = functions ? functions : FunctionBar_FLabels;
this->keys = FunctionBar_FKeys; this->keys = FunctionBar_FKeys;
this->events = FunctionBar_FEvents; this->events = FunctionBar_FEvents;
assert((!functions) || this->size == 10); this->size = 10;
} }
return this; return this;
} }
......
...@@ -37,7 +37,7 @@ extern char* FUNCTIONBAR_CLASS; ...@@ -37,7 +37,7 @@ extern char* FUNCTIONBAR_CLASS;
#define FUNCTIONBAR_CLASS NULL #define FUNCTIONBAR_CLASS NULL
#endif #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); void FunctionBar_delete(Object* cast);
......
...@@ -22,7 +22,7 @@ LoadAverageMeter.c MemoryMeter.c Meter.c MetersPanel.c Object.c Panel.c \ ...@@ -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 \ BatteryMeter.c Process.c ProcessList.c RichString.c ScreenManager.c Settings.c \
SignalItem.c SignalsPanel.c String.c SwapMeter.c TasksMeter.c TraceScreen.c \ SignalItem.c SignalsPanel.c String.c SwapMeter.c TasksMeter.c TraceScreen.c \
UptimeMeter.c UsersTable.c Vector.c AvailableColumnsPanel.c AffinityPanel.c \ UptimeMeter.c UsersTable.c Vector.c AvailableColumnsPanel.c AffinityPanel.c \
HostnameMeter.c HostnameMeter.c OpenFilesScreen.c
myhtopheaders = AvailableColumnsPanel.h AvailableMetersPanel.h \ myhtopheaders = AvailableColumnsPanel.h AvailableMetersPanel.h \
CategoriesPanel.h CheckItem.h ClockMeter.h ColorsPanel.h ColumnsPanel.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 \ ...@@ -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 \ BatteryMeter.h Meter.h MetersPanel.h Object.h Panel.h ProcessList.h RichString.h \
ScreenManager.h Settings.h SignalItem.h SignalsPanel.h String.h \ ScreenManager.h Settings.h SignalItem.h SignalsPanel.h String.h \
SwapMeter.h TasksMeter.h TraceScreen.h UptimeMeter.h UsersTable.h Vector.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 SUFFIXES = .h
......
...@@ -6,19 +6,18 @@ in the source distribution for its full text. ...@@ -6,19 +6,18 @@ in the source distribution for its full text.
*/ */
#define _GNU_SOURCE #define _GNU_SOURCE
#include <math.h> #include "RichString.h"
#include <string.h>
#include <stdlib.h>
#include <curses.h>
#include <stdarg.h>
#include "Meter.h" #include "Meter.h"
#include "Object.h" #include "Object.h"
#include "CRT.h" #include "CRT.h"
#include "ListItem.h" #include "ListItem.h"
#include "String.h" #include "String.h"
#include "ProcessList.h" #include "ProcessList.h"
#include "RichString.h"
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include "debug.h" #include "debug.h"
#include <assert.h> #include <assert.h>
......
...@@ -10,18 +10,17 @@ in the source distribution for its full text. ...@@ -10,18 +10,17 @@ in the source distribution for its full text.
*/ */
#define _GNU_SOURCE #define _GNU_SOURCE
#include <math.h> #include "RichString.h"
#include <string.h>
#include <stdlib.h>
#include <curses.h>
#include <stdarg.h>
#include "Object.h" #include "Object.h"
#include "CRT.h" #include "CRT.h"
#include "ListItem.h" #include "ListItem.h"
#include "String.h" #include "String.h"
#include "ProcessList.h" #include "ProcessList.h"
#include "RichString.h"
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include "debug.h" #include "debug.h"
#include <assert.h> #include <assert.h>
......
...@@ -79,6 +79,7 @@ static HandlerResult MetersPanel_EventHandler(Panel* super, int ch) { ...@@ -79,6 +79,7 @@ static HandlerResult MetersPanel_EventHandler(Panel* super, int ch) {
} }
if (result == HANDLED) { if (result == HANDLED) {
Header* header = this->settings->header; Header* header = this->settings->header;
this->settings->changed = true;
Header_calculateHeight(header); Header_calculateHeight(header);
Header_draw(header); Header_draw(header);
ScreenManager_resize(this->scr, this->scr->x1, header->height, this->scr->x2, this->scr->y2); ScreenManager_resize(this->scr, this->scr->x1, header->height, this->scr->x2, this->scr->y2);
......
...@@ -94,9 +94,9 @@ void Panel_init(Panel* this, int x, int y, int w, int h, char* type, bool owner) ...@@ -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->selected = 0;
this->oldSelected = 0; this->oldSelected = 0;
this->needsRedraw = true; this->needsRedraw = true;
this->header.len = 0; RichString_prune(&(this->header));
if (String_eq(CRT_termType, "linux")) if (String_eq(CRT_termType, "linux"))
this->scrollHAmount = 40; this->scrollHAmount = 20;
else else
this->scrollHAmount = 5; this->scrollHAmount = 5;
} }
...@@ -213,7 +213,7 @@ int Panel_getSelectedIndex(Panel* this) { ...@@ -213,7 +213,7 @@ int Panel_getSelectedIndex(Panel* this) {
return this->selected; return this->selected;
} }
int Panel_getSize(Panel* this) { int Panel_size(Panel* this) {
assert (this != NULL); assert (this != NULL);
return Vector_size(this->items); return Vector_size(this->items);
...@@ -326,43 +326,74 @@ void Panel_draw(Panel* this, bool focus) { ...@@ -326,43 +326,74 @@ void Panel_draw(Panel* this, bool focus) {
move(0, 0); move(0, 0);
} }
void Panel_onKey(Panel* this, int key) { bool Panel_onKey(Panel* this, int key) {
assert (this != NULL); assert (this != NULL);
switch (key) { switch (key) {
case KEY_DOWN: case KEY_DOWN:
if (this->selected + 1 < Vector_size(this->items)) if (this->selected + 1 < Vector_size(this->items))
this->selected++; this->selected++;
break; return true;
case KEY_UP: case KEY_UP:
if (this->selected > 0) if (this->selected > 0)
this->selected--; 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: case KEY_LEFT:
if (this->scrollH > 0) { if (this->scrollH > 0) {
this->scrollH -= this->scrollHAmount; this->scrollH -= 5;
this->needsRedraw = true; this->needsRedraw = true;
} }
break; return true;
case KEY_RIGHT: case KEY_RIGHT:
this->scrollH += this->scrollHAmount; this->scrollH += 5;
this->needsRedraw = true; this->needsRedraw = true;
break; return true;
case KEY_PPAGE: case KEY_PPAGE:
this->selected -= this->h; this->selected -= (this->h - 1);
this->scrollV -= (this->h - 1);
if (this->selected < 0) if (this->selected < 0)
this->selected = 0; this->selected = 0;
break; if (this->scrollV < 0)
this->scrollV = 0;
this->needsRedraw = true;
return true;
case KEY_NPAGE: case KEY_NPAGE:
this->selected += this->h; this->selected += (this->h - 1);
int size = Vector_size(this->items); int size = Vector_size(this->items);
if (this->selected >= size) if (this->selected >= size)
this->selected = size - 1; 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: case KEY_HOME:
this->selected = 0; this->selected = 0;
break; return true;
case KEY_END: case KEY_END:
this->selected = Vector_size(this->items) - 1; this->selected = Vector_size(this->items) - 1;
break; return true;
} }
return false;
} }
...@@ -104,12 +104,12 @@ void Panel_moveSelectedDown(Panel* this); ...@@ -104,12 +104,12 @@ void Panel_moveSelectedDown(Panel* this);
int Panel_getSelectedIndex(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_setSelected(Panel* this, int selected);
void Panel_draw(Panel* this, bool focus); void Panel_draw(Panel* this, bool focus);
void Panel_onKey(Panel* this, int key); bool Panel_onKey(Panel* this, int key);
#endif #endif
...@@ -208,8 +208,8 @@ static int Process_getuid = -1; ...@@ -208,8 +208,8 @@ static int Process_getuid = -1;
static void Process_printLargeNumber(Process* this, RichString *str, unsigned long number) { static void Process_printLargeNumber(Process* this, RichString *str, unsigned long number) {
char buffer[11]; char buffer[11];
int len; int len;
if(number >= (1000 * ONE_M)) { if(number >= (10 * ONE_M)) {
len = snprintf(buffer, 10, "%4.2fG ", (float)number / ONE_M); len = snprintf(buffer, 10, "%3.1fG ", (float)number / ONE_M);
RichString_appendn(str, CRT_colors[LARGE_NUMBER], buffer, len); RichString_appendn(str, CRT_colors[LARGE_NUMBER], buffer, len);
} else if(number >= (100000)) { } else if(number >= (100000)) {
len = snprintf(buffer, 10, "%4ldM ", number / ONE_K); len = snprintf(buffer, 10, "%4ldM ", number / ONE_K);
...@@ -535,7 +535,7 @@ int Process_compare(const void* v1, const void* v2) { ...@@ -535,7 +535,7 @@ int Process_compare(const void* v1, const void* v2) {
case PPID: case PPID:
return (p1->ppid - p2->ppid); return (p1->ppid - p2->ppid);
case USER: case USER:
return strcmp(p1->user, p2->user); return strcmp(p1->user ? p1->user : "", p2->user ? p2->user : "");
case PRIORITY: case PRIORITY:
return (p1->priority - p2->priority); return (p1->priority - p2->priority);
case PROCESSOR: case PROCESSOR:
......
...@@ -8,13 +8,14 @@ ...@@ -8,13 +8,14 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <curses.h>
#include <ctype.h> #include <ctype.h>
#include "debug.h" #include "debug.h"
#include <assert.h> #include <assert.h>
#ifdef HAVE_LIBNCURSESW #ifdef HAVE_LIBNCURSESW
#include <wchar.h> #include <curses.h>
#else
#include <ncursesw/curses.h>
#endif #endif
#define RICHSTRING_MAXLEN 300 #define RICHSTRING_MAXLEN 300
...@@ -116,6 +117,10 @@ int RichString_findChar(RichString *this, char c, int start) { ...@@ -116,6 +117,10 @@ int RichString_findChar(RichString *this, char c, int start) {
#endif #endif
void RichString_prune(RichString* this) {
this->len = 0;
}
void RichString_setAttr(RichString *this, int attrs) { void RichString_setAttr(RichString *this, int attrs) {
RichString_setAttrn(this, attrs, 0, this->len - 1); RichString_setAttrn(this, attrs, 0, this->len - 1);
} }
......
...@@ -11,13 +11,14 @@ ...@@ -11,13 +11,14 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <curses.h>
#include <ctype.h> #include <ctype.h>
#include "debug.h" #include "debug.h"
#include <assert.h> #include <assert.h>
#ifdef HAVE_LIBNCURSESW #ifdef HAVE_LIBNCURSESW
#include <wchar.h> #include <curses.h>
#else
#include <ncursesw/curses.h>
#endif #endif
#define RICHSTRING_MAXLEN 300 #define RICHSTRING_MAXLEN 300
...@@ -68,6 +69,8 @@ int RichString_findChar(RichString *this, char c, int start); ...@@ -68,6 +69,8 @@ int RichString_findChar(RichString *this, char c, int start);
#endif #endif
void RichString_prune(RichString* this);
void RichString_setAttr(RichString *this, int attrs); void RichString_setAttr(RichString *this, int attrs);
extern void RichString_append(RichString* this, int attrs, char* data); extern void RichString_append(RichString* this, int attrs, char* data);
......
...@@ -83,7 +83,7 @@ void ScreenManager_add(ScreenManager* this, Panel* item, FunctionBar* fuBar, int ...@@ -83,7 +83,7 @@ void ScreenManager_add(ScreenManager* this, Panel* item, FunctionBar* fuBar, int
if (fuBar) if (fuBar)
Vector_add(this->fuBars, fuBar); Vector_add(this->fuBars, fuBar);
else 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; if (!this->fuBar && fuBar) this->fuBar = fuBar;
item->needsRedraw = true; item->needsRedraw = true;
this->itemCount++; this->itemCount++;
...@@ -188,7 +188,7 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) { ...@@ -188,7 +188,7 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
if (focus > 0) if (focus > 0)
focus--; focus--;
panelFocus = (Panel*) Vector_get(this->items, focus); panelFocus = (Panel*) Vector_get(this->items, focus);
if (Panel_getSize(panelFocus) == 0 && focus > 0) if (Panel_size(panelFocus) == 0 && focus > 0)
goto tryLeft; goto tryLeft;
break; break;
case KEY_RIGHT: case KEY_RIGHT:
...@@ -197,7 +197,7 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) { ...@@ -197,7 +197,7 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
if (focus < this->itemCount - 1) if (focus < this->itemCount - 1)
focus++; focus++;
panelFocus = (Panel*) Vector_get(this->items, 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; goto tryRight;
break; break;
case KEY_F(10): case KEY_F(10):
......
...@@ -23,7 +23,7 @@ typedef struct SignalsPanel_ { ...@@ -23,7 +23,7 @@ typedef struct SignalsPanel_ {
static HandlerResult SignalsPanel_eventHandler(Panel* super, int ch) { static HandlerResult SignalsPanel_eventHandler(Panel* super, int ch) {
SignalsPanel* this = (SignalsPanel*) super; SignalsPanel* this = (SignalsPanel*) super;
int size = Panel_getSize(super); int size = Panel_size(super);
if (ch <= 255 && isdigit(ch)) { if (ch <= 255 && isdigit(ch)) {
int signal = ch-48 + this->state; int signal = ch-48 + this->state;
......
...@@ -32,17 +32,17 @@ typedef struct TraceScreen_ { ...@@ -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* TraceScreen_new(Process* process) {
TraceScreen* this = (TraceScreen*) malloc(sizeof(TraceScreen)); TraceScreen* this = (TraceScreen*) malloc(sizeof(TraceScreen));
this->process = process; this->process = process;
this->display = Panel_new(0, 1, COLS, LINES-2, LISTITEM_CLASS, true, ListItem_compare); 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; this->tracing = true;
return this; return this;
} }
...@@ -105,7 +105,7 @@ void TraceScreen_run(TraceScreen* this) { ...@@ -105,7 +105,7 @@ void TraceScreen_run(TraceScreen* this) {
buffer[i] = '\0'; buffer[i] = '\0';
if (contLine) { if (contLine) {
ListItem_append((ListItem*)Panel_get(panel, ListItem_append((ListItem*)Panel_get(panel,
Panel_getSize(panel)-1), line); Panel_size(panel)-1), line);
contLine = false; contLine = false;
} else { } else {
Panel_add(panel, (Object*) ListItem_new(line, 0)); Panel_add(panel, (Object*) ListItem_new(line, 0));
...@@ -119,7 +119,7 @@ void TraceScreen_run(TraceScreen* this) { ...@@ -119,7 +119,7 @@ void TraceScreen_run(TraceScreen* this) {
contLine = true; contLine = true;
} }
if (follow) if (follow)
Panel_setSelected(panel, Panel_getSize(panel)-1); Panel_setSelected(panel, Panel_size(panel)-1);
Panel_draw(panel, true); Panel_draw(panel, true);
} }
int ch = getch(); int ch = getch();
...@@ -146,7 +146,7 @@ void TraceScreen_run(TraceScreen* this) { ...@@ -146,7 +146,7 @@ void TraceScreen_run(TraceScreen* this) {
case KEY_F(4): case KEY_F(4):
follow = !follow; follow = !follow;
if (follow) if (follow)
Panel_setSelected(panel, Panel_getSize(panel)-1); Panel_setSelected(panel, Panel_size(panel)-1);
break; break;
case 'q': case 'q':
case 27: case 27:
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script. # Process this file with autoconf to produce a configure script.
AC_PREREQ(2.57) 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 AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([htop.c]) AC_CONFIG_SRCDIR([htop.c])
AC_CONFIG_HEADER([config.h]) AC_CONFIG_HEADER([config.h])
...@@ -88,8 +88,10 @@ fi ...@@ -88,8 +88,10 @@ fi
AC_ARG_ENABLE(unicode, [AC_HELP_STRING([--enable-unicode], [enable Unicode support])], ,enable_unicode="no") AC_ARG_ENABLE(unicode, [AC_HELP_STRING([--enable-unicode], [enable Unicode support])], ,enable_unicode="no")
if test "x$enable_unicode" = xyes; then if test "x$enable_unicode" = xyes; then
AC_CHECK_LIB([ncursesw], [refresh], [], [missing_libraries="$missing_libraries libncursesw"]) AC_CHECK_LIB([ncursesw], [refresh], [], [missing_libraries="$missing_libraries libncursesw"])
AC_CHECK_HEADERS([ncursesw/curses.h],[:],[missing_headers="$missing_headers $ac_header"])
else else
AC_CHECK_LIB([ncurses], [refresh], [], [missing_libraries="$missing_libraries libncurses"]) AC_CHECK_LIB([ncurses], [refresh], [], [missing_libraries="$missing_libraries libncurses"])
AC_CHECK_HEADERS([curses.h],[:],[missing_headers="$missing_headers $ac_header"])
fi 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.)) 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.))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment