summaryrefslogtreecommitdiffstats
path: root/CommandScreen.c
diff options
context:
space:
mode:
authorryenus <ryenus@gmail.com>2020-09-26 05:22:24 +0800
committercgzones <cgzones@googlemail.com>2020-09-29 10:11:28 +0200
commit214c742ae176078c3b081e1598b3fbf0cc122f77 (patch)
tree9204f331ca1b73d3984bd405b998587f699c677a /CommandScreen.c
parent9ee72568dc36e2c83add9c602387509909f3d292 (diff)
command screen: fill current line when scanning
Diffstat (limited to 'CommandScreen.c')
-rw-r--r--CommandScreen.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/CommandScreen.c b/CommandScreen.c
index 0e261175..d8e709c4 100644
--- a/CommandScreen.c
+++ b/CommandScreen.c
@@ -12,33 +12,33 @@
#include <unistd.h>
-static void CommandScreen_addLine(InfoScreen* this, char* line, const char* p, int line_offset, int len) {
- memcpy(line, p - line_offset, len);
- line[len] = '\0';
- InfoScreen_addLine(this, line);
-}
-
static void CommandScreen_scan(InfoScreen* this) {
Panel* panel = this->display;
int idx = MAXIMUM(Panel_getSelectedIndex(panel), 0);
-
Panel_prune(panel);
const char* p = this->process->comm;
char* line = xMalloc(COLS + 1);
int line_offset = 0, last_spc = -1, len;
for (; *p != '\0'; p++, line_offset++) {
+ line[line_offset] = *p;
if (*p == ' ') last_spc = line_offset;
if (line_offset == COLS) {
len = (last_spc == -1) ? line_offset : last_spc;
- CommandScreen_addLine(this, line, p, line_offset, len);
+ line[len] = '\0';
+ InfoScreen_addLine(this, line);
+
line_offset -= len;
last_spc = -1;
+ memcpy(line, p - line_offset, line_offset + 1);
}
}
- if (line_offset > 0) CommandScreen_addLine(this, line, p, line_offset, line_offset);
+ if (line_offset > 0) {
+ line[line_offset] = '\0';
+ InfoScreen_addLine(this, line);
+ }
free(line);
Panel_setSelected(panel, idx);

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