2019-06-15 22:22:44 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
#include <stddef.h>
|
2019-08-02 18:19:07 +02:00
|
|
|
#include <wchar.h>
|
2019-06-15 22:22:44 +02:00
|
|
|
|
2019-06-19 10:04:47 +02:00
|
|
|
#include <threads.h>
|
2019-07-29 20:13:26 +02:00
|
|
|
#include <semaphore.h>
|
2019-06-19 10:04:47 +02:00
|
|
|
|
2019-12-01 13:43:51 +01:00
|
|
|
#include <tllist.h>
|
2019-12-01 14:03:24 +01:00
|
|
|
#include <fcft/fcft.h>
|
2019-12-01 13:43:51 +01:00
|
|
|
|
2019-10-28 18:25:19 +01:00
|
|
|
//#include "config.h"
|
|
|
|
|
#include "fdm.h"
|
2020-05-21 20:17:29 +02:00
|
|
|
#include "reaper.h"
|
2019-10-27 13:06:39 +01:00
|
|
|
#include "wayland.h"
|
2019-06-19 14:17:43 +02:00
|
|
|
|
2019-07-06 13:25:36 +02:00
|
|
|
#define likely(c) __builtin_expect(!!(c), 1)
|
|
|
|
|
#define unlikely(c) __builtin_expect(!!(c), 0)
|
|
|
|
|
|
2019-07-16 13:19:17 +02:00
|
|
|
struct rgb { float r, g, b; };
|
2019-06-26 20:33:32 +02:00
|
|
|
|
2019-07-10 18:48:46 +02:00
|
|
|
/*
|
|
|
|
|
* Note: we want the cells to be as small as possible. Larger cells
|
|
|
|
|
* means fewer scrollback lines (or performance drops due to cache
|
2019-08-02 18:19:07 +02:00
|
|
|
* misses)
|
|
|
|
|
*
|
|
|
|
|
* Note that the members are laid out optimized for x86
|
|
|
|
|
*/
|
2019-06-16 16:44:42 +02:00
|
|
|
struct attributes {
|
2019-08-02 18:19:07 +02:00
|
|
|
uint32_t bold:1;
|
|
|
|
|
uint32_t dim:1;
|
|
|
|
|
uint32_t italic:1;
|
|
|
|
|
uint32_t underline:1;
|
|
|
|
|
uint32_t strikethrough:1;
|
|
|
|
|
uint32_t blink:1;
|
|
|
|
|
uint32_t conceal:1;
|
|
|
|
|
uint32_t reverse:1;
|
|
|
|
|
uint32_t fg:24;
|
2019-07-10 18:48:46 +02:00
|
|
|
|
2019-07-30 18:03:03 +02:00
|
|
|
uint32_t clean:1;
|
2019-08-02 18:19:07 +02:00
|
|
|
uint32_t have_fg:1;
|
|
|
|
|
uint32_t have_bg:1;
|
2020-01-06 11:56:18 +01:00
|
|
|
uint32_t selected:2;
|
2020-02-14 22:39:26 +01:00
|
|
|
uint32_t reserved:3;
|
2019-08-02 18:19:07 +02:00
|
|
|
uint32_t bg:24;
|
|
|
|
|
};
|
|
|
|
|
static_assert(sizeof(struct attributes) == 8, "bad size");
|
2019-06-16 16:44:42 +02:00
|
|
|
|
|
|
|
|
struct cell {
|
2019-08-02 18:19:07 +02:00
|
|
|
wchar_t wc;
|
2019-06-16 16:44:42 +02:00
|
|
|
struct attributes attrs;
|
2019-08-02 18:19:07 +02:00
|
|
|
};
|
|
|
|
|
static_assert(sizeof(struct cell) == 12, "bad size");
|
2019-06-15 22:22:44 +02:00
|
|
|
|
2019-06-25 20:11:08 +02:00
|
|
|
struct scroll_region {
|
|
|
|
|
int start;
|
|
|
|
|
int end;
|
|
|
|
|
};
|
|
|
|
|
|
2019-07-08 13:57:31 +02:00
|
|
|
struct coord {
|
2019-06-29 21:15:32 +02:00
|
|
|
int col;
|
2019-07-08 13:57:31 +02:00
|
|
|
int row;
|
2019-06-29 21:15:32 +02:00
|
|
|
};
|
|
|
|
|
|
2019-11-17 09:44:31 +01:00
|
|
|
struct cursor {
|
|
|
|
|
struct coord point;
|
2019-11-17 09:46:20 +01:00
|
|
|
bool lcf;
|
2019-11-17 09:44:31 +01:00
|
|
|
};
|
|
|
|
|
|
2019-10-29 21:09:37 +01:00
|
|
|
enum damage_type {DAMAGE_SCROLL, DAMAGE_SCROLL_REVERSE,
|
|
|
|
|
DAMAGE_SCROLL_IN_VIEW, DAMAGE_SCROLL_REVERSE_IN_VIEW};
|
|
|
|
|
|
2019-06-19 14:17:43 +02:00
|
|
|
struct damage {
|
|
|
|
|
enum damage_type type;
|
2020-04-26 12:47:19 +02:00
|
|
|
struct scroll_region region;
|
|
|
|
|
int lines;
|
2019-06-19 14:17:43 +02:00
|
|
|
};
|
|
|
|
|
|
unicode-combining: store seen combining chains "globally" in the term struct
Instead of storing combining data per cell, realize that most
combinations are re-occurring and that there's lots of available space
left in the unicode range, and store seen base+combining combinations
chains in a per-terminal array.
When we encounter a combining character, we first try to pre-compose,
like before. If that fails, we then search for the current
base+combining combo in the list of previously seen combinations. If
not found there either, we allocate a new combo and add it to the
list. Regardless, the result is an index into this array. We store
this index, offsetted by COMB_CHARS_LO=0x40000000ul in the cell.
When rendering, we need to check if the cell character is a plain
character, or if it's a composed character (identified by checking if
the cell character is >= COMB_CHARS_LO).
Then we render the grapheme pretty much like before.
2020-05-03 11:03:22 +02:00
|
|
|
struct composed {
|
|
|
|
|
wchar_t base;
|
|
|
|
|
wchar_t combining[5];
|
2020-05-01 11:49:11 +02:00
|
|
|
uint8_t count;
|
unicode-combining: store seen combining chains "globally" in the term struct
Instead of storing combining data per cell, realize that most
combinations are re-occurring and that there's lots of available space
left in the unicode range, and store seen base+combining combinations
chains in a per-terminal array.
When we encounter a combining character, we first try to pre-compose,
like before. If that fails, we then search for the current
base+combining combo in the list of previously seen combinations. If
not found there either, we allocate a new combo and add it to the
list. Regardless, the result is an index into this array. We store
this index, offsetted by COMB_CHARS_LO=0x40000000ul in the cell.
When rendering, we need to check if the cell character is a plain
character, or if it's a composed character (identified by checking if
the cell character is >= COMB_CHARS_LO).
Then we render the grapheme pretty much like before.
2020-05-03 11:03:22 +02:00
|
|
|
};
|
2020-05-01 11:49:11 +02:00
|
|
|
|
2019-07-08 13:57:31 +02:00
|
|
|
struct row {
|
|
|
|
|
struct cell *cells;
|
|
|
|
|
bool dirty;
|
2020-02-14 22:39:26 +01:00
|
|
|
bool linebreak;
|
2019-07-08 13:57:31 +02:00
|
|
|
};
|
|
|
|
|
|
2020-03-13 18:44:23 +01:00
|
|
|
struct sixel {
|
|
|
|
|
void *data;
|
|
|
|
|
pixman_image_t *pix;
|
|
|
|
|
int width;
|
|
|
|
|
int height;
|
|
|
|
|
int rows;
|
2020-06-06 13:59:46 +02:00
|
|
|
int cols;
|
2020-03-13 18:44:23 +01:00
|
|
|
struct coord pos;
|
|
|
|
|
};
|
|
|
|
|
|
2019-06-15 22:22:44 +02:00
|
|
|
struct grid {
|
2019-07-08 13:57:31 +02:00
|
|
|
int num_rows;
|
2019-07-10 16:27:55 +02:00
|
|
|
int num_cols;
|
2019-07-01 12:23:38 +02:00
|
|
|
int offset;
|
2019-07-09 16:26:36 +02:00
|
|
|
int view;
|
2019-06-29 21:23:36 +02:00
|
|
|
|
2020-04-16 18:51:14 +02:00
|
|
|
struct cursor cursor;
|
|
|
|
|
struct cursor saved_cursor;
|
|
|
|
|
|
2019-07-08 13:57:31 +02:00
|
|
|
struct row **rows;
|
|
|
|
|
struct row *cur_row;
|
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;
|
2020-03-13 18:44:23 +01:00
|
|
|
tll(struct sixel) sixel_images;
|
2019-06-15 22:22:44 +02:00
|
|
|
};
|
|
|
|
|
|
2019-06-23 14:12:20 +02:00
|
|
|
struct vt_subparams {
|
|
|
|
|
unsigned value[16];
|
2020-02-01 19:24:46 +01:00
|
|
|
uint8_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 */
|
2020-01-20 18:37:20 +01:00
|
|
|
wchar_t last_printed;
|
2019-06-15 22:22:44 +02:00
|
|
|
struct {
|
2019-06-23 14:12:20 +02:00
|
|
|
struct vt_param v[16];
|
2020-02-01 19:24:46 +01:00
|
|
|
uint8_t idx;
|
2019-06-15 22:22:44 +02:00
|
|
|
} params;
|
2019-07-19 09:56:59 +02:00
|
|
|
char private[2];
|
2019-06-15 22:22:44 +02:00
|
|
|
struct {
|
2019-07-19 08:59:35 +02:00
|
|
|
uint8_t *data;
|
|
|
|
|
size_t size;
|
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];
|
2020-02-01 19:24:46 +01:00
|
|
|
uint8_t idx;
|
2019-06-15 22:22:44 +02:00
|
|
|
} utf8;
|
2020-01-12 11:55:22 +01:00
|
|
|
struct {
|
|
|
|
|
uint8_t *data;
|
|
|
|
|
size_t size;
|
|
|
|
|
size_t idx;
|
2020-02-21 21:53:23 +01:00
|
|
|
void (*put_handler)(struct terminal *term, uint8_t c);
|
2020-01-12 11:55:22 +01:00
|
|
|
void (*unhook_handler)(struct terminal *term);
|
|
|
|
|
} dcs;
|
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
|
|
|
};
|
|
|
|
|
|
2019-11-05 13:27:37 +01:00
|
|
|
enum cursor_origin { ORIGIN_ABSOLUTE, ORIGIN_RELATIVE };
|
|
|
|
|
enum cursor_keys { CURSOR_KEYS_DONTCARE, CURSOR_KEYS_NORMAL, CURSOR_KEYS_APPLICATION };
|
2019-07-09 11:07:06 +02:00
|
|
|
enum keypad_keys { KEYPAD_DONTCARE, 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-11-17 10:00:30 +01:00
|
|
|
struct charsets {
|
|
|
|
|
int selected;
|
|
|
|
|
enum charset set[4]; /* G0-G3 */
|
|
|
|
|
};
|
|
|
|
|
|
2019-07-05 14:24:51 +02:00
|
|
|
/* *What* to report */
|
|
|
|
|
enum mouse_tracking {
|
|
|
|
|
MOUSE_NONE,
|
|
|
|
|
MOUSE_X10, /* ?9h */
|
2019-11-29 22:30:56 +01:00
|
|
|
MOUSE_CLICK, /* ?1000h - report mouse clicks */
|
2019-07-05 14:24:51 +02:00
|
|
|
MOUSE_DRAG, /* ?1002h - report clicks and drag motions */
|
2019-11-29 22:30:56 +01:00
|
|
|
MOUSE_MOTION, /* ?1003h - report clicks and motion */
|
2019-07-05 14:24:51 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* *How* to report */
|
|
|
|
|
enum mouse_reporting {
|
|
|
|
|
MOUSE_NORMAL,
|
|
|
|
|
MOUSE_UTF8, /* ?1005h */
|
|
|
|
|
MOUSE_SGR, /* ?1006h */
|
|
|
|
|
MOUSE_URXVT, /* ?1015h */
|
|
|
|
|
};
|
|
|
|
|
|
2019-07-22 20:15:14 +02:00
|
|
|
enum cursor_style { CURSOR_BLOCK, CURSOR_UNDERLINE, CURSOR_BAR };
|
|
|
|
|
|
2020-01-04 12:09:09 +01:00
|
|
|
enum selection_kind { SELECTION_NONE, SELECTION_NORMAL, SELECTION_BLOCK };
|
2020-01-03 23:29:45 +01:00
|
|
|
|
2019-11-03 01:03:52 +01:00
|
|
|
struct ptmx_buffer {
|
|
|
|
|
void *data;
|
|
|
|
|
size_t len;
|
|
|
|
|
size_t idx;
|
|
|
|
|
};
|
|
|
|
|
|
2020-02-24 22:38:35 +01:00
|
|
|
enum term_surface {
|
|
|
|
|
TERM_SURF_NONE,
|
|
|
|
|
TERM_SURF_GRID,
|
|
|
|
|
TERM_SURF_SEARCH,
|
|
|
|
|
TERM_SURF_TITLE,
|
|
|
|
|
TERM_SURF_BORDER_LEFT,
|
|
|
|
|
TERM_SURF_BORDER_RIGHT,
|
|
|
|
|
TERM_SURF_BORDER_TOP,
|
|
|
|
|
TERM_SURF_BORDER_BOTTOM,
|
2020-03-02 20:29:28 +01:00
|
|
|
TERM_SURF_BUTTON_MINIMIZE,
|
|
|
|
|
TERM_SURF_BUTTON_MAXIMIZE,
|
|
|
|
|
TERM_SURF_BUTTON_CLOSE,
|
2020-02-24 22:38:35 +01:00
|
|
|
};
|
|
|
|
|
|
2019-06-15 22:22:44 +02:00
|
|
|
struct terminal {
|
2019-10-28 18:25:19 +01:00
|
|
|
struct fdm *fdm;
|
2020-05-21 20:17:29 +02:00
|
|
|
struct reaper *reaper;
|
2020-02-08 14:09:06 +01:00
|
|
|
const struct config *conf;
|
2019-10-28 18:25:19 +01:00
|
|
|
|
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
|
|
|
|
2020-02-08 14:09:06 +01:00
|
|
|
struct grid normal;
|
|
|
|
|
struct grid alt;
|
|
|
|
|
struct grid *grid;
|
|
|
|
|
|
unicode-combining: store seen combining chains "globally" in the term struct
Instead of storing combining data per cell, realize that most
combinations are re-occurring and that there's lots of available space
left in the unicode range, and store seen base+combining combinations
chains in a per-terminal array.
When we encounter a combining character, we first try to pre-compose,
like before. If that fails, we then search for the current
base+combining combo in the list of previously seen combinations. If
not found there either, we allocate a new combo and add it to the
list. Regardless, the result is an index into this array. We store
this index, offsetted by COMB_CHARS_LO=0x40000000ul in the cell.
When rendering, we need to check if the cell character is a plain
character, or if it's a composed character (identified by checking if
the cell character is >= COMB_CHARS_LO).
Then we render the grapheme pretty much like before.
2020-05-03 11:03:22 +02:00
|
|
|
#define COMB_CHARS_LO 0x40000000ul
|
2020-05-03 11:31:59 +02:00
|
|
|
#define COMB_CHARS_HI 0x400ffffful
|
unicode-combining: store seen combining chains "globally" in the term struct
Instead of storing combining data per cell, realize that most
combinations are re-occurring and that there's lots of available space
left in the unicode range, and store seen base+combining combinations
chains in a per-terminal array.
When we encounter a combining character, we first try to pre-compose,
like before. If that fails, we then search for the current
base+combining combo in the list of previously seen combinations. If
not found there either, we allocate a new combo and add it to the
list. Regardless, the result is an index into this array. We store
this index, offsetted by COMB_CHARS_LO=0x40000000ul in the cell.
When rendering, we need to check if the cell character is a plain
character, or if it's a composed character (identified by checking if
the cell character is >= COMB_CHARS_LO).
Then we render the grapheme pretty much like before.
2020-05-03 11:03:22 +02:00
|
|
|
size_t composed_count;
|
|
|
|
|
struct composed *composed;
|
|
|
|
|
|
2020-04-21 19:29:36 +02:00
|
|
|
struct fcft_font *fonts[4];
|
term: implement term_font_dpi_changed()
This function reloads the font *if* the DPI has changed. To handle
user run-time adjusted font sizes, we record the number of adjustments
made.
Then, when re-loading the font, we first load the font as specified in
the configuration. Then, we re-apply the size adjustment using
font_size_adjust().
Note that this means we end up loading the fonts twice; first using
the default size (but with adjusted DPI), and then again with the
adjusted size. This can probably be improved upon.
The existing font code has been refactored to avoid code
duplication. For example, term_init() now calls
term_font_dpi_changed() to load the initial fonts, instead of directly
instantiating them.
Finally, the way we calculate the DPI to use has changed: instead of
using the highest DPI of all available outputs, we use the highest DPI
of the output's we're actually mapped on. If we're not mapped at all,
we use the globally highest DPI.
Doing it this way means we usually only have to load the fonts
once. Otherwise, we'd end up using the default DPI of 96 when the
terminal is first instantiated (since it's not mapped at that time).
On a single monitor system, we'll use the globally highest DPI at
first, before being mapped. Then when we get mapped, we re-load the
fonts using the highest mapped DPI. But since they'll be the same,
we can skip actually reloading the fonts.
2020-02-15 19:08:14 +01:00
|
|
|
int font_dpi;
|
|
|
|
|
int font_adjustments;
|
2020-04-21 19:29:36 +02:00
|
|
|
enum fcft_subpixel font_subpixel;
|
2020-02-08 14:09:06 +01:00
|
|
|
|
2019-11-03 01:03:52 +01:00
|
|
|
tll(struct ptmx_buffer) ptmx_buffer;
|
|
|
|
|
|
2019-07-09 11:07:06 +02:00
|
|
|
enum cursor_keys cursor_keys_mode;
|
|
|
|
|
enum keypad_keys keypad_keys_mode;
|
2019-07-05 20:12:40 +02:00
|
|
|
bool reverse;
|
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-07-16 10:34:08 +02:00
|
|
|
bool focus_events;
|
2019-08-19 21:16:47 +02:00
|
|
|
bool alt_scrolling;
|
2019-07-05 14:24:51 +02:00
|
|
|
enum mouse_tracking mouse_tracking;
|
|
|
|
|
enum mouse_reporting mouse_reporting;
|
2019-06-29 21:03:28 +02:00
|
|
|
|
2019-11-17 10:00:30 +01:00
|
|
|
struct charsets charsets;
|
2019-11-17 10:02:46 +01:00
|
|
|
struct charsets saved_charsets; /* For save/restore cursor + attributes */
|
2019-11-17 09:59:12 +01:00
|
|
|
|
2019-07-21 17:35:53 +02:00
|
|
|
char *window_title;
|
2019-07-21 17:48:06 +02:00
|
|
|
tll(char *) window_title_stack;
|
2019-07-04 19:17:18 +02:00
|
|
|
|
2019-07-22 19:15:56 +02:00
|
|
|
struct {
|
|
|
|
|
bool active;
|
|
|
|
|
int fd;
|
|
|
|
|
} flash;
|
2019-07-21 19:14:19 +02:00
|
|
|
|
2019-07-22 19:17:57 +02:00
|
|
|
struct {
|
|
|
|
|
bool active;
|
|
|
|
|
enum { BLINK_ON, BLINK_OFF } state;
|
|
|
|
|
int fd;
|
|
|
|
|
} blink;
|
2019-07-21 20:11:20 +02:00
|
|
|
|
2019-06-15 22:22:44 +02:00
|
|
|
struct vt vt;
|
2019-06-29 21:08:08 +02:00
|
|
|
|
2019-08-12 21:22:38 +02:00
|
|
|
int scale;
|
2019-07-05 10:16:56 +02:00
|
|
|
int width; /* pixels */
|
|
|
|
|
int height; /* pixels */
|
2020-02-26 20:59:11 +01:00
|
|
|
int unmaximized_width; /* last unmaximized size, pixels */
|
|
|
|
|
int unmaximized_height; /* last unmaximized size, pixels */
|
2020-02-24 18:38:11 +01:00
|
|
|
struct {
|
|
|
|
|
int left;
|
|
|
|
|
int right;
|
|
|
|
|
int top;
|
|
|
|
|
int bottom;
|
|
|
|
|
} margins;
|
2019-07-05 10:16:56 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
struct scroll_region scroll_region;
|
|
|
|
|
|
2019-07-21 10:58:09 +02:00
|
|
|
struct {
|
|
|
|
|
uint32_t fg;
|
|
|
|
|
uint32_t bg;
|
2019-08-21 18:50:24 +02:00
|
|
|
uint32_t table[256];
|
2020-01-03 21:53:16 +01:00
|
|
|
uint16_t alpha;
|
2019-07-21 10:58:09 +02:00
|
|
|
|
|
|
|
|
uint32_t default_fg;
|
2019-07-21 11:06:28 +02:00
|
|
|
uint32_t default_bg;
|
2019-08-21 18:50:24 +02:00
|
|
|
uint32_t default_table[256];
|
2019-07-21 10:58:09 +02:00
|
|
|
} colors;
|
2019-06-29 21:15:32 +02:00
|
|
|
|
2019-11-05 13:27:37 +01:00
|
|
|
enum cursor_origin origin;
|
2019-07-22 20:19:27 +02:00
|
|
|
enum cursor_style default_cursor_style;
|
2019-07-22 20:15:14 +02:00
|
|
|
enum cursor_style cursor_style;
|
2019-12-15 15:07:56 +01:00
|
|
|
struct {
|
2019-12-16 21:31:40 +01:00
|
|
|
bool active;
|
2019-12-15 15:07:56 +01:00
|
|
|
enum { CURSOR_BLINK_ON, CURSOR_BLINK_OFF } state;
|
|
|
|
|
int fd;
|
|
|
|
|
} cursor_blink;
|
2019-07-23 18:54:58 +02:00
|
|
|
struct {
|
|
|
|
|
uint32_t text;
|
|
|
|
|
uint32_t cursor;
|
|
|
|
|
} default_cursor_color;
|
|
|
|
|
struct {
|
|
|
|
|
uint32_t text;
|
|
|
|
|
uint32_t cursor;
|
|
|
|
|
} cursor_color;
|
2019-11-28 19:35:47 +01:00
|
|
|
const char *xcursor;
|
2019-06-29 21:23:36 +02:00
|
|
|
|
2019-07-10 20:57:09 +02:00
|
|
|
struct {
|
2020-01-03 23:29:45 +01:00
|
|
|
enum selection_kind kind;
|
2019-07-10 20:57:09 +02:00
|
|
|
struct coord start;
|
|
|
|
|
struct coord end;
|
|
|
|
|
} selection;
|
|
|
|
|
|
2019-08-27 17:23:28 +02:00
|
|
|
bool is_searching;
|
|
|
|
|
struct {
|
|
|
|
|
wchar_t *buf;
|
|
|
|
|
size_t len;
|
|
|
|
|
size_t sz;
|
2019-08-29 21:02:35 +02:00
|
|
|
size_t cursor;
|
2019-08-30 20:15:12 +02:00
|
|
|
enum { SEARCH_BACKWARD, SEARCH_FORWARD} direction;
|
2019-08-27 19:33:19 +02:00
|
|
|
|
|
|
|
|
int original_view;
|
|
|
|
|
bool view_followed_offset;
|
|
|
|
|
struct coord match;
|
|
|
|
|
size_t match_len;
|
2019-08-27 17:23:28 +02:00
|
|
|
} search;
|
|
|
|
|
|
2020-01-20 18:38:50 +01:00
|
|
|
struct {
|
|
|
|
|
bool esc_prefix;
|
|
|
|
|
bool eight_bit;
|
|
|
|
|
} meta;
|
|
|
|
|
|
2019-11-16 10:54:21 +01:00
|
|
|
tll(int) tab_stops;
|
|
|
|
|
|
2019-10-27 18:51:14 +01:00
|
|
|
struct wayland *wl;
|
2019-10-27 19:08:48 +01:00
|
|
|
struct wl_window *window;
|
2020-01-02 16:06:35 +01:00
|
|
|
bool visual_focus;
|
2020-02-24 22:38:35 +01:00
|
|
|
enum term_surface active_surface;
|
2019-10-27 12:57:37 +01:00
|
|
|
|
2019-07-24 20:11:49 +02:00
|
|
|
struct {
|
2020-03-06 19:16:54 +01:00
|
|
|
/* Scheduled for rendering, as soon-as-possible */
|
|
|
|
|
struct {
|
|
|
|
|
bool grid;
|
|
|
|
|
bool csd;
|
|
|
|
|
bool search;
|
2020-03-25 18:23:55 +01:00
|
|
|
bool title;
|
2020-03-06 19:16:54 +01:00
|
|
|
} refresh;
|
|
|
|
|
|
|
|
|
|
/* Scheduled for rendering, in the next frame callback */
|
|
|
|
|
struct {
|
|
|
|
|
bool grid;
|
|
|
|
|
bool csd;
|
|
|
|
|
bool search;
|
2020-03-25 18:23:55 +01:00
|
|
|
bool title;
|
2020-03-06 19:16:54 +01:00
|
|
|
} pending;
|
|
|
|
|
|
2020-01-04 19:56:59 +01:00
|
|
|
int scrollback_lines; /* Number of scrollback lines, from conf (TODO: move out from render struct?) */
|
2019-07-24 20:21:41 +02:00
|
|
|
|
2020-01-12 12:40:42 +01:00
|
|
|
struct {
|
|
|
|
|
bool enabled;
|
|
|
|
|
int timer_fd;
|
2020-03-16 17:05:44 +01:00
|
|
|
bool flipped;
|
2020-01-12 12:55:19 +01:00
|
|
|
} app_sync_updates;
|
2020-01-12 12:40:42 +01:00
|
|
|
|
2020-01-04 19:56:59 +01:00
|
|
|
/* Render threads + synchronization primitives */
|
2019-07-29 20:13:26 +02:00
|
|
|
struct {
|
|
|
|
|
size_t count;
|
|
|
|
|
sem_t start;
|
|
|
|
|
sem_t done;
|
|
|
|
|
cnd_t cond;
|
|
|
|
|
mtx_t lock;
|
|
|
|
|
tll(int) queue;
|
|
|
|
|
thrd_t *threads;
|
|
|
|
|
struct buffer *buf;
|
|
|
|
|
} workers;
|
|
|
|
|
|
2019-07-24 20:21:41 +02:00
|
|
|
/* Last rendered cursor position */
|
|
|
|
|
struct {
|
|
|
|
|
struct coord actual; /* Absolute */
|
|
|
|
|
struct coord in_view; /* Offset by view */
|
2020-05-01 11:56:13 +02:00
|
|
|
struct row *row; /* Actual row TODO: remove */
|
2019-07-24 20:21:41 +02:00
|
|
|
} last_cursor;
|
|
|
|
|
|
2019-11-02 01:28:29 +01:00
|
|
|
struct buffer *last_buf; /* Buffer we rendered to last time */
|
2019-07-24 20:21:41 +02:00
|
|
|
bool was_flashing; /* Flash was active last time we rendered */
|
2019-08-27 17:23:28 +02:00
|
|
|
bool was_searching;
|
2019-12-31 15:39:40 +01:00
|
|
|
|
2020-01-05 15:25:24 +01:00
|
|
|
size_t search_glyph_offset;
|
2020-01-05 15:16:40 +01:00
|
|
|
|
2019-12-31 15:39:40 +01:00
|
|
|
bool presentation_timings;
|
|
|
|
|
struct timespec input_time;
|
2019-07-24 20:11:49 +02:00
|
|
|
} render;
|
2019-10-27 11:46:18 +01:00
|
|
|
|
|
|
|
|
/* Temporary: for FDM */
|
|
|
|
|
struct {
|
|
|
|
|
bool is_armed;
|
|
|
|
|
int lower_fd;
|
|
|
|
|
int upper_fd;
|
|
|
|
|
} delayed_render_timer;
|
2019-11-01 20:34:32 +01:00
|
|
|
|
2020-02-21 21:53:23 +01:00
|
|
|
struct {
|
2020-02-22 11:30:30 +01:00
|
|
|
enum {
|
|
|
|
|
SIXEL_DECSIXEL, /* DECSIXEL body part ", $, -, ? ... ~ */
|
|
|
|
|
SIXEL_DECGRA, /* DECGRA Set Raster Attributes " Pan; Pad; Ph; Pv */
|
|
|
|
|
SIXEL_DECGRI, /* DECGRI Graphics Repeat Introducer ! Pn Ch */
|
|
|
|
|
SIXEL_DECGCI, /* DECGCI Graphics Color Introducer # Pc; Pu; Px; Py; Pz */
|
|
|
|
|
} state;
|
2020-02-22 10:54:52 +01:00
|
|
|
|
|
|
|
|
struct coord pos; /* Current sixel coordinate */
|
|
|
|
|
int color_idx; /* Current palette index */
|
|
|
|
|
int max_col; /* Largest column index we've seen (aka the image width) */
|
|
|
|
|
uint32_t *palette; /* Color palette */
|
2020-02-22 10:46:35 +01:00
|
|
|
|
|
|
|
|
struct {
|
2020-02-22 10:54:52 +01:00
|
|
|
uint32_t *data; /* Raw image data, in ARGB */
|
|
|
|
|
int width; /* Image width, in pixels */
|
|
|
|
|
int height; /* Image height, in pixels */
|
2020-02-22 10:46:35 +01:00
|
|
|
} image;
|
2020-02-21 21:53:23 +01:00
|
|
|
|
2020-02-22 11:30:30 +01:00
|
|
|
unsigned params[5]; /* Collected parmaeters, for RASTER, COLOR_SPEC */
|
|
|
|
|
unsigned param; /* Currently collecting parameter, for RASTER, COLOR_SPEC and REPEAT */
|
2020-02-22 10:54:52 +01:00
|
|
|
unsigned param_idx; /* Parameters seen */
|
2020-02-22 14:02:00 +01:00
|
|
|
|
|
|
|
|
/* Application configurable */
|
2020-02-22 21:03:24 +01:00
|
|
|
unsigned palette_size; /* Number of colors in palette */
|
|
|
|
|
unsigned max_width; /* Maximum image width, in pixels */
|
|
|
|
|
unsigned max_height; /* Maximum image height, in pixels */
|
2020-02-21 21:53:23 +01:00
|
|
|
} sixel;
|
|
|
|
|
|
2020-02-03 19:58:32 +01:00
|
|
|
bool hold_at_exit;
|
2019-11-01 20:34:32 +01:00
|
|
|
bool is_shutting_down;
|
|
|
|
|
void (*shutdown_cb)(void *data, int exit_code);
|
|
|
|
|
void *shutdown_data;
|
2019-12-21 15:27:17 +01:00
|
|
|
|
|
|
|
|
char *foot_exe;
|
2019-12-21 15:35:54 +01:00
|
|
|
char *cwd;
|
2019-06-15 22:22:44 +02:00
|
|
|
};
|
2019-06-29 21:03:28 +02:00
|
|
|
|
2019-10-28 18:25:19 +01:00
|
|
|
struct config;
|
|
|
|
|
struct terminal *term_init(
|
2020-05-21 20:17:29 +02:00
|
|
|
const struct config *conf, struct fdm *fdm, struct reaper *reaper,
|
|
|
|
|
struct wayland *wayl, const char *foot_exe, const char *cwd,
|
|
|
|
|
int argc, char *const *argv,
|
2019-11-01 20:34:32 +01:00
|
|
|
void (*shutdown_cb)(void *data, int exit_code), void *shutdown_data);
|
|
|
|
|
|
2019-10-30 20:03:11 +01:00
|
|
|
bool term_shutdown(struct terminal *term);
|
2019-10-28 18:25:19 +01:00
|
|
|
int term_destroy(struct terminal *term);
|
|
|
|
|
|
2019-08-01 20:51:11 +02:00
|
|
|
void term_reset(struct terminal *term, bool hard);
|
2019-11-03 00:27:39 +01:00
|
|
|
bool term_to_slave(struct terminal *term, const void *data, size_t len);
|
2019-08-01 20:51:11 +02:00
|
|
|
|
term: implement term_font_dpi_changed()
This function reloads the font *if* the DPI has changed. To handle
user run-time adjusted font sizes, we record the number of adjustments
made.
Then, when re-loading the font, we first load the font as specified in
the configuration. Then, we re-apply the size adjustment using
font_size_adjust().
Note that this means we end up loading the fonts twice; first using
the default size (but with adjusted DPI), and then again with the
adjusted size. This can probably be improved upon.
The existing font code has been refactored to avoid code
duplication. For example, term_init() now calls
term_font_dpi_changed() to load the initial fonts, instead of directly
instantiating them.
Finally, the way we calculate the DPI to use has changed: instead of
using the highest DPI of all available outputs, we use the highest DPI
of the output's we're actually mapped on. If we're not mapped at all,
we use the globally highest DPI.
Doing it this way means we usually only have to load the fonts
once. Otherwise, we'd end up using the default DPI of 96 when the
terminal is first instantiated (since it's not mapped at that time).
On a single monitor system, we'll use the globally highest DPI at
first, before being mapped. Then when we get mapped, we re-load the
fonts using the highest mapped DPI. But since they'll be the same,
we can skip actually reloading the fonts.
2020-02-15 19:08:14 +01:00
|
|
|
bool term_font_size_increase(struct terminal *term);
|
|
|
|
|
bool term_font_size_decrease(struct terminal *term);
|
|
|
|
|
bool term_font_size_reset(struct terminal *term);
|
|
|
|
|
bool term_font_dpi_changed(struct terminal *term);
|
2020-04-20 18:37:59 +02:00
|
|
|
void term_font_subpixel_changed(struct terminal *term);
|
|
|
|
|
|
2020-04-30 17:22:57 +02:00
|
|
|
void term_window_configured(struct terminal *term);
|
2020-02-08 14:09:06 +01:00
|
|
|
|
2019-07-11 09:51:51 +02:00
|
|
|
void term_damage_rows(struct terminal *term, int start, int end);
|
|
|
|
|
void term_damage_rows_in_view(struct terminal *term, int start, int end);
|
|
|
|
|
|
2019-06-29 21:03:28 +02:00
|
|
|
void term_damage_all(struct terminal *term);
|
2019-07-10 14:32:40 +02:00
|
|
|
void term_damage_view(struct terminal *term);
|
2019-07-11 09:51:51 +02:00
|
|
|
|
2019-08-28 17:25:42 +02:00
|
|
|
void term_reset_view(struct terminal *term);
|
|
|
|
|
|
2019-06-29 21:03:28 +02:00
|
|
|
void term_damage_scroll(
|
|
|
|
|
struct terminal *term, enum damage_type damage_type,
|
|
|
|
|
struct scroll_region region, int lines);
|
|
|
|
|
|
2019-07-08 13:57:31 +02:00
|
|
|
void term_erase(
|
|
|
|
|
struct terminal *term, const struct coord *start, const struct coord *end);
|
2019-06-29 21:03:28 +02:00
|
|
|
|
2019-11-17 18:52:27 +01:00
|
|
|
int term_row_rel_to_abs(const struct terminal *term, int row);
|
2019-11-05 13:27:37 +01:00
|
|
|
void term_cursor_home(struct terminal *term);
|
2019-06-29 21:03:28 +02:00
|
|
|
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);
|
2019-12-15 15:07:56 +01:00
|
|
|
void term_cursor_blink_enable(struct terminal *term);
|
|
|
|
|
void term_cursor_blink_disable(struct terminal *term);
|
2019-12-16 21:31:40 +01:00
|
|
|
void term_cursor_blink_restart(struct terminal *term);
|
2019-06-29 21:03:28 +02:00
|
|
|
|
2020-01-20 18:34:32 +01:00
|
|
|
void term_print(struct terminal *term, wchar_t wc, int width);
|
|
|
|
|
|
2019-06-29 21:03:28 +02:00
|
|
|
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);
|
|
|
|
|
|
2020-02-10 21:52:14 +01:00
|
|
|
void term_formfeed(struct terminal *term);
|
2019-07-10 16:02:03 +02:00
|
|
|
void term_linefeed(struct terminal *term);
|
|
|
|
|
void term_reverse_index(struct terminal *term);
|
|
|
|
|
|
2019-12-17 19:11:27 +01:00
|
|
|
void term_arm_blink_timer(struct terminal *term);
|
|
|
|
|
|
2020-03-16 12:00:25 +01:00
|
|
|
void term_restore_cursor(struct terminal *term, const struct cursor *cursor);
|
2019-07-23 17:57:07 +02:00
|
|
|
|
2020-01-02 19:35:32 +01:00
|
|
|
void term_visual_focus_in(struct terminal *term);
|
|
|
|
|
void term_visual_focus_out(struct terminal *term);
|
2020-01-02 19:29:42 +01:00
|
|
|
void term_kbd_focus_in(struct terminal *term);
|
|
|
|
|
void term_kbd_focus_out(struct terminal *term);
|
2019-11-30 17:11:00 +01:00
|
|
|
void term_mouse_down(struct terminal *term, int button, int row, int col);
|
|
|
|
|
void term_mouse_up(struct terminal *term, int button, int row, int col);
|
|
|
|
|
void term_mouse_motion(struct terminal *term, int button, int row, int col);
|
2019-11-30 17:06:15 +01:00
|
|
|
bool term_mouse_grabbed(const struct terminal *term);
|
2019-11-28 19:35:47 +01:00
|
|
|
void term_xcursor_update(struct terminal *term);
|
2019-07-21 17:35:53 +02:00
|
|
|
|
|
|
|
|
void term_set_window_title(struct terminal *term, const char *title);
|
2019-07-30 22:06:02 +02:00
|
|
|
void term_flash(struct terminal *term, unsigned duration_ms);
|
2019-12-21 15:27:17 +01:00
|
|
|
bool term_spawn_new(const struct terminal *term);
|
2020-01-12 12:43:28 +01:00
|
|
|
|
2020-01-12 12:55:19 +01:00
|
|
|
void term_enable_app_sync_updates(struct terminal *term);
|
|
|
|
|
void term_disable_app_sync_updates(struct terminal *term);
|
2020-02-24 22:38:35 +01:00
|
|
|
|
|
|
|
|
enum term_surface term_surface_kind(
|
|
|
|
|
const struct terminal *term, const struct wl_surface *surface);
|