-
Notifications
You must be signed in to change notification settings - Fork 15
/
zterm.h
136 lines (116 loc) · 3.39 KB
/
zterm.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#ifndef _ZTERM_H
#define _ZTERM_H
#define _GNU_SOURCE
#include <string.h>
#include <stdio.h>
#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <gio/gio.h>
#include <vte/vte.h>
#define MAX_WINDOWS 8
#define MAX_COLOR_SCHEMES 8
typedef enum bind_actions {
BIND_ACT_SWITCH = 0,
BIND_ACT_CUT,
BIND_ACT_CUT_HTML,
BIND_ACT_PASTE,
BIND_ACT_MENU,
BIND_ACT_NEXT_TERM,
BIND_ACT_PREV_TERM,
BIND_ACT_OPEN_URI,
BIND_ACT_CUT_URI,
} bind_actions_t;
typedef struct bind_s {
guint state;
guint key_min, key_max;
guint base;
struct bind_s *next;
char *cmd;
char **argv;
char **env;
bind_actions_t action;
} bind_t;
typedef struct {
char *cmd;
char **argv;
char **env;
} exec_t;
typedef struct bind_button_s {
guint state;
guint button;
struct bind_button_s *next;
bind_actions_t action;
} bind_button_t;
typedef struct color_scheme_s {
GdkRGBA foreground;
GdkRGBA background;
char name[32];
char action[32];
} color_scheme_t;
typedef struct window_s {
GtkNotebook *notebook;
GtkWidget *window;
GtkWidget *menu;
GMenuModel *menu_model;
GtkEventController *key_controller;
int color_scheme;
double menu_x, menu_y; // Where the mouse cursor was when we opened the menu.
char *menu_hyperlink_uri;
} window_t;
typedef struct terms_s {
struct {
int spawned;
int moving;
int window;
char *cmd;
char **argv; // NULL terminated, only evaluated if cmd is NULL.
char **env; // If this term has a unique environment.
char *hyperlink_uri;
GtkWidget *term;
} *active;
gint n_active; // Total number of configured terms.
gint alive; // Total number of 'alive' terms.
char **envp;
/* Configuration options. */
bind_t *keys;
bind_button_t *buttons;
char *font;
gboolean audible_bell;
char word_char_exceptions[64];
gdouble font_scale;
gboolean scroll_on_output;
gboolean scroll_on_keystroke;
gboolean rewrap_on_resize;
glong scrollback_lines;
gboolean allow_bold;
gboolean bold_is_bright;
gboolean mouse_autohide;
color_scheme_t color_schemes[MAX_COLOR_SCHEMES];
} terms_t;
extern GdkRGBA colors[256];
extern terms_t terms;
extern window_t windows[MAX_WINDOWS];
extern GtkApplication *app;
extern int start_width;
extern int start_height;
extern unsigned int bind_mask;
int _fprintf(bool print, FILE *io, const char *fmt, ...);
#define errorf(format, ...) _fprintf(true, stderr, "ERROR: %s %d (%s): " format "\n", __FILE__, __LINE__, __func__ __VA_OPT__(,) __VA_ARGS__)
#define infof(format, ...) _fprintf(true, stderr, "Info: %s %d (%s): " format "\n", __FILE__, __LINE__, __func__ __VA_OPT__(,) __VA_ARGS__)
#if DEBUG
#define FUNC_DEBUG true
#define debugf(format, ...) _fprintf(FUNC_DEBUG, stderr, "Debug: %s %d (%s): " format "\n", __FILE__, __LINE__, __func__ __VA_OPT__(,) __VA_ARGS__)
#else
#define debugf(format, ...) _fnullf(stderr, "Debug: %s %d (%s): " format "\n", __FILE__, __LINE__, __func__ __VA_OPT__(,) __VA_ARGS__)
#endif
int _fnullf(FILE *io, const char *fmt, ...);
void do_copy (GSimpleAction *self, GVariant *parameter, gpointer user_data);
bool term_find (GtkWidget *term, int *i);
void term_set_window (int n, int window_i);
void term_switch (long n, char *cmd, char **argv, char **env, int window_i);
void temu_parse_config (void);
void term_config (GtkWidget *term, int window_i);
gboolean process_uri(int64_t term_n, window_t *window, bind_actions_t action, double x, double y, bool menu);
void rebuild_menus(void);
#endif // _ZTERM_H
// vim: set ts=4 sw=4 noexpandtab :