Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/tsm/libtsm.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ enum tsm_vte_color {
#define TSM_VTE_MOUSE_EVENT_ANY 1003 /* sends position on mouse click and mouse move */
#define TSM_VTE_MOUSE_MODE_SGR 1006 /* modern mode that allows unlimited x and y coordinates */
#define TSM_VTE_MOUSE_MODE_PIXEL 1016 /* sends pixel coordinates instead of cell coordinates */
#define TSM_VTE_BRACKETED_PASTE 2004 /* enclose paste data with escape characters */

enum tsm_mouse_track_mode {
TSM_MOUSE_TRACK_DISABLE = 0, /* don't track mouse events */
Expand Down Expand Up @@ -520,6 +521,7 @@ bool tsm_vte_handle_mouse(struct tsm_vte *vte, unsigned int cell_x,
unsigned int cell_y, unsigned int pixel_x, unsigned int pixel_y,
unsigned int button, unsigned int event, unsigned char flags);

void tsm_vte_paste(struct tsm_vte *vte, const char *data);
/** @} */

#ifdef __cplusplus
Expand Down
5 changes: 5 additions & 0 deletions src/tsm/libtsm.sym
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,8 @@ LIBTSM_4_3 {
global:
tsm_screen_selection_word;
} LIBTSM_4_1;

LIBTSM_4_4 {
global:
tsm_vte_paste;
} LIBTSM_4_3;
23 changes: 23 additions & 0 deletions src/tsm/tsm-vte.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ struct tsm_vte {
unsigned int mouse_event;
unsigned int mouse_last_col;
unsigned int mouse_last_row;
bool bracketed_paste;

uint8_t (*custom_palette_storage)[3];
uint8_t (*palette)[3];
Expand Down Expand Up @@ -1756,6 +1757,9 @@ static void csi_mode(struct tsm_vte *vte, bool set)
continue;
}
continue;
case TSM_VTE_BRACKETED_PASTE:
vte->bracketed_paste = set;
continue;
default:
llog_debug(vte, "unknown DEC %set-Mode %d",
set?"S":"Res", vte->csi_argv[i]);
Expand Down Expand Up @@ -3358,3 +3362,22 @@ bool tsm_vte_handle_mouse(struct tsm_vte *vte, unsigned int cell_x,

return false;
}

void tsm_vte_paste(struct tsm_vte *vte, const char *data)
{
if (vte->bracketed_paste) {
const char start[] = "\e[200~";
const char end[] = "\e[201~";
char *buf;
int len;

len = strlen(data) + sizeof(start) + sizeof(end) + 1;
buf = malloc(len);
if (!buf)
return;
snprintf(buf, len, "%s%s%s", start, data, end);
vte_write(vte, buf, strlen(buf));
free(buf);
} else
vte_write(vte, data, strlen(data));
}
Loading