1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-01 19:42:48 -05:00

Add a system of clipboard identifiers.

This lays some groundwork for making PuTTY's cut and paste handling
more flexible in the area of which clipboard(s) it reads and writes,
if more than one is available on the system.

I've introduced a system of list macros which define an enumeration of
integer clipboard ids, some defined centrally in putty.h (at present
just a CLIP_NULL which never has any text in it, because that seems
like the sort of thing that will come in useful for configuring a
given copy or paste UI action to be ignored) and some defined per
platform. All the front end functions that copy and paste take a
clipboard id, and the Terminal structure is now configured at startup
to tell it which clipboard id it should paste from on a mouse click,
and which it should copy from on a selection.

However, I haven't actually added _real_ support for multiple X11
clipboards, in that the Unix front end supports a single CLIP_SYSTEM
regardless of whether it's in OS X or GTK mode. So this is currently a
NFC refactoring which does nothing but prepare the way for real
changes to come.
This commit is contained in:
Simon Tatham
2017-12-09 12:00:13 +00:00
parent 9bff5595a2
commit 1829719639
10 changed files with 115 additions and 35 deletions

29
putty.h
View File

@ -615,6 +615,25 @@ typedef struct truecolour {
optionalrgb_equal((c1).fg, (c2).fg) && \
optionalrgb_equal((c1).bg, (c2).bg))
/*
* Enumeration of clipboards. CLIP_NULL is the only one provided
* systemwide: it's a non=clipboard, writes to which are ignored and
* reads from which return no data. Each platform front end extends
* this enumeration in its own way.
*/
#define CROSS_PLATFORM_CLIPBOARDS(X) \
X(CLIP_NULL, "null clipboard") \
/* end of list */
#define ALL_CLIPBOARDS(X) \
CROSS_PLATFORM_CLIPBOARDS(X) \
PLATFORM_CLIPBOARDS(X) \
/* end of list */
#define CLIP_ID(id,name) id,
enum { ALL_CLIPBOARDS(CLIP_ID) N_CLIPBOARDS };
#undef CLIP_ID
/*
* Exports from the front end.
*/
@ -635,7 +654,8 @@ void free_ctx(Context);
void palette_set(void *frontend, int, int, int, int);
void palette_reset(void *frontend);
int palette_get(void *frontend, int n, int *r, int *g, int *b);
void write_clip(void *frontend, wchar_t *, int *, truecolour *, int, int);
void write_clip(void *frontend, int clipboard, wchar_t *, int *,
truecolour *, int, int);
void optimised_move(void *frontend, int, int, int);
void set_raw_mouse_mode(void *frontend, int);
void connection_fatal(void *frontend, const char *, ...);
@ -647,7 +667,7 @@ void modalfatalbox(const char *, ...);
void do_beep(void *frontend, int);
void begin_session(void *frontend);
void sys_cursor(void *frontend, int x, int y);
void request_paste(void *frontend);
void frontend_request_paste(void *frontend, int clipboard);
void frontend_keypress(void *frontend);
void frontend_echoedit_update(void *frontend, int echo, int edit);
/* It's the backend's responsibility to invoke this at the start of a
@ -1051,15 +1071,16 @@ void term_mouse(Terminal *, Mouse_Button, Mouse_Button, Mouse_Action,
int,int,int,int,int);
void term_key(Terminal *, Key_Sym, wchar_t *, size_t, unsigned int,
unsigned int);
void term_deselect(Terminal *);
void term_lost_clipboard_ownership(Terminal *, int clipboard);
void term_update(Terminal *);
void term_invalidate(Terminal *);
void term_blink(Terminal *, int set_cursor);
void term_do_paste(Terminal *, const wchar_t *, int);
void term_nopaste(Terminal *);
int term_ldisc(Terminal *, int option);
void term_copyall(Terminal *);
void term_copyall(Terminal *, int clipboard);
void term_reconfig(Terminal *, Conf *);
void term_request_paste(Terminal *, int clipboard);
void term_seen_key_event(Terminal *);
int term_data(Terminal *, int is_stderr, const char *data, int len);
int term_data_untrusted(Terminal *, const char *data, int len);