GUACAMOLE-1538 - Consolidate clipboard handling; opaque clipboard struct to avoid exposing internal guac_common_clipboard.

This commit is contained in:
James Muehlner 2022-02-22 12:45:35 -08:00
parent 037045a054
commit 589e0ecd03
38 changed files with 504 additions and 523 deletions

View File

@ -29,15 +29,15 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
guac_common_clipboard* guac_common_clipboard_alloc(int size) { guac_common_clipboard* guac_common_clipboard_alloc() {
guac_common_clipboard* clipboard = malloc(sizeof(guac_common_clipboard)); guac_common_clipboard* clipboard = malloc(sizeof(guac_common_clipboard));
/* Init clipboard */ /* Init clipboard */
clipboard->mimetype[0] = '\0'; clipboard->mimetype[0] = '\0';
clipboard->buffer = malloc(size); clipboard->buffer = malloc(GUAC_COMMON_CLIPBOARD_MAX_LENGTH);
clipboard->available = GUAC_COMMON_CLIPBOARD_MAX_LENGTH;
clipboard->length = 0; clipboard->length = 0;
clipboard->available = size;
pthread_mutex_init(&(clipboard->lock), NULL); pthread_mutex_init(&(clipboard->lock), NULL);

View File

@ -31,6 +31,11 @@
*/ */
#define GUAC_COMMON_CLIPBOARD_BLOCK_SIZE 4096 #define GUAC_COMMON_CLIPBOARD_BLOCK_SIZE 4096
/**
* The maximum number of bytes to allow within the clipboard.
*/
#define GUAC_COMMON_CLIPBOARD_MAX_LENGTH 262144
/** /**
* Generic clipboard structure. * Generic clipboard structure.
*/ */
@ -66,12 +71,9 @@ typedef struct guac_common_clipboard {
} guac_common_clipboard; } guac_common_clipboard;
/** /**
* Creates a new clipboard having the given initial size. * Creates a new clipboard.
*
* @param size The maximum number of bytes to allow within the clipboard.
* @return A newly-allocated clipboard.
*/ */
guac_common_clipboard* guac_common_clipboard_alloc(int size); guac_common_clipboard* guac_common_clipboard_alloc();
/** /**
* Frees the given clipboard. * Frees the given clipboard.

View File

@ -21,6 +21,7 @@
#include "argv.h" #include "argv.h"
#include "kubernetes.h" #include "kubernetes.h"
#include "terminal/terminal.h" #include "terminal/terminal.h"
#include "terminal/terminal_priv.h"
#include <guacamole/protocol.h> #include <guacamole/protocol.h>
#include <guacamole/socket.h> #include <guacamole/socket.h>

View File

@ -19,7 +19,6 @@
#include "argv.h" #include "argv.h"
#include "client.h" #include "client.h"
#include "common/clipboard.h"
#include "kubernetes.h" #include "kubernetes.h"
#include "settings.h" #include "settings.h"
#include "user.h" #include "user.h"
@ -95,9 +94,6 @@ int guac_client_init(guac_client* client) {
guac_kubernetes_client* kubernetes_client = calloc(1, sizeof(guac_kubernetes_client)); guac_kubernetes_client* kubernetes_client = calloc(1, sizeof(guac_kubernetes_client));
client->data = kubernetes_client; client->data = kubernetes_client;
/* Init clipboard */
kubernetes_client->clipboard = guac_common_clipboard_alloc(GUAC_KUBERNETES_CLIPBOARD_MAX_LENGTH);
/* Set handlers */ /* Set handlers */
client->join_handler = guac_kubernetes_user_join_handler; client->join_handler = guac_kubernetes_user_join_handler;
client->free_handler = guac_kubernetes_client_free_handler; client->free_handler = guac_kubernetes_client_free_handler;
@ -133,7 +129,6 @@ int guac_kubernetes_client_free_handler(guac_client* client) {
if (kubernetes_client->settings != NULL) if (kubernetes_client->settings != NULL)
guac_kubernetes_settings_free(kubernetes_client->settings); guac_kubernetes_settings_free(kubernetes_client->settings);
guac_common_clipboard_free(kubernetes_client->clipboard);
free(kubernetes_client); free(kubernetes_client);
return 0; return 0;

View File

@ -22,11 +22,6 @@
#include <guacamole/client.h> #include <guacamole/client.h>
/**
* The maximum number of bytes to allow within the clipboard.
*/
#define GUAC_KUBERNETES_CLIPBOARD_MAX_LENGTH 262144
/** /**
* Static reference to the guac_client associated with the active Kubernetes * Static reference to the guac_client associated with the active Kubernetes
* connection. While libwebsockets provides some means of storing and * connection. While libwebsockets provides some means of storing and

View File

@ -20,6 +20,7 @@
#include "clipboard.h" #include "clipboard.h"
#include "common/clipboard.h" #include "common/clipboard.h"
#include "kubernetes.h" #include "kubernetes.h"
#include "terminal/terminal_priv.h"
#include <guacamole/client.h> #include <guacamole/client.h>
#include <guacamole/stream.h> #include <guacamole/stream.h>
@ -33,7 +34,7 @@ int guac_kubernetes_clipboard_handler(guac_user* user, guac_stream* stream,
(guac_kubernetes_client*) client->data; (guac_kubernetes_client*) client->data;
/* Clear clipboard and prepare for new data */ /* Clear clipboard and prepare for new data */
guac_common_clipboard_reset(kubernetes_client->clipboard, mimetype); guac_common_clipboard_reset(kubernetes_client->term->clipboard, mimetype);
/* Set handlers for clipboard stream */ /* Set handlers for clipboard stream */
stream->blob_handler = guac_kubernetes_clipboard_blob_handler; stream->blob_handler = guac_kubernetes_clipboard_blob_handler;
@ -50,7 +51,7 @@ int guac_kubernetes_clipboard_blob_handler(guac_user* user,
(guac_kubernetes_client*) client->data; (guac_kubernetes_client*) client->data;
/* Append new data */ /* Append new data */
guac_common_clipboard_append(kubernetes_client->clipboard, data, length); guac_common_clipboard_append(kubernetes_client->term->clipboard, data, length);
return 0; return 0;
} }

View File

@ -21,6 +21,7 @@
#include "input.h" #include "input.h"
#include "kubernetes.h" #include "kubernetes.h"
#include "terminal/terminal.h" #include "terminal/terminal.h"
#include "terminal/terminal_priv.h"
#include <guacamole/client.h> #include <guacamole/client.h>
#include <guacamole/user.h> #include <guacamole/user.h>

View File

@ -26,6 +26,7 @@
#include "kubernetes.h" #include "kubernetes.h"
#include "ssl.h" #include "ssl.h"
#include "terminal/terminal.h" #include "terminal/terminal.h"
#include "terminal/terminal_priv.h"
#include "url.h" #include "url.h"
#include <guacamole/client.h> #include <guacamole/client.h>
@ -241,8 +242,7 @@ void* guac_kubernetes_client_thread(void* data) {
/* Create terminal options with required parameters */ /* Create terminal options with required parameters */
guac_terminal_options* options = guac_terminal_options_create( guac_terminal_options* options = guac_terminal_options_create(
client, kubernetes_client->clipboard, client, settings->width, settings->height, settings->resolution);
settings->width, settings->height, settings->resolution);
/* Set optional parameters */ /* Set optional parameters */
options->disable_copy = settings->disable_copy; options->disable_copy = settings->disable_copy;

View File

@ -102,11 +102,6 @@ typedef struct guac_kubernetes_client {
*/ */
pthread_t client_thread; pthread_t client_thread;
/**
* The current clipboard contents.
*/
guac_common_clipboard* clipboard;
/** /**
* The terminal which will render all output from the Kubernetes pod. * The terminal which will render all output from the Kubernetes pod.
*/ */

View File

@ -25,6 +25,7 @@
#include "pipe.h" #include "pipe.h"
#include "settings.h" #include "settings.h"
#include "terminal/terminal.h" #include "terminal/terminal.h"
#include "terminal/terminal_priv.h"
#include "user.h" #include "user.h"
#include <guacamole/client.h> #include <guacamole/client.h>

View File

@ -358,7 +358,7 @@ static UINT guac_rdp_cliprdr_format_data_request(CliprdrClientContext* cliprdr,
guac_iconv_write* remote_writer; guac_iconv_write* remote_writer;
const char* input = clipboard->clipboard->buffer; const char* input = clipboard->clipboard->buffer;
char* output = malloc(GUAC_RDP_CLIPBOARD_MAX_LENGTH); char* output = malloc(GUAC_COMMON_CLIPBOARD_MAX_LENGTH);
/* Map requested clipboard format to a guac_iconv writer */ /* Map requested clipboard format to a guac_iconv writer */
switch (format_data_request->requestedFormatId) { switch (format_data_request->requestedFormatId) {
@ -389,7 +389,7 @@ static UINT guac_rdp_cliprdr_format_data_request(CliprdrClientContext* cliprdr,
BYTE* start = (BYTE*) output; BYTE* start = (BYTE*) output;
guac_iconv_read* local_reader = settings->normalize_clipboard ? GUAC_READ_UTF8_NORMALIZED : GUAC_READ_UTF8; guac_iconv_read* local_reader = settings->normalize_clipboard ? GUAC_READ_UTF8_NORMALIZED : GUAC_READ_UTF8;
guac_iconv(local_reader, &input, clipboard->clipboard->length, guac_iconv(local_reader, &input, clipboard->clipboard->length,
remote_writer, &output, GUAC_RDP_CLIPBOARD_MAX_LENGTH); remote_writer, &output, GUAC_COMMON_CLIPBOARD_MAX_LENGTH);
CLIPRDR_FORMAT_DATA_RESPONSE data_response = { CLIPRDR_FORMAT_DATA_RESPONSE data_response = {
.requestedFormatData = (BYTE*) start, .requestedFormatData = (BYTE*) start,
@ -449,7 +449,7 @@ static UINT guac_rdp_cliprdr_format_data_response(CliprdrClientContext* cliprdr,
return CHANNEL_RC_OK; return CHANNEL_RC_OK;
} }
char received_data[GUAC_RDP_CLIPBOARD_MAX_LENGTH]; char received_data[GUAC_COMMON_CLIPBOARD_MAX_LENGTH];
guac_iconv_read* remote_reader; guac_iconv_read* remote_reader;
const char* input = (char*) format_data_response->requestedFormatData; const char* input = (char*) format_data_response->requestedFormatData;
@ -595,7 +595,7 @@ guac_rdp_clipboard* guac_rdp_clipboard_alloc(guac_client* client) {
/* Allocate clipboard and underlying storage */ /* Allocate clipboard and underlying storage */
guac_rdp_clipboard* clipboard = calloc(1, sizeof(guac_rdp_clipboard)); guac_rdp_clipboard* clipboard = calloc(1, sizeof(guac_rdp_clipboard));
clipboard->client = client; clipboard->client = client;
clipboard->clipboard = guac_common_clipboard_alloc(GUAC_RDP_CLIPBOARD_MAX_LENGTH); clipboard->clipboard = guac_common_clipboard_alloc();
clipboard->requested_format = CF_TEXT; clipboard->requested_format = CF_TEXT;
return clipboard; return clipboard;

View File

@ -62,11 +62,6 @@
*/ */
#define GUAC_RDP_REASONABLE_AREA (800*600) #define GUAC_RDP_REASONABLE_AREA (800*600)
/**
* The maximum number of bytes to allow within the clipboard.
*/
#define GUAC_RDP_CLIPBOARD_MAX_LENGTH 262144
/** /**
* Initial rate of audio to stream, in Hz. If the RDP server uses a different * Initial rate of audio to stream, in Hz. If the RDP server uses a different
* value, the Guacamole audio stream will simply be reset appropriately. * value, the Guacamole audio stream will simply be reset appropriately.

View File

@ -21,6 +21,7 @@
#include "argv.h" #include "argv.h"
#include "ssh.h" #include "ssh.h"
#include "terminal/terminal.h" #include "terminal/terminal.h"
#include "terminal/terminal_priv.h"
#include <guacamole/protocol.h> #include <guacamole/protocol.h>
#include <guacamole/socket.h> #include <guacamole/socket.h>

View File

@ -21,7 +21,6 @@
#include "argv.h" #include "argv.h"
#include "client.h" #include "client.h"
#include "common/clipboard.h"
#include "common/recording.h" #include "common/recording.h"
#include "common-ssh/sftp.h" #include "common-ssh/sftp.h"
#include "ssh.h" #include "ssh.h"
@ -45,9 +44,6 @@ int guac_client_init(guac_client* client) {
guac_ssh_client* ssh_client = calloc(1, sizeof(guac_ssh_client)); guac_ssh_client* ssh_client = calloc(1, sizeof(guac_ssh_client));
client->data = ssh_client; client->data = ssh_client;
/* Init clipboard */
ssh_client->clipboard = guac_common_clipboard_alloc(GUAC_SSH_CLIPBOARD_MAX_LENGTH);
/* Set handlers */ /* Set handlers */
client->join_handler = guac_ssh_user_join_handler; client->join_handler = guac_ssh_user_join_handler;
client->free_handler = guac_ssh_client_free_handler; client->free_handler = guac_ssh_client_free_handler;
@ -118,7 +114,6 @@ int guac_ssh_client_free_handler(guac_client* client) {
guac_ssh_settings_free(ssh_client->settings); guac_ssh_settings_free(ssh_client->settings);
/* Free client structure */ /* Free client structure */
guac_common_clipboard_free(ssh_client->clipboard);
free(ssh_client); free(ssh_client);
guac_common_ssh_uninit(); guac_common_ssh_uninit();

View File

@ -22,11 +22,6 @@
#include <guacamole/client.h> #include <guacamole/client.h>
/**
* The maximum number of bytes to allow within the clipboard.
*/
#define GUAC_SSH_CLIPBOARD_MAX_LENGTH 262144
/** /**
* Handler which is invoked when the SSH client needs to be disconnected (if * Handler which is invoked when the SSH client needs to be disconnected (if
* connected) and freed. This can happen if initialization fails, or all users * connected) and freed. This can happen if initialization fails, or all users

View File

@ -22,6 +22,7 @@
#include "common/clipboard.h" #include "common/clipboard.h"
#include "ssh.h" #include "ssh.h"
#include "terminal/terminal.h" #include "terminal/terminal.h"
#include "terminal/terminal_priv.h"
#include <guacamole/client.h> #include <guacamole/client.h>
#include <guacamole/stream.h> #include <guacamole/stream.h>
@ -33,7 +34,7 @@ int guac_ssh_clipboard_handler(guac_user* user, guac_stream* stream,
/* Clear clipboard and prepare for new data */ /* Clear clipboard and prepare for new data */
guac_client* client = user->client; guac_client* client = user->client;
guac_ssh_client* ssh_client = (guac_ssh_client*) client->data; guac_ssh_client* ssh_client = (guac_ssh_client*) client->data;
guac_common_clipboard_reset(ssh_client->clipboard, mimetype); guac_common_clipboard_reset(ssh_client->term->clipboard, mimetype);
/* Set handlers for clipboard stream */ /* Set handlers for clipboard stream */
stream->blob_handler = guac_ssh_clipboard_blob_handler; stream->blob_handler = guac_ssh_clipboard_blob_handler;
@ -48,7 +49,7 @@ int guac_ssh_clipboard_blob_handler(guac_user* user, guac_stream* stream,
/* Append new data */ /* Append new data */
guac_client* client = user->client; guac_client* client = user->client;
guac_ssh_client* ssh_client = (guac_ssh_client*) client->data; guac_ssh_client* ssh_client = (guac_ssh_client*) client->data;
guac_common_clipboard_append(ssh_client->clipboard, data, length); guac_common_clipboard_append(ssh_client->term->clipboard, data, length);
return 0; return 0;
} }

View File

@ -24,6 +24,7 @@
#include "common/recording.h" #include "common/recording.h"
#include "ssh.h" #include "ssh.h"
#include "terminal/terminal.h" #include "terminal/terminal.h"
#include "terminal/terminal_priv.h"
#include <guacamole/client.h> #include <guacamole/client.h>
#include <guacamole/user.h> #include <guacamole/user.h>

View File

@ -27,6 +27,7 @@
#include "sftp.h" #include "sftp.h"
#include "ssh.h" #include "ssh.h"
#include "terminal/terminal.h" #include "terminal/terminal.h"
#include "terminal/terminal_priv.h"
#include "ttymode.h" #include "ttymode.h"
#ifdef ENABLE_SSH_AGENT #ifdef ENABLE_SSH_AGENT
@ -240,8 +241,7 @@ void* ssh_client_thread(void* data) {
/* Create terminal options with required parameters */ /* Create terminal options with required parameters */
guac_terminal_options* options = guac_terminal_options_create( guac_terminal_options* options = guac_terminal_options_create(
client, ssh_client->clipboard, client, settings->width, settings->height, settings->resolution);
settings->width, settings->height, settings->resolution);
/* Set optional parameters */ /* Set optional parameters */
options->disable_copy = settings->disable_copy; options->disable_copy = settings->disable_copy;

View File

@ -90,11 +90,6 @@ typedef struct guac_ssh_client {
*/ */
pthread_mutex_t term_channel_lock; pthread_mutex_t term_channel_lock;
/**
* The current clipboard contents.
*/
guac_common_clipboard* clipboard;
/** /**
* The terminal which will render all output from the SSH client. * The terminal which will render all output from the SSH client.
*/ */

View File

@ -25,6 +25,7 @@
#include "input.h" #include "input.h"
#include "user.h" #include "user.h"
#include "pipe.h" #include "pipe.h"
#include "terminal/terminal_priv.h"
#include "sftp.h" #include "sftp.h"
#include "ssh.h" #include "ssh.h"
#include "settings.h" #include "settings.h"

View File

@ -21,6 +21,7 @@
#include "argv.h" #include "argv.h"
#include "telnet.h" #include "telnet.h"
#include "terminal/terminal.h" #include "terminal/terminal.h"
#include "terminal/terminal_priv.h"
#include <guacamole/protocol.h> #include <guacamole/protocol.h>
#include <guacamole/socket.h> #include <guacamole/socket.h>

View File

@ -23,7 +23,6 @@
#include "common/recording.h" #include "common/recording.h"
#include "settings.h" #include "settings.h"
#include "telnet.h" #include "telnet.h"
#include "terminal/terminal.h"
#include "user.h" #include "user.h"
#include <langinfo.h> #include <langinfo.h>
@ -44,9 +43,6 @@ int guac_client_init(guac_client* client) {
guac_telnet_client* telnet_client = calloc(1, sizeof(guac_telnet_client)); guac_telnet_client* telnet_client = calloc(1, sizeof(guac_telnet_client));
client->data = telnet_client; client->data = telnet_client;
/* Init clipboard */
telnet_client->clipboard = guac_common_clipboard_alloc(GUAC_TELNET_CLIPBOARD_MAX_LENGTH);
/* Init telnet client */ /* Init telnet client */
telnet_client->socket_fd = -1; telnet_client->socket_fd = -1;
telnet_client->naws_enabled = 0; telnet_client->naws_enabled = 0;
@ -100,7 +96,6 @@ int guac_telnet_client_free_handler(guac_client* client) {
if (telnet_client->settings != NULL) if (telnet_client->settings != NULL)
guac_telnet_settings_free(telnet_client->settings); guac_telnet_settings_free(telnet_client->settings);
guac_common_clipboard_free(telnet_client->clipboard);
free(telnet_client); free(telnet_client);
return 0; return 0;

View File

@ -29,11 +29,6 @@
#include <libtelnet.h> #include <libtelnet.h>
/**
* The maximum number of bytes to allow within the clipboard.
*/
#define GUAC_TELNET_CLIPBOARD_MAX_LENGTH 262144
/** /**
* Free handler. Required by libguac and called when the guac_client is * Free handler. Required by libguac and called when the guac_client is
* disconnected and must be cleaned up. * disconnected and must be cleaned up.

View File

@ -22,6 +22,7 @@
#include "common/clipboard.h" #include "common/clipboard.h"
#include "telnet.h" #include "telnet.h"
#include "terminal/terminal.h" #include "terminal/terminal.h"
#include "terminal/terminal_priv.h"
#include <guacamole/client.h> #include <guacamole/client.h>
#include <guacamole/stream.h> #include <guacamole/stream.h>
@ -33,7 +34,7 @@ int guac_telnet_clipboard_handler(guac_user* user, guac_stream* stream,
/* Clear clipboard and prepare for new data */ /* Clear clipboard and prepare for new data */
guac_client* client = user->client; guac_client* client = user->client;
guac_telnet_client* telnet_client = (guac_telnet_client*) client->data; guac_telnet_client* telnet_client = (guac_telnet_client*) client->data;
guac_common_clipboard_reset(telnet_client->clipboard, mimetype); guac_common_clipboard_reset(telnet_client->term->clipboard, mimetype);
/* Set handlers for clipboard stream */ /* Set handlers for clipboard stream */
stream->blob_handler = guac_telnet_clipboard_blob_handler; stream->blob_handler = guac_telnet_clipboard_blob_handler;
@ -48,7 +49,7 @@ int guac_telnet_clipboard_blob_handler(guac_user* user, guac_stream* stream,
/* Append new data */ /* Append new data */
guac_client* client = user->client; guac_client* client = user->client;
guac_telnet_client* telnet_client = (guac_telnet_client*) client->data; guac_telnet_client* telnet_client = (guac_telnet_client*) client->data;
guac_common_clipboard_append(telnet_client->clipboard, data, length); guac_common_clipboard_append(telnet_client->term->clipboard, data, length);
return 0; return 0;
} }

View File

@ -21,6 +21,7 @@
#include "common/recording.h" #include "common/recording.h"
#include "input.h" #include "input.h"
#include "terminal/terminal.h" #include "terminal/terminal.h"
#include "terminal/terminal_priv.h"
#include "telnet.h" #include "telnet.h"
#include <guacamole/client.h> #include <guacamole/client.h>

View File

@ -23,6 +23,7 @@
#include "common/recording.h" #include "common/recording.h"
#include "telnet.h" #include "telnet.h"
#include "terminal/terminal.h" #include "terminal/terminal.h"
#include "terminal/terminal_priv.h"
#include <guacamole/client.h> #include <guacamole/client.h>
#include <guacamole/protocol.h> #include <guacamole/protocol.h>
@ -587,8 +588,7 @@ void* guac_telnet_client_thread(void* data) {
/* Create terminal options with required parameters */ /* Create terminal options with required parameters */
guac_terminal_options* options = guac_terminal_options_create( guac_terminal_options* options = guac_terminal_options_create(
client, telnet_client->clipboard, client, settings->width, settings->height, settings->resolution);
settings->width, settings->height, settings->resolution);
/* Set optional parameters */ /* Set optional parameters */
options->disable_copy = settings->disable_copy; options->disable_copy = settings->disable_copy;

View File

@ -21,7 +21,6 @@
#define GUAC_TELNET_H #define GUAC_TELNET_H
#include "config.h" #include "config.h"
#include "common/clipboard.h"
#include "common/recording.h" #include "common/recording.h"
#include "settings.h" #include "settings.h"
#include "terminal/terminal.h" #include "terminal/terminal.h"
@ -67,11 +66,6 @@ typedef struct guac_telnet_client {
*/ */
int echo_enabled; int echo_enabled;
/**
* The current clipboard contents.
*/
guac_common_clipboard* clipboard;
/** /**
* The terminal which will render all output from the telnet client. * The terminal which will render all output from the telnet client.
*/ */

View File

@ -26,6 +26,7 @@
#include "settings.h" #include "settings.h"
#include "telnet.h" #include "telnet.h"
#include "terminal/terminal.h" #include "terminal/terminal.h"
#include "terminal/terminal_priv.h"
#include "user.h" #include "user.h"
#include <guacamole/client.h> #include <guacamole/client.h>

View File

@ -55,7 +55,7 @@ int guac_client_init(guac_client* client) {
#endif #endif
/* Init clipboard */ /* Init clipboard */
vnc_client->clipboard = guac_common_clipboard_alloc(GUAC_VNC_CLIPBOARD_MAX_LENGTH); vnc_client->clipboard = guac_common_clipboard_alloc();
/* Set handlers */ /* Set handlers */
client->join_handler = guac_vnc_user_join_handler; client->join_handler = guac_vnc_user_join_handler;

View File

@ -49,11 +49,6 @@
*/ */
#define GUAC_VNC_CONNECT_INTERVAL 1000 #define GUAC_VNC_CONNECT_INTERVAL 1000
/**
* The maximum number of bytes to allow within the clipboard.
*/
#define GUAC_VNC_CLIPBOARD_MAX_LENGTH 262144
/** /**
* Handler which frees all data associated with the guac_client. * Handler which frees all data associated with the guac_client.
*/ */

View File

@ -103,7 +103,7 @@ int guac_vnc_clipboard_end_handler(guac_user* user, guac_stream* stream) {
guac_vnc_client* vnc_client = (guac_vnc_client*) user->client->data; guac_vnc_client* vnc_client = (guac_vnc_client*) user->client->data;
rfbClient* rfb_client = vnc_client->rfb_client; rfbClient* rfb_client = vnc_client->rfb_client;
char output_data[GUAC_VNC_CLIPBOARD_MAX_LENGTH]; char output_data[GUAC_COMMON_CLIPBOARD_MAX_LENGTH];
const char* input = vnc_client->clipboard->buffer; const char* input = vnc_client->clipboard->buffer;
char* output = output_data; char* output = output_data;
@ -129,7 +129,7 @@ void guac_vnc_cut_text(rfbClient* client, const char* text, int textlen) {
if (vnc_client->settings->disable_copy) if (vnc_client->settings->disable_copy)
return; return;
char received_data[GUAC_VNC_CLIPBOARD_MAX_LENGTH]; char received_data[GUAC_COMMON_CLIPBOARD_MAX_LENGTH];
const char* input = text; const char* input = text;
char* output = received_data; char* output = received_data;

View File

@ -30,6 +30,9 @@ lib_LTLIBRARIES = libguac-terminal.la
libguac_terminalincdir = $(includedir)/guacamole/terminal libguac_terminalincdir = $(includedir)/guacamole/terminal
noinst_HEADERS = \
terminal/terminal_priv.h
libguac_terminalinc_HEADERS = \ libguac_terminalinc_HEADERS = \
terminal/buffer.h \ terminal/buffer.h \
terminal/char_mappings.h \ terminal/char_mappings.h \

View File

@ -24,6 +24,7 @@
#include "terminal/display.h" #include "terminal/display.h"
#include "terminal/select.h" #include "terminal/select.h"
#include "terminal/terminal.h" #include "terminal/terminal.h"
#include "terminal/terminal_priv.h"
#include "terminal/types.h" #include "terminal/types.h"
#include <guacamole/client.h> #include <guacamole/client.h>

View File

@ -20,6 +20,7 @@
#include "config.h" #include "config.h"
#include "terminal/common.h" #include "terminal/common.h"
#include "terminal/terminal.h" #include "terminal/terminal.h"
#include "terminal/terminal_priv.h"
#include <guacamole/protocol.h> #include <guacamole/protocol.h>
#include <guacamole/socket.h> #include <guacamole/socket.h>

View File

@ -29,6 +29,7 @@
#include "terminal/select.h" #include "terminal/select.h"
#include "terminal/terminal.h" #include "terminal/terminal.h"
#include "terminal/terminal_handlers.h" #include "terminal/terminal_handlers.h"
#include "terminal/terminal_priv.h"
#include "terminal/types.h" #include "terminal/types.h"
#include "terminal/typescript.h" #include "terminal/typescript.h"
@ -307,14 +308,13 @@ void* guac_terminal_thread(void* data) {
} }
guac_terminal_options* guac_terminal_options_create(guac_client* client, guac_terminal_options* guac_terminal_options_create(guac_client* client,
guac_common_clipboard* clipboard, int width, int height, int dpi) { int width, int height, int dpi) {
guac_terminal_options* options = malloc(sizeof(guac_terminal_options)); guac_terminal_options* options = malloc(sizeof(guac_terminal_options));
/* Set all required parameters */ /* Set all required parameters */
options->client = client; options->client = client;
options->clipboard = clipboard;
options->width = width; options->width = width;
options->height = height; options->height = height;
options->dpi = dpi; options->dpi = dpi;
@ -416,7 +416,7 @@ guac_terminal* guac_terminal_create(guac_terminal_options* options) {
/* Init terminal state */ /* Init terminal state */
term->current_attributes = default_char.attributes; term->current_attributes = default_char.attributes;
term->default_char = default_char; term->default_char = default_char;
term->clipboard = options->clipboard; term->clipboard = guac_common_clipboard_alloc();
term->disable_copy = options->disable_copy; term->disable_copy = options->disable_copy;
/* Calculate character size */ /* Calculate character size */
@ -546,6 +546,9 @@ void guac_terminal_free(guac_terminal* term) {
free((char*) term->color_scheme); free((char*) term->color_scheme);
free((char*) term->font_name); free((char*) term->font_name);
/* Free clipboard */
guac_common_clipboard_free(term->clipboard);
/* Free the terminal itself */ /* Free the terminal itself */
free(term); free(term);

View File

@ -24,7 +24,6 @@
#include "config.h" #include "config.h"
#include "buffer.h" #include "buffer.h"
#include "common/clipboard.h"
#include "common/cursor.h" #include "common/cursor.h"
#include "display.h" #include "display.h"
#include "scrollbar.h" #include "scrollbar.h"
@ -156,428 +155,6 @@ typedef void guac_terminal_upload_path_handler(guac_client* client, char* path);
*/ */
typedef guac_stream* guac_terminal_file_download_handler(guac_client* client, char* filename); typedef guac_stream* guac_terminal_file_download_handler(guac_client* client, char* filename);
/**
* Represents a terminal emulator which uses a given Guacamole client to
* render itself.
*/
struct guac_terminal {
/**
* The Guacamole client associated with this terminal emulator.
*/
guac_client* client;
/**
* Whether user input should be handled and this terminal should render
* frames. Initially, this will be false, user input will be ignored, and
* rendering of frames will be withheld until guac_terminal_start() has
* been invoked. The data within frames will still be rendered, and text
* data received will still be handled, however actual frame boundaries
* will not be sent.
*/
bool started;
/**
* The terminal render thread.
*/
pthread_t thread;
/**
* Called whenever the necessary terminal codes are sent to change
* the path for future file uploads.
*/
guac_terminal_upload_path_handler* upload_path_handler;
/**
* Called whenever the necessary terminal codes are sent to initiate
* a download of a given remote file.
*/
guac_terminal_file_download_handler* file_download_handler;
/**
* Lock which restricts simultaneous access to this terminal via the root
* guac_terminal_* functions.
*/
pthread_mutex_t lock;
/**
* The mutex associated with the modified condition and flag, locked
* whenever a thread is waiting on the modified condition, the modified
* condition is being signalled, or the modified flag is being changed.
*/
pthread_mutex_t modified_lock;
/**
* Flag set whenever an operation has affected the terminal in a way that
* will require a frame flush. When this flag is set, the modified_cond
* condition will be signalled. The modified_lock will always be
* acquired before this flag is altered.
*/
int modified;
/**
* Condition which is signalled when the modified flag has been set
*/
pthread_cond_t modified_cond;
/**
* Pipe which will be the source of user input. When a terminal code
* generates synthesized user input, that data will be written to
* this pipe.
*/
int stdin_pipe_fd[2];
/**
* The currently-open pipe stream from which all terminal input should be
* read, if any. If no pipe stream is open, terminal input will be received
* through keyboard, clipboard, and mouse events, and this value will be
* NULL.
*/
guac_stream* input_stream;
/**
* The currently-open pipe stream to which all terminal output should be
* written, if any. If no pipe stream is open, terminal output will be
* written to the terminal display, and this value will be NULL.
*/
guac_stream* pipe_stream;
/**
* Bitwise OR of all flags which apply to the currently-open pipe stream.
* If no pipe stream is open, this value has no meaning, and its contents
* are undefined.
*
* @see GUAC_TERMINAL_PIPE_INTERPRET_OUTPUT
* @see GUAC_TERMINAL_PIPE_AUTOFLUSH
*/
int pipe_stream_flags;
/**
* Buffer of data pending write to the pipe_stream. Data within this buffer
* will be flushed to the pipe_stream when either (1) the buffer is full
* and another character needs to be written or (2) the pipe_stream is
* closed.
*/
char pipe_buffer[6048];
/**
* The number of bytes currently stored within the pipe_buffer.
*/
int pipe_buffer_length;
/**
* The currently-active typescript recording all terminal output, or NULL
* if no typescript is being used for the terminal session.
*/
guac_terminal_typescript* typescript;
/**
* Terminal-wide mouse cursor, synchronized across all users.
*/
guac_common_cursor* cursor;
/**
* Graphical representation of the current scroll state.
*/
guac_terminal_scrollbar* scrollbar;
/**
* The relative offset of the display. A positive value indicates that
* many rows have been scrolled into view, zero indicates that no
* scrolling has occurred. Negative values are illegal.
*/
int scroll_offset;
/**
* The maximum number of rows to allow within the terminal buffer. Note
* that while this value is traditionally referred to as the scrollback
* size, it actually encompasses both the display and the off-screen
* region. The terminal will ensure enough buffer space is allocated for
* the on-screen rows, even if this exceeds the defined maximum, however
* additional rows for off-screen data will only be available if the
* display is smaller than this value.
*/
int max_scrollback;
/**
* The number of rows that the user has requested be avalable within the
* terminal buffer. This value may be adjusted by the user while the
* terminal is running through console codes, and will adjust the number
* of rows available within the terminal buffer, subject to the maximum
* defined at terminal creation and stored within max_scrollback.
*/
int requested_scrollback;
/**
* The width of the space available to all components of the terminal, in
* pixels. This may include space which will not actually be used for
* character rendering.
*/
int outer_width;
/**
* The height of the space available to all components of the terminal, in
* pixels. This may include space which will not actually be used for
* character rendering.
*/
int outer_height;
/**
* The width of the terminal, in pixels.
*/
int width;
/**
* The height of the terminal, in pixels.
*/
int height;
/**
* The width of the terminal, in characters.
*/
int term_width;
/**
* The height of the terminal, in characters.
*/
int term_height;
/**
* The index of the first row in the scrolling region.
*/
int scroll_start;
/**
* The index of the last row in the scrolling region.
*/
int scroll_end;
/**
* The current row location of the cursor. Note that while most terminal
* operations will clip the cursor location within the bounds of the
* terminal, this is not guaranteed.
*/
int cursor_row;
/**
* The current column location of the cursor. Note that while most
* terminal operations will clip the cursor location within the bounds
* of the terminal, this is not guaranteed. There are times when the
* cursor is legitimately outside the terminal bounds (such as when the
* end of a line is reached, but it is not yet necessary to scroll up).
*/
int cursor_col;
/**
* The desired visibility state of the cursor.
*/
bool cursor_visible;
/**
* The row of the rendered cursor.
* Will be set to -1 if the cursor is not visible.
*/
int visible_cursor_row;
/**
* The column of the rendered cursor.
* Will be set to -1 if the cursor is not visible.
*/
int visible_cursor_col;
/**
* The row of the saved cursor (ESC 7).
*/
int saved_cursor_row;
/**
* The column of the saved cursor (ESC 7).
*/
int saved_cursor_col;
/**
* The attributes which will be applied to future characters.
*/
guac_terminal_attributes current_attributes;
/**
* The character whose attributes dictate the default attributes
* of all characters. When new screen space is allocated, this
* character fills the gaps.
*/
guac_terminal_char default_char;
/**
* Handler which will receive all printed characters, updating the terminal
* accordingly.
*/
guac_terminal_char_handler* char_handler;
/**
* The difference between the currently-rendered screen and the current
* state of the terminal, and the contextual information necessary to
* interpret and render those differences.
*/
guac_terminal_display* display;
/**
* Current terminal display state. All characters present on the screen
* are within this buffer. This has nothing to do with the display, which
* facilitates transfer of a set of changes to the remote display.
*/
guac_terminal_buffer* buffer;
/**
* Automatically place a tabstop every N characters. If zero, then no
* tabstops exist automatically.
*/
int tab_interval;
/**
* Array of all tabs set. Each entry is the column number of a tab + 1,
* or 0 if that tab cell is unset.
*/
int custom_tabs[GUAC_TERMINAL_MAX_TABS];
/**
* Array of arrays of mapped characters, where the character N is located at the N-32
* position within the array. Each element in a contained array is the corresponding Unicode
* codepoint. If NULL, a direct mapping from Unicode is used. The entries of the main array
* correspond to the character set in use (G0, G1, etc.)
*/
const int* char_mapping[2];
/**
* The active character set. For example, 0 for G0, 1 for G1, etc.
*/
int active_char_set;
/**
* Whether text is currently selected.
*/
bool text_selected;
/**
* Whether the selection is finished, and will no longer be modified. A
* committed selection remains highlighted for reference, but the
* highlight will be removed if characters within the selected region are
* modified.
*/
bool selection_committed;
/**
* The row that the selection starts at.
*/
int selection_start_row;
/**
* The column that the selection starts at.
*/
int selection_start_column;
/**
* The width of the character at selection start.
*/
int selection_start_width;
/**
* The row that the selection ends at.
*/
int selection_end_row;
/**
* The column that the selection ends at.
*/
int selection_end_column;
/**
* The width of the character at selection end.
*/
int selection_end_width;
/**
* Whether the cursor (arrow) keys should send cursor sequences
* or application sequences (DECCKM).
*/
bool application_cursor_keys;
/**
* Whether a CR should automatically follow a LF, VT, or FF.
*/
bool automatic_carriage_return;
/**
* Whether insert mode is enabled (DECIM).
*/
bool insert_mode;
/**
* Whether the alt key is currently being held down.
*/
int mod_alt;
/**
* Whether the control key is currently being held down.
*/
int mod_ctrl;
/**
* Whether the shift key is currently being held down.
*/
int mod_shift;
/**
* The current mouse button state.
*/
int mouse_mask;
/**
* The current mouse cursor, to avoid re-setting the cursor image.
*/
guac_terminal_cursor_type current_cursor;
/**
* The current contents of the clipboard. This clipboard instance is
* maintained externally (will not be freed when this terminal is freed)
* and will be updated both internally by the terminal and externally
* through received clipboard instructions.
*/
guac_common_clipboard* clipboard;
/**
* The name of the font to use when rendering glyphs, as requested at
* creation time or via guac_terminal_apply_font().
*/
const char* font_name;
/**
* The size of each glyph, in points, as requested at creation time or via
* guac_terminal_apply_font().
*/
int font_size;
/**
* The name of the color scheme to use, as requested at creation time or
* via guac_terminal_apply_color_scheme(). This string must be in the
* format accepted by guac_terminal_parse_color_scheme().
*/
const char* color_scheme;
/**
* ASCII character to send when backspace is pressed.
*/
char backspace;
/**
* Whether copying from the terminal clipboard should be blocked. If set,
* the contents of the terminal can still be copied, but will be usable
* only within the terminal itself. The clipboard contents will not be
* automatically streamed to the client.
*/
bool disable_copy;
};
/** /**
* Configuration options that may be passed when creating a new guac_terminal. * Configuration options that may be passed when creating a new guac_terminal.
* *
@ -591,15 +168,6 @@ typedef struct guac_terminal_options {
*/ */
guac_client* client; guac_client* client;
/**
* The guac_common_clipboard which will contain the current clipboard
* state. It is expected that this clipboard instance will be updated
* both internally by the terminal and externally through received
* clipboard instructions. This clipboard will not be automatically
* freed when this terminal is freed.
*/
guac_common_clipboard* clipboard;
/** /**
* Whether copying from the terminal clipboard should be blocked. If set, * Whether copying from the terminal clipboard should be blocked. If set,
* the contents of the terminal can still be copied, but will be usable * the contents of the terminal can still be copied, but will be usable
@ -691,10 +259,6 @@ guac_terminal* guac_terminal_create(guac_terminal_options* terminal_options);
* @param guac_client * @param guac_client
* The client to which the terminal will be rendered. * The client to which the terminal will be rendered.
* *
* @param clipboard
* The guac_common_clipboard which will contain the current clipboard
* state.
*
* @param width * @param width
* The width of the terminal, in pixels. * The width of the terminal, in pixels.
* *
@ -710,7 +274,7 @@ guac_terminal* guac_terminal_create(guac_terminal_options* terminal_options);
* ready to have any defaults overriden as needed. * ready to have any defaults overriden as needed.
*/ */
guac_terminal_options* guac_terminal_options_create(guac_client* client, guac_terminal_options* guac_terminal_options_create(guac_client* client,
guac_common_clipboard* clipboard, int width, int height, int dpi); int width, int height, int dpi);
/** /**
* Frees all resources associated with the given terminal. * Frees all resources associated with the given terminal.

View File

@ -0,0 +1,450 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
#ifndef _GUAC_TERMINAL_PRIV_H
#define _GUAC_TERMINAL_PRIV_H
#include "common/clipboard.h"
#include "terminal/terminal.h"
/**
* Represents a terminal emulator which uses a given Guacamole client to
* render itself.
*/
struct guac_terminal {
/**
* The Guacamole client associated with this terminal emulator.
*/
guac_client* client;
/**
* Whether user input should be handled and this terminal should render
* frames. Initially, this will be false, user input will be ignored, and
* rendering of frames will be withheld until guac_terminal_start() has
* been invoked. The data within frames will still be rendered, and text
* data received will still be handled, however actual frame boundaries
* will not be sent.
*/
bool started;
/**
* The terminal render thread.
*/
pthread_t thread;
/**
* Called whenever the necessary terminal codes are sent to change
* the path for future file uploads.
*/
guac_terminal_upload_path_handler* upload_path_handler;
/**
* Called whenever the necessary terminal codes are sent to initiate
* a download of a given remote file.
*/
guac_terminal_file_download_handler* file_download_handler;
/**
* Lock which restricts simultaneous access to this terminal via the root
* guac_terminal_* functions.
*/
pthread_mutex_t lock;
/**
* The mutex associated with the modified condition and flag, locked
* whenever a thread is waiting on the modified condition, the modified
* condition is being signalled, or the modified flag is being changed.
*/
pthread_mutex_t modified_lock;
/**
* Flag set whenever an operation has affected the terminal in a way that
* will require a frame flush. When this flag is set, the modified_cond
* condition will be signalled. The modified_lock will always be
* acquired before this flag is altered.
*/
int modified;
/**
* Condition which is signalled when the modified flag has been set
*/
pthread_cond_t modified_cond;
/**
* Pipe which will be the source of user input. When a terminal code
* generates synthesized user input, that data will be written to
* this pipe.
*/
int stdin_pipe_fd[2];
/**
* The currently-open pipe stream from which all terminal input should be
* read, if any. If no pipe stream is open, terminal input will be received
* through keyboard, clipboard, and mouse events, and this value will be
* NULL.
*/
guac_stream* input_stream;
/**
* The currently-open pipe stream to which all terminal output should be
* written, if any. If no pipe stream is open, terminal output will be
* written to the terminal display, and this value will be NULL.
*/
guac_stream* pipe_stream;
/**
* Bitwise OR of all flags which apply to the currently-open pipe stream.
* If no pipe stream is open, this value has no meaning, and its contents
* are undefined.
*
* @see GUAC_TERMINAL_PIPE_INTERPRET_OUTPUT
* @see GUAC_TERMINAL_PIPE_AUTOFLUSH
*/
int pipe_stream_flags;
/**
* Buffer of data pending write to the pipe_stream. Data within this buffer
* will be flushed to the pipe_stream when either (1) the buffer is full
* and another character needs to be written or (2) the pipe_stream is
* closed.
*/
char pipe_buffer[6048];
/**
* The number of bytes currently stored within the pipe_buffer.
*/
int pipe_buffer_length;
/**
* The currently-active typescript recording all terminal output, or NULL
* if no typescript is being used for the terminal session.
*/
guac_terminal_typescript* typescript;
/**
* Terminal-wide mouse cursor, synchronized across all users.
*/
guac_common_cursor* cursor;
/**
* Graphical representation of the current scroll state.
*/
guac_terminal_scrollbar* scrollbar;
/**
* The relative offset of the display. A positive value indicates that
* many rows have been scrolled into view, zero indicates that no
* scrolling has occurred. Negative values are illegal.
*/
int scroll_offset;
/**
* The maximum number of rows to allow within the terminal buffer. Note
* that while this value is traditionally referred to as the scrollback
* size, it actually encompasses both the display and the off-screen
* region. The terminal will ensure enough buffer space is allocated for
* the on-screen rows, even if this exceeds the defined maximum, however
* additional rows for off-screen data will only be available if the
* display is smaller than this value.
*/
int max_scrollback;
/**
* The number of rows that the user has requested be avalable within the
* terminal buffer. This value may be adjusted by the user while the
* terminal is running through console codes, and will adjust the number
* of rows available within the terminal buffer, subject to the maximum
* defined at terminal creation and stored within max_scrollback.
*/
int requested_scrollback;
/**
* The width of the space available to all components of the terminal, in
* pixels. This may include space which will not actually be used for
* character rendering.
*/
int outer_width;
/**
* The height of the space available to all components of the terminal, in
* pixels. This may include space which will not actually be used for
* character rendering.
*/
int outer_height;
/**
* The width of the terminal, in pixels.
*/
int width;
/**
* The height of the terminal, in pixels.
*/
int height;
/**
* The width of the terminal, in characters.
*/
int term_width;
/**
* The height of the terminal, in characters.
*/
int term_height;
/**
* The index of the first row in the scrolling region.
*/
int scroll_start;
/**
* The index of the last row in the scrolling region.
*/
int scroll_end;
/**
* The current row location of the cursor. Note that while most terminal
* operations will clip the cursor location within the bounds of the
* terminal, this is not guaranteed.
*/
int cursor_row;
/**
* The current column location of the cursor. Note that while most
* terminal operations will clip the cursor location within the bounds
* of the terminal, this is not guaranteed. There are times when the
* cursor is legitimately outside the terminal bounds (such as when the
* end of a line is reached, but it is not yet necessary to scroll up).
*/
int cursor_col;
/**
* The desired visibility state of the cursor.
*/
bool cursor_visible;
/**
* The row of the rendered cursor.
* Will be set to -1 if the cursor is not visible.
*/
int visible_cursor_row;
/**
* The column of the rendered cursor.
* Will be set to -1 if the cursor is not visible.
*/
int visible_cursor_col;
/**
* The row of the saved cursor (ESC 7).
*/
int saved_cursor_row;
/**
* The column of the saved cursor (ESC 7).
*/
int saved_cursor_col;
/**
* The attributes which will be applied to future characters.
*/
guac_terminal_attributes current_attributes;
/**
* The character whose attributes dictate the default attributes
* of all characters. When new screen space is allocated, this
* character fills the gaps.
*/
guac_terminal_char default_char;
/**
* Handler which will receive all printed characters, updating the terminal
* accordingly.
*/
guac_terminal_char_handler* char_handler;
/**
* The difference between the currently-rendered screen and the current
* state of the terminal, and the contextual information necessary to
* interpret and render those differences.
*/
guac_terminal_display* display;
/**
* Current terminal display state. All characters present on the screen
* are within this buffer. This has nothing to do with the display, which
* facilitates transfer of a set of changes to the remote display.
*/
guac_terminal_buffer* buffer;
/**
* Automatically place a tabstop every N characters. If zero, then no
* tabstops exist automatically.
*/
int tab_interval;
/**
* Array of all tabs set. Each entry is the column number of a tab + 1,
* or 0 if that tab cell is unset.
*/
int custom_tabs[GUAC_TERMINAL_MAX_TABS];
/**
* Array of arrays of mapped characters, where the character N is located at the N-32
* position within the array. Each element in a contained array is the corresponding Unicode
* codepoint. If NULL, a direct mapping from Unicode is used. The entries of the main array
* correspond to the character set in use (G0, G1, etc.)
*/
const int* char_mapping[2];
/**
* The active character set. For example, 0 for G0, 1 for G1, etc.
*/
int active_char_set;
/**
* Whether text is currently selected.
*/
bool text_selected;
/**
* Whether the selection is finished, and will no longer be modified. A
* committed selection remains highlighted for reference, but the
* highlight will be removed if characters within the selected region are
* modified.
*/
bool selection_committed;
/**
* The row that the selection starts at.
*/
int selection_start_row;
/**
* The column that the selection starts at.
*/
int selection_start_column;
/**
* The width of the character at selection start.
*/
int selection_start_width;
/**
* The row that the selection ends at.
*/
int selection_end_row;
/**
* The column that the selection ends at.
*/
int selection_end_column;
/**
* The width of the character at selection end.
*/
int selection_end_width;
/**
* Whether the cursor (arrow) keys should send cursor sequences
* or application sequences (DECCKM).
*/
bool application_cursor_keys;
/**
* Whether a CR should automatically follow a LF, VT, or FF.
*/
bool automatic_carriage_return;
/**
* Whether insert mode is enabled (DECIM).
*/
bool insert_mode;
/**
* Whether the alt key is currently being held down.
*/
int mod_alt;
/**
* Whether the control key is currently being held down.
*/
int mod_ctrl;
/**
* Whether the shift key is currently being held down.
*/
int mod_shift;
/**
* The current mouse button state.
*/
int mouse_mask;
/**
* The current mouse cursor, to avoid re-setting the cursor image.
*/
guac_terminal_cursor_type current_cursor;
/**
* The current contents of the clipboard. This clipboard instance is
* maintained externally (will not be freed when this terminal is freed)
* and will be updated both internally by the terminal and externally
* through received clipboard instructions.
*/
guac_common_clipboard* clipboard;
/**
* The name of the font to use when rendering glyphs, as requested at
* creation time or via guac_terminal_apply_font().
*/
const char* font_name;
/**
* The size of each glyph, in points, as requested at creation time or via
* guac_terminal_apply_font().
*/
int font_size;
/**
* The name of the color scheme to use, as requested at creation time or
* via guac_terminal_apply_color_scheme(). This string must be in the
* format accepted by guac_terminal_parse_color_scheme().
*/
const char* color_scheme;
/**
* ASCII character to send when backspace is pressed.
*/
char backspace;
/**
* Whether copying from the terminal clipboard should be blocked. If set,
* the contents of the terminal can still be copied, but will be usable
* only within the terminal itself. The clipboard contents will not be
* automatically streamed to the client.
*/
bool disable_copy;
};
#endif

View File

@ -23,6 +23,7 @@
#include "terminal/palette.h" #include "terminal/palette.h"
#include "terminal/terminal.h" #include "terminal/terminal.h"
#include "terminal/terminal_handlers.h" #include "terminal/terminal_handlers.h"
#include "terminal/terminal_priv.h"
#include "terminal/types.h" #include "terminal/types.h"
#include "terminal/xparsecolor.h" #include "terminal/xparsecolor.h"