mirror of https://github.com/xzeldon/htop.git
Some visual code cleanup
This commit is contained in:
parent
5fe2a88c08
commit
9adb94a379
16
Panel.c
16
Panel.c
|
@ -355,39 +355,45 @@ bool Panel_onKey(Panel* this, int key) {
|
||||||
this->needsRedraw = true;
|
this->needsRedraw = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KEY_RIGHT:
|
case KEY_RIGHT:
|
||||||
case KEY_CTRL('F'):
|
case KEY_CTRL('F'):
|
||||||
this->scrollH += CRT_scrollHAmount;
|
this->scrollH += CRT_scrollHAmount;
|
||||||
this->needsRedraw = true;
|
this->needsRedraw = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KEY_PPAGE:
|
case KEY_PPAGE:
|
||||||
this->selected -= (this->h - 1);
|
this->selected -= (this->h - 1);
|
||||||
this->scrollV = CLAMP_INDEX(this->scrollV, -(this->h - 1), 0, size - this->h);
|
this->scrollV = CLAMP_INDEX(this->scrollV, -(this->h - 1), 0, size - this->h);
|
||||||
this->needsRedraw = true;
|
this->needsRedraw = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KEY_NPAGE:
|
case KEY_NPAGE:
|
||||||
this->selected += (this->h - 1);
|
this->selected += (this->h - 1);
|
||||||
this->scrollV = CLAMP_INDEX(this->scrollV, +(this->h - 1), 0, size - this->h);
|
this->scrollV = CLAMP_INDEX(this->scrollV, +(this->h - 1), 0, size - this->h);
|
||||||
this->needsRedraw = true;
|
this->needsRedraw = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KEY_WHEELUP:
|
case KEY_WHEELUP:
|
||||||
this->selected -= CRT_scrollWheelVAmount;
|
this->selected -= CRT_scrollWheelVAmount;
|
||||||
this->scrollV = CLAMP_INDEX(this->scrollV, -CRT_scrollWheelVAmount, 0, size - this->h);
|
this->scrollV = CLAMP_INDEX(this->scrollV, -CRT_scrollWheelVAmount, 0, size - this->h);
|
||||||
this->needsRedraw = true;
|
this->needsRedraw = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KEY_WHEELDOWN:
|
case KEY_WHEELDOWN:
|
||||||
{
|
|
||||||
this->selected += CRT_scrollWheelVAmount;
|
this->selected += CRT_scrollWheelVAmount;
|
||||||
this->scrollV = CLAMP_INDEX(this->scrollV, +CRT_scrollWheelVAmount, 0, size - this->h);
|
this->scrollV = CLAMP_INDEX(this->scrollV, +CRT_scrollWheelVAmount, 0, size - this->h);
|
||||||
this->needsRedraw = true;
|
this->needsRedraw = true;
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case KEY_HOME:
|
case KEY_HOME:
|
||||||
this->selected = 0;
|
this->selected = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KEY_END:
|
case KEY_END:
|
||||||
this->selected = size - 1;
|
this->selected = size - 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KEY_CTRL('A'):
|
case KEY_CTRL('A'):
|
||||||
case '^':
|
case '^':
|
||||||
this->scrollH = 0;
|
this->scrollH = 0;
|
||||||
|
@ -412,12 +418,14 @@ bool Panel_onKey(Panel* this, int key) {
|
||||||
this->selected = size - 1;
|
this->selected = size - 1;
|
||||||
this->needsRedraw = true;
|
this->needsRedraw = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
HandlerResult Panel_selectByTyping(Panel* this, int ch) {
|
HandlerResult Panel_selectByTyping(Panel* this, int ch) {
|
||||||
int size = Panel_size(this);
|
int size = Panel_size(this);
|
||||||
|
|
||||||
if (!this->eventHandlerState)
|
if (!this->eventHandlerState)
|
||||||
this->eventHandlerState = xCalloc(100, sizeof(char));
|
this->eventHandlerState = xCalloc(100, sizeof(char));
|
||||||
char* buffer = this->eventHandlerState;
|
char* buffer = this->eventHandlerState;
|
||||||
|
@ -438,17 +446,21 @@ HandlerResult Panel_selectByTyping(Panel* this, int ch) {
|
||||||
return HANDLED;
|
return HANDLED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if current word did not match,
|
// if current word did not match,
|
||||||
// retry considering the character the start of a new word.
|
// retry considering the character the start of a new word.
|
||||||
buffer[0] = ch;
|
buffer[0] = ch;
|
||||||
buffer[1] = '\0';
|
buffer[1] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
return HANDLED;
|
return HANDLED;
|
||||||
} else if (ch != ERR) {
|
} else if (ch != ERR) {
|
||||||
buffer[0] = '\0';
|
buffer[0] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ch == 13) {
|
if (ch == 13) {
|
||||||
return BREAK_LOOP;
|
return BREAK_LOOP;
|
||||||
}
|
}
|
||||||
|
|
||||||
return IGNORED;
|
return IGNORED;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue