2019-06-15 22:22:44 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
|
2019-06-19 10:04:47 +02:00
|
|
|
#include <threads.h>
|
|
|
|
|
|
2019-07-05 10:16:56 +02:00
|
|
|
#include <cairo.h>
|
2019-06-19 10:04:47 +02:00
|
|
|
#include <xkbcommon/xkbcommon.h>
|
|
|
|
|
#include <xkbcommon/xkbcommon-keysyms.h>
|
|
|
|
|
|
2019-06-19 14:17:43 +02:00
|
|
|
#include "tllist.h"
|
|
|
|
|
|
2019-07-05 10:16:56 +02:00
|
|
|
struct wayland {
|
|
|
|
|
struct wl_display *display;
|
|
|
|
|
struct wl_registry *registry;
|
|
|
|
|
struct wl_compositor *compositor;
|
|
|
|
|
struct wl_surface *surface;
|
|
|
|
|
struct wl_shm *shm;
|
|
|
|
|
struct wl_seat *seat;
|
|
|
|
|
struct wl_keyboard *keyboard;
|
2019-07-05 10:44:09 +02:00
|
|
|
struct {
|
|
|
|
|
struct wl_pointer *pointer;
|
|
|
|
|
uint32_t serial;
|
|
|
|
|
|
|
|
|
|
struct wl_surface *surface;
|
|
|
|
|
struct wl_cursor_theme *theme;
|
|
|
|
|
struct wl_cursor *cursor;
|
|
|
|
|
} pointer;
|
2019-07-05 10:16:56 +02:00
|
|
|
struct xdg_wm_base *shell;
|
|
|
|
|
struct xdg_surface *xdg_surface;
|
|
|
|
|
struct xdg_toplevel *xdg_toplevel;
|
|
|
|
|
};
|
|
|
|
|
|
2019-06-26 20:33:32 +02:00
|
|
|
struct rgba { double r, g, b, a; };
|
|
|
|
|
|
2019-06-16 16:44:42 +02:00
|
|
|
struct attributes {
|
|
|
|
|
bool bold;
|
|
|
|
|
bool italic;
|
|
|
|
|
bool underline;
|
|
|
|
|
bool strikethrough;
|
|
|
|
|
bool blink;
|
|
|
|
|
bool conceal;
|
|
|
|
|
bool reverse;
|
2019-06-26 19:44:31 +02:00
|
|
|
bool have_foreground;
|
|
|
|
|
bool have_background;
|
2019-06-26 20:33:32 +02:00
|
|
|
struct rgba foreground; /* Only valid when have_foreground == true */
|
|
|
|
|
struct rgba background; /* Only valid when have_background == true */
|
2019-06-16 16:44:42 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct cell {
|
|
|
|
|
char c[5];
|
|
|
|
|
struct attributes attrs;
|
2019-06-15 22:22:44 +02:00
|
|
|
};
|
|
|
|
|
|
2019-06-25 20:11:08 +02:00
|
|
|
struct scroll_region {
|
|
|
|
|
int start;
|
|
|
|
|
int end;
|
|
|
|
|
};
|
|
|
|
|
|
2019-06-29 21:15:32 +02:00
|
|
|
struct cursor {
|
|
|
|
|
int row;
|
|
|
|
|
int col;
|
|
|
|
|
int linear;
|
|
|
|
|
};
|
|
|
|
|
|
2019-06-25 20:11:08 +02:00
|
|
|
enum damage_type {DAMAGE_UPDATE, DAMAGE_ERASE, DAMAGE_SCROLL, DAMAGE_SCROLL_REVERSE};
|
2019-06-19 14:17:43 +02:00
|
|
|
struct damage {
|
|
|
|
|
enum damage_type type;
|
|
|
|
|
union {
|
2019-06-21 14:29:15 +02:00
|
|
|
/* DAMAGE_UPDATE, DAMAGE_ERASE */
|
2019-06-19 14:17:43 +02:00
|
|
|
struct {
|
|
|
|
|
int start;
|
|
|
|
|
int length;
|
2019-06-21 14:29:15 +02:00
|
|
|
} range;
|
|
|
|
|
|
2019-06-23 17:16:52 +02:00
|
|
|
/* DAMAGE_SCROLL, DAMAGE_SCROLL_REVERSE */
|
2019-06-21 14:29:15 +02:00
|
|
|
struct {
|
2019-06-25 20:11:08 +02:00
|
|
|
struct scroll_region region;
|
2019-06-21 14:29:15 +02:00
|
|
|
int lines;
|
|
|
|
|
} scroll;
|
2019-06-19 14:17:43 +02:00
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2019-06-15 22:22:44 +02:00
|
|
|
struct grid {
|
2019-07-01 12:23:38 +02:00
|
|
|
int size;
|
|
|
|
|
int offset;
|
2019-06-29 21:23:36 +02:00
|
|
|
|
2019-06-15 22:22:44 +02:00
|
|
|
struct cell *cells;
|
2019-07-02 22:18:25 +02:00
|
|
|
struct cell *cur_line;
|
2019-06-15 22:22:44 +02:00
|
|
|
|
2019-06-19 14:17:43 +02:00
|
|
|
tll(struct damage) damage;
|
2019-06-25 20:11:08 +02:00
|
|
|
tll(struct damage) scroll_damage;
|
2019-06-15 22:22:44 +02:00
|
|
|
};
|
|
|
|
|
|
2019-06-23 14:12:20 +02:00
|
|
|
struct vt_subparams {
|
|
|
|
|
unsigned value[16];
|
2019-07-05 09:46:48 +02:00
|
|
|
size_t idx;
|
2019-06-23 14:12:20 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct vt_param {
|
|
|
|
|
unsigned value;
|
|
|
|
|
struct vt_subparams sub;
|
|
|
|
|
};
|
|
|
|
|
|
2019-06-15 22:22:44 +02:00
|
|
|
struct vt {
|
|
|
|
|
int state; /* enum state */
|
|
|
|
|
struct {
|
2019-06-23 14:12:20 +02:00
|
|
|
struct vt_param v[16];
|
2019-07-05 09:46:48 +02:00
|
|
|
size_t idx;
|
2019-06-15 22:22:44 +02:00
|
|
|
} params;
|
|
|
|
|
struct {
|
|
|
|
|
uint8_t data[2];
|
2019-07-05 09:46:48 +02:00
|
|
|
size_t idx;
|
2019-06-15 22:22:44 +02:00
|
|
|
} intermediates;
|
|
|
|
|
struct {
|
|
|
|
|
uint8_t data[1024];
|
2019-07-05 09:46:48 +02:00
|
|
|
size_t idx;
|
2019-06-15 22:22:44 +02:00
|
|
|
} osc;
|
|
|
|
|
struct {
|
|
|
|
|
uint8_t data[4];
|
2019-07-05 09:46:48 +02:00
|
|
|
size_t idx;
|
|
|
|
|
size_t left;
|
2019-06-15 22:22:44 +02:00
|
|
|
} utf8;
|
2019-06-16 16:44:42 +02:00
|
|
|
struct attributes attrs;
|
2019-07-04 19:23:25 +02:00
|
|
|
struct attributes saved_attrs;
|
2019-06-15 22:22:44 +02:00
|
|
|
bool dim;
|
|
|
|
|
};
|
|
|
|
|
|
2019-06-19 10:04:47 +02:00
|
|
|
struct kbd {
|
|
|
|
|
struct xkb_context *xkb;
|
|
|
|
|
struct xkb_keymap *xkb_keymap;
|
|
|
|
|
struct xkb_state *xkb_state;
|
|
|
|
|
struct {
|
|
|
|
|
mtx_t mutex;
|
|
|
|
|
cnd_t cond;
|
|
|
|
|
int trigger;
|
|
|
|
|
int pipe_read_fd;
|
|
|
|
|
int pipe_write_fd;
|
|
|
|
|
enum {REPEAT_STOP, REPEAT_START, REPEAT_EXIT} cmd;
|
|
|
|
|
|
|
|
|
|
bool dont_re_repeat;
|
|
|
|
|
int32_t delay;
|
|
|
|
|
int32_t rate;
|
|
|
|
|
uint32_t key;
|
|
|
|
|
} repeat;
|
|
|
|
|
};
|
|
|
|
|
|
2019-06-23 14:12:20 +02:00
|
|
|
enum decckm { DECCKM_CSI, DECCKM_SS3 };
|
|
|
|
|
enum keypad_mode { KEYPAD_NUMERICAL, KEYPAD_APPLICATION };
|
2019-07-04 19:17:18 +02:00
|
|
|
enum charset { CHARSET_ASCII, CHARSET_GRAPHIC };
|
2019-06-23 14:12:20 +02:00
|
|
|
|
2019-06-15 22:22:44 +02:00
|
|
|
struct terminal {
|
2019-06-19 10:04:47 +02:00
|
|
|
pid_t slave;
|
2019-06-17 18:57:12 +02:00
|
|
|
int ptmx;
|
2019-07-05 10:16:56 +02:00
|
|
|
bool quit;
|
2019-06-29 21:03:28 +02:00
|
|
|
|
2019-06-23 14:12:20 +02:00
|
|
|
enum decckm decckm;
|
|
|
|
|
enum keypad_mode keypad_mode;
|
2019-07-03 21:16:41 +02:00
|
|
|
bool hide_cursor;
|
|
|
|
|
bool auto_margin;
|
|
|
|
|
bool insert_mode;
|
2019-06-22 22:25:50 +02:00
|
|
|
bool bracketed_paste;
|
2019-06-29 21:03:28 +02:00
|
|
|
|
2019-07-04 19:17:18 +02:00
|
|
|
int selected_charset;
|
|
|
|
|
enum charset charset[4]; /* G0-G3 */
|
|
|
|
|
|
2019-06-15 22:22:44 +02:00
|
|
|
struct vt vt;
|
2019-06-19 10:04:47 +02:00
|
|
|
struct kbd kbd;
|
2019-06-29 21:08:08 +02:00
|
|
|
|
2019-07-05 10:16:56 +02:00
|
|
|
int width; /* pixels */
|
|
|
|
|
int height; /* pixels */
|
|
|
|
|
int cols; /* number of columns */
|
|
|
|
|
int rows; /* number of rows */
|
|
|
|
|
int cell_width; /* pixels per cell, x-wise */
|
|
|
|
|
int cell_height; /* pixels per cell, y-wise */
|
2019-06-29 21:08:08 +02:00
|
|
|
|
2019-06-29 21:16:06 +02:00
|
|
|
bool print_needs_wrap;
|
2019-06-29 21:08:08 +02:00
|
|
|
struct scroll_region scroll_region;
|
|
|
|
|
|
2019-06-29 21:09:58 +02:00
|
|
|
struct rgba foreground;
|
|
|
|
|
struct rgba background;
|
2019-06-29 21:15:32 +02:00
|
|
|
|
2019-07-05 10:44:57 +02:00
|
|
|
struct {
|
|
|
|
|
int x;
|
|
|
|
|
int y;
|
|
|
|
|
} mouse;
|
|
|
|
|
|
2019-06-29 21:15:32 +02:00
|
|
|
struct cursor cursor;
|
|
|
|
|
struct cursor saved_cursor;
|
|
|
|
|
struct cursor alt_saved_cursor;
|
2019-06-29 21:23:36 +02:00
|
|
|
|
|
|
|
|
struct grid normal;
|
|
|
|
|
struct grid alt;
|
|
|
|
|
struct grid *grid;
|
2019-07-05 10:16:56 +02:00
|
|
|
|
|
|
|
|
cairo_scaled_font_t *fonts[4];
|
|
|
|
|
cairo_font_extents_t fextents;
|
|
|
|
|
|
|
|
|
|
struct wayland wl;
|
|
|
|
|
bool frame_is_scheduled;
|
2019-06-15 22:22:44 +02:00
|
|
|
};
|
2019-06-29 21:03:28 +02:00
|
|
|
|
|
|
|
|
void term_damage_all(struct terminal *term);
|
|
|
|
|
void term_damage_update(struct terminal *term, int start, int length);
|
|
|
|
|
void term_damage_erase(struct terminal *term, int start, int length);
|
|
|
|
|
void term_damage_scroll(
|
|
|
|
|
struct terminal *term, enum damage_type damage_type,
|
|
|
|
|
struct scroll_region region, int lines);
|
|
|
|
|
|
|
|
|
|
void term_erase(struct terminal *term, int start, int end);
|
|
|
|
|
|
|
|
|
|
void term_cursor_to(struct terminal *term, int row, int col);
|
|
|
|
|
void term_cursor_left(struct terminal *term, int count);
|
|
|
|
|
void term_cursor_right(struct terminal *term, int count);
|
|
|
|
|
void term_cursor_up(struct terminal *term, int count);
|
|
|
|
|
void term_cursor_down(struct terminal *term, int count);
|
|
|
|
|
|
|
|
|
|
void term_scroll(struct terminal *term, int rows);
|
|
|
|
|
void term_scroll_reverse(struct terminal *term, int rows);
|
|
|
|
|
|
|
|
|
|
void term_scroll_partial(
|
|
|
|
|
struct terminal *term, struct scroll_region region, int rows);
|
|
|
|
|
void term_scroll_reverse_partial(
|
|
|
|
|
struct terminal *term, struct scroll_region region, int rows);
|
|
|
|
|
|
|
|
|
|
int term_cursor_linear(const struct terminal *term, int row, int col);
|