mirror of https://github.com/xzeldon/htop.git
limit max screen title length to window width
Applies screen title truncating to all InfoScreen classes.
This commit is contained in:
parent
72613a38f4
commit
ff455b0004
|
@ -45,14 +45,7 @@ static void CommandScreen_scan(InfoScreen* this) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CommandScreen_draw(InfoScreen* this) {
|
static void CommandScreen_draw(InfoScreen* this) {
|
||||||
char* title = xMalloc(COLS + 1);
|
InfoScreen_drawTitled(this, "Command of process %d - %s", this->process->pid, this->process->comm);
|
||||||
int len = snprintf(title, COLS + 1, "Command of process %d - %s", this->process->pid, this->process->comm);
|
|
||||||
if (len > COLS) {
|
|
||||||
memset(&title[COLS - 3], '.', 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
InfoScreen_drawTitled(this, "%s", title);
|
|
||||||
free(title);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
InfoScreenClass CommandScreen_class = {
|
InfoScreenClass CommandScreen_class = {
|
||||||
|
|
11
InfoScreen.c
11
InfoScreen.c
|
@ -42,14 +42,21 @@ InfoScreen* InfoScreen_done(InfoScreen* this) {
|
||||||
void InfoScreen_drawTitled(InfoScreen* this, const char* fmt, ...) {
|
void InfoScreen_drawTitled(InfoScreen* this, const char* fmt, ...) {
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
|
|
||||||
|
char* title = xMalloc(COLS + 1);
|
||||||
|
int len = vsnprintf(title, COLS + 1, fmt, ap);
|
||||||
|
if (len > COLS) {
|
||||||
|
memset(&title[COLS - 3], '.', 3);
|
||||||
|
}
|
||||||
|
|
||||||
attrset(CRT_colors[METER_TEXT]);
|
attrset(CRT_colors[METER_TEXT]);
|
||||||
mvhline(0, 0, ' ', COLS);
|
mvhline(0, 0, ' ', COLS);
|
||||||
(void) wmove(stdscr, 0, 0);
|
mvwprintw(stdscr, 0, 0, title);
|
||||||
vw_printw(stdscr, fmt, ap);
|
|
||||||
attrset(CRT_colors[DEFAULT_COLOR]);
|
attrset(CRT_colors[DEFAULT_COLOR]);
|
||||||
this->display->needsRedraw = true;
|
this->display->needsRedraw = true;
|
||||||
Panel_draw(this->display, true);
|
Panel_draw(this->display, true);
|
||||||
IncSet_drawBar(this->inc);
|
IncSet_drawBar(this->inc);
|
||||||
|
free(title);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue