mirror of
https://github.com/tmux/tmux.git
synced 2025-11-26 03:56:09 +00:00
Add seconds options for clock mode, from augustus7613 dot mail at pm dot
me in GitHub issue 4697.
This commit is contained in:
@@ -45,7 +45,7 @@ const struct window_mode window_clock_mode = {
|
||||
};
|
||||
|
||||
struct window_clock_mode_data {
|
||||
struct screen screen;
|
||||
struct screen screen;
|
||||
time_t tim;
|
||||
struct event timer;
|
||||
};
|
||||
@@ -142,7 +142,7 @@ window_clock_timer_callback(__unused int fd, __unused short events, void *arg)
|
||||
t = time(NULL);
|
||||
gmtime_r(&t, &now);
|
||||
gmtime_r(&data->tim, &then);
|
||||
if (now.tm_min == then.tm_min)
|
||||
if (now.tm_sec == then.tm_sec)
|
||||
return;
|
||||
data->tim = t;
|
||||
|
||||
@@ -207,11 +207,12 @@ window_clock_draw_screen(struct window_mode_entry *wme)
|
||||
{
|
||||
struct window_pane *wp = wme->wp;
|
||||
struct window_clock_mode_data *data = wme->data;
|
||||
struct screen_write_ctx ctx;
|
||||
struct screen_write_ctx ctx;
|
||||
int colour, style;
|
||||
struct screen *s = &data->screen;
|
||||
struct grid_cell gc;
|
||||
char tim[64], *ptr;
|
||||
const char *timeformat;
|
||||
time_t t;
|
||||
struct tm *tm;
|
||||
u_int i, j, x, y, idx;
|
||||
@@ -223,14 +224,23 @@ window_clock_draw_screen(struct window_mode_entry *wme)
|
||||
|
||||
t = time(NULL);
|
||||
tm = localtime(&t);
|
||||
if (style == 0) {
|
||||
strftime(tim, sizeof tim, "%l:%M ", localtime(&t));
|
||||
if (style == 0 || style == 2) {
|
||||
if (style == 2)
|
||||
timeformat = "%l:%M:%S ";
|
||||
else
|
||||
timeformat = "%l:%M ";
|
||||
strftime(tim, sizeof tim, timeformat, localtime(&t));
|
||||
if (tm->tm_hour >= 12)
|
||||
strlcat(tim, "PM", sizeof tim);
|
||||
else
|
||||
strlcat(tim, "AM", sizeof tim);
|
||||
} else
|
||||
strftime(tim, sizeof tim, "%H:%M", tm);
|
||||
} else {
|
||||
if (style == 3)
|
||||
timeformat = "%H:%M:%S";
|
||||
else
|
||||
timeformat = "%H:%M";
|
||||
strftime(tim, sizeof tim, timeformat, tm);
|
||||
}
|
||||
|
||||
screen_write_clearscreen(&ctx, 8);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user