Embracing branches

This commit is contained in:
Benny Baumann
2020-11-01 01:09:51 +01:00
parent 61e14d4bb2
commit 45869513bf
46 changed files with 656 additions and 277 deletions

View File

@ -103,8 +103,12 @@ static void checkRecalculation(ScreenManager* this, double* oldTime, int* sortTi
gettimeofday(&tv, NULL);
double newTime = ((double)tv.tv_sec * 10) + ((double)tv.tv_usec / 100000);
*timedOut = (newTime - *oldTime > this->settings->delay);
*rescan = *rescan || *timedOut;
if (newTime < *oldTime) *rescan = true; // clock was adjusted?
*rescan |= *timedOut;
if (newTime < *oldTime) {
*rescan = true; // clock was adjusted?
}
if (*rescan) {
*oldTime = newTime;
ProcessList_scan(pl, this->state->pauseProcessUpdate);
@ -134,8 +138,9 @@ static void ScreenManager_drawPanels(ScreenManager* this, int focus) {
static Panel* setCurrentPanel(const ScreenManager* this, Panel* panel) {
FunctionBar_draw(panel->currentBar);
if (panel == this->state->panel && this->state->pauseProcessUpdate)
if (panel == this->state->panel && this->state->pauseProcessUpdate) {
FunctionBar_append("PAUSED", CRT_colors[PAUSED]);
}
return panel;
}
@ -218,8 +223,9 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
if (closeTimeout == 100) {
break;
}
} else
} else {
closeTimeout = 0;
}
redraw = false;
continue;
}
@ -261,14 +267,21 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
if (this->panelCount < 2) {
goto defaultHandler;
}
if (!this->allowFocusChange)
if (!this->allowFocusChange) {
break;
tryLeft:
if (focus > 0)
}
tryLeft:
if (focus > 0) {
focus--;
}
panelFocus = setCurrentPanel(this, (Panel*) Vector_get(this->panels, focus));
if (Panel_size(panelFocus) == 0 && focus > 0)
if (Panel_size(panelFocus) == 0 && focus > 0) {
goto tryLeft;
}
break;
case KEY_RIGHT:
case KEY_CTRL('F'):
@ -276,14 +289,20 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
if (this->panelCount < 2) {
goto defaultHandler;
}
if (!this->allowFocusChange)
if (!this->allowFocusChange) {
break;
tryRight:
if (focus < this->panelCount - 1)
}
tryRight:
if (focus < this->panelCount - 1) {
focus++;
}
panelFocus = setCurrentPanel(this, (Panel*) Vector_get(this->panels, focus));
if (Panel_size(panelFocus) == 0 && focus < this->panelCount - 1)
if (Panel_size(panelFocus) == 0 && focus < this->panelCount - 1) {
goto tryRight;
}
break;
case KEY_F(10):
case 'q':
@ -291,15 +310,18 @@ void ScreenManager_run(ScreenManager* this, Panel** lastFocus, int* lastKey) {
quit = true;
continue;
default:
defaultHandler:
defaultHandler:
sortTimeout = resetSortTimeout;
Panel_onKey(panelFocus, ch);
break;
}
}
if (lastFocus)
if (lastFocus) {
*lastFocus = panelFocus;
if (lastKey)
}
if (lastKey) {
*lastKey = ch;
}
}