mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-08-27 09:31:39 +00:00
terminal: expose progress report effect
This commit is contained in:
@@ -95,6 +95,7 @@ extern "C" {
|
||||
* | `GHOSTTY_TERMINAL_OPT_DEVICE_ATTRIBUTES`| `GhosttyTerminalDeviceAttributesFn`| Device attributes query (CSI c / > c / = c)|
|
||||
* | `GHOSTTY_TERMINAL_OPT_CLIPBOARD_WRITE` | `GhosttyTerminalClipboardWriteFn` | Clipboard write via OSC 52 / OSC 1337 |
|
||||
* | `GHOSTTY_TERMINAL_OPT_DESKTOP_NOTIFICATION`| `GhosttyTerminalDesktopNotificationFn` | Desktop notification via OSC 9 / OSC 777 |
|
||||
* | `GHOSTTY_TERMINAL_OPT_PROGRESS_REPORT` | `GhosttyTerminalProgressReportFn` | Progress report via OSC 9;4 |
|
||||
*
|
||||
* ### Defining a write_pty callback
|
||||
* @snippet c-vt-effects/src/main.c effects-write-pty
|
||||
@@ -484,6 +485,64 @@ typedef void (*GhosttyTerminalDesktopNotificationFn)(
|
||||
void* userdata,
|
||||
const GhosttyTerminalDesktopNotification* notification);
|
||||
|
||||
/**
|
||||
* State of a terminal progress report.
|
||||
*
|
||||
* @ingroup terminal
|
||||
*/
|
||||
typedef enum GHOSTTY_ENUM_TYPED {
|
||||
/** Remove any visible progress indication. */
|
||||
GHOSTTY_TERMINAL_PROGRESS_STATE_REMOVE = 0,
|
||||
|
||||
/** Show determinate progress. */
|
||||
GHOSTTY_TERMINAL_PROGRESS_STATE_SET = 1,
|
||||
|
||||
/** Show a failed progress state. */
|
||||
GHOSTTY_TERMINAL_PROGRESS_STATE_ERROR = 2,
|
||||
|
||||
/** Show indeterminate progress. */
|
||||
GHOSTTY_TERMINAL_PROGRESS_STATE_INDETERMINATE = 3,
|
||||
|
||||
/** Show paused progress. */
|
||||
GHOSTTY_TERMINAL_PROGRESS_STATE_PAUSE = 4,
|
||||
GHOSTTY_TERMINAL_PROGRESS_STATE_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
|
||||
} GhosttyTerminalProgressState;
|
||||
|
||||
/**
|
||||
* A progress report emitted by the running program.
|
||||
*
|
||||
* This is a sized struct. The callback must only access fields present in the
|
||||
* size reported by `size`.
|
||||
*
|
||||
* @ingroup terminal
|
||||
*/
|
||||
typedef struct {
|
||||
/** Size of this struct in bytes. */
|
||||
size_t size;
|
||||
|
||||
/** Literal progress state reported by the running program. */
|
||||
GhosttyTerminalProgressState state;
|
||||
|
||||
/** Progress percentage from 0 through 100, or -1 when omitted. */
|
||||
int8_t progress;
|
||||
} GhosttyTerminalProgressReport;
|
||||
|
||||
/**
|
||||
* Callback function type for progress reports.
|
||||
*
|
||||
* Called synchronously when the terminal receives OSC 9;4.
|
||||
*
|
||||
* @param terminal The terminal handle
|
||||
* @param userdata The userdata pointer set via GHOSTTY_TERMINAL_OPT_USERDATA
|
||||
* @param report Borrowed progress report
|
||||
*
|
||||
* @ingroup terminal
|
||||
*/
|
||||
typedef void (*GhosttyTerminalProgressReportFn)(
|
||||
GhosttyTerminal terminal,
|
||||
void* userdata,
|
||||
const GhosttyTerminalProgressReport* report);
|
||||
|
||||
/**
|
||||
* Callback function type for color scheme queries (CSI ? 996 n).
|
||||
*
|
||||
@@ -960,6 +1019,14 @@ typedef enum GHOSTTY_ENUM_TYPED {
|
||||
* Input type: GhosttyTerminalDesktopNotificationFn
|
||||
*/
|
||||
GHOSTTY_TERMINAL_OPT_DESKTOP_NOTIFICATION = 29,
|
||||
|
||||
/**
|
||||
* Callback invoked when the running program reports progress via OSC 9;4.
|
||||
* Set to NULL to ignore progress reports.
|
||||
*
|
||||
* Input type: GhosttyTerminalProgressReportFn
|
||||
*/
|
||||
GHOSTTY_TERMINAL_OPT_PROGRESS_REPORT = 30,
|
||||
GHOSTTY_TERMINAL_OPT_MAX_VALUE = GHOSTTY_ENUM_MAX_VALUE,
|
||||
} GhosttyTerminalOption;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user