mirror of https://github.com/xzeldon/htop.git
changes for htop 0.8.2
This commit is contained in:
parent
1371ee28a7
commit
6330ff3a0a
|
@ -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) {
|
||||||
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) {
|
||||||
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_ {
|
||||||
|
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
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) {
|
||||||
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) {
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
|
|
||||||
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) {
|
||||||
|
|
||||||
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) {
|
||||||
|
|
||||||
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";
|
||||||
#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;
|
||||||
#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 \
|
||||||
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 \
|
||||||
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
|
||||||
|
|
||||||
|
|
13
Meter.c
13
Meter.c
|
@ -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>
|
||||||
|
|
13
Meter.h
13
Meter.h
|
@ -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) {
|
||||||
}
|
}
|
||||||
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);
|
||||||
|
|
69
Panel.c
69
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->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) {
|
||||||
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) {
|
||||||
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;
|
||||||
case KEY_LEFT:
|
#ifdef KEY_C_DOWN
|
||||||
if (this->scrollH > 0) {
|
case KEY_C_DOWN:
|
||||||
this->scrollH -= this->scrollHAmount;
|
if (this->selected + 1 < Vector_size(this->items)) {
|
||||||
|
this->selected++;
|
||||||
|
if (this->scrollV < Vector_size(this->items) - this->h) {
|
||||||
|
this->scrollV++;
|
||||||
this->needsRedraw = true;
|
this->needsRedraw = true;
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
case KEY_RIGHT:
|
return true;
|
||||||
this->scrollH += this->scrollHAmount;
|
#endif
|
||||||
|
#ifdef KEY_C_UP
|
||||||
|
case KEY_C_UP:
|
||||||
|
if (this->selected > 0) {
|
||||||
|
this->selected--;
|
||||||
|
if (this->scrollV > 0) {
|
||||||
|
this->scrollV--;
|
||||||
this->needsRedraw = true;
|
this->needsRedraw = true;
|
||||||
break;
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
case KEY_LEFT:
|
||||||
|
if (this->scrollH > 0) {
|
||||||
|
this->scrollH -= 5;
|
||||||
|
this->needsRedraw = true;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
case KEY_RIGHT:
|
||||||
|
this->scrollH += 5;
|
||||||
|
this->needsRedraw = true;
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
4
Panel.h
4
Panel.h
|
@ -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;
|
||||||
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) {
|
||||||
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 @@
|
||||||
|
|
||||||
#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) {
|
||||||
|
|
||||||
#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 @@
|
||||||
|
|
||||||
#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);
|
||||||
|
|
||||||
#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
|
||||||
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) {
|
||||||
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) {
|
||||||
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_ {
|
||||||
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_ {
|
||||||
|
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
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) {
|
||||||
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) {
|
||||||
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) {
|
||||||
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 @@
|
||||||
# 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
|
||||||
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.))
|
||||||
|
|
2
htop.1
2
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"
|
.SH "NAME"
|
||||||
htop \- interactive process viewer
|
htop \- interactive process viewer
|
||||||
.SH "SYNTAX"
|
.SH "SYNTAX"
|
||||||
|
|
65
htop.c
65
htop.c
|
@ -26,6 +26,7 @@ in the source distribution for its full text.
|
||||||
#include "CategoriesPanel.h"
|
#include "CategoriesPanel.h"
|
||||||
#include "SignalsPanel.h"
|
#include "SignalsPanel.h"
|
||||||
#include "TraceScreen.h"
|
#include "TraceScreen.h"
|
||||||
|
#include "OpenFilesScreen.h"
|
||||||
#include "AffinityPanel.h"
|
#include "AffinityPanel.h"
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
@ -110,8 +111,8 @@ static void showHelp(ProcessList* pl) {
|
||||||
mvaddstr(13, 0, " Space: tag processes F: cursor follows process");
|
mvaddstr(13, 0, " Space: tag processes F: cursor follows process");
|
||||||
mvaddstr(14, 0, " U: untag all processes");
|
mvaddstr(14, 0, " U: untag all processes");
|
||||||
mvaddstr(15, 0, " F9 k: kill process/tagged processes P: sort by CPU%");
|
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(16, 0, " - ] F7: higher priority (root only) M: sort by MEM%");
|
||||||
mvaddstr(17, 0, " - ] F8: higher priority (root only) T: sort by TIME");
|
mvaddstr(17, 0, " + [ F8: lower priority (+ nice) T: sort by TIME");
|
||||||
#ifdef HAVE_PLPA
|
#ifdef HAVE_PLPA
|
||||||
if (pl->processorCount > 1)
|
if (pl->processorCount > 1)
|
||||||
mvaddstr(18, 0, " a: set CPU affinity F4 I: invert sort order");
|
mvaddstr(18, 0, " a: set CPU affinity F4 I: invert sort order");
|
||||||
|
@ -119,7 +120,7 @@ static void showHelp(ProcessList* pl) {
|
||||||
#endif
|
#endif
|
||||||
mvaddstr(18, 0, " F4 I: invert sort order");
|
mvaddstr(18, 0, " F4 I: invert sort order");
|
||||||
mvaddstr(19, 0, " F2 S: setup F6 >: select sort column");
|
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");
|
mvaddstr(21, 0, " F10 q: quit s: trace syscalls with strace");
|
||||||
|
|
||||||
attrset(CRT_colors[HELP_BOLD]);
|
attrset(CRT_colors[HELP_BOLD]);
|
||||||
|
@ -155,7 +156,7 @@ static char* CategoriesFunctions[10] = {" ", " ", " ", " ",
|
||||||
static void Setup_run(Settings* settings, int headerHeight) {
|
static void Setup_run(Settings* settings, int headerHeight) {
|
||||||
ScreenManager* scr = ScreenManager_new(0, headerHeight, 0, -1, HORIZONTAL, true);
|
ScreenManager* scr = ScreenManager_new(0, headerHeight, 0, -1, HORIZONTAL, true);
|
||||||
CategoriesPanel* panelCategories = CategoriesPanel_new(settings, scr);
|
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);
|
CategoriesPanel_makeMetersPage(panelCategories);
|
||||||
Panel* panelFocus;
|
Panel* panelFocus;
|
||||||
int ch;
|
int ch;
|
||||||
|
@ -166,7 +167,7 @@ static void Setup_run(Settings* settings, int headerHeight) {
|
||||||
static bool changePriority(Panel* panel, int delta) {
|
static bool changePriority(Panel* panel, int delta) {
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
bool anyTagged = false;
|
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);
|
Process* p = (Process*) Panel_get(panel, i);
|
||||||
if (p->tag) {
|
if (p->tag) {
|
||||||
ok = Process_setPriority(p, p->nice + delta) && ok;
|
ok = Process_setPriority(p, p->nice + delta) && ok;
|
||||||
|
@ -188,13 +189,13 @@ static HandlerResult pickWithEnter(Panel* panel, int ch) {
|
||||||
return IGNORED;
|
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"};
|
char* fuKeys[2] = {"Enter", "Esc"};
|
||||||
int fuEvents[2] = {13, 27};
|
int fuEvents[2] = {13, 27};
|
||||||
if (!list->eventHandler)
|
if (!list->eventHandler)
|
||||||
Panel_setEventHandler(list, pickWithEnter);
|
Panel_setEventHandler(list, pickWithEnter);
|
||||||
ScreenManager* scr = ScreenManager_new(0, y, 0, -1, HORIZONTAL, false);
|
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);
|
ScreenManager_add(scr, panel, NULL, -1);
|
||||||
Panel* panelFocus;
|
Panel* panelFocus;
|
||||||
int ch;
|
int ch;
|
||||||
|
@ -209,7 +210,7 @@ static Object* pickFromList(Panel* panel, Panel* list, int x, int y, char** keyL
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void addUserToList(int key, void* userCast, void* panelCast) {
|
static void addUserToVector(int key, void* userCast, void* panelCast) {
|
||||||
char* user = (char*) userCast;
|
char* user = (char*) userCast;
|
||||||
Panel* panel = (Panel*) panelCast;
|
Panel* panel = (Panel*) panelCast;
|
||||||
Panel_add(panel, (Object*) ListItem_new(user, key));
|
Panel_add(panel, (Object*) ListItem_new(user, key));
|
||||||
|
@ -274,6 +275,9 @@ int main(int argc, char** argv) {
|
||||||
if (arg == argc - 1) printHelpFlag();
|
if (arg == argc - 1) printHelpFlag();
|
||||||
arg++;
|
arg++;
|
||||||
setUserOnly(argv[arg], &userOnly, &userId);
|
setUserOnly(argv[arg], &userOnly, &userId);
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "Error: unknown flag: %s\n", argv[arg]);
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
arg++;
|
arg++;
|
||||||
}
|
}
|
||||||
|
@ -321,14 +325,14 @@ int main(int argc, char** argv) {
|
||||||
}
|
}
|
||||||
Panel_setRichHeader(panel, ProcessList_printHeader(pl));
|
Panel_setRichHeader(panel, ProcessList_printHeader(pl));
|
||||||
|
|
||||||
char* searchFunctions[3] = {"Next ", "Exit ", " Search: "};
|
char* searchFunctions[] = {"Next ", "Exit ", " Search: ", NULL};
|
||||||
char* searchKeys[3] = {"F3", "Esc", " "};
|
char* searchKeys[] = {"F3", "Esc", " "};
|
||||||
int searchEvents[3] = {KEY_F(3), 27, ERR};
|
int searchEvents[] = {KEY_F(3), 27, ERR};
|
||||||
FunctionBar* searchBar = FunctionBar_new(3, searchFunctions, searchKeys, searchEvents);
|
FunctionBar* searchBar = FunctionBar_new(searchFunctions, searchKeys, searchEvents);
|
||||||
|
|
||||||
char* defaultFunctions[10] = {"Help ", "Setup ", "Search", "Invert", "Tree ",
|
char* defaultFunctions[] = {"Help ", "Setup ", "Search", "Invert", "Tree ",
|
||||||
"SortBy", "Nice -", "Nice +", "Kill ", "Quit "};
|
"SortBy", "Nice -", "Nice +", "Kill ", "Quit ", NULL};
|
||||||
FunctionBar* defaultBar = FunctionBar_new(10, defaultFunctions, NULL, NULL);
|
FunctionBar* defaultBar = FunctionBar_new(defaultFunctions, NULL, NULL);
|
||||||
|
|
||||||
ProcessList_scan(pl);
|
ProcessList_scan(pl);
|
||||||
usleep(75000);
|
usleep(75000);
|
||||||
|
@ -512,7 +516,7 @@ int main(int argc, char** argv) {
|
||||||
}
|
}
|
||||||
case 'U':
|
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);
|
Process* p = (Process*) Panel_get(panel, i);
|
||||||
p->tag = false;
|
p->tag = false;
|
||||||
}
|
}
|
||||||
|
@ -558,6 +562,17 @@ int main(int argc, char** argv) {
|
||||||
CRT_enableDelay();
|
CRT_enableDelay();
|
||||||
break;
|
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 'S':
|
||||||
case 'C':
|
case 'C':
|
||||||
case KEY_F(2):
|
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* usersPanel = Panel_new(0, 0, 0, 0, LISTITEM_CLASS, true, ListItem_compare);
|
||||||
Panel_setHeader(usersPanel, "Show processes of:");
|
Panel_setHeader(usersPanel, "Show processes of:");
|
||||||
UsersTable_foreach(ut, addUserToList, usersPanel);
|
UsersTable_foreach(ut, addUserToVector, usersPanel);
|
||||||
Vector_sort(usersPanel->items);
|
Vector_sort(usersPanel->items);
|
||||||
ListItem* allUsers = ListItem_new("All users", -1);
|
ListItem* allUsers = ListItem_new("All users", -1);
|
||||||
Panel_insert(usersPanel, 0, (Object*) allUsers);
|
Panel_insert(usersPanel, 0, (Object*) allUsers);
|
||||||
char* fuFunctions[2] = {"Show ", "Cancel "};
|
char* fuFunctions[] = {"Show ", "Cancel ", NULL};
|
||||||
ListItem* picked = (ListItem*) pickFromList(panel, usersPanel, 20, headerHeight, fuFunctions, defaultBar);
|
ListItem* picked = (ListItem*) pickFromVector(panel, usersPanel, 20, headerHeight, fuFunctions, defaultBar);
|
||||||
if (picked) {
|
if (picked) {
|
||||||
if (picked == allUsers) {
|
if (picked == allUsers) {
|
||||||
userOnly = false;
|
userOnly = false;
|
||||||
|
@ -604,15 +619,15 @@ int main(int argc, char** argv) {
|
||||||
killPanel = (Panel*) SignalsPanel_new(0, 0, 0, 0);
|
killPanel = (Panel*) SignalsPanel_new(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
SignalsPanel_reset((SignalsPanel*) killPanel);
|
SignalsPanel_reset((SignalsPanel*) killPanel);
|
||||||
char* fuFunctions[2] = {"Send ", "Cancel "};
|
char* fuFunctions[] = {"Send ", "Cancel ", NULL};
|
||||||
Signal* signal = (Signal*) pickFromList(panel, killPanel, 15, headerHeight, fuFunctions, defaultBar);
|
Signal* signal = (Signal*) pickFromVector(panel, killPanel, 15, headerHeight, fuFunctions, defaultBar);
|
||||||
if (signal) {
|
if (signal) {
|
||||||
if (signal->number != 0) {
|
if (signal->number != 0) {
|
||||||
Panel_setHeader(panel, "Sending...");
|
Panel_setHeader(panel, "Sending...");
|
||||||
Panel_draw(panel, true);
|
Panel_draw(panel, true);
|
||||||
refresh();
|
refresh();
|
||||||
bool anyTagged = false;
|
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);
|
Process* p = (Process*) Panel_get(panel, i);
|
||||||
if (p->tag) {
|
if (p->tag) {
|
||||||
Process_sendSignal(p, signal->number);
|
Process_sendSignal(p, signal->number);
|
||||||
|
@ -642,12 +657,12 @@ int main(int argc, char** argv) {
|
||||||
Panel* affinityPanel = AffinityPanel_new(pl->processorCount, curr);
|
Panel* affinityPanel = AffinityPanel_new(pl->processorCount, curr);
|
||||||
|
|
||||||
char* fuFunctions[2] = {"Set ", "Cancel "};
|
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) {
|
if (set) {
|
||||||
unsigned long new = AffinityPanel_getAffinity(affinityPanel);
|
unsigned long new = AffinityPanel_getAffinity(affinityPanel);
|
||||||
bool anyTagged = false;
|
bool anyTagged = false;
|
||||||
bool ok = true;
|
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);
|
Process* p = (Process*) Panel_get(panel, i);
|
||||||
if (p->tag) {
|
if (p->tag) {
|
||||||
ok = Process_setAffinity(p, new) && ok;
|
ok = Process_setAffinity(p, new) && ok;
|
||||||
|
@ -689,7 +704,7 @@ int main(int argc, char** argv) {
|
||||||
Panel_setSelected(sortPanel, i);
|
Panel_setSelected(sortPanel, i);
|
||||||
free(name);
|
free(name);
|
||||||
}
|
}
|
||||||
ListItem* field = (ListItem*) pickFromList(panel, sortPanel, 15, headerHeight, fuFunctions, defaultBar);
|
ListItem* field = (ListItem*) pickFromVector(panel, sortPanel, 15, headerHeight, fuFunctions, defaultBar);
|
||||||
if (field) {
|
if (field) {
|
||||||
settings->changed = true;
|
settings->changed = true;
|
||||||
setSortKey(pl, field->key, panel, settings);
|
setSortKey(pl, field->key, panel, settings);
|
||||||
|
|
1
htop.h
1
htop.h
|
@ -30,6 +30,7 @@ in the source distribution for its full text.
|
||||||
#include "CategoriesPanel.h"
|
#include "CategoriesPanel.h"
|
||||||
#include "SignalsPanel.h"
|
#include "SignalsPanel.h"
|
||||||
#include "TraceScreen.h"
|
#include "TraceScreen.h"
|
||||||
|
#include "OpenFilesScreen.h"
|
||||||
#include "AffinityPanel.h"
|
#include "AffinityPanel.h"
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
|
@ -122,6 +122,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||||
RANLIB = @RANLIB@
|
RANLIB = @RANLIB@
|
||||||
|
SED = @SED@
|
||||||
SET_MAKE = @SET_MAKE@
|
SET_MAKE = @SET_MAKE@
|
||||||
SHELL = @SHELL@
|
SHELL = @SHELL@
|
||||||
STRIP = @STRIP@
|
STRIP = @STRIP@
|
||||||
|
|
|
@ -157,6 +157,7 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||||
RANLIB = @RANLIB@
|
RANLIB = @RANLIB@
|
||||||
|
SED = @SED@
|
||||||
SET_MAKE = @SET_MAKE@
|
SET_MAKE = @SET_MAKE@
|
||||||
SHELL = @SHELL@
|
SHELL = @SHELL@
|
||||||
STRIP = @STRIP@
|
STRIP = @STRIP@
|
||||||
|
|
Loading…
Reference in New Issue