mirror of https://github.com/xzeldon/htop.git
Rename ListBox to Panel, matching dit.
This commit is contained in:
parent
a853faaa2d
commit
c2cdcd0c1d
|
@ -1,57 +1,57 @@
|
|||
|
||||
#include "AvailableColumnsListBox.h"
|
||||
#include "AvailableColumnsPanel.h"
|
||||
#include "Settings.h"
|
||||
#include "Header.h"
|
||||
#include "ScreenManager.h"
|
||||
#include "ColumnsListBox.h"
|
||||
#include "ColumnsPanel.h"
|
||||
|
||||
#include "ListBox.h"
|
||||
#include "Panel.h"
|
||||
|
||||
#include "debug.h"
|
||||
#include <assert.h>
|
||||
|
||||
/*{
|
||||
|
||||
typedef struct AvailableColumnsListBox_ {
|
||||
ListBox super;
|
||||
ListBox* columns;
|
||||
typedef struct AvailableColumnsPanel_ {
|
||||
Panel super;
|
||||
Panel* columns;
|
||||
|
||||
Settings* settings;
|
||||
ScreenManager* scr;
|
||||
} AvailableColumnsListBox;
|
||||
} AvailableColumnsPanel;
|
||||
|
||||
}*/
|
||||
|
||||
AvailableColumnsListBox* AvailableColumnsListBox_new(Settings* settings, ListBox* columns, ScreenManager* scr) {
|
||||
AvailableColumnsListBox* this = (AvailableColumnsListBox*) malloc(sizeof(AvailableColumnsListBox));
|
||||
ListBox* super = (ListBox*) this;
|
||||
ListBox_init(super, 1, 1, 1, 1, LISTITEM_CLASS, true);
|
||||
((Object*)this)->delete = AvailableColumnsListBox_delete;
|
||||
AvailableColumnsPanel* AvailableColumnsPanel_new(Settings* settings, Panel* columns, ScreenManager* scr) {
|
||||
AvailableColumnsPanel* this = (AvailableColumnsPanel*) malloc(sizeof(AvailableColumnsPanel));
|
||||
Panel* super = (Panel*) this;
|
||||
Panel_init(super, 1, 1, 1, 1, LISTITEM_CLASS, true);
|
||||
((Object*)this)->delete = AvailableColumnsPanel_delete;
|
||||
|
||||
this->settings = settings;
|
||||
this->scr = scr;
|
||||
super->eventHandler = AvailableColumnsListBox_eventHandler;
|
||||
super->eventHandler = AvailableColumnsPanel_eventHandler;
|
||||
|
||||
ListBox_setHeader(super, "Available Columns");
|
||||
Panel_setHeader(super, "Available Columns");
|
||||
|
||||
for (int i = 1; i < LAST_PROCESSFIELD; i++) {
|
||||
if (i != COMM)
|
||||
ListBox_add(super, (Object*) ListItem_new(Process_fieldNames[i], 0));
|
||||
Panel_add(super, (Object*) ListItem_new(Process_fieldNames[i], 0));
|
||||
}
|
||||
this->columns = columns;
|
||||
return this;
|
||||
}
|
||||
|
||||
void AvailableColumnsListBox_delete(Object* object) {
|
||||
ListBox* super = (ListBox*) object;
|
||||
AvailableColumnsListBox* this = (AvailableColumnsListBox*) object;
|
||||
ListBox_done(super);
|
||||
void AvailableColumnsPanel_delete(Object* object) {
|
||||
Panel* super = (Panel*) object;
|
||||
AvailableColumnsPanel* this = (AvailableColumnsPanel*) object;
|
||||
Panel_done(super);
|
||||
free(this);
|
||||
}
|
||||
|
||||
HandlerResult AvailableColumnsListBox_eventHandler(ListBox* super, int ch) {
|
||||
AvailableColumnsListBox* this = (AvailableColumnsListBox*) super;
|
||||
char* text = ((ListItem*) ListBox_getSelected(super))->value;
|
||||
HandlerResult AvailableColumnsPanel_eventHandler(Panel* super, int ch) {
|
||||
AvailableColumnsPanel* this = (AvailableColumnsPanel*) super;
|
||||
char* text = ((ListItem*) Panel_getSelected(super))->value;
|
||||
HandlerResult result = IGNORED;
|
||||
|
||||
switch(ch) {
|
||||
|
@ -59,11 +59,11 @@ HandlerResult AvailableColumnsListBox_eventHandler(ListBox* super, int ch) {
|
|||
case KEY_ENTER:
|
||||
case KEY_F(5):
|
||||
{
|
||||
int at = ListBox_getSelectedIndex(this->columns) + 1;
|
||||
if (at == ListBox_getSize(this->columns))
|
||||
int at = Panel_getSelectedIndex(this->columns) + 1;
|
||||
if (at == Panel_getSize(this->columns))
|
||||
at--;
|
||||
ListBox_insert(this->columns, at, (Object*) ListItem_new(text, 0));
|
||||
ColumnsListBox_update(this->columns);
|
||||
Panel_insert(this->columns, at, (Object*) ListItem_new(text, 0));
|
||||
ColumnsPanel_update(this->columns);
|
||||
result = HANDLED;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,31 +1,31 @@
|
|||
/* Do not edit this file. It was automatically genarated. */
|
||||
|
||||
#ifndef HEADER_AvailableColumnsListBox
|
||||
#define HEADER_AvailableColumnsListBox
|
||||
#ifndef HEADER_AvailableColumnsPanel
|
||||
#define HEADER_AvailableColumnsPanel
|
||||
|
||||
#include "Settings.h"
|
||||
#include "Header.h"
|
||||
#include "ScreenManager.h"
|
||||
|
||||
#include "ListBox.h"
|
||||
#include "Panel.h"
|
||||
|
||||
#include "debug.h"
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
typedef struct AvailableColumnsListBox_ {
|
||||
ListBox super;
|
||||
typedef struct AvailableColumnsPanel_ {
|
||||
Panel super;
|
||||
|
||||
Settings* settings;
|
||||
ScreenManager* scr;
|
||||
ListBox* columns;
|
||||
} AvailableColumnsListBox;
|
||||
Panel* columns;
|
||||
} AvailableColumnsPanel;
|
||||
|
||||
|
||||
AvailableColumnsListBox* AvailableColumnsListBox_new(Settings* settings, ListBox* columns, ScreenManager* scr);
|
||||
AvailableColumnsPanel* AvailableColumnsPanel_new(Settings* settings, Panel* columns, ScreenManager* scr);
|
||||
|
||||
void AvailableColumnsListBox_delete(Object* object);
|
||||
void AvailableColumnsPanel_delete(Object* object);
|
||||
|
||||
HandlerResult AvailableColumnsListBox_eventHandler(ListBox* super, int ch);
|
||||
HandlerResult AvailableColumnsPanel_eventHandler(Panel* super, int ch);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,79 +1,79 @@
|
|||
|
||||
#include "AvailableMetersListBox.h"
|
||||
#include "AvailableMetersPanel.h"
|
||||
#include "Settings.h"
|
||||
#include "Header.h"
|
||||
#include "ScreenManager.h"
|
||||
|
||||
#include "ListBox.h"
|
||||
#include "Panel.h"
|
||||
|
||||
#include "debug.h"
|
||||
#include <assert.h>
|
||||
|
||||
/*{
|
||||
|
||||
typedef struct AvailableMetersListBox_ {
|
||||
ListBox super;
|
||||
typedef struct AvailableMetersPanel_ {
|
||||
Panel super;
|
||||
|
||||
Settings* settings;
|
||||
ListBox* leftBox;
|
||||
ListBox* rightBox;
|
||||
Panel* leftBox;
|
||||
Panel* rightBox;
|
||||
ScreenManager* scr;
|
||||
} AvailableMetersListBox;
|
||||
} AvailableMetersPanel;
|
||||
|
||||
}*/
|
||||
|
||||
AvailableMetersListBox* AvailableMetersListBox_new(Settings* settings, ListBox* leftMeters, ListBox* rightMeters, ScreenManager* scr) {
|
||||
AvailableMetersListBox* this = (AvailableMetersListBox*) malloc(sizeof(AvailableMetersListBox));
|
||||
ListBox* super = (ListBox*) this;
|
||||
ListBox_init(super, 1, 1, 1, 1, LISTITEM_CLASS, true);
|
||||
((Object*)this)->delete = AvailableMetersListBox_delete;
|
||||
AvailableMetersPanel* AvailableMetersPanel_new(Settings* settings, Panel* leftMeters, Panel* rightMeters, ScreenManager* scr) {
|
||||
AvailableMetersPanel* this = (AvailableMetersPanel*) malloc(sizeof(AvailableMetersPanel));
|
||||
Panel* super = (Panel*) this;
|
||||
Panel_init(super, 1, 1, 1, 1, LISTITEM_CLASS, true);
|
||||
((Object*)this)->delete = AvailableMetersPanel_delete;
|
||||
|
||||
this->settings = settings;
|
||||
this->leftBox = leftMeters;
|
||||
this->rightBox = rightMeters;
|
||||
this->scr = scr;
|
||||
super->eventHandler = AvailableMetersListBox_EventHandler;
|
||||
super->eventHandler = AvailableMetersPanel_EventHandler;
|
||||
|
||||
ListBox_setHeader(super, "Available meters");
|
||||
Panel_setHeader(super, "Available meters");
|
||||
for (int i = 1; Meter_types[i]; i++) {
|
||||
MeterType* type = Meter_types[i];
|
||||
if (type != &CPUMeter) {
|
||||
ListBox_add(super, (Object*) ListItem_new(type->uiName, i << 16));
|
||||
Panel_add(super, (Object*) ListItem_new(type->uiName, i << 16));
|
||||
}
|
||||
}
|
||||
MeterType* type = &CPUMeter;
|
||||
int processors = settings->pl->processorCount;
|
||||
if (processors > 1) {
|
||||
ListBox_add(super, (Object*) ListItem_new("CPU average", 0));
|
||||
Panel_add(super, (Object*) ListItem_new("CPU average", 0));
|
||||
for (int i = 1; i <= processors; i++) {
|
||||
char buffer[50];
|
||||
sprintf(buffer, "%s %d", type->uiName, i);
|
||||
ListBox_add(super, (Object*) ListItem_new(buffer, i));
|
||||
Panel_add(super, (Object*) ListItem_new(buffer, i));
|
||||
}
|
||||
} else {
|
||||
ListBox_add(super, (Object*) ListItem_new("CPU", 1));
|
||||
Panel_add(super, (Object*) ListItem_new("CPU", 1));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
void AvailableMetersListBox_delete(Object* object) {
|
||||
ListBox* super = (ListBox*) object;
|
||||
AvailableMetersListBox* this = (AvailableMetersListBox*) object;
|
||||
ListBox_done(super);
|
||||
void AvailableMetersPanel_delete(Object* object) {
|
||||
Panel* super = (Panel*) object;
|
||||
AvailableMetersPanel* this = (AvailableMetersPanel*) object;
|
||||
Panel_done(super);
|
||||
free(this);
|
||||
}
|
||||
|
||||
/* private */
|
||||
inline void AvailableMetersListBox_addHeader(Header* header, ListBox* lb, MeterType* type, int param, HeaderSide side) {
|
||||
inline void AvailableMetersPanel_addHeader(Header* header, Panel* lb, MeterType* type, int param, HeaderSide side) {
|
||||
Meter* meter = (Meter*) Header_addMeter(header, type, param, side);
|
||||
ListBox_add(lb, (Object*) Meter_toListItem(meter));
|
||||
Panel_add(lb, (Object*) Meter_toListItem(meter));
|
||||
}
|
||||
|
||||
HandlerResult AvailableMetersListBox_EventHandler(ListBox* super, int ch) {
|
||||
AvailableMetersListBox* this = (AvailableMetersListBox*) super;
|
||||
HandlerResult AvailableMetersPanel_EventHandler(Panel* super, int ch) {
|
||||
AvailableMetersPanel* this = (AvailableMetersPanel*) super;
|
||||
Header* header = this->settings->header;
|
||||
|
||||
ListItem* selected = (ListItem*) ListBox_getSelected(super);
|
||||
ListItem* selected = (ListItem*) Panel_getSelected(super);
|
||||
int param = selected->key & 0xff;
|
||||
int type = selected->key >> 16;
|
||||
HandlerResult result = IGNORED;
|
||||
|
@ -83,7 +83,7 @@ HandlerResult AvailableMetersListBox_EventHandler(ListBox* super, int ch) {
|
|||
case 'l':
|
||||
case 'L':
|
||||
{
|
||||
AvailableMetersListBox_addHeader(header, this->leftBox, Meter_types[type], param, LEFT_HEADER);
|
||||
AvailableMetersPanel_addHeader(header, this->leftBox, Meter_types[type], param, LEFT_HEADER);
|
||||
result = HANDLED;
|
||||
break;
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ HandlerResult AvailableMetersListBox_EventHandler(ListBox* super, int ch) {
|
|||
case 'r':
|
||||
case 'R':
|
||||
{
|
||||
AvailableMetersListBox_addHeader(header, this->rightBox, Meter_types[type], param, RIGHT_HEADER);
|
||||
AvailableMetersPanel_addHeader(header, this->rightBox, Meter_types[type], param, RIGHT_HEADER);
|
||||
result = HANDLED;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1,33 +1,33 @@
|
|||
/* Do not edit this file. It was automatically genarated. */
|
||||
|
||||
#ifndef HEADER_AvailableMetersListBox
|
||||
#define HEADER_AvailableMetersListBox
|
||||
#ifndef HEADER_AvailableMetersPanel
|
||||
#define HEADER_AvailableMetersPanel
|
||||
|
||||
#include "Settings.h"
|
||||
#include "Header.h"
|
||||
#include "ScreenManager.h"
|
||||
|
||||
#include "ListBox.h"
|
||||
#include "Panel.h"
|
||||
|
||||
#include "debug.h"
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
typedef struct AvailableMetersListBox_ {
|
||||
ListBox super;
|
||||
typedef struct AvailableMetersPanel_ {
|
||||
Panel super;
|
||||
|
||||
Settings* settings;
|
||||
ListBox* leftBox;
|
||||
ListBox* rightBox;
|
||||
Panel* leftBox;
|
||||
Panel* rightBox;
|
||||
ScreenManager* scr;
|
||||
} AvailableMetersListBox;
|
||||
} AvailableMetersPanel;
|
||||
|
||||
|
||||
AvailableMetersListBox* AvailableMetersListBox_new(Settings* settings, ListBox* leftMeters, ListBox* rightMeters, ScreenManager* scr);
|
||||
AvailableMetersPanel* AvailableMetersPanel_new(Settings* settings, Panel* leftMeters, Panel* rightMeters, ScreenManager* scr);
|
||||
|
||||
void AvailableMetersListBox_delete(Object* object);
|
||||
void AvailableMetersPanel_delete(Object* object);
|
||||
|
||||
|
||||
HandlerResult AvailableMetersListBox_EventHandler(ListBox* super, int ch);
|
||||
HandlerResult AvailableMetersPanel_EventHandler(Panel* super, int ch);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
|
||||
#include "CategoriesListBox.h"
|
||||
#include "AvailableMetersListBox.h"
|
||||
#include "MetersListBox.h"
|
||||
#include "DisplayOptionsListBox.h"
|
||||
#include "ColumnsListBox.h"
|
||||
#include "ColorsListBox.h"
|
||||
#include "AvailableColumnsListBox.h"
|
||||
#include "CategoriesPanel.h"
|
||||
#include "AvailableMetersPanel.h"
|
||||
#include "MetersPanel.h"
|
||||
#include "DisplayOptionsPanel.h"
|
||||
#include "ColumnsPanel.h"
|
||||
#include "ColorsPanel.h"
|
||||
#include "AvailableColumnsPanel.h"
|
||||
|
||||
#include "ListBox.h"
|
||||
#include "Panel.h"
|
||||
|
||||
#include "debug.h"
|
||||
#include <assert.h>
|
||||
|
||||
/*{
|
||||
|
||||
typedef struct CategoriesListBox_ {
|
||||
ListBox super;
|
||||
typedef struct CategoriesPanel_ {
|
||||
Panel super;
|
||||
|
||||
Settings* settings;
|
||||
ScreenManager* scr;
|
||||
} CategoriesListBox;
|
||||
} CategoriesPanel;
|
||||
|
||||
}*/
|
||||
|
||||
|
@ -41,36 +41,36 @@ char* ColorsFunctions[10] = {" ", " ", " ", " ", " ", "
|
|||
/* private property */
|
||||
char* AvailableColumnsFunctions[10] = {" ", " ", " ", " ", "Add ", " ", " ", " ", " ", "Done "};
|
||||
|
||||
CategoriesListBox* CategoriesListBox_new(Settings* settings, ScreenManager* scr) {
|
||||
CategoriesListBox* this = (CategoriesListBox*) malloc(sizeof(CategoriesListBox));
|
||||
ListBox* super = (ListBox*) this;
|
||||
ListBox_init(super, 1, 1, 1, 1, LISTITEM_CLASS, true);
|
||||
((Object*)this)->delete = CategoriesListBox_delete;
|
||||
CategoriesPanel* CategoriesPanel_new(Settings* settings, ScreenManager* scr) {
|
||||
CategoriesPanel* this = (CategoriesPanel*) malloc(sizeof(CategoriesPanel));
|
||||
Panel* super = (Panel*) this;
|
||||
Panel_init(super, 1, 1, 1, 1, LISTITEM_CLASS, true);
|
||||
((Object*)this)->delete = CategoriesPanel_delete;
|
||||
|
||||
this->settings = settings;
|
||||
this->scr = scr;
|
||||
super->eventHandler = CategoriesListBox_eventHandler;
|
||||
ListBox_setHeader(super, "Setup");
|
||||
ListBox_add(super, (Object*) ListItem_new("Meters", 0));
|
||||
ListBox_add(super, (Object*) ListItem_new("Display options", 0));
|
||||
ListBox_add(super, (Object*) ListItem_new("Colors", 0));
|
||||
ListBox_add(super, (Object*) ListItem_new("Columns", 0));
|
||||
super->eventHandler = CategoriesPanel_eventHandler;
|
||||
Panel_setHeader(super, "Setup");
|
||||
Panel_add(super, (Object*) ListItem_new("Meters", 0));
|
||||
Panel_add(super, (Object*) ListItem_new("Display options", 0));
|
||||
Panel_add(super, (Object*) ListItem_new("Colors", 0));
|
||||
Panel_add(super, (Object*) ListItem_new("Columns", 0));
|
||||
return this;
|
||||
}
|
||||
|
||||
void CategoriesListBox_delete(Object* object) {
|
||||
ListBox* super = (ListBox*) object;
|
||||
CategoriesListBox* this = (CategoriesListBox*) object;
|
||||
ListBox_done(super);
|
||||
void CategoriesPanel_delete(Object* object) {
|
||||
Panel* super = (Panel*) object;
|
||||
CategoriesPanel* this = (CategoriesPanel*) object;
|
||||
Panel_done(super);
|
||||
free(this);
|
||||
}
|
||||
|
||||
HandlerResult CategoriesListBox_eventHandler(ListBox* super, int ch) {
|
||||
CategoriesListBox* this = (CategoriesListBox*) super;
|
||||
HandlerResult CategoriesPanel_eventHandler(Panel* super, int ch) {
|
||||
CategoriesPanel* this = (CategoriesPanel*) super;
|
||||
|
||||
HandlerResult result = IGNORED;
|
||||
|
||||
int previous = ListBox_getSelectedIndex(super);
|
||||
int previous = Panel_getSelectedIndex(super);
|
||||
|
||||
switch (ch) {
|
||||
case KEY_UP:
|
||||
|
@ -79,24 +79,24 @@ HandlerResult CategoriesListBox_eventHandler(ListBox* super, int ch) {
|
|||
case KEY_PPAGE:
|
||||
case KEY_HOME:
|
||||
case KEY_END: {
|
||||
ListBox_onKey(super, ch);
|
||||
int selected = ListBox_getSelectedIndex(super);
|
||||
Panel_onKey(super, ch);
|
||||
int selected = Panel_getSelectedIndex(super);
|
||||
if (previous != selected) {
|
||||
int size = ScreenManager_size(this->scr);
|
||||
for (int i = 1; i < size; i++)
|
||||
ScreenManager_remove(this->scr, 1);
|
||||
switch (selected) {
|
||||
case 0:
|
||||
CategoriesListBox_makeMetersPage(this);
|
||||
CategoriesPanel_makeMetersPage(this);
|
||||
break;
|
||||
case 1:
|
||||
CategoriesListBox_makeDisplayOptionsPage(this);
|
||||
CategoriesPanel_makeDisplayOptionsPage(this);
|
||||
break;
|
||||
case 2:
|
||||
CategoriesListBox_makeColorsPage(this);
|
||||
CategoriesPanel_makeColorsPage(this);
|
||||
break;
|
||||
case 3:
|
||||
CategoriesListBox_makeColumnsPage(this);
|
||||
CategoriesPanel_makeColumnsPage(this);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -107,28 +107,28 @@ HandlerResult CategoriesListBox_eventHandler(ListBox* super, int ch) {
|
|||
return result;
|
||||
}
|
||||
|
||||
void CategoriesListBox_makeMetersPage(CategoriesListBox* this) {
|
||||
ListBox* lbLeftMeters = (ListBox*) MetersListBox_new(this->settings, "Left column", this->settings->header->leftMeters, this->scr);
|
||||
ListBox* lbRightMeters = (ListBox*) MetersListBox_new(this->settings, "Right column", this->settings->header->rightMeters, this->scr);
|
||||
ListBox* lbAvailableMeters = (ListBox*) AvailableMetersListBox_new(this->settings, lbLeftMeters, lbRightMeters, this->scr);
|
||||
void CategoriesPanel_makeMetersPage(CategoriesPanel* this) {
|
||||
Panel* lbLeftMeters = (Panel*) MetersPanel_new(this->settings, "Left column", this->settings->header->leftMeters, this->scr);
|
||||
Panel* lbRightMeters = (Panel*) MetersPanel_new(this->settings, "Right column", this->settings->header->rightMeters, this->scr);
|
||||
Panel* lbAvailableMeters = (Panel*) AvailableMetersPanel_new(this->settings, lbLeftMeters, lbRightMeters, this->scr);
|
||||
ScreenManager_add(this->scr, lbLeftMeters, FunctionBar_new(10, MetersFunctions, NULL, NULL), 20);
|
||||
ScreenManager_add(this->scr, lbRightMeters, FunctionBar_new(10, MetersFunctions, NULL, NULL), 20);
|
||||
ScreenManager_add(this->scr, lbAvailableMeters, FunctionBar_new(10, AvailableMetersFunctions, NULL, NULL), -1);
|
||||
}
|
||||
|
||||
void CategoriesListBox_makeDisplayOptionsPage(CategoriesListBox* this) {
|
||||
ListBox* lbDisplayOptions = (ListBox*) DisplayOptionsListBox_new(this->settings, this->scr);
|
||||
void CategoriesPanel_makeDisplayOptionsPage(CategoriesPanel* this) {
|
||||
Panel* lbDisplayOptions = (Panel*) DisplayOptionsPanel_new(this->settings, this->scr);
|
||||
ScreenManager_add(this->scr, lbDisplayOptions, FunctionBar_new(10, DisplayOptionsFunctions, NULL, NULL), -1);
|
||||
}
|
||||
|
||||
void CategoriesListBox_makeColorsPage(CategoriesListBox* this) {
|
||||
ListBox* lbColors = (ListBox*) ColorsListBox_new(this->settings, this->scr);
|
||||
void CategoriesPanel_makeColorsPage(CategoriesPanel* this) {
|
||||
Panel* lbColors = (Panel*) ColorsPanel_new(this->settings, this->scr);
|
||||
ScreenManager_add(this->scr, lbColors, FunctionBar_new(10, ColorsFunctions, NULL, NULL), -1);
|
||||
}
|
||||
|
||||
void CategoriesListBox_makeColumnsPage(CategoriesListBox* this) {
|
||||
ListBox* lbColumns = (ListBox*) ColumnsListBox_new(this->settings, this->scr);
|
||||
ListBox* lbAvailableColumns = (ListBox*) AvailableColumnsListBox_new(this->settings, lbColumns, this->scr);
|
||||
void CategoriesPanel_makeColumnsPage(CategoriesPanel* this) {
|
||||
Panel* lbColumns = (Panel*) ColumnsPanel_new(this->settings, this->scr);
|
||||
Panel* lbAvailableColumns = (Panel*) AvailableColumnsPanel_new(this->settings, lbColumns, this->scr);
|
||||
ScreenManager_add(this->scr, lbColumns, FunctionBar_new(10, ColumnsFunctions, NULL, NULL), 20);
|
||||
ScreenManager_add(this->scr, lbAvailableColumns, FunctionBar_new(10, AvailableColumnsFunctions, NULL, NULL), -1);
|
||||
}
|
||||
|
|
|
@ -1,40 +1,40 @@
|
|||
/* Do not edit this file. It was automatically genarated. */
|
||||
|
||||
#ifndef HEADER_CategoriesListBox
|
||||
#define HEADER_CategoriesListBox
|
||||
#ifndef HEADER_CategoriesPanel
|
||||
#define HEADER_CategoriesPanel
|
||||
|
||||
#include "AvailableMetersListBox.h"
|
||||
#include "MetersListBox.h"
|
||||
#include "DisplayOptionsListBox.h"
|
||||
#include "AvailableMetersPanel.h"
|
||||
#include "MetersPanel.h"
|
||||
#include "DisplayOptionsPanel.h"
|
||||
|
||||
#include "ListBox.h"
|
||||
#include "Panel.h"
|
||||
|
||||
#include "debug.h"
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
typedef struct CategoriesListBox_ {
|
||||
ListBox super;
|
||||
typedef struct CategoriesPanel_ {
|
||||
Panel super;
|
||||
|
||||
Settings* settings;
|
||||
ScreenManager* scr;
|
||||
} CategoriesListBox;
|
||||
} CategoriesPanel;
|
||||
|
||||
|
||||
|
||||
|
||||
CategoriesListBox* CategoriesListBox_new(Settings* settings, ScreenManager* scr);
|
||||
CategoriesPanel* CategoriesPanel_new(Settings* settings, ScreenManager* scr);
|
||||
|
||||
void CategoriesListBox_delete(Object* object);
|
||||
void CategoriesPanel_delete(Object* object);
|
||||
|
||||
HandlerResult CategoriesListBox_eventHandler(ListBox* super, int ch);
|
||||
HandlerResult CategoriesPanel_eventHandler(Panel* super, int ch);
|
||||
|
||||
void CategoriesListBox_makeMetersPage(CategoriesListBox* this);
|
||||
void CategoriesPanel_makeMetersPage(CategoriesPanel* this);
|
||||
|
||||
void CategoriesListBox_makeDisplayOptionsPage(CategoriesListBox* this);
|
||||
void CategoriesPanel_makeDisplayOptionsPage(CategoriesPanel* this);
|
||||
|
||||
void CategoriesListBox_makeColorsPage(CategoriesListBox* this);
|
||||
void CategoriesPanel_makeColorsPage(CategoriesPanel* this);
|
||||
|
||||
void CategoriesListBox_makeColumnsPage(CategoriesListBox* this);
|
||||
void CategoriesPanel_makeColumnsPage(CategoriesPanel* this);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -137,7 +137,7 @@ What's new in version 0.4
|
|||
* Clock and load average meters
|
||||
(thanks to Marc Calahan)
|
||||
* BUGFIX: numeric swap indicator was printing bogus value
|
||||
* BUGFIX: internal fixes on ListBox widget
|
||||
* BUGFIX: internal fixes on Panel widget
|
||||
* Clear the bottom line when exiting
|
||||
* Press "F3" during search to walk through the results
|
||||
* Improved navigation on column configuration screen
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
#include "CRT.h"
|
||||
#include "ColorsListBox.h"
|
||||
#include "ColorsPanel.h"
|
||||
|
||||
#include "ListBox.h"
|
||||
#include "Panel.h"
|
||||
#include "CheckItem.h"
|
||||
#include "Settings.h"
|
||||
#include "ScreenManager.h"
|
||||
|
@ -11,20 +11,20 @@
|
|||
#include <assert.h>
|
||||
|
||||
// TO ADD A NEW SCHEME:
|
||||
// * Increment the size of bool check in ColorsListBox.h
|
||||
// * Increment the size of bool check in ColorsPanel.h
|
||||
// * Add the entry in the ColorSchemes array below in the file
|
||||
// * Add a define in CRT.h that matches the order of the array
|
||||
// * Add the colors in CRT_setColors
|
||||
|
||||
/*{
|
||||
|
||||
typedef struct ColorsListBox_ {
|
||||
ListBox super;
|
||||
typedef struct ColorsPanel_ {
|
||||
Panel super;
|
||||
|
||||
Settings* settings;
|
||||
ScreenManager* scr;
|
||||
bool check[5];
|
||||
} ColorsListBox;
|
||||
} ColorsPanel;
|
||||
|
||||
}*/
|
||||
|
||||
|
@ -39,37 +39,37 @@ static char* ColorSchemes[] = {
|
|||
NULL
|
||||
};
|
||||
|
||||
ColorsListBox* ColorsListBox_new(Settings* settings, ScreenManager* scr) {
|
||||
ColorsListBox* this = (ColorsListBox*) malloc(sizeof(ColorsListBox));
|
||||
ListBox* super = (ListBox*) this;
|
||||
ListBox_init(super, 1, 1, 1, 1, CHECKITEM_CLASS, true);
|
||||
((Object*)this)->delete = ColorsListBox_delete;
|
||||
ColorsPanel* ColorsPanel_new(Settings* settings, ScreenManager* scr) {
|
||||
ColorsPanel* this = (ColorsPanel*) malloc(sizeof(ColorsPanel));
|
||||
Panel* super = (Panel*) this;
|
||||
Panel_init(super, 1, 1, 1, 1, CHECKITEM_CLASS, true);
|
||||
((Object*)this)->delete = ColorsPanel_delete;
|
||||
|
||||
this->settings = settings;
|
||||
this->scr = scr;
|
||||
super->eventHandler = ColorsListBox_EventHandler;
|
||||
super->eventHandler = ColorsPanel_EventHandler;
|
||||
|
||||
ListBox_setHeader(super, "Colors");
|
||||
Panel_setHeader(super, "Colors");
|
||||
for (int i = 0; ColorSchemes[i] != NULL; i++) {
|
||||
ListBox_add(super, (Object*) CheckItem_new(String_copy(ColorSchemes[i]), &(this->check[i])));
|
||||
Panel_add(super, (Object*) CheckItem_new(String_copy(ColorSchemes[i]), &(this->check[i])));
|
||||
this->check[i] = false;
|
||||
}
|
||||
this->check[settings->colorScheme] = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
void ColorsListBox_delete(Object* object) {
|
||||
ListBox* super = (ListBox*) object;
|
||||
ColorsListBox* this = (ColorsListBox*) object;
|
||||
ListBox_done(super);
|
||||
void ColorsPanel_delete(Object* object) {
|
||||
Panel* super = (Panel*) object;
|
||||
ColorsPanel* this = (ColorsPanel*) object;
|
||||
Panel_done(super);
|
||||
free(this);
|
||||
}
|
||||
|
||||
HandlerResult ColorsListBox_EventHandler(ListBox* super, int ch) {
|
||||
ColorsListBox* this = (ColorsListBox*) super;
|
||||
HandlerResult ColorsPanel_EventHandler(Panel* super, int ch) {
|
||||
ColorsPanel* this = (ColorsPanel*) super;
|
||||
|
||||
HandlerResult result = IGNORED;
|
||||
int mark = ListBox_getSelectedIndex(super);
|
||||
int mark = Panel_getSelectedIndex(super);
|
||||
|
||||
switch(ch) {
|
||||
case 0x0a:
|
||||
|
@ -88,7 +88,7 @@ HandlerResult ColorsListBox_EventHandler(ListBox* super, int ch) {
|
|||
this->settings->changed = true;
|
||||
Header* header = this->settings->header;
|
||||
CRT_setColors(mark);
|
||||
ListBox* lbMenu = (ListBox*) Vector_get(this->scr->items, 0);
|
||||
Panel* lbMenu = (Panel*) Vector_get(this->scr->items, 0);
|
||||
Header_draw(header);
|
||||
RichString_setAttr(&(super->header), CRT_colors[PANEL_HEADER_FOCUS]);
|
||||
RichString_setAttr(&(lbMenu->header), CRT_colors[PANEL_HEADER_UNFOCUS]);
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* Do not edit this file. It was automatically genarated. */
|
||||
|
||||
#ifndef HEADER_ColorsListBox
|
||||
#define HEADER_ColorsListBox
|
||||
#ifndef HEADER_ColorsPanel
|
||||
#define HEADER_ColorsPanel
|
||||
|
||||
|
||||
#include "ListBox.h"
|
||||
#include "Panel.h"
|
||||
#include "CheckItem.h"
|
||||
#include "Settings.h"
|
||||
#include "ScreenManager.h"
|
||||
|
@ -13,20 +13,20 @@
|
|||
#include <assert.h>
|
||||
|
||||
|
||||
typedef struct ColorsListBox_ {
|
||||
ListBox super;
|
||||
typedef struct ColorsPanel_ {
|
||||
Panel super;
|
||||
|
||||
Settings* settings;
|
||||
ScreenManager* scr;
|
||||
bool check[5];
|
||||
} ColorsListBox;
|
||||
} ColorsPanel;
|
||||
|
||||
|
||||
ColorsListBox* ColorsListBox_new(Settings* settings, ScreenManager* scr);
|
||||
ColorsPanel* ColorsPanel_new(Settings* settings, ScreenManager* scr);
|
||||
|
||||
void ColorsListBox_delete(Object* object);
|
||||
void ColorsPanel_delete(Object* object);
|
||||
|
||||
HandlerResult ColorsListBox_EventHandler(ListBox* super, int ch);
|
||||
HandlerResult ColorsPanel_EventHandler(Panel* super, int ch);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
#include "ColumnsListBox.h"
|
||||
#include "ColumnsPanel.h"
|
||||
|
||||
#include "ListBox.h"
|
||||
#include "Panel.h"
|
||||
#include "Settings.h"
|
||||
#include "ScreenManager.h"
|
||||
|
||||
|
@ -10,49 +10,49 @@
|
|||
|
||||
/*{
|
||||
|
||||
typedef struct ColumnsListBox_ {
|
||||
ListBox super;
|
||||
typedef struct ColumnsPanel_ {
|
||||
Panel super;
|
||||
|
||||
Settings* settings;
|
||||
ScreenManager* scr;
|
||||
} ColumnsListBox;
|
||||
} ColumnsPanel;
|
||||
|
||||
}*/
|
||||
|
||||
ColumnsListBox* ColumnsListBox_new(Settings* settings, ScreenManager* scr) {
|
||||
ColumnsListBox* this = (ColumnsListBox*) malloc(sizeof(ColumnsListBox));
|
||||
ListBox* super = (ListBox*) this;
|
||||
ListBox_init(super, 1, 1, 1, 1, LISTITEM_CLASS, true);
|
||||
((Object*)this)->delete = ColumnsListBox_delete;
|
||||
ColumnsPanel* ColumnsPanel_new(Settings* settings, ScreenManager* scr) {
|
||||
ColumnsPanel* this = (ColumnsPanel*) malloc(sizeof(ColumnsPanel));
|
||||
Panel* super = (Panel*) this;
|
||||
Panel_init(super, 1, 1, 1, 1, LISTITEM_CLASS, true);
|
||||
((Object*)this)->delete = ColumnsPanel_delete;
|
||||
|
||||
this->settings = settings;
|
||||
this->scr = scr;
|
||||
super->eventHandler = ColumnsListBox_eventHandler;
|
||||
ListBox_setHeader(super, "Active Columns");
|
||||
super->eventHandler = ColumnsPanel_eventHandler;
|
||||
Panel_setHeader(super, "Active Columns");
|
||||
|
||||
ProcessField* fields = this->settings->pl->fields;
|
||||
for (; *fields; fields++) {
|
||||
ListBox_add(super, (Object*) ListItem_new(Process_fieldNames[*fields], 0));
|
||||
Panel_add(super, (Object*) ListItem_new(Process_fieldNames[*fields], 0));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
void ColumnsListBox_delete(Object* object) {
|
||||
ListBox* super = (ListBox*) object;
|
||||
ColumnsListBox* this = (ColumnsListBox*) object;
|
||||
ListBox_done(super);
|
||||
void ColumnsPanel_delete(Object* object) {
|
||||
Panel* super = (Panel*) object;
|
||||
ColumnsPanel* this = (ColumnsPanel*) object;
|
||||
Panel_done(super);
|
||||
free(this);
|
||||
}
|
||||
|
||||
void ColumnsListBox_update(ListBox* super) {
|
||||
ColumnsListBox* this = (ColumnsListBox*) super;
|
||||
int size = ListBox_getSize(super);
|
||||
void ColumnsPanel_update(Panel* super) {
|
||||
ColumnsPanel* this = (ColumnsPanel*) super;
|
||||
int size = Panel_getSize(super);
|
||||
this->settings->changed = true;
|
||||
// FIXME: this is crappily inefficient
|
||||
free(this->settings->pl->fields);
|
||||
this->settings->pl->fields = (ProcessField*) malloc(sizeof(ProcessField) * (size+1));
|
||||
for (int i = 0; i < size; i++) {
|
||||
char* text = ((ListItem*) ListBox_get(super, i))->value;
|
||||
char* text = ((ListItem*) Panel_get(super, i))->value;
|
||||
for (int j = 1; j <= LAST_PROCESSFIELD; j++) {
|
||||
if (String_eq(text, Process_fieldNames[j])) {
|
||||
this->settings->pl->fields[i] = j;
|
||||
|
@ -63,11 +63,11 @@ void ColumnsListBox_update(ListBox* super) {
|
|||
this->settings->pl->fields[size] = 0;
|
||||
}
|
||||
|
||||
HandlerResult ColumnsListBox_eventHandler(ListBox* super, int ch) {
|
||||
HandlerResult ColumnsPanel_eventHandler(Panel* super, int ch) {
|
||||
|
||||
int selected = ListBox_getSelectedIndex(super);
|
||||
int selected = Panel_getSelectedIndex(super);
|
||||
HandlerResult result = IGNORED;
|
||||
int size = ListBox_getSize(super);
|
||||
int size = Panel_getSize(super);
|
||||
|
||||
switch(ch) {
|
||||
case KEY_F(7):
|
||||
|
@ -75,7 +75,7 @@ HandlerResult ColumnsListBox_eventHandler(ListBox* super, int ch) {
|
|||
case '-':
|
||||
{
|
||||
if (selected < size - 1)
|
||||
ListBox_moveSelectedUp(super);
|
||||
Panel_moveSelectedUp(super);
|
||||
result = HANDLED;
|
||||
break;
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ HandlerResult ColumnsListBox_eventHandler(ListBox* super, int ch) {
|
|||
case '+':
|
||||
{
|
||||
if (selected < size - 2)
|
||||
ListBox_moveSelectedDown(super);
|
||||
Panel_moveSelectedDown(super);
|
||||
result = HANDLED;
|
||||
break;
|
||||
}
|
||||
|
@ -92,13 +92,13 @@ HandlerResult ColumnsListBox_eventHandler(ListBox* super, int ch) {
|
|||
case KEY_DC:
|
||||
{
|
||||
if (selected < size - 1) {
|
||||
ListBox_remove(super, selected);
|
||||
Panel_remove(super, selected);
|
||||
}
|
||||
result = HANDLED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (result == HANDLED)
|
||||
ColumnsListBox_update(super);
|
||||
ColumnsPanel_update(super);
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* Do not edit this file. It was automatically genarated. */
|
||||
|
||||
#ifndef HEADER_ColumnsListBox
|
||||
#define HEADER_ColumnsListBox
|
||||
#ifndef HEADER_ColumnsPanel
|
||||
#define HEADER_ColumnsPanel
|
||||
|
||||
|
||||
#include "ListBox.h"
|
||||
#include "Panel.h"
|
||||
#include "Settings.h"
|
||||
#include "ScreenManager.h"
|
||||
|
||||
|
@ -12,21 +12,21 @@
|
|||
#include <assert.h>
|
||||
|
||||
|
||||
typedef struct ColumnsListBox_ {
|
||||
ListBox super;
|
||||
typedef struct ColumnsPanel_ {
|
||||
Panel super;
|
||||
|
||||
Settings* settings;
|
||||
Vector* columns;
|
||||
ScreenManager* scr;
|
||||
} ColumnsListBox;
|
||||
} ColumnsPanel;
|
||||
|
||||
|
||||
ColumnsListBox* ColumnsListBox_new(Settings* settings, ScreenManager* scr);
|
||||
ColumnsPanel* ColumnsPanel_new(Settings* settings, ScreenManager* scr);
|
||||
|
||||
void ColumnsListBox_delete(Object* object);
|
||||
void ColumnsPanel_delete(Object* object);
|
||||
|
||||
void ColumnsListBox_update(ListBox* super);
|
||||
void ColumnsPanel_update(Panel* super);
|
||||
|
||||
HandlerResult ColumnsListBox_eventHandler(ListBox* super, int ch);
|
||||
HandlerResult ColumnsPanel_eventHandler(Panel* super, int ch);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
#include "DisplayOptionsListBox.h"
|
||||
#include "DisplayOptionsPanel.h"
|
||||
|
||||
#include "ListBox.h"
|
||||
#include "Panel.h"
|
||||
#include "CheckItem.h"
|
||||
#include "Settings.h"
|
||||
#include "ScreenManager.h"
|
||||
|
@ -11,48 +11,48 @@
|
|||
|
||||
/*{
|
||||
|
||||
typedef struct DisplayOptionsListBox_ {
|
||||
ListBox super;
|
||||
typedef struct DisplayOptionsPanel_ {
|
||||
Panel super;
|
||||
|
||||
Settings* settings;
|
||||
ScreenManager* scr;
|
||||
} DisplayOptionsListBox;
|
||||
} DisplayOptionsPanel;
|
||||
|
||||
}*/
|
||||
|
||||
DisplayOptionsListBox* DisplayOptionsListBox_new(Settings* settings, ScreenManager* scr) {
|
||||
DisplayOptionsListBox* this = (DisplayOptionsListBox*) malloc(sizeof(DisplayOptionsListBox));
|
||||
ListBox* super = (ListBox*) this;
|
||||
ListBox_init(super, 1, 1, 1, 1, CHECKITEM_CLASS, true);
|
||||
((Object*)this)->delete = DisplayOptionsListBox_delete;
|
||||
DisplayOptionsPanel* DisplayOptionsPanel_new(Settings* settings, ScreenManager* scr) {
|
||||
DisplayOptionsPanel* this = (DisplayOptionsPanel*) malloc(sizeof(DisplayOptionsPanel));
|
||||
Panel* super = (Panel*) this;
|
||||
Panel_init(super, 1, 1, 1, 1, CHECKITEM_CLASS, true);
|
||||
((Object*)this)->delete = DisplayOptionsPanel_delete;
|
||||
|
||||
this->settings = settings;
|
||||
this->scr = scr;
|
||||
super->eventHandler = DisplayOptionsListBox_EventHandler;
|
||||
super->eventHandler = DisplayOptionsPanel_EventHandler;
|
||||
|
||||
ListBox_setHeader(super, "Display options");
|
||||
ListBox_add(super, (Object*) CheckItem_new(String_copy("Tree view"), &(settings->pl->treeView)));
|
||||
ListBox_add(super, (Object*) CheckItem_new(String_copy("Shadow other users' processes"), &(settings->pl->shadowOtherUsers)));
|
||||
ListBox_add(super, (Object*) CheckItem_new(String_copy("Hide kernel threads"), &(settings->pl->hideKernelThreads)));
|
||||
ListBox_add(super, (Object*) CheckItem_new(String_copy("Hide userland threads"), &(settings->pl->hideUserlandThreads)));
|
||||
ListBox_add(super, (Object*) CheckItem_new(String_copy("Highlight program \"basename\""), &(settings->pl->highlightBaseName)));
|
||||
ListBox_add(super, (Object*) CheckItem_new(String_copy("Highlight megabytes in memory counters"), &(settings->pl->highlightMegabytes)));
|
||||
ListBox_add(super, (Object*) CheckItem_new(String_copy("Leave a margin around header"), &(settings->header->margin)));
|
||||
Panel_setHeader(super, "Display options");
|
||||
Panel_add(super, (Object*) CheckItem_new(String_copy("Tree view"), &(settings->pl->treeView)));
|
||||
Panel_add(super, (Object*) CheckItem_new(String_copy("Shadow other users' processes"), &(settings->pl->shadowOtherUsers)));
|
||||
Panel_add(super, (Object*) CheckItem_new(String_copy("Hide kernel threads"), &(settings->pl->hideKernelThreads)));
|
||||
Panel_add(super, (Object*) CheckItem_new(String_copy("Hide userland threads"), &(settings->pl->hideUserlandThreads)));
|
||||
Panel_add(super, (Object*) CheckItem_new(String_copy("Highlight program \"basename\""), &(settings->pl->highlightBaseName)));
|
||||
Panel_add(super, (Object*) CheckItem_new(String_copy("Highlight megabytes in memory counters"), &(settings->pl->highlightMegabytes)));
|
||||
Panel_add(super, (Object*) CheckItem_new(String_copy("Leave a margin around header"), &(settings->header->margin)));
|
||||
return this;
|
||||
}
|
||||
|
||||
void DisplayOptionsListBox_delete(Object* object) {
|
||||
ListBox* super = (ListBox*) object;
|
||||
DisplayOptionsListBox* this = (DisplayOptionsListBox*) object;
|
||||
ListBox_done(super);
|
||||
void DisplayOptionsPanel_delete(Object* object) {
|
||||
Panel* super = (Panel*) object;
|
||||
DisplayOptionsPanel* this = (DisplayOptionsPanel*) object;
|
||||
Panel_done(super);
|
||||
free(this);
|
||||
}
|
||||
|
||||
HandlerResult DisplayOptionsListBox_EventHandler(ListBox* super, int ch) {
|
||||
DisplayOptionsListBox* this = (DisplayOptionsListBox*) super;
|
||||
HandlerResult DisplayOptionsPanel_EventHandler(Panel* super, int ch) {
|
||||
DisplayOptionsPanel* this = (DisplayOptionsPanel*) super;
|
||||
|
||||
HandlerResult result = IGNORED;
|
||||
CheckItem* selected = (CheckItem*) ListBox_getSelected(super);
|
||||
CheckItem* selected = (CheckItem*) Panel_getSelected(super);
|
||||
|
||||
switch(ch) {
|
||||
case 0x0a:
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* Do not edit this file. It was automatically genarated. */
|
||||
|
||||
#ifndef HEADER_DisplayOptionsListBox
|
||||
#define HEADER_DisplayOptionsListBox
|
||||
#ifndef HEADER_DisplayOptionsPanel
|
||||
#define HEADER_DisplayOptionsPanel
|
||||
|
||||
|
||||
#include "ListBox.h"
|
||||
#include "Panel.h"
|
||||
#include "CheckItem.h"
|
||||
#include "Settings.h"
|
||||
#include "ScreenManager.h"
|
||||
|
@ -13,19 +13,19 @@
|
|||
#include <assert.h>
|
||||
|
||||
|
||||
typedef struct DisplayOptionsListBox_ {
|
||||
ListBox super;
|
||||
typedef struct DisplayOptionsPanel_ {
|
||||
Panel super;
|
||||
|
||||
Settings* settings;
|
||||
ScreenManager* scr;
|
||||
} DisplayOptionsListBox;
|
||||
} DisplayOptionsPanel;
|
||||
|
||||
|
||||
DisplayOptionsListBox* DisplayOptionsListBox_new(Settings* settings, ScreenManager* scr);
|
||||
DisplayOptionsPanel* DisplayOptionsPanel_new(Settings* settings, ScreenManager* scr);
|
||||
|
||||
void DisplayOptionsListBox_delete(Object* object);
|
||||
void DisplayOptionsPanel_delete(Object* object);
|
||||
|
||||
HandlerResult DisplayOptionsListBox_EventHandler(ListBox* super, int ch);
|
||||
HandlerResult DisplayOptionsPanel_EventHandler(Panel* super, int ch);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
101
ListBox.h
101
ListBox.h
|
@ -1,101 +0,0 @@
|
|||
/* Do not edit this file. It was automatically genarated. */
|
||||
|
||||
#ifndef HEADER_ListBox
|
||||
#define HEADER_ListBox
|
||||
/*
|
||||
htop
|
||||
(C) 2004-2006 Hisham H. Muhammad
|
||||
Released under the GNU GPL, see the COPYING file
|
||||
in the source distribution for its full text.
|
||||
*/
|
||||
|
||||
#include "Object.h"
|
||||
#include "Vector.h"
|
||||
#include "CRT.h"
|
||||
#include "RichString.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <sys/param.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "debug.h"
|
||||
#include <assert.h>
|
||||
|
||||
#include <curses.h>
|
||||
//#link curses
|
||||
|
||||
|
||||
typedef struct ListBox_ ListBox;
|
||||
|
||||
typedef enum HandlerResult_ {
|
||||
HANDLED,
|
||||
IGNORED,
|
||||
BREAK_LOOP
|
||||
} HandlerResult;
|
||||
|
||||
typedef HandlerResult(*ListBox_EventHandler)(ListBox*, int);
|
||||
|
||||
struct ListBox_ {
|
||||
Object super;
|
||||
int x, y, w, h;
|
||||
WINDOW* window;
|
||||
Vector* items;
|
||||
int selected;
|
||||
int scrollV, scrollH;
|
||||
int oldSelected;
|
||||
bool needsRedraw;
|
||||
RichString header;
|
||||
ListBox_EventHandler eventHandler;
|
||||
};
|
||||
|
||||
extern char* LISTBOX_CLASS;
|
||||
|
||||
|
||||
|
||||
ListBox* ListBox_new(int x, int y, int w, int h, char* type, bool owner);
|
||||
|
||||
void ListBox_delete(Object* cast);
|
||||
|
||||
void ListBox_init(ListBox* this, int x, int y, int w, int h, char* type, bool owner);
|
||||
|
||||
void ListBox_done(ListBox* this);
|
||||
|
||||
void ListBox_setEventHandler(ListBox* this, ListBox_EventHandler eh);
|
||||
|
||||
void ListBox_setRichHeader(ListBox* this, RichString header);
|
||||
|
||||
void ListBox_setHeader(ListBox* this, char* header);
|
||||
|
||||
void ListBox_move(ListBox* this, int x, int y);
|
||||
|
||||
void ListBox_resize(ListBox* this, int w, int h);
|
||||
|
||||
void ListBox_prune(ListBox* this);
|
||||
|
||||
void ListBox_add(ListBox* this, Object* o);
|
||||
|
||||
void ListBox_insert(ListBox* this, int i, Object* o);
|
||||
|
||||
void ListBox_set(ListBox* this, int i, Object* o);
|
||||
|
||||
Object* ListBox_get(ListBox* this, int i);
|
||||
|
||||
Object* ListBox_remove(ListBox* this, int i);
|
||||
|
||||
Object* ListBox_getSelected(ListBox* this);
|
||||
|
||||
void ListBox_moveSelectedUp(ListBox* this);
|
||||
|
||||
void ListBox_moveSelectedDown(ListBox* this);
|
||||
|
||||
int ListBox_getSelectedIndex(ListBox* this);
|
||||
|
||||
int ListBox_getSize(ListBox* this);
|
||||
|
||||
void ListBox_setSelected(ListBox* this, int selected);
|
||||
|
||||
void ListBox_draw(ListBox* this, bool focus);
|
||||
|
||||
void ListBox_onKey(ListBox* this, int key);
|
||||
|
||||
#endif
|
24
Makefile.am
24
Makefile.am
|
@ -10,22 +10,22 @@ pixmap_DATA = htop.png
|
|||
AM_CFLAGS = -pedantic -Wall -std=c99
|
||||
AM_CPPFLAGS = -DSYSCONFDIR=\"$(sysconfdir)\"
|
||||
|
||||
htop_SOURCES = AvailableMetersListBox.c CategoriesListBox.c ClockMeter.c \
|
||||
CPUMeter.c CRT.c DebugMemory.c DisplayOptionsListBox.c FunctionBar.c \
|
||||
Hashtable.c Header.c htop.c ListBox.c ListItem.c LoadAverageMeter.c \
|
||||
MemoryMeter.c Meter.c MetersListBox.c Object.c Process.c \
|
||||
htop_SOURCES = AvailableMetersPanel.c CategoriesPanel.c ClockMeter.c \
|
||||
CPUMeter.c CRT.c DebugMemory.c DisplayOptionsPanel.c FunctionBar.c \
|
||||
Hashtable.c Header.c htop.c Panel.c ListItem.c LoadAverageMeter.c \
|
||||
MemoryMeter.c Meter.c MetersPanel.c Object.c Process.c \
|
||||
ProcessList.c RichString.c ScreenManager.c Settings.c SignalItem.c \
|
||||
SignalsListBox.c String.c SwapMeter.c TasksMeter.c Vector.c \
|
||||
UptimeMeter.c UsersTable.c AvailableMetersListBox.h CategoriesListBox.h \
|
||||
SignalsPanel.c String.c SwapMeter.c TasksMeter.c Vector.c \
|
||||
UptimeMeter.c UsersTable.c AvailableMetersPanel.h CategoriesPanel.h \
|
||||
ClockMeter.h config.h CPUMeter.h CRT.h debug.h DebugMemory.h \
|
||||
DisplayOptionsListBox.h FunctionBar.h Hashtable.h Header.h htop.h ListBox.h \
|
||||
DisplayOptionsPanel.h FunctionBar.h Hashtable.h Header.h htop.h Panel.h \
|
||||
ListItem.h LoadAverageMeter.h MemoryMeter.h Meter.h \
|
||||
MetersListBox.h Object.h Process.h ProcessList.h RichString.h ScreenManager.h \
|
||||
Settings.h SignalItem.h SignalsListBox.h String.h SwapMeter.h TasksMeter.h \
|
||||
MetersPanel.h Object.h Process.h ProcessList.h RichString.h ScreenManager.h \
|
||||
Settings.h SignalItem.h SignalsPanel.h String.h SwapMeter.h TasksMeter.h \
|
||||
Vector.h UptimeMeter.h UsersTable.h CheckItem.c CheckItem.h \
|
||||
ColorsListBox.c ColorsListBox.h TraceScreen.c TraceScreen.h \
|
||||
AvailableColumnsListBox.c AvailableColumnsListBox.h ColumnsListBox.c \
|
||||
ColumnsListBox.h
|
||||
ColorsPanel.c ColorsPanel.h TraceScreen.c TraceScreen.h \
|
||||
AvailableColumnsPanel.c AvailableColumnsPanel.h ColumnsPanel.c \
|
||||
ColumnsPanel.h
|
||||
|
||||
debug:
|
||||
$(MAKE) all CFLAGS="-g -DDEBUG"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
#include "MetersListBox.h"
|
||||
#include "MetersPanel.h"
|
||||
|
||||
#include "ListBox.h"
|
||||
#include "Panel.h"
|
||||
#include "Settings.h"
|
||||
#include "ScreenManager.h"
|
||||
|
||||
|
@ -10,45 +10,45 @@
|
|||
|
||||
/*{
|
||||
|
||||
typedef struct MetersListBox_ {
|
||||
ListBox super;
|
||||
typedef struct MetersPanel_ {
|
||||
Panel super;
|
||||
|
||||
Settings* settings;
|
||||
Vector* meters;
|
||||
ScreenManager* scr;
|
||||
} MetersListBox;
|
||||
} MetersPanel;
|
||||
|
||||
}*/
|
||||
|
||||
MetersListBox* MetersListBox_new(Settings* settings, char* header, Vector* meters, ScreenManager* scr) {
|
||||
MetersListBox* this = (MetersListBox*) malloc(sizeof(MetersListBox));
|
||||
ListBox* super = (ListBox*) this;
|
||||
ListBox_init(super, 1, 1, 1, 1, LISTITEM_CLASS, true);
|
||||
((Object*)this)->delete = MetersListBox_delete;
|
||||
MetersPanel* MetersPanel_new(Settings* settings, char* header, Vector* meters, ScreenManager* scr) {
|
||||
MetersPanel* this = (MetersPanel*) malloc(sizeof(MetersPanel));
|
||||
Panel* super = (Panel*) this;
|
||||
Panel_init(super, 1, 1, 1, 1, LISTITEM_CLASS, true);
|
||||
((Object*)this)->delete = MetersPanel_delete;
|
||||
|
||||
this->settings = settings;
|
||||
this->meters = meters;
|
||||
this->scr = scr;
|
||||
super->eventHandler = MetersListBox_EventHandler;
|
||||
ListBox_setHeader(super, header);
|
||||
super->eventHandler = MetersPanel_EventHandler;
|
||||
Panel_setHeader(super, header);
|
||||
for (int i = 0; i < Vector_size(meters); i++) {
|
||||
Meter* meter = (Meter*) Vector_get(meters, i);
|
||||
ListBox_add(super, (Object*) Meter_toListItem(meter));
|
||||
Panel_add(super, (Object*) Meter_toListItem(meter));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
void MetersListBox_delete(Object* object) {
|
||||
ListBox* super = (ListBox*) object;
|
||||
MetersListBox* this = (MetersListBox*) object;
|
||||
ListBox_done(super);
|
||||
void MetersPanel_delete(Object* object) {
|
||||
Panel* super = (Panel*) object;
|
||||
MetersPanel* this = (MetersPanel*) object;
|
||||
Panel_done(super);
|
||||
free(this);
|
||||
}
|
||||
|
||||
HandlerResult MetersListBox_EventHandler(ListBox* super, int ch) {
|
||||
MetersListBox* this = (MetersListBox*) super;
|
||||
HandlerResult MetersPanel_EventHandler(Panel* super, int ch) {
|
||||
MetersPanel* this = (MetersPanel*) super;
|
||||
|
||||
int selected = ListBox_getSelectedIndex(super);
|
||||
int selected = Panel_getSelectedIndex(super);
|
||||
HandlerResult result = IGNORED;
|
||||
|
||||
switch(ch) {
|
||||
|
@ -62,7 +62,7 @@ HandlerResult MetersListBox_EventHandler(ListBox* super, int ch) {
|
|||
int mode = meter->mode + 1;
|
||||
if (mode == LAST_METERMODE) mode = 1;
|
||||
Meter_setMode(meter, mode);
|
||||
ListBox_set(super, selected, (Object*) Meter_toListItem(meter));
|
||||
Panel_set(super, selected, (Object*) Meter_toListItem(meter));
|
||||
result = HANDLED;
|
||||
break;
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ HandlerResult MetersListBox_EventHandler(ListBox* super, int ch) {
|
|||
case '-':
|
||||
{
|
||||
Vector_moveUp(this->meters, selected);
|
||||
ListBox_moveSelectedUp(super);
|
||||
Panel_moveSelectedUp(super);
|
||||
result = HANDLED;
|
||||
break;
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ HandlerResult MetersListBox_EventHandler(ListBox* super, int ch) {
|
|||
case '+':
|
||||
{
|
||||
Vector_moveDown(this->meters, selected);
|
||||
ListBox_moveSelectedDown(super);
|
||||
Panel_moveSelectedDown(super);
|
||||
result = HANDLED;
|
||||
break;
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ HandlerResult MetersListBox_EventHandler(ListBox* super, int ch) {
|
|||
{
|
||||
if (selected < Vector_size(this->meters)) {
|
||||
Vector_remove(this->meters, selected);
|
||||
ListBox_remove(super, selected);
|
||||
Panel_remove(super, selected);
|
||||
}
|
||||
result = HANDLED;
|
||||
break;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* Do not edit this file. It was automatically genarated. */
|
||||
|
||||
#ifndef HEADER_MetersListBox
|
||||
#define HEADER_MetersListBox
|
||||
#ifndef HEADER_MetersPanel
|
||||
#define HEADER_MetersPanel
|
||||
|
||||
|
||||
#include "ListBox.h"
|
||||
#include "Panel.h"
|
||||
#include "Settings.h"
|
||||
#include "ScreenManager.h"
|
||||
|
||||
|
@ -12,19 +12,19 @@
|
|||
#include <assert.h>
|
||||
|
||||
|
||||
typedef struct MetersListBox_ {
|
||||
ListBox super;
|
||||
typedef struct MetersPanel_ {
|
||||
Panel super;
|
||||
|
||||
Settings* settings;
|
||||
Vector* meters;
|
||||
ScreenManager* scr;
|
||||
} MetersListBox;
|
||||
} MetersPanel;
|
||||
|
||||
|
||||
MetersListBox* MetersListBox_new(Settings* settings, char* header, Vector* meters, ScreenManager* scr);
|
||||
MetersPanel* MetersPanel_new(Settings* settings, char* header, Vector* meters, ScreenManager* scr);
|
||||
|
||||
void MetersListBox_delete(Object* object);
|
||||
void MetersPanel_delete(Object* object);
|
||||
|
||||
HandlerResult MetersListBox_EventHandler(ListBox* super, int ch);
|
||||
HandlerResult MetersPanel_EventHandler(Panel* super, int ch);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
/*
|
||||
htop - ListBox.c
|
||||
htop - Panel.c
|
||||
(C) 2004-2006 Hisham H. Muhammad
|
||||
Released under the GNU GPL, see the COPYING file
|
||||
in the source distribution for its full text.
|
||||
*/
|
||||
|
||||
#include "Object.h"
|
||||
#include "ListBox.h"
|
||||
#include "Panel.h"
|
||||
#include "Vector.h"
|
||||
#include "CRT.h"
|
||||
#include "RichString.h"
|
||||
|
@ -22,7 +22,7 @@ in the source distribution for its full text.
|
|||
|
||||
/*{
|
||||
|
||||
typedef struct ListBox_ ListBox;
|
||||
typedef struct Panel_ Panel;
|
||||
|
||||
typedef enum HandlerResult_ {
|
||||
HANDLED,
|
||||
|
@ -30,9 +30,9 @@ typedef enum HandlerResult_ {
|
|||
BREAK_LOOP
|
||||
} HandlerResult;
|
||||
|
||||
typedef HandlerResult(*ListBox_EventHandler)(ListBox*, int);
|
||||
typedef HandlerResult(*Panel_EventHandler)(Panel*, int);
|
||||
|
||||
struct ListBox_ {
|
||||
struct Panel_ {
|
||||
Object super;
|
||||
int x, y, w, h;
|
||||
WINDOW* window;
|
||||
|
@ -42,10 +42,10 @@ struct ListBox_ {
|
|||
int oldSelected;
|
||||
bool needsRedraw;
|
||||
RichString header;
|
||||
ListBox_EventHandler eventHandler;
|
||||
Panel_EventHandler eventHandler;
|
||||
};
|
||||
|
||||
extern char* LISTBOX_CLASS;
|
||||
extern char* PANEL_CLASS;
|
||||
|
||||
}*/
|
||||
|
||||
|
@ -57,25 +57,25 @@ extern char* LISTBOX_CLASS;
|
|||
#endif
|
||||
|
||||
/* private property */
|
||||
char* LISTBOX_CLASS = "ListBox";
|
||||
char* PANEL_CLASS = "Panel";
|
||||
|
||||
ListBox* ListBox_new(int x, int y, int w, int h, char* type, bool owner) {
|
||||
ListBox* this;
|
||||
this = malloc(sizeof(ListBox));
|
||||
ListBox_init(this, x, y, w, h, type, owner);
|
||||
Panel* Panel_new(int x, int y, int w, int h, char* type, bool owner) {
|
||||
Panel* this;
|
||||
this = malloc(sizeof(Panel));
|
||||
Panel_init(this, x, y, w, h, type, owner);
|
||||
return this;
|
||||
}
|
||||
|
||||
void ListBox_delete(Object* cast) {
|
||||
ListBox* this = (ListBox*)cast;
|
||||
ListBox_done(this);
|
||||
void Panel_delete(Object* cast) {
|
||||
Panel* this = (Panel*)cast;
|
||||
Panel_done(this);
|
||||
free(this);
|
||||
}
|
||||
|
||||
void ListBox_init(ListBox* this, int x, int y, int w, int h, char* type, bool owner) {
|
||||
void Panel_init(Panel* this, int x, int y, int w, int h, char* type, bool owner) {
|
||||
Object* super = (Object*) this;
|
||||
super->class = LISTBOX_CLASS;
|
||||
super->delete = ListBox_delete;
|
||||
super->class = PANEL_CLASS;
|
||||
super->delete = Panel_delete;
|
||||
this->x = x;
|
||||
this->y = y;
|
||||
this->w = w;
|
||||
|
@ -90,13 +90,13 @@ void ListBox_init(ListBox* this, int x, int y, int w, int h, char* type, bool ow
|
|||
this->header.len = 0;
|
||||
}
|
||||
|
||||
void ListBox_done(ListBox* this) {
|
||||
void Panel_done(Panel* this) {
|
||||
assert (this != NULL);
|
||||
RichString_delete(this->header);
|
||||
Vector_delete(this->items);
|
||||
}
|
||||
|
||||
inline void ListBox_setRichHeader(ListBox* this, RichString header) {
|
||||
inline void Panel_setRichHeader(Panel* this, RichString header) {
|
||||
assert (this != NULL);
|
||||
|
||||
if (this->header.len > 0) {
|
||||
|
@ -106,15 +106,15 @@ inline void ListBox_setRichHeader(ListBox* this, RichString header) {
|
|||
this->needsRedraw = true;
|
||||
}
|
||||
|
||||
inline void ListBox_setHeader(ListBox* this, char* header) {
|
||||
ListBox_setRichHeader(this, RichString_quickString(CRT_colors[PANEL_HEADER_FOCUS], header));
|
||||
inline void Panel_setHeader(Panel* this, char* header) {
|
||||
Panel_setRichHeader(this, RichString_quickString(CRT_colors[PANEL_HEADER_FOCUS], header));
|
||||
}
|
||||
|
||||
void ListBox_setEventHandler(ListBox* this, ListBox_EventHandler eh) {
|
||||
void Panel_setEventHandler(Panel* this, Panel_EventHandler eh) {
|
||||
this->eventHandler = eh;
|
||||
}
|
||||
|
||||
void ListBox_move(ListBox* this, int x, int y) {
|
||||
void Panel_move(Panel* this, int x, int y) {
|
||||
assert (this != NULL);
|
||||
|
||||
this->x = x;
|
||||
|
@ -122,7 +122,7 @@ void ListBox_move(ListBox* this, int x, int y) {
|
|||
this->needsRedraw = true;
|
||||
}
|
||||
|
||||
void ListBox_resize(ListBox* this, int w, int h) {
|
||||
void Panel_resize(Panel* this, int w, int h) {
|
||||
assert (this != NULL);
|
||||
|
||||
if (this->header.len > 0)
|
||||
|
@ -132,7 +132,7 @@ void ListBox_resize(ListBox* this, int w, int h) {
|
|||
this->needsRedraw = true;
|
||||
}
|
||||
|
||||
void ListBox_prune(ListBox* this) {
|
||||
void Panel_prune(Panel* this) {
|
||||
assert (this != NULL);
|
||||
|
||||
Vector_prune(this->items);
|
||||
|
@ -142,33 +142,33 @@ void ListBox_prune(ListBox* this) {
|
|||
this->needsRedraw = true;
|
||||
}
|
||||
|
||||
void ListBox_add(ListBox* this, Object* o) {
|
||||
void Panel_add(Panel* this, Object* o) {
|
||||
assert (this != NULL);
|
||||
|
||||
Vector_add(this->items, o);
|
||||
this->needsRedraw = true;
|
||||
}
|
||||
|
||||
void ListBox_insert(ListBox* this, int i, Object* o) {
|
||||
void Panel_insert(Panel* this, int i, Object* o) {
|
||||
assert (this != NULL);
|
||||
|
||||
Vector_insert(this->items, i, o);
|
||||
this->needsRedraw = true;
|
||||
}
|
||||
|
||||
void ListBox_set(ListBox* this, int i, Object* o) {
|
||||
void Panel_set(Panel* this, int i, Object* o) {
|
||||
assert (this != NULL);
|
||||
|
||||
Vector_set(this->items, i, o);
|
||||
}
|
||||
|
||||
Object* ListBox_get(ListBox* this, int i) {
|
||||
Object* Panel_get(Panel* this, int i) {
|
||||
assert (this != NULL);
|
||||
|
||||
return Vector_get(this->items, i);
|
||||
}
|
||||
|
||||
Object* ListBox_remove(ListBox* this, int i) {
|
||||
Object* Panel_remove(Panel* this, int i) {
|
||||
assert (this != NULL);
|
||||
|
||||
this->needsRedraw = true;
|
||||
|
@ -178,13 +178,13 @@ Object* ListBox_remove(ListBox* this, int i) {
|
|||
return removed;
|
||||
}
|
||||
|
||||
Object* ListBox_getSelected(ListBox* this) {
|
||||
Object* Panel_getSelected(Panel* this) {
|
||||
assert (this != NULL);
|
||||
|
||||
return Vector_get(this->items, this->selected);
|
||||
}
|
||||
|
||||
void ListBox_moveSelectedUp(ListBox* this) {
|
||||
void Panel_moveSelectedUp(Panel* this) {
|
||||
assert (this != NULL);
|
||||
|
||||
Vector_moveUp(this->items, this->selected);
|
||||
|
@ -192,7 +192,7 @@ void ListBox_moveSelectedUp(ListBox* this) {
|
|||
this->selected--;
|
||||
}
|
||||
|
||||
void ListBox_moveSelectedDown(ListBox* this) {
|
||||
void Panel_moveSelectedDown(Panel* this) {
|
||||
assert (this != NULL);
|
||||
|
||||
Vector_moveDown(this->items, this->selected);
|
||||
|
@ -200,26 +200,26 @@ void ListBox_moveSelectedDown(ListBox* this) {
|
|||
this->selected++;
|
||||
}
|
||||
|
||||
int ListBox_getSelectedIndex(ListBox* this) {
|
||||
int Panel_getSelectedIndex(Panel* this) {
|
||||
assert (this != NULL);
|
||||
|
||||
return this->selected;
|
||||
}
|
||||
|
||||
int ListBox_getSize(ListBox* this) {
|
||||
int Panel_getSize(Panel* this) {
|
||||
assert (this != NULL);
|
||||
|
||||
return Vector_size(this->items);
|
||||
}
|
||||
|
||||
void ListBox_setSelected(ListBox* this, int selected) {
|
||||
void Panel_setSelected(Panel* this, int selected) {
|
||||
assert (this != NULL);
|
||||
|
||||
selected = MAX(0, MIN(Vector_size(this->items) - 1, selected));
|
||||
this->selected = selected;
|
||||
}
|
||||
|
||||
void ListBox_draw(ListBox* this, bool focus) {
|
||||
void Panel_draw(Panel* this, bool focus) {
|
||||
assert (this != NULL);
|
||||
|
||||
int first, last;
|
||||
|
@ -311,7 +311,7 @@ void ListBox_draw(ListBox* this, bool focus) {
|
|||
move(0, 0);
|
||||
}
|
||||
|
||||
void ListBox_onKey(ListBox* this, int key) {
|
||||
void Panel_onKey(Panel* this, int key) {
|
||||
assert (this != NULL);
|
||||
switch (key) {
|
||||
case KEY_DOWN:
|
|
@ -0,0 +1,101 @@
|
|||
/* Do not edit this file. It was automatically genarated. */
|
||||
|
||||
#ifndef HEADER_Panel
|
||||
#define HEADER_Panel
|
||||
/*
|
||||
htop
|
||||
(C) 2004-2006 Hisham H. Muhammad
|
||||
Released under the GNU GPL, see the COPYING file
|
||||
in the source distribution for its full text.
|
||||
*/
|
||||
|
||||
#include "Object.h"
|
||||
#include "Vector.h"
|
||||
#include "CRT.h"
|
||||
#include "RichString.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <sys/param.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "debug.h"
|
||||
#include <assert.h>
|
||||
|
||||
#include <curses.h>
|
||||
//#link curses
|
||||
|
||||
|
||||
typedef struct Panel_ Panel;
|
||||
|
||||
typedef enum HandlerResult_ {
|
||||
HANDLED,
|
||||
IGNORED,
|
||||
BREAK_LOOP
|
||||
} HandlerResult;
|
||||
|
||||
typedef HandlerResult(*Panel_EventHandler)(Panel*, int);
|
||||
|
||||
struct Panel_ {
|
||||
Object super;
|
||||
int x, y, w, h;
|
||||
WINDOW* window;
|
||||
Vector* items;
|
||||
int selected;
|
||||
int scrollV, scrollH;
|
||||
int oldSelected;
|
||||
bool needsRedraw;
|
||||
RichString header;
|
||||
Panel_EventHandler eventHandler;
|
||||
};
|
||||
|
||||
extern char* PANEL_CLASS;
|
||||
|
||||
|
||||
|
||||
Panel* Panel_new(int x, int y, int w, int h, char* type, bool owner);
|
||||
|
||||
void Panel_delete(Object* cast);
|
||||
|
||||
void Panel_init(Panel* this, int x, int y, int w, int h, char* type, bool owner);
|
||||
|
||||
void Panel_done(Panel* this);
|
||||
|
||||
void Panel_setEventHandler(Panel* this, Panel_EventHandler eh);
|
||||
|
||||
void Panel_setRichHeader(Panel* this, RichString header);
|
||||
|
||||
void Panel_setHeader(Panel* this, char* header);
|
||||
|
||||
void Panel_move(Panel* this, int x, int y);
|
||||
|
||||
void Panel_resize(Panel* this, int w, int h);
|
||||
|
||||
void Panel_prune(Panel* this);
|
||||
|
||||
void Panel_add(Panel* this, Object* o);
|
||||
|
||||
void Panel_insert(Panel* this, int i, Object* o);
|
||||
|
||||
void Panel_set(Panel* this, int i, Object* o);
|
||||
|
||||
Object* Panel_get(Panel* this, int i);
|
||||
|
||||
Object* Panel_remove(Panel* this, int i);
|
||||
|
||||
Object* Panel_getSelected(Panel* this);
|
||||
|
||||
void Panel_moveSelectedUp(Panel* this);
|
||||
|
||||
void Panel_moveSelectedDown(Panel* this);
|
||||
|
||||
int Panel_getSelectedIndex(Panel* this);
|
||||
|
||||
int Panel_getSize(Panel* this);
|
||||
|
||||
void Panel_setSelected(Panel* this, int selected);
|
||||
|
||||
void Panel_draw(Panel* this, bool focus);
|
||||
|
||||
void Panel_onKey(Panel* this, int key);
|
||||
|
||||
#endif
|
|
@ -6,7 +6,7 @@ in the source distribution for its full text.
|
|||
*/
|
||||
|
||||
#include "ScreenManager.h"
|
||||
#include "ListBox.h"
|
||||
#include "Panel.h"
|
||||
#include "Object.h"
|
||||
#include "Vector.h"
|
||||
#include "FunctionBar.h"
|
||||
|
@ -47,7 +47,7 @@ ScreenManager* ScreenManager_new(int x1, int y1, int x2, int y2, Orientation ori
|
|||
this->y2 = y2;
|
||||
this->fuBar = NULL;
|
||||
this->orientation = orientation;
|
||||
this->items = Vector_new(LISTBOX_CLASS, owner, DEFAULT_SIZE);
|
||||
this->items = Vector_new(PANEL_CLASS, owner, DEFAULT_SIZE);
|
||||
this->fuBars = Vector_new(FUNCTIONBAR_CLASS, true, DEFAULT_SIZE);
|
||||
this->itemCount = 0;
|
||||
this->owner = owner;
|
||||
|
@ -64,19 +64,19 @@ inline int ScreenManager_size(ScreenManager* this) {
|
|||
return this->itemCount;
|
||||
}
|
||||
|
||||
void ScreenManager_add(ScreenManager* this, ListBox* item, FunctionBar* fuBar, int size) {
|
||||
void ScreenManager_add(ScreenManager* this, Panel* item, FunctionBar* fuBar, int size) {
|
||||
if (this->orientation == HORIZONTAL) {
|
||||
int lastX = 0;
|
||||
if (this->itemCount > 0) {
|
||||
ListBox* last = (ListBox*) Vector_get(this->items, this->itemCount - 1);
|
||||
Panel* last = (Panel*) Vector_get(this->items, this->itemCount - 1);
|
||||
lastX = last->x + last->w + 1;
|
||||
}
|
||||
if (size > 0) {
|
||||
ListBox_resize(item, size, LINES-this->y1+this->y2);
|
||||
Panel_resize(item, size, LINES-this->y1+this->y2);
|
||||
} else {
|
||||
ListBox_resize(item, COLS-this->x1+this->x2-lastX, LINES-this->y1+this->y2);
|
||||
Panel_resize(item, COLS-this->x1+this->x2-lastX, LINES-this->y1+this->y2);
|
||||
}
|
||||
ListBox_move(item, lastX, this->y1);
|
||||
Panel_move(item, lastX, this->y1);
|
||||
}
|
||||
// TODO: VERTICAL
|
||||
Vector_add(this->items, item);
|
||||
|
@ -89,9 +89,9 @@ void ScreenManager_add(ScreenManager* this, ListBox* item, FunctionBar* fuBar, i
|
|||
this->itemCount++;
|
||||
}
|
||||
|
||||
ListBox* ScreenManager_remove(ScreenManager* this, int index) {
|
||||
Panel* ScreenManager_remove(ScreenManager* this, int index) {
|
||||
assert(this->itemCount > index);
|
||||
ListBox* lb = (ListBox*) Vector_remove(this->items, index);
|
||||
Panel* lb = (Panel*) Vector_remove(this->items, index);
|
||||
Vector_remove(this->fuBars, index);
|
||||
this->fuBar = NULL;
|
||||
this->itemCount--;
|
||||
|
@ -112,21 +112,21 @@ void ScreenManager_resize(ScreenManager* this, int x1, int y1, int x2, int y2) {
|
|||
int items = this->itemCount;
|
||||
int lastX = 0;
|
||||
for (int i = 0; i < items - 1; i++) {
|
||||
ListBox* lb = (ListBox*) Vector_get(this->items, i);
|
||||
ListBox_resize(lb, lb->w, LINES-y1+y2);
|
||||
ListBox_move(lb, lastX, y1);
|
||||
Panel* lb = (Panel*) Vector_get(this->items, i);
|
||||
Panel_resize(lb, lb->w, LINES-y1+y2);
|
||||
Panel_move(lb, lastX, y1);
|
||||
lastX = lb->x + lb->w + 1;
|
||||
}
|
||||
ListBox* lb = (ListBox*) Vector_get(this->items, items-1);
|
||||
ListBox_resize(lb, COLS-x1+x2-lastX, LINES-y1+y2);
|
||||
ListBox_move(lb, lastX, y1);
|
||||
Panel* lb = (Panel*) Vector_get(this->items, items-1);
|
||||
Panel_resize(lb, COLS-x1+x2-lastX, LINES-y1+y2);
|
||||
Panel_move(lb, lastX, y1);
|
||||
}
|
||||
|
||||
void ScreenManager_run(ScreenManager* this, ListBox** lastFocus, int* lastKey) {
|
||||
void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
|
||||
bool quit = false;
|
||||
int focus = 0;
|
||||
|
||||
ListBox* lbFocus = (ListBox*) Vector_get(this->items, focus);
|
||||
Panel* lbFocus = (Panel*) Vector_get(this->items, focus);
|
||||
if (this->fuBar)
|
||||
FunctionBar_draw(this->fuBar, NULL);
|
||||
|
||||
|
@ -134,8 +134,8 @@ void ScreenManager_run(ScreenManager* this, ListBox** lastFocus, int* lastKey) {
|
|||
while (!quit) {
|
||||
int items = this->itemCount;
|
||||
for (int i = 0; i < items; i++) {
|
||||
ListBox* lb = (ListBox*) Vector_get(this->items, i);
|
||||
ListBox_draw(lb, i == focus);
|
||||
Panel* lb = (Panel*) Vector_get(this->items, i);
|
||||
Panel_draw(lb, i == focus);
|
||||
if (i < items) {
|
||||
if (this->orientation == HORIZONTAL) {
|
||||
mvvline(lb->y, lb->x+lb->w, ' ', lb->h+1);
|
||||
|
@ -159,12 +159,12 @@ void ScreenManager_run(ScreenManager* this, ListBox** lastFocus, int* lastKey) {
|
|||
ch = FunctionBar_synthesizeEvent(this->fuBar, mevent.x);
|
||||
} else {
|
||||
for (int i = 0; i < this->itemCount; i++) {
|
||||
ListBox* lb = (ListBox*) Vector_get(this->items, i);
|
||||
Panel* lb = (Panel*) Vector_get(this->items, i);
|
||||
if (mevent.x > lb->x && mevent.x <= lb->x+lb->w &&
|
||||
mevent.y > lb->y && mevent.y <= lb->y+lb->h) {
|
||||
focus = i;
|
||||
lbFocus = lb;
|
||||
ListBox_setSelected(lb, mevent.y - lb->y + lb->scrollV - 1);
|
||||
Panel_setSelected(lb, mevent.y - lb->y + lb->scrollV - 1);
|
||||
loop = true;
|
||||
break;
|
||||
}
|
||||
|
@ -196,8 +196,8 @@ void ScreenManager_run(ScreenManager* this, ListBox** lastFocus, int* lastKey) {
|
|||
tryLeft:
|
||||
if (focus > 0)
|
||||
focus--;
|
||||
lbFocus = (ListBox*) Vector_get(this->items, focus);
|
||||
if (ListBox_getSize(lbFocus) == 0 && focus > 0)
|
||||
lbFocus = (Panel*) Vector_get(this->items, focus);
|
||||
if (Panel_getSize(lbFocus) == 0 && focus > 0)
|
||||
goto tryLeft;
|
||||
break;
|
||||
case KEY_RIGHT:
|
||||
|
@ -205,8 +205,8 @@ void ScreenManager_run(ScreenManager* this, ListBox** lastFocus, int* lastKey) {
|
|||
tryRight:
|
||||
if (focus < this->itemCount - 1)
|
||||
focus++;
|
||||
lbFocus = (ListBox*) Vector_get(this->items, focus);
|
||||
if (ListBox_getSize(lbFocus) == 0 && focus < this->itemCount - 1)
|
||||
lbFocus = (Panel*) Vector_get(this->items, focus);
|
||||
if (Panel_getSize(lbFocus) == 0 && focus < this->itemCount - 1)
|
||||
goto tryRight;
|
||||
break;
|
||||
case KEY_F(10):
|
||||
|
@ -215,7 +215,7 @@ void ScreenManager_run(ScreenManager* this, ListBox** lastFocus, int* lastKey) {
|
|||
quit = true;
|
||||
continue;
|
||||
default:
|
||||
ListBox_onKey(lbFocus, ch);
|
||||
Panel_onKey(lbFocus, ch);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ Released under the GNU GPL, see the COPYING file
|
|||
in the source distribution for its full text.
|
||||
*/
|
||||
|
||||
#include "ListBox.h"
|
||||
#include "Panel.h"
|
||||
#include "Object.h"
|
||||
#include "Vector.h"
|
||||
#include "FunctionBar.h"
|
||||
|
@ -45,14 +45,14 @@ void ScreenManager_delete(ScreenManager* this);
|
|||
|
||||
inline int ScreenManager_size(ScreenManager* this);
|
||||
|
||||
void ScreenManager_add(ScreenManager* this, ListBox* item, FunctionBar* fuBar, int size);
|
||||
void ScreenManager_add(ScreenManager* this, Panel* item, FunctionBar* fuBar, int size);
|
||||
|
||||
ListBox* ScreenManager_remove(ScreenManager* this, int index);
|
||||
Panel* ScreenManager_remove(ScreenManager* this, int index);
|
||||
|
||||
void ScreenManager_setFunctionBar(ScreenManager* this, FunctionBar* fuBar);
|
||||
|
||||
void ScreenManager_resize(ScreenManager* this, int x1, int y1, int x2, int y2);
|
||||
|
||||
void ScreenManager_run(ScreenManager* this, ListBox** lastFocus, int* lastKey);
|
||||
void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
#include "SignalsListBox.h"
|
||||
#include "ListBox.h"
|
||||
#include "SignalsPanel.h"
|
||||
#include "Panel.h"
|
||||
#include "SignalItem.h"
|
||||
#include "RichString.h"
|
||||
|
||||
|
@ -11,56 +11,56 @@
|
|||
|
||||
/*{
|
||||
|
||||
typedef struct SignalsListBox_ {
|
||||
ListBox super;
|
||||
typedef struct SignalsPanel_ {
|
||||
Panel super;
|
||||
|
||||
int state;
|
||||
Signal** signals;
|
||||
} SignalsListBox;
|
||||
} SignalsPanel;
|
||||
|
||||
}*/
|
||||
|
||||
SignalsListBox* SignalsListBox_new(int x, int y, int w, int h) {
|
||||
SignalsListBox* this = (SignalsListBox*) malloc(sizeof(SignalsListBox));
|
||||
ListBox* super = (ListBox*) this;
|
||||
ListBox_init(super, x, y, w, h, SIGNAL_CLASS, true);
|
||||
((Object*)this)->delete = SignalsListBox_delete;
|
||||
SignalsPanel* SignalsPanel_new(int x, int y, int w, int h) {
|
||||
SignalsPanel* this = (SignalsPanel*) malloc(sizeof(SignalsPanel));
|
||||
Panel* super = (Panel*) this;
|
||||
Panel_init(super, x, y, w, h, SIGNAL_CLASS, true);
|
||||
((Object*)this)->delete = SignalsPanel_delete;
|
||||
|
||||
this->signals = Signal_getSignalTable();
|
||||
super->eventHandler = SignalsListBox_EventHandler;
|
||||
super->eventHandler = SignalsPanel_EventHandler;
|
||||
int sigCount = Signal_getSignalCount();
|
||||
for(int i = 0; i < sigCount; i++)
|
||||
ListBox_set(super, i, (Object*) this->signals[i]);
|
||||
SignalsListBox_reset(this);
|
||||
Panel_set(super, i, (Object*) this->signals[i]);
|
||||
SignalsPanel_reset(this);
|
||||
return this;
|
||||
}
|
||||
|
||||
void SignalsListBox_delete(Object* object) {
|
||||
ListBox* super = (ListBox*) object;
|
||||
SignalsListBox* this = (SignalsListBox*) object;
|
||||
ListBox_done(super);
|
||||
void SignalsPanel_delete(Object* object) {
|
||||
Panel* super = (Panel*) object;
|
||||
SignalsPanel* this = (SignalsPanel*) object;
|
||||
Panel_done(super);
|
||||
free(this->signals);
|
||||
free(this);
|
||||
}
|
||||
|
||||
void SignalsListBox_reset(SignalsListBox* this) {
|
||||
ListBox* super = (ListBox*) this;
|
||||
void SignalsPanel_reset(SignalsPanel* this) {
|
||||
Panel* super = (Panel*) this;
|
||||
|
||||
ListBox_setHeader(super, "Send signal:");
|
||||
ListBox_setSelected(super, 16); // 16th item is SIGTERM
|
||||
Panel_setHeader(super, "Send signal:");
|
||||
Panel_setSelected(super, 16); // 16th item is SIGTERM
|
||||
this->state = 0;
|
||||
}
|
||||
|
||||
HandlerResult SignalsListBox_EventHandler(ListBox* super, int ch) {
|
||||
SignalsListBox* this = (SignalsListBox*) super;
|
||||
HandlerResult SignalsPanel_EventHandler(Panel* super, int ch) {
|
||||
SignalsPanel* this = (SignalsPanel*) super;
|
||||
|
||||
int size = ListBox_getSize(super);
|
||||
int size = Panel_getSize(super);
|
||||
|
||||
if (ch <= 255 && isdigit(ch)) {
|
||||
int signal = ch-48 + this->state;
|
||||
for (int i = 0; i < size; i++)
|
||||
if (((Signal*) ListBox_get(super, i))->number == signal) {
|
||||
ListBox_setSelected(super, i);
|
||||
if (((Signal*) Panel_get(super, i))->number == signal) {
|
||||
Panel_setSelected(super, i);
|
||||
break;
|
||||
}
|
||||
this->state = signal * 10;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/* Do not edit this file. It was automatically genarated. */
|
||||
|
||||
#ifndef HEADER_SignalsListBox
|
||||
#define HEADER_SignalsListBox
|
||||
#ifndef HEADER_SignalsPanel
|
||||
#define HEADER_SignalsPanel
|
||||
|
||||
#include "ListBox.h"
|
||||
#include "Panel.h"
|
||||
#include "SignalItem.h"
|
||||
#include "RichString.h"
|
||||
|
||||
|
@ -13,20 +13,20 @@
|
|||
#include <ctype.h>
|
||||
|
||||
|
||||
typedef struct SignalsListBox_ {
|
||||
ListBox super;
|
||||
typedef struct SignalsPanel_ {
|
||||
Panel super;
|
||||
|
||||
int state;
|
||||
Signal** signals;
|
||||
} SignalsListBox;
|
||||
} SignalsPanel;
|
||||
|
||||
|
||||
SignalsListBox* SignalsListBox_new(int x, int y, int w, int h);
|
||||
SignalsPanel* SignalsPanel_new(int x, int y, int w, int h);
|
||||
|
||||
void SignalsListBox_delete(Object* object);
|
||||
void SignalsPanel_delete(Object* object);
|
||||
|
||||
void SignalsListBox_reset(SignalsListBox* this);
|
||||
void SignalsPanel_reset(SignalsPanel* this);
|
||||
|
||||
HandlerResult SignalsListBox_EventHandler(ListBox* super, int ch);
|
||||
HandlerResult SignalsPanel_EventHandler(Panel* super, int ch);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -18,14 +18,14 @@ in the source distribution for its full text.
|
|||
#include "ProcessList.h"
|
||||
#include "Process.h"
|
||||
#include "ListItem.h"
|
||||
#include "ListBox.h"
|
||||
#include "Panel.h"
|
||||
#include "FunctionBar.h"
|
||||
|
||||
/*{
|
||||
|
||||
typedef struct TraceScreen_ {
|
||||
Process* process;
|
||||
ListBox* display;
|
||||
Panel* display;
|
||||
FunctionBar* bar;
|
||||
bool tracing;
|
||||
} TraceScreen;
|
||||
|
@ -44,14 +44,14 @@ static int tbEvents[3] = {KEY_F(4), KEY_F(5), 27};
|
|||
TraceScreen* TraceScreen_new(Process* process) {
|
||||
TraceScreen* this = (TraceScreen*) malloc(sizeof(TraceScreen));
|
||||
this->process = process;
|
||||
this->display = ListBox_new(0, 1, COLS, LINES-2, LISTITEM_CLASS, true);
|
||||
this->display = Panel_new(0, 1, COLS, LINES-2, LISTITEM_CLASS, true);
|
||||
this->bar = FunctionBar_new(3, tbFunctions, tbKeys, tbEvents);
|
||||
this->tracing = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
void TraceScreen_delete(TraceScreen* this) {
|
||||
ListBox_delete((Object*)this->display);
|
||||
Panel_delete((Object*)this->display);
|
||||
FunctionBar_delete((Object*)this->bar);
|
||||
free(this);
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ void TraceScreen_run(TraceScreen* this) {
|
|||
}
|
||||
fcntl(fdpair[0], F_SETFL, O_NONBLOCK);
|
||||
FILE* strace = fdopen(fdpair[0], "r");
|
||||
ListBox* lb = this->display;
|
||||
Panel* lb = this->display;
|
||||
int fd_strace = fileno(strace);
|
||||
TraceScreen_draw(this);
|
||||
CRT_disableDelay();
|
||||
|
@ -105,23 +105,23 @@ void TraceScreen_run(TraceScreen* this) {
|
|||
if (buffer[i] == '\n') {
|
||||
buffer[i] = '\0';
|
||||
if (contLine) {
|
||||
ListItem_append((ListItem*)ListBox_get(lb,
|
||||
ListBox_getSize(lb)-1), line);
|
||||
ListItem_append((ListItem*)Panel_get(lb,
|
||||
Panel_getSize(lb)-1), line);
|
||||
contLine = false;
|
||||
} else {
|
||||
ListBox_add(lb, (Object*) ListItem_new(line, 0));
|
||||
Panel_add(lb, (Object*) ListItem_new(line, 0));
|
||||
}
|
||||
line = buffer+i+1;
|
||||
}
|
||||
}
|
||||
if (line < buffer+nread) {
|
||||
ListBox_add(lb, (Object*) ListItem_new(line, 0));
|
||||
Panel_add(lb, (Object*) ListItem_new(line, 0));
|
||||
buffer[nread] = '\0';
|
||||
contLine = true;
|
||||
}
|
||||
if (follow)
|
||||
ListBox_setSelected(lb, ListBox_getSize(lb)-1);
|
||||
ListBox_draw(lb, true);
|
||||
Panel_setSelected(lb, Panel_getSize(lb)-1);
|
||||
Panel_draw(lb, true);
|
||||
}
|
||||
int ch = getch();
|
||||
if (ch == KEY_MOUSE) {
|
||||
|
@ -129,7 +129,7 @@ void TraceScreen_run(TraceScreen* this) {
|
|||
int ok = getmouse(&mevent);
|
||||
if (ok == OK)
|
||||
if (mevent.y >= lb->y && mevent.y < LINES - 1) {
|
||||
ListBox_setSelected(lb, mevent.y - lb->y + lb->scrollV);
|
||||
Panel_setSelected(lb, mevent.y - lb->y + lb->scrollV);
|
||||
follow = false;
|
||||
ch = 0;
|
||||
} if (mevent.y == LINES - 1)
|
||||
|
@ -147,21 +147,21 @@ void TraceScreen_run(TraceScreen* this) {
|
|||
case KEY_F(4):
|
||||
follow = !follow;
|
||||
if (follow)
|
||||
ListBox_setSelected(lb, ListBox_getSize(lb)-1);
|
||||
Panel_setSelected(lb, Panel_getSize(lb)-1);
|
||||
break;
|
||||
case 'q':
|
||||
case 27:
|
||||
looping = false;
|
||||
break;
|
||||
case KEY_RESIZE:
|
||||
ListBox_resize(lb, COLS, LINES-2);
|
||||
Panel_resize(lb, COLS, LINES-2);
|
||||
TraceScreen_draw(this);
|
||||
break;
|
||||
default:
|
||||
follow = false;
|
||||
ListBox_onKey(lb, ch);
|
||||
Panel_onKey(lb, ch);
|
||||
}
|
||||
ListBox_draw(lb, true);
|
||||
Panel_draw(lb, true);
|
||||
}
|
||||
kill(child, SIGTERM);
|
||||
waitpid(child, NULL, 0);
|
||||
|
|
|
@ -15,12 +15,12 @@ in the source distribution for its full text.
|
|||
#include <fcntl.h>
|
||||
|
||||
#include "ProcessList.h"
|
||||
#include "ListBox.h"
|
||||
#include "Panel.h"
|
||||
#include "FunctionBar.h"
|
||||
|
||||
typedef struct TraceScreen_ {
|
||||
Process* process;
|
||||
ListBox* display;
|
||||
Panel* display;
|
||||
FunctionBar* bar;
|
||||
bool tracing;
|
||||
} TraceScreen;
|
||||
|
|
128
htop.c
128
htop.c
|
@ -14,7 +14,7 @@ in the source distribution for its full text.
|
|||
|
||||
#include "ProcessList.h"
|
||||
#include "CRT.h"
|
||||
#include "ListBox.h"
|
||||
#include "Panel.h"
|
||||
#include "UsersTable.h"
|
||||
#include "SignalItem.h"
|
||||
#include "RichString.h"
|
||||
|
@ -22,8 +22,8 @@ in the source distribution for its full text.
|
|||
#include "ScreenManager.h"
|
||||
#include "FunctionBar.h"
|
||||
#include "ListItem.h"
|
||||
#include "CategoriesListBox.h"
|
||||
#include "SignalsListBox.h"
|
||||
#include "CategoriesPanel.h"
|
||||
#include "SignalsPanel.h"
|
||||
#include "TraceScreen.h"
|
||||
|
||||
#include "config.h"
|
||||
|
@ -126,62 +126,62 @@ void showHelp() {
|
|||
|
||||
static void Setup_run(Settings* settings, int headerHeight) {
|
||||
ScreenManager* scr = ScreenManager_new(0, headerHeight, 0, -1, HORIZONTAL, true);
|
||||
CategoriesListBox* lbCategories = CategoriesListBox_new(settings, scr);
|
||||
ScreenManager_add(scr, (ListBox*) lbCategories, NULL, 16);
|
||||
CategoriesListBox_makeMetersPage(lbCategories);
|
||||
ListBox* lbFocus;
|
||||
CategoriesPanel* lbCategories = CategoriesPanel_new(settings, scr);
|
||||
ScreenManager_add(scr, (Panel*) lbCategories, NULL, 16);
|
||||
CategoriesPanel_makeMetersPage(lbCategories);
|
||||
Panel* lbFocus;
|
||||
int ch;
|
||||
ScreenManager_run(scr, &lbFocus, &ch);
|
||||
ScreenManager_delete(scr);
|
||||
}
|
||||
|
||||
static bool changePriority(ListBox* lb, int delta) {
|
||||
static bool changePriority(Panel* lb, int delta) {
|
||||
bool anyTagged = false;
|
||||
for (int i = 0; i < ListBox_getSize(lb); i++) {
|
||||
Process* p = (Process*) ListBox_get(lb, i);
|
||||
for (int i = 0; i < Panel_getSize(lb); i++) {
|
||||
Process* p = (Process*) Panel_get(lb, i);
|
||||
if (p->tag) {
|
||||
Process_setPriority(p, p->nice + delta);
|
||||
anyTagged = true;
|
||||
}
|
||||
}
|
||||
if (!anyTagged) {
|
||||
Process* p = (Process*) ListBox_getSelected(lb);
|
||||
Process* p = (Process*) Panel_getSelected(lb);
|
||||
Process_setPriority(p, p->nice + delta);
|
||||
}
|
||||
return anyTagged;
|
||||
}
|
||||
|
||||
static HandlerResult pickWithEnter(ListBox* lb, int ch) {
|
||||
static HandlerResult pickWithEnter(Panel* lb, int ch) {
|
||||
if (ch == 13)
|
||||
return BREAK_LOOP;
|
||||
return IGNORED;
|
||||
}
|
||||
|
||||
static Object* pickFromList(ListBox* lb, ListBox* list, int x, int y, char** keyLabels, FunctionBar* prevBar) {
|
||||
static Object* pickFromList(Panel* lb, Panel* list, int x, int y, char** keyLabels, FunctionBar* prevBar) {
|
||||
char* fuKeys[2] = {"Enter", "Esc"};
|
||||
int fuEvents[2] = {13, 27};
|
||||
if (!lb->eventHandler)
|
||||
ListBox_setEventHandler(list, pickWithEnter);
|
||||
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, lb, NULL, -1);
|
||||
ListBox* lbFocus;
|
||||
Panel* lbFocus;
|
||||
int ch;
|
||||
ScreenManager_run(scr, &lbFocus, &ch);
|
||||
ScreenManager_delete(scr);
|
||||
ListBox_move(lb, 0, y);
|
||||
ListBox_resize(lb, COLS, LINES-y-1);
|
||||
Panel_move(lb, 0, y);
|
||||
Panel_resize(lb, COLS, LINES-y-1);
|
||||
FunctionBar_draw(prevBar, NULL);
|
||||
if (lbFocus == list && ch == 13) {
|
||||
return ListBox_getSelected(list);
|
||||
return Panel_getSelected(list);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void addUserToList(int key, void* userCast, void* lbCast) {
|
||||
char* user = (char*) userCast;
|
||||
ListBox* lb = (ListBox*) lbCast;
|
||||
ListBox_add(lb, (Object*) ListItem_new(user, key));
|
||||
Panel* lb = (Panel*) lbCast;
|
||||
Panel_add(lb, (Object*) ListItem_new(user, key));
|
||||
}
|
||||
|
||||
void setUserOnly(const char* userName, bool* userOnly, uid_t* userId) {
|
||||
|
@ -219,14 +219,14 @@ int main(int argc, char** argv) {
|
|||
exit(1);
|
||||
}
|
||||
|
||||
ListBox* lb;
|
||||
Panel* lb;
|
||||
int quit = 0;
|
||||
int refreshTimeout = 0;
|
||||
int resetRefreshTimeout = 5;
|
||||
bool doRefresh = true;
|
||||
Settings* settings;
|
||||
|
||||
ListBox* lbk = NULL;
|
||||
Panel* lbk = NULL;
|
||||
|
||||
char incSearchBuffer[INCSEARCH_MAX];
|
||||
int incSearchIndex = 0;
|
||||
|
@ -248,8 +248,8 @@ int main(int argc, char** argv) {
|
|||
|
||||
CRT_init(settings->delay, settings->colorScheme);
|
||||
|
||||
lb = ListBox_new(0, headerHeight, COLS, LINES - headerHeight - 2, PROCESS_CLASS, false);
|
||||
ListBox_setRichHeader(lb, ProcessList_printHeader(pl));
|
||||
lb = Panel_new(0, headerHeight, COLS, LINES - headerHeight - 2, PROCESS_CLASS, false);
|
||||
Panel_setRichHeader(lb, ProcessList_printHeader(pl));
|
||||
|
||||
char* searchFunctions[3] = {"Next ", "Exit ", " Search: "};
|
||||
char* searchKeys[3] = {"F3", "Esc", " "};
|
||||
|
@ -285,7 +285,7 @@ int main(int argc, char** argv) {
|
|||
if (doRefresh) {
|
||||
incSearchIndex = 0;
|
||||
incSearchBuffer[0] = 0;
|
||||
int currPos = ListBox_getSelectedIndex(lb);
|
||||
int currPos = Panel_getSelectedIndex(lb);
|
||||
int currPid = 0;
|
||||
int currScrollV = lb->scrollV;
|
||||
if (follow)
|
||||
|
@ -296,15 +296,15 @@ int main(int argc, char** argv) {
|
|||
ProcessList_sort(pl);
|
||||
refreshTimeout = 1;
|
||||
}
|
||||
ListBox_prune(lb);
|
||||
Panel_prune(lb);
|
||||
int size = ProcessList_size(pl);
|
||||
int lbi = 0;
|
||||
for (int i = 0; i < size; i++) {
|
||||
Process* p = ProcessList_get(pl, i);
|
||||
if (!userOnly || (p->st_uid == userId)) {
|
||||
ListBox_set(lb, lbi, (Object*)p);
|
||||
Panel_set(lb, lbi, (Object*)p);
|
||||
if ((!follow && lbi == currPos) || (follow && p->pid == currPid)) {
|
||||
ListBox_setSelected(lb, lbi);
|
||||
Panel_setSelected(lb, lbi);
|
||||
lb->scrollV = currScrollV;
|
||||
}
|
||||
lbi++;
|
||||
|
@ -315,7 +315,7 @@ int main(int argc, char** argv) {
|
|||
|
||||
Header_draw(header);
|
||||
|
||||
ListBox_draw(lb, true);
|
||||
Panel_draw(lb, true);
|
||||
int prev = ch;
|
||||
ch = getch();
|
||||
|
||||
|
@ -334,7 +334,7 @@ int main(int argc, char** argv) {
|
|||
if (incSearchMode) {
|
||||
doRefresh = false;
|
||||
if (ch == KEY_F(3)) {
|
||||
int here = ListBox_getSelectedIndex(lb);
|
||||
int here = Panel_getSelectedIndex(lb);
|
||||
int size = ProcessList_size(pl);
|
||||
int i = here+1;
|
||||
while (i != here) {
|
||||
|
@ -342,7 +342,7 @@ int main(int argc, char** argv) {
|
|||
i = 0;
|
||||
Process* p = ProcessList_get(pl, i);
|
||||
if (String_contains_i(p->comm, incSearchBuffer)) {
|
||||
ListBox_setSelected(lb, i);
|
||||
Panel_setSelected(lb, i);
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
|
@ -367,7 +367,7 @@ int main(int argc, char** argv) {
|
|||
for (int i = 0; i < ProcessList_size(pl); i++) {
|
||||
Process* p = ProcessList_get(pl, i);
|
||||
if (String_contains_i(p->comm, incSearchBuffer)) {
|
||||
ListBox_setSelected(lb, i);
|
||||
Panel_setSelected(lb, i);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
@ -381,8 +381,8 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
if (isdigit((char)ch)) {
|
||||
int pid = ch-48 + acc;
|
||||
for (int i = 0; i < ProcessList_size(pl) && ((Process*) ListBox_getSelected(lb))->pid != pid; i++)
|
||||
ListBox_setSelected(lb, i);
|
||||
for (int i = 0; i < ProcessList_size(pl) && ((Process*) Panel_getSelected(lb))->pid != pid; i++)
|
||||
Panel_setSelected(lb, i);
|
||||
acc = pid * 10;
|
||||
if (acc > 100000)
|
||||
acc = 0;
|
||||
|
@ -396,7 +396,7 @@ int main(int argc, char** argv) {
|
|||
int ok = getmouse(&mevent);
|
||||
if (ok == OK) {
|
||||
if (mevent.y >= lb->y + 1 && mevent.y < LINES - 1) {
|
||||
ListBox_setSelected(lb, mevent.y - lb->y + lb->scrollV - 1);
|
||||
Panel_setSelected(lb, mevent.y - lb->y + lb->scrollV - 1);
|
||||
doRefresh = false;
|
||||
refreshTimeout = resetRefreshTimeout;
|
||||
follow = true;
|
||||
|
@ -413,7 +413,7 @@ int main(int argc, char** argv) {
|
|||
|
||||
switch (ch) {
|
||||
case KEY_RESIZE:
|
||||
ListBox_resize(lb, COLS, LINES-headerHeight-1);
|
||||
Panel_resize(lb, COLS, LINES-headerHeight-1);
|
||||
if (incSearchMode)
|
||||
FunctionBar_draw(searchBar, incSearchBuffer);
|
||||
else
|
||||
|
@ -425,7 +425,7 @@ int main(int argc, char** argv) {
|
|||
pl->sortKey = PERCENT_MEM;
|
||||
pl->treeView = false;
|
||||
settings->changed = true;
|
||||
ListBox_setRichHeader(lb, ProcessList_printHeader(pl));
|
||||
Panel_setRichHeader(lb, ProcessList_printHeader(pl));
|
||||
break;
|
||||
}
|
||||
case 'T':
|
||||
|
@ -434,13 +434,13 @@ int main(int argc, char** argv) {
|
|||
pl->sortKey = TIME;
|
||||
pl->treeView = false;
|
||||
settings->changed = true;
|
||||
ListBox_setRichHeader(lb, ProcessList_printHeader(pl));
|
||||
Panel_setRichHeader(lb, ProcessList_printHeader(pl));
|
||||
break;
|
||||
}
|
||||
case 'U':
|
||||
{
|
||||
for (int i = 0; i < ListBox_getSize(lb); i++) {
|
||||
Process* p = (Process*) ListBox_get(lb, i);
|
||||
for (int i = 0; i < Panel_getSize(lb); i++) {
|
||||
Process* p = (Process*) Panel_get(lb, i);
|
||||
p->tag = false;
|
||||
}
|
||||
doRefresh = true;
|
||||
|
@ -452,7 +452,7 @@ int main(int argc, char** argv) {
|
|||
pl->sortKey = PERCENT_CPU;
|
||||
pl->treeView = false;
|
||||
settings->changed = true;
|
||||
ListBox_setRichHeader(lb, ProcessList_printHeader(pl));
|
||||
Panel_setRichHeader(lb, ProcessList_printHeader(pl));
|
||||
break;
|
||||
}
|
||||
case KEY_F(1):
|
||||
|
@ -472,14 +472,14 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
case ' ':
|
||||
{
|
||||
Process* p = (Process*) ListBox_getSelected(lb);
|
||||
Process* p = (Process*) Panel_getSelected(lb);
|
||||
Process_toggleTag(p);
|
||||
ListBox_onKey(lb, KEY_DOWN);
|
||||
Panel_onKey(lb, KEY_DOWN);
|
||||
break;
|
||||
}
|
||||
case 's':
|
||||
{
|
||||
TraceScreen* ts = TraceScreen_new((Process*) ListBox_getSelected(lb));
|
||||
TraceScreen* ts = TraceScreen_new((Process*) Panel_getSelected(lb));
|
||||
TraceScreen_run(ts);
|
||||
TraceScreen_delete(ts);
|
||||
clear();
|
||||
|
@ -494,10 +494,10 @@ int main(int argc, char** argv) {
|
|||
{
|
||||
Setup_run(settings, headerHeight);
|
||||
// TODO: shouldn't need this, colors should be dynamic
|
||||
ListBox_setRichHeader(lb, ProcessList_printHeader(pl));
|
||||
Panel_setRichHeader(lb, ProcessList_printHeader(pl));
|
||||
headerHeight = Header_calculateHeight(header);
|
||||
ListBox_move(lb, 0, headerHeight);
|
||||
ListBox_resize(lb, COLS, LINES-headerHeight-1);
|
||||
Panel_move(lb, 0, headerHeight);
|
||||
Panel_resize(lb, COLS, LINES-headerHeight-1);
|
||||
FunctionBar_draw(defaultBar, NULL);
|
||||
refreshTimeout = 0;
|
||||
break;
|
||||
|
@ -509,12 +509,12 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
case 'u':
|
||||
{
|
||||
ListBox* lbu = ListBox_new(0, 0, 0, 0, LISTITEM_CLASS, true);
|
||||
ListBox_setHeader(lbu, "Show processes of:");
|
||||
Panel* lbu = Panel_new(0, 0, 0, 0, LISTITEM_CLASS, true);
|
||||
Panel_setHeader(lbu, "Show processes of:");
|
||||
UsersTable_foreach(ut, addUserToList, lbu);
|
||||
Vector_sort(lbu->items);
|
||||
ListItem* allUsers = ListItem_new("All users", -1);
|
||||
ListBox_insert(lbu, 0, (Object*) allUsers);
|
||||
Panel_insert(lbu, 0, (Object*) allUsers);
|
||||
char* fuFunctions[2] = {"Show ", "Cancel "};
|
||||
ListItem* picked = (ListItem*) pickFromList(lb, lbu, 20, headerHeight, fuFunctions, defaultBar);
|
||||
if (picked) {
|
||||
|
@ -531,19 +531,19 @@ int main(int argc, char** argv) {
|
|||
case 'k':
|
||||
{
|
||||
if (!lbk) {
|
||||
lbk = (ListBox*) SignalsListBox_new(0, 0, 0, 0);
|
||||
lbk = (Panel*) SignalsPanel_new(0, 0, 0, 0);
|
||||
}
|
||||
SignalsListBox_reset((SignalsListBox*) lbk);
|
||||
SignalsPanel_reset((SignalsPanel*) lbk);
|
||||
char* fuFunctions[2] = {"Send ", "Cancel "};
|
||||
Signal* signal = (Signal*) pickFromList(lb, lbk, 15, headerHeight, fuFunctions, defaultBar);
|
||||
if (signal) {
|
||||
if (signal->number != 0) {
|
||||
ListBox_setHeader(lb, "Sending...");
|
||||
ListBox_draw(lb, true);
|
||||
Panel_setHeader(lb, "Sending...");
|
||||
Panel_draw(lb, true);
|
||||
refresh();
|
||||
bool anyTagged = false;
|
||||
for (int i = 0; i < ListBox_getSize(lb); i++) {
|
||||
Process* p = (Process*) ListBox_get(lb, i);
|
||||
for (int i = 0; i < Panel_getSize(lb); i++) {
|
||||
Process* p = (Process*) Panel_get(lb, i);
|
||||
if (p->tag) {
|
||||
Process_sendSignal(p, signal->number);
|
||||
Process_toggleTag(p);
|
||||
|
@ -551,13 +551,13 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
}
|
||||
if (!anyTagged) {
|
||||
Process* p = (Process*) ListBox_getSelected(lb);
|
||||
Process* p = (Process*) Panel_getSelected(lb);
|
||||
Process_sendSignal(p, signal->number);
|
||||
}
|
||||
napms(500);
|
||||
}
|
||||
}
|
||||
ListBox_setRichHeader(lb, ProcessList_printHeader(pl));
|
||||
Panel_setRichHeader(lb, ProcessList_printHeader(pl));
|
||||
refreshTimeout = 0;
|
||||
break;
|
||||
}
|
||||
|
@ -572,15 +572,15 @@ int main(int argc, char** argv) {
|
|||
case '.':
|
||||
case KEY_F(6):
|
||||
{
|
||||
ListBox* lbf = ListBox_new(0,0,0,0,LISTITEM_CLASS,true);
|
||||
ListBox_setHeader(lbf, "Sort by");
|
||||
Panel* lbf = Panel_new(0,0,0,0,LISTITEM_CLASS,true);
|
||||
Panel_setHeader(lbf, "Sort by");
|
||||
char* fuFunctions[2] = {"Sort ", "Cancel "};
|
||||
ProcessField* fields = pl->fields;
|
||||
for (int i = 0; fields[i]; i++) {
|
||||
char* name = String_trim(Process_printField(fields[i]));
|
||||
ListBox_add(lbf, (Object*) ListItem_new(name, fields[i]));
|
||||
Panel_add(lbf, (Object*) ListItem_new(name, fields[i]));
|
||||
if (fields[i] == pl->sortKey)
|
||||
ListBox_setSelected(lbf, i);
|
||||
Panel_setSelected(lbf, i);
|
||||
free(name);
|
||||
}
|
||||
ListItem* field = (ListItem*) pickFromList(lb, lbf, 15, headerHeight, fuFunctions, defaultBar);
|
||||
|
@ -590,7 +590,7 @@ int main(int argc, char** argv) {
|
|||
pl->sortKey = field->key;
|
||||
}
|
||||
((Object*)lbf)->delete((Object*)lbf);
|
||||
ListBox_setRichHeader(lb, ProcessList_printHeader(pl));
|
||||
Panel_setRichHeader(lb, ProcessList_printHeader(pl));
|
||||
refreshTimeout = 0;
|
||||
break;
|
||||
}
|
||||
|
@ -641,7 +641,7 @@ int main(int argc, char** argv) {
|
|||
default:
|
||||
doRefresh = false;
|
||||
refreshTimeout = resetRefreshTimeout;
|
||||
ListBox_onKey(lb, ch);
|
||||
Panel_onKey(lb, ch);
|
||||
break;
|
||||
}
|
||||
follow = false;
|
||||
|
|
6
htop.h
6
htop.h
|
@ -11,7 +11,7 @@ in the source distribution for its full text.
|
|||
|
||||
#include "ProcessList.h"
|
||||
#include "CRT.h"
|
||||
#include "ListBox.h"
|
||||
#include "Panel.h"
|
||||
#include "UsersTable.h"
|
||||
#include "SignalItem.h"
|
||||
#include "RichString.h"
|
||||
|
@ -19,8 +19,8 @@ in the source distribution for its full text.
|
|||
#include "ScreenManager.h"
|
||||
#include "FunctionBar.h"
|
||||
#include "ListItem.h"
|
||||
#include "CategoriesListBox.h"
|
||||
#include "SignalsListBox.h"
|
||||
#include "CategoriesPanel.h"
|
||||
#include "SignalsPanel.h"
|
||||
|
||||
#include "config.h"
|
||||
#include "debug.h"
|
||||
|
|
Loading…
Reference in New Issue