mirror of
https://github.com/tmux/tmux.git
synced 2026-06-24 07:28:24 +00:00
Rewrite screen-redraw.c to make it tidier and more maintainable. A scene
is generated and cached in the client: it holds positions and sizes of panes, borders and so on. The scene is invalidated when a pane is moved or resized or relevant option is changed. This scene is then drawn to the client as needed and text and colours are filled in. With Michael Grant.
This commit is contained in:
86
tmux.h
86
tmux.h
@@ -62,6 +62,8 @@ struct mouse_event;
|
||||
struct options;
|
||||
struct options_array_item;
|
||||
struct options_entry;
|
||||
struct redraw_scene;
|
||||
struct redraw_span;
|
||||
struct screen_write_citem;
|
||||
struct screen_write_cline;
|
||||
struct screen_write_ctx;
|
||||
@@ -787,20 +789,23 @@ struct colour_palette {
|
||||
#define GRID_STRING_USED_ONLY 0x8
|
||||
#define GRID_STRING_EMPTY_CELLS 0x10
|
||||
|
||||
/* Cell positions. */
|
||||
/*
|
||||
* Cell border characters. Border cells are named for the directions they
|
||||
* connect to: U for up, D for down, L for left and R for right.
|
||||
*/
|
||||
#define CELL_INSIDE 0
|
||||
#define CELL_TOPBOTTOM 1
|
||||
#define CELL_LEFTRIGHT 2
|
||||
#define CELL_TOPLEFT 3
|
||||
#define CELL_TOPRIGHT 4
|
||||
#define CELL_BOTTOMLEFT 5
|
||||
#define CELL_BOTTOMRIGHT 6
|
||||
#define CELL_TOPJOIN 7
|
||||
#define CELL_BOTTOMJOIN 8
|
||||
#define CELL_LEFTJOIN 9
|
||||
#define CELL_RIGHTJOIN 10
|
||||
#define CELL_JOIN 11
|
||||
#define CELL_OUTSIDE 12
|
||||
#define CELL_UD 1
|
||||
#define CELL_LR 2
|
||||
#define CELL_RD 3
|
||||
#define CELL_LD 4
|
||||
#define CELL_RU 5
|
||||
#define CELL_LU 6
|
||||
#define CELL_LRD 7
|
||||
#define CELL_LRU 8
|
||||
#define CELL_URD 9
|
||||
#define CELL_ULD 10
|
||||
#define CELL_LRUD 11
|
||||
#define CELL_NONE 12
|
||||
#define CELL_SCROLLBAR 13
|
||||
|
||||
/* Cell borders. */
|
||||
@@ -1079,27 +1084,6 @@ enum pane_lines {
|
||||
#define WINDOW_PANE_COPY_MODE 1
|
||||
#define WINDOW_PANE_VIEW_MODE 2
|
||||
|
||||
/* Screen redraw context. */
|
||||
struct screen_redraw_ctx {
|
||||
struct client *c;
|
||||
|
||||
u_int statuslines;
|
||||
int statustop;
|
||||
|
||||
enum pane_lines pane_lines;
|
||||
|
||||
int pane_scrollbars;
|
||||
int pane_scrollbars_pos;
|
||||
|
||||
struct grid_cell no_pane_gc;
|
||||
int no_pane_gc_set;
|
||||
|
||||
u_int sx;
|
||||
u_int sy;
|
||||
int ox;
|
||||
int oy;
|
||||
};
|
||||
|
||||
/* Screen size. */
|
||||
#define screen_size_x(s) ((s)->grid->sx)
|
||||
#define screen_size_y(s) ((s)->grid->sy)
|
||||
@@ -1250,7 +1234,7 @@ struct window_pane {
|
||||
#define PANE_FOCUSED 0x4
|
||||
#define PANE_VISITED 0x8
|
||||
#define PANE_ZOOMED 0x10
|
||||
/* 0x20 unused */
|
||||
#define PANE_NEWSTATUS 0x20
|
||||
#define PANE_INPUTOFF 0x40
|
||||
#define PANE_CHANGED 0x80
|
||||
#define PANE_EXITED 0x100
|
||||
@@ -1306,7 +1290,6 @@ struct window_pane {
|
||||
struct screen base;
|
||||
|
||||
struct screen status_screen;
|
||||
size_t status_size;
|
||||
|
||||
TAILQ_HEAD(, window_mode_entry) modes;
|
||||
|
||||
@@ -1371,6 +1354,8 @@ struct window {
|
||||
u_int new_xpixel;
|
||||
u_int new_ypixel;
|
||||
|
||||
uint64_t redraw_scene_generation;
|
||||
|
||||
u_int last_new_pane_x;
|
||||
u_int last_new_pane_y;
|
||||
|
||||
@@ -2008,12 +1993,11 @@ RB_HEAD(client_windows, client_window);
|
||||
/* Client connection. */
|
||||
typedef int (*prompt_input_cb)(struct client *, void *, const char *, int);
|
||||
typedef void (*prompt_free_cb)(void *);
|
||||
typedef struct visible_ranges *(*overlay_check_cb)(struct client*, void *,
|
||||
typedef struct visible_ranges *(*overlay_check_cb)(struct client *, void *,
|
||||
u_int, u_int, u_int);
|
||||
typedef struct screen *(*overlay_mode_cb)(struct client *, void *, u_int *,
|
||||
u_int *);
|
||||
typedef void (*overlay_draw_cb)(struct client *, void *,
|
||||
struct screen_redraw_ctx *);
|
||||
typedef void (*overlay_draw_cb)(struct client *, void *);
|
||||
typedef int (*overlay_key_cb)(struct client *, void *, struct key_event *);
|
||||
typedef void (*overlay_free_cb)(struct client *, void *);
|
||||
typedef void (*overlay_resize_cb)(struct client *, void *);
|
||||
@@ -2059,6 +2043,8 @@ struct client {
|
||||
size_t discarded;
|
||||
size_t redraw;
|
||||
|
||||
struct redraw_scene *redraw_scene;
|
||||
|
||||
struct event repeat_timer;
|
||||
|
||||
struct event click_timer;
|
||||
@@ -3338,8 +3324,13 @@ void screen_write_alternateoff(struct screen_write_ctx *,
|
||||
struct grid_cell *, int);
|
||||
|
||||
/* screen-redraw.c */
|
||||
void screen_redraw_screen(struct client *);
|
||||
void screen_redraw_pane(struct client *, struct window_pane *, int);
|
||||
void redraw_screen(struct client *);
|
||||
void redraw_pane(struct client *, struct window_pane *);
|
||||
void redraw_pane_scrollbar(struct client *, struct window_pane *);
|
||||
void redraw_free_scene(struct redraw_scene *);
|
||||
void redraw_invalidate_scene(struct window *);
|
||||
void redraw_invalidate_all_scenes(void);
|
||||
int redraw_get_status_border_cell_type(struct redraw_span **, u_int);
|
||||
|
||||
/* screen.c */
|
||||
void screen_init(struct screen *, u_int, u_int, u_int);
|
||||
@@ -3487,6 +3478,16 @@ struct style_range *window_pane_status_get_range(struct window_pane *, u_int,
|
||||
u_int);
|
||||
int window_pane_is_floating(struct window_pane *);
|
||||
|
||||
/* window-border.c */
|
||||
void window_get_border_cell(struct window *, struct window_pane *,
|
||||
enum pane_lines, int, struct grid_cell *);
|
||||
void window_pane_get_border_cell(struct window_pane *, int,
|
||||
struct grid_cell *);
|
||||
void window_pane_get_border_style(struct window_pane *,
|
||||
struct client *, struct grid_cell *);
|
||||
int window_make_pane_status(struct window_pane *, struct client *,
|
||||
u_int, struct redraw_span *);
|
||||
|
||||
/* window-visible.c */
|
||||
int window_position_is_visible(struct visible_ranges *, u_int);
|
||||
struct visible_ranges *window_visible_ranges(struct window_pane *, int, int,
|
||||
@@ -3783,8 +3784,7 @@ int menu_display(struct menu *, int, int, struct cmdq_item *,
|
||||
struct screen *menu_mode_cb(struct client *, void *, u_int *, u_int *);
|
||||
struct visible_ranges *menu_check_cb(struct client *, void *, u_int, u_int,
|
||||
u_int);
|
||||
void menu_draw_cb(struct client *, void *,
|
||||
struct screen_redraw_ctx *);
|
||||
void menu_draw_cb(struct client *, void *);
|
||||
void menu_free_cb(struct client *, void *);
|
||||
int menu_key_cb(struct client *, void *, struct key_event *);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user