static void Process_printTime(RichString* str, unsigned long long t) { if(jiffy == 0.0) jiffy = sysconf(_SC_CLK_TCK); double jiffytime = 1.0 / jiffy; double realTime = t * jiffytime; unsigned long long iRealTime = (unsigned long long) realTime; unsigned long long hours = iRealTime / 3600; int minutes = (iRealTime / 60) % 60; int seconds = iRealTime % 60; int hundredths = (realTime - iRealTime) * 100; char buffer[11]; if (hours >= 100) { snprintf(buffer, 10, "%7lluh ", hours); RichString_append(str, CRT_colors[LARGE_NUMBER], buffer); } else { if (hours) { snprintf(buffer, 10, "%2lluh", hours); RichString_append(str, CRT_colors[LARGE_NUMBER], buffer); snprintf(buffer, 10, "%02d:%02d ", minutes, seconds); } else { snprintf(buffer, 10, "%2d:%02d.%02d ", minutes, seconds, hundredths); } RichString_append(str, CRT_colors[DEFAULT_COLOR], buffer); } }
static void CheckItem_display(Object* cast, RichString* out) { CheckItem* this = (CheckItem*)cast; assert (this != NULL); RichString_write(out, CRT_colors[CHECK_BOX], "["); if (CheckItem_get(this)) RichString_append(out, CRT_colors[CHECK_MARK], "x"); else RichString_append(out, CRT_colors[CHECK_MARK], " "); RichString_append(out, CRT_colors[CHECK_BOX], "] "); RichString_append(out, CRT_colors[CHECK_TEXT], this->text); }
void Process_printTime(RichString* str, unsigned long long totalHundredths) { unsigned long long totalSeconds = totalHundredths / 100; unsigned long long hours = totalSeconds / 3600; int minutes = (totalSeconds / 60) % 60; int seconds = totalSeconds % 60; int hundredths = totalHundredths - (totalSeconds * 100); char buffer[11]; if (hours >= 100) { snprintf(buffer, 10, "%7lluh ", hours); RichString_append(str, CRT_colors[LARGE_NUMBER], buffer); } else { if (hours) { snprintf(buffer, 10, "%2lluh", hours); RichString_append(str, CRT_colors[LARGE_NUMBER], buffer); snprintf(buffer, 10, "%02d:%02d ", minutes, seconds); } else { snprintf(buffer, 10, "%2d:%02d.%02d ", minutes, seconds, hundredths); } RichString_append(str, CRT_colors[DEFAULT_COLOR], buffer); } }
static void ListItem_display(Object* cast, RichString* out) { ListItem* const this = (ListItem*)cast; assert (this != NULL); /* int len = strlen(this->value)+1; char buffer[len+1]; snprintf(buffer, len, "%s", this->value); */ if (this->moving) { RichString_write(out, CRT_colors[DEFAULT_COLOR], #ifdef HAVE_LIBNCURSESW CRT_utf8 ? "↕ " : #endif "+ "); } else { RichString_prune(out); } RichString_append(out, CRT_colors[DEFAULT_COLOR], this->value/*buffer*/); }