diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2008-03-09 02:33:23 +0000 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2008-03-09 02:33:23 +0000 |
commit | 8fa33dc3365f0e27a5013748321def4bef937049 (patch) | |
tree | cf1498456001b55157c4ce9dcd516dd5226158e3 /Process.c | |
parent | fa87ff02514cdd148cdcf8d24de0599a400f3918 (diff) |
Add Unicode support, enabled with the --enable-unicode
flag, which requires libncursesw.
Thanks to Sergej Pupykin!
Diffstat (limited to 'Process.c')
-rw-r--r-- | Process.c | 28 |
1 files changed, 13 insertions, 15 deletions
@@ -11,6 +11,7 @@ in the source distribution for its full text. #include "CRT.h" #include "String.h" #include "Process.h" +#include "RichString.h" #include "debug.h" @@ -265,23 +266,20 @@ static void Process_printTime(RichString* str, unsigned long t) { } static inline void Process_writeCommand(Process* this, int attr, int baseattr, RichString* str) { + int start = str->len; + RichString_append(str, attr, this->comm); if (this->pl->highlightBaseName) { - char* firstSpace = strchr(this->comm, ' '); - if (firstSpace) { - char* slash = firstSpace; - while (slash > this->comm && *slash != '/') - slash--; - if (slash > this->comm) { - slash++; - RichString_appendn(str, attr, this->comm, slash - this->comm); - } - RichString_appendn(str, baseattr, slash, firstSpace - slash); - RichString_append(str, attr, firstSpace); - } else { - RichString_append(str, baseattr, this->comm); + int finish = str->len - 1; + int space = RichString_findChar(str, ' ', start); + if (space != -1) + finish = space - 1; + for (;;) { + int slash = RichString_findChar(str, '/', start); + if (slash == -1 || slash > finish) + break; + start = slash + 1; } - } else { - RichString_append(str, attr, this->comm); + RichString_setAttrn(str, baseattr, start, finish); } } |