summaryrefslogtreecommitdiffstats
path: root/Process.c
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2011-11-03 22:12:12 +0000
committerHisham Muhammad <hisham@gobolinux.org>2011-11-03 22:12:12 +0000
commitca6b9238a39980aac650eb4bd82ace74c31a285f (patch)
treeded9fb3f434b3b2b313f5581a969a0e91cec10c1 /Process.c
parentb45b9e2b33d474f6bef70ead2011f2da65333fa2 (diff)
Support for UTF-8 tree drawing
(thanks to Bin Guo)
Diffstat (limited to 'Process.c')
-rw-r--r--Process.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/Process.c b/Process.c
index 0632278a..31c87406 100644
--- a/Process.c
+++ b/Process.c
@@ -387,21 +387,26 @@ static void Process_writeField(Process* this, RichString* str, ProcessField fiel
} else {
char* buf = buffer;
int maxIndent = 0;
+ const char **treeStr = this->pl->treeStr;
+ bool lastItem = (this->indent < 0);
+ int indent = (this->indent < 0 ? -this->indent : this->indent);
+ if (treeStr == NULL)
+ treeStr = ProcessList_treeStrAscii;
+
for (int i = 0; i < 32; i++)
- if (this->indent & (1 << i))
+ if (indent & (1 << i))
maxIndent = i+1;
for (int i = 0; i < maxIndent - 1; i++) {
- if (this->indent & (1 << i))
- snprintf(buf, n, " | ");
+ int written;
+ if (indent & (1 << i))
+ written = snprintf(buf, n, "%s ", treeStr[TREE_STR_VERT]);
else
- snprintf(buf, n, " ");
- buf += 4;
- n -= 4;
+ written = snprintf(buf, n, " ");
+ buf += written;
+ n -= written;
}
- if (this->pl->direction == 1)
- snprintf(buf, n, " `%s ", this->showChildren ? "-" : "+" );
- else
- snprintf(buf, n, " ,%s ", this->showChildren ? "-" : "+" );
+ const char* draw = treeStr[lastItem ? (this->pl->direction == 1 ? TREE_STR_BEND : TREE_STR_TEND) : TREE_STR_RTEE];
+ snprintf(buf, n, "%s%s ", draw, this->showChildren ? treeStr[TREE_STR_SHUT] : treeStr[TREE_STR_OPEN] );
RichString_append(str, CRT_colors[PROCESS_TREE], buffer);
Process_writeCommand(this, attr, baseattr, str);
return;

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