| 40 |
#define STR_TOP_MIDDLE_MAX_LEN 40 |
#define STR_TOP_MIDDLE_MAX_LEN 40 |
| 41 |
#define STR_TOP_RIGHT_MAX_LEN 40 |
#define STR_TOP_RIGHT_MAX_LEN 40 |
| 42 |
|
|
| 43 |
|
static const char *get_time_str(char *s, size_t len) |
| 44 |
|
{ |
| 45 |
|
static const char *weekday[] = { |
| 46 |
|
"天", "一", "二", "三", "四", "五", "六"}; |
| 47 |
|
time_t curtime; |
| 48 |
|
struct tm local_tm; |
| 49 |
|
|
| 50 |
|
time(&curtime); |
| 51 |
|
localtime_r(&curtime, &local_tm); |
| 52 |
|
size_t j = strftime(s, len, "%b %d %H:%M 星期", &local_tm); |
| 53 |
|
|
| 54 |
|
if (j == 0 || j + strlen(weekday[local_tm.tm_wday]) + 1 > len) |
| 55 |
|
{ |
| 56 |
|
return NULL; |
| 57 |
|
} |
| 58 |
|
|
| 59 |
|
strncat(s, weekday[local_tm.tm_wday], len - 1 - j); |
| 60 |
|
|
| 61 |
|
return s; |
| 62 |
|
} |
| 63 |
|
|
| 64 |
void moveto(int row, int col) |
void moveto(int row, int col) |
| 65 |
{ |
{ |
| 66 |
if (row >= 0) |
if (row >= 0) |
| 206 |
ch = igetch(100); // 0.1 second |
ch = igetch(100); // 0.1 second |
| 207 |
if (ch == KEY_NULL || ch == KEY_TIMEOUT) // Ignore received bytes if no futher input |
if (ch == KEY_NULL || ch == KEY_TIMEOUT) // Ignore received bytes if no futher input |
| 208 |
{ |
{ |
| 209 |
|
#ifdef _DEBUG |
| 210 |
log_error("Ignore %d bytes of incomplete UTF8 character\n", str_len); |
log_error("Ignore %d bytes of incomplete UTF8 character\n", str_len); |
| 211 |
|
#endif |
| 212 |
str_len = 0; |
str_len = 0; |
| 213 |
break; |
break; |
| 214 |
} |
} |