diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2011-11-03 22:12:12 +0000 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2011-11-03 22:12:12 +0000 |
commit | ca6b9238a39980aac650eb4bd82ace74c31a285f (patch) | |
tree | ded9fb3f434b3b2b313f5581a969a0e91cec10c1 /Process.c | |
parent | b45b9e2b33d474f6bef70ead2011f2da65333fa2 (diff) |
Support for UTF-8 tree drawing
(thanks to Bin Guo)
Diffstat (limited to 'Process.c')
-rw-r--r-- | Process.c | 25 |
1 files changed, 15 insertions, 10 deletions
@@ -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; |