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:
@@ -37,7 +37,7 @@ static const char *options_table_mode_keys_list[] = {
|
|||||||
"emacs", "vi", NULL
|
"emacs", "vi", NULL
|
||||||
};
|
};
|
||||||
static const char *options_table_clock_mode_style_list[] = {
|
static const char *options_table_clock_mode_style_list[] = {
|
||||||
"12", "24", NULL
|
"12", "24", "12-with-seconds", "24-with-seconds", NULL
|
||||||
};
|
};
|
||||||
static const char *options_table_status_list[] = {
|
static const char *options_table_status_list[] = {
|
||||||
"off", "on", "2", "3", "4", "5", NULL
|
"off", "on", "2", "3", "4", "5", NULL
|
||||||
|
|||||||
2
tmux.1
2
tmux.1
@@ -4925,7 +4925,7 @@ option is enabled.
|
|||||||
Set clock colour.
|
Set clock colour.
|
||||||
.Pp
|
.Pp
|
||||||
.It Xo Ic clock-mode-style
|
.It Xo Ic clock-mode-style
|
||||||
.Op Ic 12 | 24
|
.Op Ic 12 | 24 | 12-with-seconds | 24-with-seconds
|
||||||
.Xc
|
.Xc
|
||||||
Set clock hour format.
|
Set clock hour format.
|
||||||
.Pp
|
.Pp
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ const struct window_mode window_clock_mode = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct window_clock_mode_data {
|
struct window_clock_mode_data {
|
||||||
struct screen screen;
|
struct screen screen;
|
||||||
time_t tim;
|
time_t tim;
|
||||||
struct event timer;
|
struct event timer;
|
||||||
};
|
};
|
||||||
@@ -142,7 +142,7 @@ window_clock_timer_callback(__unused int fd, __unused short events, void *arg)
|
|||||||
t = time(NULL);
|
t = time(NULL);
|
||||||
gmtime_r(&t, &now);
|
gmtime_r(&t, &now);
|
||||||
gmtime_r(&data->tim, &then);
|
gmtime_r(&data->tim, &then);
|
||||||
if (now.tm_min == then.tm_min)
|
if (now.tm_sec == then.tm_sec)
|
||||||
return;
|
return;
|
||||||
data->tim = t;
|
data->tim = t;
|
||||||
|
|
||||||
@@ -207,11 +207,12 @@ window_clock_draw_screen(struct window_mode_entry *wme)
|
|||||||
{
|
{
|
||||||
struct window_pane *wp = wme->wp;
|
struct window_pane *wp = wme->wp;
|
||||||
struct window_clock_mode_data *data = wme->data;
|
struct window_clock_mode_data *data = wme->data;
|
||||||
struct screen_write_ctx ctx;
|
struct screen_write_ctx ctx;
|
||||||
int colour, style;
|
int colour, style;
|
||||||
struct screen *s = &data->screen;
|
struct screen *s = &data->screen;
|
||||||
struct grid_cell gc;
|
struct grid_cell gc;
|
||||||
char tim[64], *ptr;
|
char tim[64], *ptr;
|
||||||
|
const char *timeformat;
|
||||||
time_t t;
|
time_t t;
|
||||||
struct tm *tm;
|
struct tm *tm;
|
||||||
u_int i, j, x, y, idx;
|
u_int i, j, x, y, idx;
|
||||||
@@ -223,14 +224,23 @@ window_clock_draw_screen(struct window_mode_entry *wme)
|
|||||||
|
|
||||||
t = time(NULL);
|
t = time(NULL);
|
||||||
tm = localtime(&t);
|
tm = localtime(&t);
|
||||||
if (style == 0) {
|
if (style == 0 || style == 2) {
|
||||||
strftime(tim, sizeof tim, "%l:%M ", localtime(&t));
|
if (style == 2)
|
||||||
|
timeformat = "%l:%M:%S ";
|
||||||
|
else
|
||||||
|
timeformat = "%l:%M ";
|
||||||
|
strftime(tim, sizeof tim, timeformat, localtime(&t));
|
||||||
if (tm->tm_hour >= 12)
|
if (tm->tm_hour >= 12)
|
||||||
strlcat(tim, "PM", sizeof tim);
|
strlcat(tim, "PM", sizeof tim);
|
||||||
else
|
else
|
||||||
strlcat(tim, "AM", sizeof tim);
|
strlcat(tim, "AM", sizeof tim);
|
||||||
} else
|
} else {
|
||||||
strftime(tim, sizeof tim, "%H:%M", tm);
|
if (style == 3)
|
||||||
|
timeformat = "%H:%M:%S";
|
||||||
|
else
|
||||||
|
timeformat = "%H:%M";
|
||||||
|
strftime(tim, sizeof tim, timeformat, tm);
|
||||||
|
}
|
||||||
|
|
||||||
screen_write_clearscreen(&ctx, 8);
|
screen_write_clearscreen(&ctx, 8);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user