2006-04-10 20:40:38 +00:00
|
|
|
/* Do not edit this file. It was automatically generated. */
|
2006-03-04 18:16:49 +00:00
|
|
|
|
|
|
|
#ifndef HEADER_Meter
|
|
|
|
#define HEADER_Meter
|
|
|
|
/*
|
2006-04-10 20:40:38 +00:00
|
|
|
htop - Meter.c
|
2006-03-04 18:16:49 +00:00
|
|
|
(C) 2004-2006 Hisham H. Muhammad
|
|
|
|
Released under the GNU GPL, see the COPYING file
|
|
|
|
in the source distribution for its full text.
|
|
|
|
*/
|
|
|
|
|
2006-04-10 20:40:38 +00:00
|
|
|
#define _GNU_SOURCE
|
|
|
|
#include <math.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <curses.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
2006-03-04 18:16:49 +00:00
|
|
|
#include "Object.h"
|
|
|
|
#include "CRT.h"
|
|
|
|
#include "ListItem.h"
|
|
|
|
#include "String.h"
|
2006-04-10 20:40:38 +00:00
|
|
|
#include "ProcessList.h"
|
2006-03-04 18:16:49 +00:00
|
|
|
|
|
|
|
#include "debug.h"
|
|
|
|
#include <assert.h>
|
|
|
|
|
2006-04-10 20:40:38 +00:00
|
|
|
#ifndef USE_FUNKY_MODES
|
|
|
|
#define USE_FUNKY_MODES 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define METER_BUFFER_LEN 128
|
2006-03-04 18:16:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
typedef struct Meter_ Meter;
|
2006-04-10 20:40:38 +00:00
|
|
|
typedef struct MeterType_ MeterType;
|
|
|
|
typedef struct MeterMode_ MeterMode;
|
2006-03-04 18:16:49 +00:00
|
|
|
|
2006-04-10 20:40:38 +00:00
|
|
|
typedef void(*MeterType_Init)(Meter*);
|
|
|
|
typedef void(*MeterType_Done)(Meter*);
|
2006-05-09 18:35:51 +00:00
|
|
|
typedef void(*MeterType_SetMode)(Meter*, int);
|
2006-04-10 20:40:38 +00:00
|
|
|
typedef void(*Meter_SetValues)(Meter*, char*, int);
|
2006-03-04 18:16:49 +00:00
|
|
|
typedef void(*Meter_Draw)(Meter*, int, int, int);
|
|
|
|
|
2006-04-10 20:40:38 +00:00
|
|
|
struct MeterMode_ {
|
2006-03-04 18:16:49 +00:00
|
|
|
Meter_Draw draw;
|
2006-04-10 20:40:38 +00:00
|
|
|
char* uiName;
|
|
|
|
int h;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct MeterType_ {
|
2006-03-04 18:16:49 +00:00
|
|
|
Meter_SetValues setValues;
|
2006-04-10 20:40:38 +00:00
|
|
|
Object_Display display;
|
|
|
|
int mode;
|
2006-03-04 18:16:49 +00:00
|
|
|
int items;
|
2006-04-10 20:40:38 +00:00
|
|
|
double total;
|
2006-03-04 18:16:49 +00:00
|
|
|
int* attributes;
|
2006-04-10 20:40:38 +00:00
|
|
|
char* name;
|
|
|
|
char* uiName;
|
|
|
|
char* caption;
|
|
|
|
MeterType_Init init;
|
|
|
|
MeterType_Done done;
|
2006-05-09 18:35:51 +00:00
|
|
|
MeterType_SetMode setMode;
|
2006-04-10 20:40:38 +00:00
|
|
|
Meter_Draw draw;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Meter_ {
|
|
|
|
Object super;
|
|
|
|
char* caption;
|
|
|
|
MeterType* type;
|
|
|
|
int mode;
|
|
|
|
int param;
|
|
|
|
Meter_Draw draw;
|
|
|
|
void* drawBuffer;
|
|
|
|
int h;
|
|
|
|
ProcessList* pl;
|
2006-03-04 18:16:49 +00:00
|
|
|
double* values;
|
|
|
|
double total;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern char* METER_CLASS;
|
|
|
|
|
2006-04-10 20:40:38 +00:00
|
|
|
extern MeterType CPUMeter;
|
|
|
|
extern MeterType ClockMeter;
|
|
|
|
extern MeterType LoadAverageMeter;
|
|
|
|
extern MeterType LoadMeter;
|
|
|
|
extern MeterType MemoryMeter;
|
|
|
|
extern MeterType SwapMeter;
|
|
|
|
extern MeterType TasksMeter;
|
|
|
|
extern MeterType UptimeMeter;
|
|
|
|
extern MeterType AllCPUsMeter;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
CUSTOM_METERMODE = 0,
|
|
|
|
BAR_METERMODE,
|
|
|
|
TEXT_METERMODE,
|
|
|
|
#ifdef USE_FUNKY_MODES
|
|
|
|
GRAPH_METERMODE,
|
|
|
|
LED_METERMODE,
|
|
|
|
#endif
|
|
|
|
LAST_METERMODE
|
|
|
|
} MeterModeId;
|
2006-03-04 18:16:49 +00:00
|
|
|
|
2006-05-09 18:35:51 +00:00
|
|
|
extern MeterType* Meter_types[];
|
2006-04-10 20:40:38 +00:00
|
|
|
extern MeterMode* Meter_modes[];
|
2006-03-04 18:16:49 +00:00
|
|
|
|
|
|
|
|
2006-04-10 20:40:38 +00:00
|
|
|
#ifndef MIN
|
|
|
|
#define MIN(a,b) ((a)<(b)?(a):(b))
|
|
|
|
#endif
|
|
|
|
#ifndef MAX
|
|
|
|
#define MAX(a,b) ((a)>(b)?(a):(b))
|
|
|
|
#endif
|
|
|
|
|
2006-03-04 18:16:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-04-10 20:40:38 +00:00
|
|
|
#ifdef USE_FUNKY_MODES
|
2006-03-04 18:16:49 +00:00
|
|
|
|
2006-04-10 20:40:38 +00:00
|
|
|
#endif
|
2006-03-04 18:16:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2006-04-10 20:40:38 +00:00
|
|
|
Meter* Meter_new(ProcessList* pl, int param, MeterType* type);
|
2006-03-04 18:16:49 +00:00
|
|
|
|
2006-04-10 20:40:38 +00:00
|
|
|
void Meter_delete(Object* cast);
|
2006-03-04 18:16:49 +00:00
|
|
|
|
2006-04-10 20:40:38 +00:00
|
|
|
void Meter_setCaption(Meter* this, char* caption);
|
2006-03-04 18:16:49 +00:00
|
|
|
|
|
|
|
|
2006-04-10 20:40:38 +00:00
|
|
|
void Meter_setMode(Meter* this, int modeIndex);
|
2006-03-04 18:16:49 +00:00
|
|
|
|
|
|
|
ListItem* Meter_toListItem(Meter* this);
|
|
|
|
|
2006-04-10 20:40:38 +00:00
|
|
|
/* ---------- TextMeterMode ---------- */
|
|
|
|
|
|
|
|
void TextMeterMode_draw(Meter* this, int x, int y, int w);
|
|
|
|
|
|
|
|
/* ---------- BarMeterMode ---------- */
|
|
|
|
|
|
|
|
|
|
|
|
void BarMeterMode_draw(Meter* this, int x, int y, int w);
|
|
|
|
|
|
|
|
#ifdef USE_FUNKY_MODES
|
|
|
|
|
|
|
|
/* ---------- GraphMeterMode ---------- */
|
|
|
|
|
|
|
|
#define DrawDot(a,y,c) do { attrset(a); mvaddch(y, x+k, c); } while(0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void GraphMeterMode_draw(Meter* this, int x, int y, int w);
|
|
|
|
|
|
|
|
/* ---------- LEDMeterMode ---------- */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void LEDMeterMode_draw(Meter* this, int x, int y, int w);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2006-03-04 18:16:49 +00:00
|
|
|
#endif
|