Debian Codegraph @

src/shared/ptyfwd.h

raw
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3
4 #include "shared-forward.h"
5
6 typedef struct PTYForward PTYForward;
7
8 typedef enum PTYForwardFlags {
9 /* Only output to STDOUT, never try to read from STDIN */
10 PTY_FORWARD_READ_ONLY = 1 << 0,
11
12 /* Continue reading after hangup? */
13 PTY_FORWARD_IGNORE_VHANGUP = 1 << 1,
14
15 /* Continue reading after hangup but only if we never read anything else? */
16 PTY_FORWARD_IGNORE_INITIAL_VHANGUP = 1 << 2,
17
18 /* Don't tint the background, or set window title */
19 PTY_FORWARD_DUMB_TERMINAL = 1 << 3,
20
21 /* Don't interpret escape sequences (^] exit, hotkeys), just forward everything as-is */
22 PTY_FORWARD_TRANSPARENT = 1 << 4,
23 } PTYForwardFlags;
24
25 typedef int (*PTYForwardHangupHandler)(PTYForward *f, int rcode, void *userdata);
26 typedef int (*PTYForwardHotkeyHandler)(PTYForward *f, char key, void *userdata);
27
28 #define N_PTY_FORWARD_SIGNALS 7
29 extern const int pty_forward_signals[N_PTY_FORWARD_SIGNALS];
30
31 int pty_forward_new(sd_event *event, int master, PTYForwardFlags flags, PTYForward **ret);
32 PTYForward* pty_forward_free(PTYForward *f);
33
34 int pty_forward_honor_vhangup(PTYForward *f);
35 bool pty_forward_vhangup_honored(const PTYForward *f);
36
37 void pty_forward_set_hangup_handler(PTYForward *f, PTYForwardHangupHandler cb, void *userdata);
38 void pty_forward_set_hotkey_handler(PTYForward *f, PTYForwardHotkeyHandler cb, void *userdata);
39
40 int pty_forward_drain(PTYForward *f);
41
42 int pty_forward_set_priority(PTYForward *f, int64_t priority);
43
44 int pty_forward_set_width_height(PTYForward *f, unsigned width, unsigned height);
45
46 int pty_forward_set_background_color(PTYForward *f, const char *color);
47
48 int pty_forward_set_title(PTYForward *f, const char *title);
49 int pty_forward_set_titlef(PTYForward *f, const char *format, ...) _printf_(2,3);
50
51 int pty_forward_set_title_prefix(PTYForward *f, const char *prefix);
52
53 bool shall_set_terminal_title(void);
54
55 int pty_forward_set_window_title(
56 PTYForward *f,
57 Glyph circle, /* e.g. GLYPH_GREEN_CIRCLE */
58 const char *hostname, /* Can be NULL, and obtained by gethostname_strict() in that case. */
59 char * const *msg);
60
61 DEFINE_TRIVIAL_CLEANUP_FUNC(PTYForward*, pty_forward_free);