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.
#define DEFAULT_DELAY 15
#include "ProcessList.h"
#include "Header.h"
#include "Process.h"
#include <stdbool.h>
typedef struct {
int len;
char** names;
int* modes;
} MeterColumnSettings;
typedef struct Settings_ {
char* userSettings;
ProcessList* pl;
Header* header;
char* filename;
MeterColumnSettings columns[2];
ProcessField* fields;
int flags;
int colorScheme;
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;
} Settings;
#ifndef Settings_cpuId
#define Settings_cpuId(settings, cpu) ((settings)->countCPUsFromZero ? (cpu) : (cpu)+1)
#endif
void Settings_delete(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
......@@ -8,7 +8,7 @@ in the source distribution for its full text.
#include "SwapMeter.h"
#include "CRT.h"
#include "ProcessList.h"
#include "Platform.h"
#include <stdlib.h>
#include <string.h>
......@@ -34,11 +34,8 @@ static void SwapMeter_humanNumber(char* buffer, const long int* value) {
}
static void SwapMeter_setValues(Meter* this, char* buffer, int len) {
long int usedSwap = this->pl->usedSwap;
this->total = this->pl->totalSwap;
this->values[0] = usedSwap;
snprintf(buffer, len, "%ld/%ldMB", (long int) usedSwap / MEGABYTE, (long int) this->total / MEGABYTE);
Platform_setSwapValues(this);
snprintf(buffer, len, "%ld/%ldMB", (long int) this->values[0] / MEGABYTE, (long int) this->total / MEGABYTE);
}
static void SwapMeter_display(Object* cast, RichString* out) {
......
......@@ -7,7 +7,7 @@ in the source distribution for its full text.
#include "TasksMeter.h"
#include "ProcessList.h"
#include "Platform.h"
#include "CRT.h"
/*{
......@@ -15,42 +15,46 @@ in the source distribution for its full text.
}*/
int TasksMeter_attributes[] = {
TASKS_RUNNING
CPU_KERNEL, PROCESS_THREAD, PROCESS, TASKS_RUNNING
};
static void TasksMeter_setValues(Meter* this, char* buffer, int len) {
ProcessList* pl = this->pl;
this->total = pl->totalTasks;
this->values[0] = pl->runningTasks;
snprintf(buffer, len, "%d/%d", (int) this->values[0], (int) this->total);
Platform_setTasksValues(this);
if (this->pl->settings->hideKernelThreads) {
this->values[0] = 0;
}
snprintf(buffer, len, "%d/%d", (int) this->values[3], (int) this->total);
}
static void TasksMeter_display(Object* cast, RichString* out) {
Meter* this = (Meter*)cast;
ProcessList* pl = this->pl;
Settings* settings = this->pl->settings;
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);
int threadValueColor = CRT_colors[METER_VALUE];
int threadCaptionColor = CRT_colors[METER_TEXT];
if (pl->highlightThreads) {
if (settings->highlightThreads) {
threadValueColor = CRT_colors[PROCESS_THREAD_BASENAME];
threadCaptionColor = CRT_colors[PROCESS_THREAD];
}
if (!pl->hideUserlandThreads) {
if (!settings->hideUserlandThreads) {
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, threadCaptionColor, " thr");
}
if (!pl->hideKernelThreads) {
if (!settings->hideKernelThreads) {
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, threadCaptionColor, " kthr");
}
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[METER_TEXT], " running");
}
......@@ -64,6 +68,7 @@ MeterClass TasksMeter_class = {
.setValues = TasksMeter_setValues,
.defaultMode = TEXT_METERMODE,
.total = 100.0,
.maxItems = 4,
.attributes = TasksMeter_attributes,
.name = "Tasks",
.uiName = "Task counter",
......
......@@ -192,6 +192,10 @@ void Vector_insert(Vector* this, int idx, void* data_) {
assert(idx <= this->items);
assert(Object_isA(data, this->type));
assert(Vector_isConsistent(this));
if (idx > this->items) {
idx = this->items;
}
Vector_checkArraySize(this);
//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.
//#link m
#define COPYRIGHT "(C) 2004-2014 Hisham Muhammad"
// ----------------------------------------
// ----------------------------------------
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