mirror of
https://github.com/tmux/tmux.git
synced 2024-11-17 18:08:51 +00:00
Store time lines are scrolled into history and display in copy mode.
This commit is contained in:
parent
a888ce9963
commit
9c89f7c2af
13
format.c
13
format.c
@ -3387,12 +3387,12 @@ format_quote_style(const char *s)
|
||||
}
|
||||
|
||||
/* Make a prettier time. */
|
||||
static char *
|
||||
format_pretty_time(time_t t)
|
||||
char *
|
||||
format_pretty_time(time_t t, int seconds)
|
||||
{
|
||||
struct tm now_tm, tm;
|
||||
time_t now, age;
|
||||
char s[6];
|
||||
char s[9];
|
||||
|
||||
time(&now);
|
||||
if (now < t)
|
||||
@ -3404,7 +3404,10 @@ format_pretty_time(time_t t)
|
||||
|
||||
/* Last 24 hours. */
|
||||
if (age < 24 * 3600) {
|
||||
strftime(s, sizeof s, "%H:%M", &tm);
|
||||
if (seconds)
|
||||
strftime(s, sizeof s, "%H:%M:%S", &tm);
|
||||
else
|
||||
strftime(s, sizeof s, "%H:%M", &tm);
|
||||
return (xstrdup(s));
|
||||
}
|
||||
|
||||
@ -3509,7 +3512,7 @@ found:
|
||||
if (t == 0)
|
||||
return (NULL);
|
||||
if (modifiers & FORMAT_PRETTY)
|
||||
found = format_pretty_time(t);
|
||||
found = format_pretty_time(t, 0);
|
||||
else {
|
||||
if (time_format != NULL) {
|
||||
localtime_r(&t, &tm);
|
||||
|
2
grid.c
2
grid.c
@ -399,6 +399,7 @@ grid_scroll_history(struct grid *gd, u_int bg)
|
||||
|
||||
gd->hscrolled++;
|
||||
grid_compact_line(&gd->linedata[gd->hsize]);
|
||||
gd->linedata[gd->hsize].time = current_time;
|
||||
gd->hsize++;
|
||||
}
|
||||
|
||||
@ -438,6 +439,7 @@ grid_scroll_history_region(struct grid *gd, u_int upper, u_int lower, u_int bg)
|
||||
|
||||
/* Move the line into the history. */
|
||||
memcpy(gl_history, gl_upper, sizeof *gl_history);
|
||||
gl_history->time = current_time;
|
||||
|
||||
/* Then move the region up and clear the bottom line. */
|
||||
memmove(gl_upper, gl_upper + 1, (lower - upper) * sizeof *gl_upper);
|
||||
|
4
server.c
4
server.c
@ -55,6 +55,8 @@ struct cmd_find_state marked_pane;
|
||||
static u_int message_next;
|
||||
struct message_list message_log;
|
||||
|
||||
time_t current_time;
|
||||
|
||||
static int server_loop(void);
|
||||
static void server_send_exit(void);
|
||||
static void server_accept(int, short, void *);
|
||||
@ -257,6 +259,8 @@ server_loop(void)
|
||||
struct client *c;
|
||||
u_int items;
|
||||
|
||||
current_time = time (NULL);
|
||||
|
||||
do {
|
||||
items = cmdq_next(NULL);
|
||||
TAILQ_FOREACH(c, &clients, entry) {
|
||||
|
3
tmux.h
3
tmux.h
@ -725,6 +725,7 @@ struct grid_line {
|
||||
u_int extdsize;
|
||||
|
||||
int flags;
|
||||
time_t time;
|
||||
};
|
||||
|
||||
/* Entire grid of cells. */
|
||||
@ -2095,6 +2096,7 @@ void format_add_cb(struct format_tree *, const char *, format_cb);
|
||||
void format_log_debug(struct format_tree *, const char *);
|
||||
void format_each(struct format_tree *, void (*)(const char *,
|
||||
const char *, void *), void *);
|
||||
char *format_pretty_time(time_t, int);
|
||||
char *format_expand_time(struct format_tree *, const char *);
|
||||
char *format_expand(struct format_tree *, const char *);
|
||||
char *format_single(struct cmdq_item *, const char *,
|
||||
@ -2587,6 +2589,7 @@ extern struct tmuxproc *server_proc;
|
||||
extern struct clients clients;
|
||||
extern struct cmd_find_state marked_pane;
|
||||
extern struct message_list message_log;
|
||||
extern time_t current_time;
|
||||
void server_set_marked(struct session *, struct winlink *,
|
||||
struct window_pane *);
|
||||
void server_clear_marked(void);
|
||||
|
@ -4092,8 +4092,9 @@ window_copy_write_line(struct window_mode_entry *wme,
|
||||
struct window_copy_mode_data *data = wme->data;
|
||||
struct screen *s = &data->screen;
|
||||
struct options *oo = wp->window->options;
|
||||
struct grid_line *gl;
|
||||
struct grid_cell gc, mgc, cgc, mkgc;
|
||||
char hdr[512];
|
||||
char hdr[512], tmp[256], *t;
|
||||
size_t size = 0;
|
||||
u_int hsize = screen_hsize(data->backing);
|
||||
|
||||
@ -4107,23 +4108,29 @@ window_copy_write_line(struct window_mode_entry *wme,
|
||||
mkgc.flags |= GRID_FLAG_NOPALETTE;
|
||||
|
||||
if (py == 0 && s->rupper < s->rlower && !data->hide_position) {
|
||||
gl = grid_get_line(data->backing->grid, hsize - data->oy);
|
||||
if (gl->time == 0)
|
||||
xsnprintf(tmp, sizeof tmp, "[%u/%u]", data->oy, hsize);
|
||||
else {
|
||||
t = format_pretty_time(gl->time, 1);
|
||||
xsnprintf(tmp, sizeof tmp, "%s [%u/%u]", t, data->oy,
|
||||
hsize);
|
||||
free(t);
|
||||
}
|
||||
|
||||
if (data->searchmark == NULL) {
|
||||
if (data->timeout) {
|
||||
size = xsnprintf(hdr, sizeof hdr,
|
||||
"(timed out) [%u/%u]", data->oy, hsize);
|
||||
} else {
|
||||
size = xsnprintf(hdr, sizeof hdr,
|
||||
"[%u/%u]", data->oy, hsize);
|
||||
}
|
||||
"(timed out) %s", tmp);
|
||||
} else
|
||||
size = xsnprintf(hdr, sizeof hdr, "%s", tmp);
|
||||
} else {
|
||||
if (data->searchcount == -1) {
|
||||
if (data->searchcount == -1)
|
||||
size = xsnprintf(hdr, sizeof hdr, "%s", tmp);
|
||||
else {
|
||||
size = xsnprintf(hdr, sizeof hdr,
|
||||
"[%u/%u]", data->oy, hsize);
|
||||
} else {
|
||||
size = xsnprintf(hdr, sizeof hdr,
|
||||
"(%d%s results) [%u/%u]", data->searchcount,
|
||||
data->searchmore ? "+" : "", data->oy,
|
||||
hsize);
|
||||
"(%d%s results) %s", data->searchcount,
|
||||
data->searchmore ? "+" : "", tmp);
|
||||
}
|
||||
}
|
||||
if (size > screen_size_x(s))
|
||||
|
Loading…
Reference in New Issue
Block a user