mirror of
https://github.com/tmux/tmux.git
synced 2026-10-09 11:44:23 +00:00
Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master: build: don't exit build: always attempt portable merge build: capture openbsd-base before filtering build: fetch cutover master before merge Use _exit in child after fork, from Yayo Razo in GitHub issue 5376. Add missing calloc check and use fatal. Prompted by a similar change from Yayo Razo. actions: use published openbsd-git as base update github actions: automate updates Do not make pty fds blocking again until all the data has been consumed or control mode clients can get stuck, GitHub issue 5356 from Ben Maurer. Add formats and events for OSC 133 commmands, as well as a -T flag to set-hook -B to only fire when the format is true. Replace the notification system with events. Events can carry a payload of additional payload (to reduce problems with lifetime of objects) and are delivered to one or more event sinks. This is more powerful and reduces the complex dependencies between control mode and hooks. Events are now used for hooks, control mode notifications and for monitors (set-hook -B).
This commit is contained in:
123
format.c
123
format.c
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD$ */
|
||||
/* $OpenBSD: format.c,v 1.403 2026/07/10 15:20:06 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011 Nicholas Marriott <nicholas.marriott@gmail.com>
|
||||
@@ -2187,6 +2187,106 @@ format_cb_pane_dead_time(struct format_tree *ft)
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/* Callback for pane_last_output_time. */
|
||||
static void *
|
||||
format_cb_pane_last_output_time(struct format_tree *ft)
|
||||
{
|
||||
struct window_pane *wp = ft->wp;
|
||||
static struct timeval tv;
|
||||
|
||||
if (wp != NULL && wp->last_output_time != 0) {
|
||||
tv.tv_sec = wp->last_output_time;
|
||||
tv.tv_usec = 0;
|
||||
return (&tv);
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/* Callback for pane_last_prompt_time. */
|
||||
static void *
|
||||
format_cb_pane_last_prompt_time(struct format_tree *ft)
|
||||
{
|
||||
struct window_pane *wp = ft->wp;
|
||||
static struct timeval tv;
|
||||
|
||||
if (wp != NULL && wp->last_prompt_time != 0) {
|
||||
tv.tv_sec = wp->last_prompt_time;
|
||||
tv.tv_usec = 0;
|
||||
return (&tv);
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/* Callback for pane_command_start_time. */
|
||||
static void *
|
||||
format_cb_pane_command_start_time(struct format_tree *ft)
|
||||
{
|
||||
struct window_pane *wp = ft->wp;
|
||||
static struct timeval tv;
|
||||
|
||||
if (wp != NULL && wp->cmd_start_time != 0) {
|
||||
tv.tv_sec = wp->cmd_start_time;
|
||||
tv.tv_usec = 0;
|
||||
return (&tv);
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/* Callback for pane_command_end_time. */
|
||||
static void *
|
||||
format_cb_pane_command_end_time(struct format_tree *ft)
|
||||
{
|
||||
struct window_pane *wp = ft->wp;
|
||||
static struct timeval tv;
|
||||
|
||||
if (wp != NULL && wp->cmd_end_time != 0) {
|
||||
tv.tv_sec = wp->cmd_end_time;
|
||||
tv.tv_usec = 0;
|
||||
return (&tv);
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/* Callback for pane_command_running. */
|
||||
static void *
|
||||
format_cb_pane_command_running(struct format_tree *ft)
|
||||
{
|
||||
struct window_pane *wp = ft->wp;
|
||||
|
||||
if (wp != NULL)
|
||||
return (format_printf("%d", !!(wp->flags & PANE_CMDRUNNING)));
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/* Callback for pane_command_duration. */
|
||||
static void *
|
||||
format_cb_pane_command_duration(struct format_tree *ft)
|
||||
{
|
||||
struct window_pane *wp = ft->wp;
|
||||
time_t end;
|
||||
|
||||
if (wp == NULL || wp->cmd_start_time == 0)
|
||||
return (NULL);
|
||||
if (wp->flags & PANE_CMDRUNNING)
|
||||
end = time(NULL);
|
||||
else
|
||||
end = wp->cmd_end_time;
|
||||
if (end < wp->cmd_start_time)
|
||||
end = wp->cmd_start_time;
|
||||
return (format_printf("%lld", (long long)(end - wp->cmd_start_time)));
|
||||
}
|
||||
|
||||
/* Callback for pane_command_status. */
|
||||
static void *
|
||||
format_cb_pane_command_status(struct format_tree *ft)
|
||||
{
|
||||
struct window_pane *wp = ft->wp;
|
||||
|
||||
if (wp != NULL && wp->cmd_status != -1)
|
||||
return (format_printf("%d", wp->cmd_status));
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/* Callback for pane_format. */
|
||||
static void *
|
||||
format_cb_pane_format(struct format_tree *ft)
|
||||
@@ -3503,6 +3603,21 @@ static const struct format_table_entry format_table[] = {
|
||||
{ "pane_bottom", FORMAT_TABLE_STRING,
|
||||
format_cb_pane_bottom
|
||||
},
|
||||
{ "pane_command_duration", FORMAT_TABLE_STRING,
|
||||
format_cb_pane_command_duration
|
||||
},
|
||||
{ "pane_command_end_time", FORMAT_TABLE_TIME,
|
||||
format_cb_pane_command_end_time
|
||||
},
|
||||
{ "pane_command_running", FORMAT_TABLE_STRING,
|
||||
format_cb_pane_command_running
|
||||
},
|
||||
{ "pane_command_start_time", FORMAT_TABLE_TIME,
|
||||
format_cb_pane_command_start_time
|
||||
},
|
||||
{ "pane_command_status", FORMAT_TABLE_STRING,
|
||||
format_cb_pane_command_status
|
||||
},
|
||||
{ "pane_current_command", FORMAT_TABLE_STRING,
|
||||
format_cb_current_command
|
||||
},
|
||||
@@ -3554,6 +3669,12 @@ static const struct format_table_entry format_table[] = {
|
||||
{ "pane_last", FORMAT_TABLE_STRING,
|
||||
format_cb_pane_last
|
||||
},
|
||||
{ "pane_last_output_time", FORMAT_TABLE_TIME,
|
||||
format_cb_pane_last_output_time
|
||||
},
|
||||
{ "pane_last_prompt_time", FORMAT_TABLE_TIME,
|
||||
format_cb_pane_last_prompt_time
|
||||
},
|
||||
{ "pane_left", FORMAT_TABLE_STRING,
|
||||
format_cb_pane_left
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user