Commit d2acffa5 authored by Hisham Muhammad's avatar Hisham Muhammad
Browse files

Merge branch 'wip' of https://github.com/hishamhm/htop into freebsd

Conflicts:
	htop.c
	unsupported/Platform.h
parents c29e53c5 50000d80
This diff is collapsed.
...@@ -11,24 +11,57 @@ in the source distribution for its full text. ...@@ -11,24 +11,57 @@ in the source distribution for its full text.
#define DEFAULT_DELAY 15 #define DEFAULT_DELAY 15
#include "ProcessList.h" #include "Process.h"
#include "Header.h"
#include <stdbool.h> #include <stdbool.h>
typedef struct {
int len;
char** names;
int* modes;
} MeterColumnSettings;
typedef struct Settings_ { typedef struct Settings_ {
char* userSettings; char* filename;
ProcessList* pl;
Header* header; MeterColumnSettings columns[2];
ProcessField* fields;
int flags;
int colorScheme; int colorScheme;
int delay; int delay;
int direction;
ProcessField sortKey;
bool countCPUsFromZero;
bool detailedCPUTime;
bool treeView;
bool hideThreads;
bool shadowOtherUsers;
bool showThreadNames;
bool hideKernelThreads;
bool hideUserlandThreads;
bool highlightBaseName;
bool highlightMegabytes;
bool highlightThreads;
bool updateProcessNames;
bool accountGuestInCPUMeter;
bool headerMargin;
bool changed; bool changed;
} Settings; } Settings;
#ifndef Settings_cpuId
#define Settings_cpuId(settings, cpu) ((settings)->countCPUsFromZero ? (cpu) : (cpu)+1)
#endif
void Settings_delete(Settings* this); void Settings_delete(Settings* this);
bool Settings_write(Settings* this); bool Settings_write(Settings* this);
Settings* Settings_new(ProcessList* pl, Header* header, int cpuCount); Settings* Settings_new(int cpuCount);
void Settings_invertSortOrder(Settings* this);
#endif #endif
...@@ -8,7 +8,7 @@ in the source distribution for its full text. ...@@ -8,7 +8,7 @@ in the source distribution for its full text.
#include "SwapMeter.h" #include "SwapMeter.h"
#include "CRT.h" #include "CRT.h"
#include "ProcessList.h" #include "Platform.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
...@@ -34,11 +34,8 @@ static void SwapMeter_humanNumber(char* buffer, const long int* value) { ...@@ -34,11 +34,8 @@ static void SwapMeter_humanNumber(char* buffer, const long int* value) {
} }
static void SwapMeter_setValues(Meter* this, char* buffer, int len) { static void SwapMeter_setValues(Meter* this, char* buffer, int len) {
long int usedSwap = this->pl->usedSwap; Platform_setSwapValues(this);
this->total = this->pl->totalSwap; snprintf(buffer, len, "%ld/%ldMB", (long int) this->values[0] / MEGABYTE, (long int) this->total / MEGABYTE);
this->values[0] = usedSwap;
snprintf(buffer, len, "%ld/%ldMB", (long int) usedSwap / MEGABYTE, (long int) this->total / MEGABYTE);
} }
static void SwapMeter_display(Object* cast, RichString* out) { static void SwapMeter_display(Object* cast, RichString* out) {
......
...@@ -7,7 +7,7 @@ in the source distribution for its full text. ...@@ -7,7 +7,7 @@ in the source distribution for its full text.
#include "TasksMeter.h" #include "TasksMeter.h"
#include "ProcessList.h" #include "Platform.h"
#include "CRT.h" #include "CRT.h"
/*{ /*{
...@@ -15,42 +15,46 @@ in the source distribution for its full text. ...@@ -15,42 +15,46 @@ in the source distribution for its full text.
}*/ }*/
int TasksMeter_attributes[] = { int TasksMeter_attributes[] = {
TASKS_RUNNING CPU_KERNEL, PROCESS_THREAD, PROCESS, TASKS_RUNNING
}; };
static void TasksMeter_setValues(Meter* this, char* buffer, int len) { static void TasksMeter_setValues(Meter* this, char* buffer, int len) {
ProcessList* pl = this->pl; Platform_setTasksValues(this);
this->total = pl->totalTasks; if (this->pl->settings->hideKernelThreads) {
this->values[0] = pl->runningTasks; this->values[0] = 0;
snprintf(buffer, len, "%d/%d", (int) this->values[0], (int) this->total); }
snprintf(buffer, len, "%d/%d", (int) this->values[3], (int) this->total);
} }
static void TasksMeter_display(Object* cast, RichString* out) { static void TasksMeter_display(Object* cast, RichString* out) {
Meter* this = (Meter*)cast; Meter* this = (Meter*)cast;
ProcessList* pl = this->pl; Settings* settings = this->pl->settings;
char buffer[20]; char buffer[20];
sprintf(buffer, "%d", (int)(this->total - pl->userlandThreads - pl->kernelThreads));
int processes = (int) this->values[2];
sprintf(buffer, "%d", processes);
RichString_write(out, CRT_colors[METER_VALUE], buffer); RichString_write(out, CRT_colors[METER_VALUE], buffer);
int threadValueColor = CRT_colors[METER_VALUE]; int threadValueColor = CRT_colors[METER_VALUE];
int threadCaptionColor = CRT_colors[METER_TEXT]; int threadCaptionColor = CRT_colors[METER_TEXT];
if (pl->highlightThreads) { if (settings->highlightThreads) {
threadValueColor = CRT_colors[PROCESS_THREAD_BASENAME]; threadValueColor = CRT_colors[PROCESS_THREAD_BASENAME];
threadCaptionColor = CRT_colors[PROCESS_THREAD]; threadCaptionColor = CRT_colors[PROCESS_THREAD];
} }
if (!pl->hideUserlandThreads) { if (!settings->hideUserlandThreads) {
RichString_append(out, CRT_colors[METER_TEXT], ", "); RichString_append(out, CRT_colors[METER_TEXT], ", ");
sprintf(buffer, "%d", (int)pl->userlandThreads); sprintf(buffer, "%d", (int)this->values[1]);
RichString_append(out, threadValueColor, buffer); RichString_append(out, threadValueColor, buffer);
RichString_append(out, threadCaptionColor, " thr"); RichString_append(out, threadCaptionColor, " thr");
} }
if (!pl->hideKernelThreads) { if (!settings->hideKernelThreads) {
RichString_append(out, CRT_colors[METER_TEXT], ", "); RichString_append(out, CRT_colors[METER_TEXT], ", ");
sprintf(buffer, "%d", (int)pl->kernelThreads); sprintf(buffer, "%d", (int)this->values[0]);
RichString_append(out, threadValueColor, buffer); RichString_append(out, threadValueColor, buffer);
RichString_append(out, threadCaptionColor, " kthr"); RichString_append(out, threadCaptionColor, " kthr");
} }
RichString_append(out, CRT_colors[METER_TEXT], "; "); RichString_append(out, CRT_colors[METER_TEXT], "; ");
sprintf(buffer, "%d", (int)this->values[0]); sprintf(buffer, "%d", (int)this->values[3]);
RichString_append(out, CRT_colors[TASKS_RUNNING], buffer); RichString_append(out, CRT_colors[TASKS_RUNNING], buffer);
RichString_append(out, CRT_colors[METER_TEXT], " running"); RichString_append(out, CRT_colors[METER_TEXT], " running");
} }
...@@ -64,6 +68,7 @@ MeterClass TasksMeter_class = { ...@@ -64,6 +68,7 @@ MeterClass TasksMeter_class = {
.setValues = TasksMeter_setValues, .setValues = TasksMeter_setValues,
.defaultMode = TEXT_METERMODE, .defaultMode = TEXT_METERMODE,
.total = 100.0, .total = 100.0,
.maxItems = 4,
.attributes = TasksMeter_attributes, .attributes = TasksMeter_attributes,
.name = "Tasks", .name = "Tasks",
.uiName = "Task counter", .uiName = "Task counter",
......
...@@ -192,6 +192,10 @@ void Vector_insert(Vector* this, int idx, void* data_) { ...@@ -192,6 +192,10 @@ void Vector_insert(Vector* this, int idx, void* data_) {
assert(idx <= this->items); assert(idx <= this->items);
assert(Object_isA(data, this->type)); assert(Object_isA(data, this->type));
assert(Vector_isConsistent(this)); assert(Vector_isConsistent(this));
if (idx > this->items) {
idx = this->items;
}
Vector_checkArraySize(this); Vector_checkArraySize(this);
//assert(this->array[this->items] == NULL); //assert(this->array[this->items] == NULL);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -11,11 +11,8 @@ in the source distribution for its full text. ...@@ -11,11 +11,8 @@ in the source distribution for its full text.
//#link m //#link m
#define COPYRIGHT "(C) 2004-2014 Hisham Muhammad"
// ---------------------------------------- // ----------------------------------------
// ----------------------------------------
int main(int argc, char** argv); int main(int argc, char** argv);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment