aboutsummaryrefslogtreecommitdiffstats
path: root/htop.c
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2016-04-11 13:01:17 +0200
committerDaniel Lange <DLange@git.local>2016-04-11 13:01:17 +0200
commit8c82a38002ce09db2a0b83dab8b598cf1ab0596c (patch)
tree596b13ab61b4454e347ff476a84c14c2c9dc3441 /htop.c
parentff9409b1737627857eb47f64f536a3f66b6a09a4 (diff)
downloaddebian_htop-8c82a38002ce09db2a0b83dab8b598cf1ab0596c.tar.gz
debian_htop-8c82a38002ce09db2a0b83dab8b598cf1ab0596c.tar.bz2
debian_htop-8c82a38002ce09db2a0b83dab8b598cf1ab0596c.zip
Imported Upstream version 2.0.1upstream/2.0.1
Diffstat (limited to 'htop.c')
-rw-r--r--htop.c196
1 files changed, 2 insertions, 194 deletions
diff --git a/htop.c b/htop.c
index 9e82a12..239b5d6 100644
--- a/htop.c
+++ b/htop.c
@@ -176,7 +176,8 @@ int main(int argc, char** argv) {
#ifdef HAVE_PROC
if (access(PROCDIR, R_OK) != 0) {
- fprintf("Error: could not read procfs (compiled to look in %s).\n", PROCDIR);
+ fprintf(stderr, "Error: could not read procfs (compiled to look in %s).\n", PROCDIR);
+ exit(1);
}
#endif
@@ -229,194 +230,6 @@ int main(int argc, char** argv) {
ScreenManager_run(scr, NULL, NULL);
- /*
- FunctionBar_draw(defaultBar, NULL);
-
- int acc = 0;
- bool follow = false;
-
- struct timeval tv;
- double oldTime = 0.0;
-
- int ch = ERR;
- int closeTimeout = 0;
-
- bool drawPanel = true;
-
- bool collapsed = false;
-
- Htop_Action keys[KEY_MAX] = { NULL };
- setBindings(keys);
- Platform_setBindings(keys);
-
- bool quit = false;
- int sortTimeout = 0;
- int resetSortTimeout = 5;
- bool doRefresh = true;
- bool forceRecalculate = false;
-
- while (!quit) {
- gettimeofday(&tv, NULL);
- double newTime = ((double)tv.tv_sec * 10) + ((double)tv.tv_usec / 100000);
- bool timeToRecalculate = (newTime - oldTime > settings->delay);
- if (newTime < oldTime) timeToRecalculate = true; // clock was adjusted?
- int following = follow ? MainPanel_selectedPid((MainPanel*)panel) : -1;
- if (timeToRecalculate) {
- Header_draw(header);
- oldTime = newTime;
- }
- if (doRefresh) {
- if (timeToRecalculate || forceRecalculate) {
- ProcessList_scan(pl);
- forceRecalculate = false;
- }
- if (sortTimeout == 0 || settings->treeView) {
- ProcessList_sort(pl);
- sortTimeout = 1;
- }
- ProcessList_rebuildPanel(pl, true, following, IncSet_filter(inc));
- drawPanel = true;
- }
- doRefresh = true;
-
- if (settings->treeView) {
- Process* p = (Process*) Panel_getSelected(panel);
- if (p) {
- if (!p->showChildren && !collapsed) {
- FunctionBar_setLabel(defaultBar, KEY_F(6), "Expand");
- FunctionBar_draw(defaultBar, NULL);
- } else if (p->showChildren && collapsed) {
- FunctionBar_setLabel(defaultBar, KEY_F(6), "Collap");
- FunctionBar_draw(defaultBar, NULL);
- }
- collapsed = !p->showChildren;
- }
- } else {
- collapsed = false;
- }
-
- if (drawPanel) {
- Panel_draw(panel, true);
- }
-
- int prev = ch;
- if (inc->active)
- move(LINES-1, CRT_cursorX);
- ch = getch();
-
- if (ch == ERR) {
- if (!inc->active)
- sortTimeout--;
- if (prev == ch && !timeToRecalculate) {
- closeTimeout++;
- if (closeTimeout == 100) {
- break;
- }
- } else
- closeTimeout = 0;
- drawPanel = false;
- continue;
- }
- drawPanel = true;
-
- Htop_Reaction reaction = HTOP_OK;
-
- if (ch == KEY_MOUSE) {
- MEVENT mevent;
- int ok = getmouse(&mevent);
- if (ok == OK) {
- if (mevent.bstate & BUTTON1_CLICKED) {
- if (mevent.y == panel->y) {
- int x = panel->scrollH + mevent.x + 1;
- ProcessField field = ProcessList_keyAt(pl, x);
- if (field == settings->sortKey) {
- Settings_invertSortOrder(settings);
- settings->treeView = false;
- reaction |= HTOP_REDRAW_BAR;
- } else {
- reaction |= setSortKey(settings, field);
- }
- sortTimeout = 0;
- ch = ERR;
- } else if (mevent.y >= panel->y + 1 && mevent.y < LINES - 1) {
- Panel_setSelected(panel, mevent.y - panel->y + panel->scrollV - 1);
- follow = true;
- ch = ERR;
- } if (mevent.y == LINES - 1) {
- ch = FunctionBar_synthesizeEvent(inc->bar, mevent.x);
- }
- } else if (mevent.bstate & BUTTON4_CLICKED) {
- ch = KEY_UP;
- #if NCURSES_MOUSE_VERSION > 1
- } else if (mevent.bstate & BUTTON5_CLICKED) {
- ch = KEY_DOWN;
- #endif
- }
- }
- }
-
- if (inc->active) {
- doRefresh = IncSet_handleKey(inc, ch, panel, getMainPanelValue, NULL);
- if (!inc->active) {
- follow = true;
- }
- continue;
- }
-
- if (ch < 255 && isdigit((char)ch)) {
- if (Panel_size(panel) == 0) continue;
- pid_t pid = ch-48 + acc;
- for (int i = 0; i < ProcessList_size(pl); i++) {
- Panel_setSelected(panel, i);
- Process* p = (Process*) Panel_getSelected(panel);
- if (p && p->pid == pid) {
- break;
- }
- }
- acc = pid * 10;
- if (acc > 10000000)
- acc = 0;
- continue;
- } else {
- acc = 0;
- }
-
- if(ch != ERR && keys[ch]) {
- reaction |= (keys[ch])(&state);
- } else {
- doRefresh = false;
- sortTimeout = resetSortTimeout;
- Panel_onKey(panel, ch);
- }
-
- // Reaction handlers:
-
- if (reaction & HTOP_REDRAW_BAR) {
- updateTreeFunctions(defaultBar, settings->treeView);
- IncSet_drawBar(inc);
- }
- if (reaction & HTOP_UPDATE_PANELHDR) {
- ProcessList_printHeader(pl, Panel_getHeader(panel));
- }
- if (reaction & HTOP_REFRESH) {
- doRefresh = true;
- sortTimeout = 0;
- }
- if (reaction & HTOP_RECALCULATE) {
- forceRecalculate = true;
- sortTimeout = 0;
- }
- if (reaction & HTOP_SAVE_SETTINGS) {
- settings->changed = true;
- }
- if (reaction & HTOP_QUIT) {
- quit = true;
- }
- follow = (reaction & HTOP_KEEP_FOLLOWING);
- }
-
- */
-
attron(CRT_colors[RESET_COLOR]);
mvhline(LINES-1, 0, ' ', COLS);
attroff(CRT_colors[RESET_COLOR]);
@@ -428,11 +241,6 @@ int main(int argc, char** argv) {
Header_delete(header);
ProcessList_delete(pl);
- /*
- FunctionBar_delete((Object*)defaultBar);
- Panel_delete((Object*)panel);
- */
-
ScreenManager_delete(scr);
UsersTable_delete(ut);

© 2014-2024 Faster IT GmbH | imprint | privacy policy