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",
......
......@@ -193,6 +193,10 @@ void Vector_insert(Vector* this, int idx, void* data_) {
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);
for (int i = this->items; i > idx; i--) {
......
......@@ -4,6 +4,8 @@
AC_PREREQ(2.65)
AC_INIT([htop],[1.0.3],[hisham@gobolinux.org])
year=$(date +%Y)
# The following two lines are required by hwloc scripts
AC_USE_SYSTEM_EXTENSIONS
AC_CANONICAL_TARGET
......@@ -71,6 +73,19 @@ AC_TRY_COMPILE(AC_INCLUDES_DEFAULT, [char *a; a = strdup("foo"); int i = 0; i++;
AC_MSG_ERROR([htop is written in C99. A newer version of gcc is required.]))
CFLAGS="$save_cflags"
save_cflags="${CFLAGS}"
CFLAGS="$CFLAGS -Wextra"
AC_MSG_CHECKING([if compiler supports -Wextra])
AC_TRY_COMPILE([], [], [
wextra_flag=-Wextra
AC_MSG_RESULT([yes])
],[
wextra_flag=
AC_MSG_RESULT([no])
])
CFLAGS="$save_cflags"
AC_SUBST(wextra_flag)
# Checks for features and flags.
# ----------------------------------------------------------------------
PROCDIR=/proc
......@@ -187,6 +202,8 @@ if test ! -z "$missing_headers"; then
AC_MSG_ERROR([missing headers: $missing_headers])
fi
AC_DEFINE_UNQUOTED(COPYRIGHT, "(C) 2004-$year Hisham Muhammad", [Copyright message.])
# We're done, let's go!
# ----------------------------------------------------------------------
AM_CONDITIONAL([HTOP_LINUX], [test "$my_htop_platform" = linux])
......
......@@ -319,13 +319,13 @@ Bytes of write(2) I/O for the process.
.B CNCLWB (IO_CANCEL)
Bytes of cancelled write(2) I/O.
.TP
.B IO_READ_RATE (IORR)
.B IO_READ_RATE (DISK READ)
The I/O rate of read(2) in bytes per second, for the process.
.TP
.B IO_WRITE_RATE (IOWR)
.B IO_WRITE_RATE (DISK WRITE)
The I/O rate of write(2) in bytes per second, for the process.
.TP
.B IO_RATE (IORW)
.B IO_RATE (DISK R/W)
The I/O rate, IO_READ_RATE + IO_WRITE_RATE (see above).
.TP
.B CGROUP
......
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