From 46e813343e4a6896d96a671533a343712a1bda7f Mon Sep 17 00:00:00 2001 From: James Muehlner Date: Sat, 26 Feb 2022 02:13:22 +0000 Subject: [PATCH] GUACAMOLE-1538: Only the core functionality of the terminal lib should be public. --- doc/libguac-terminal/Doxyfile.in | 3 +- src/protocols/ssh/argv.c | 1 + src/protocols/ssh/ssh.c | 22 +- src/protocols/telnet/argv.c | 1 + src/protocols/telnet/client.c | 1 + src/protocols/telnet/telnet.c | 7 +- src/terminal/Makefile.am | 12 +- src/terminal/buffer.c | 1 - src/terminal/char-mappings.c | 1 - src/terminal/color-scheme.c | 1 - src/terminal/common.c | 1 - src/terminal/display.c | 3 +- src/terminal/named-colors.c | 1 - src/terminal/palette.c | 1 - src/terminal/scrollbar.c | 1 - src/terminal/select.c | 1 - src/terminal/terminal-stdin-stream.c | 1 - src/terminal/terminal.c | 1 - src/terminal/terminal/buffer.h | 1 - src/terminal/terminal/char-mappings.h | 1 - src/terminal/terminal/color-scheme.h | 7 +- src/terminal/terminal/common.h | 1 - src/terminal/terminal/display.h | 1 - src/terminal/terminal/named-colors.h | 3 +- src/terminal/terminal/palette.h | 1 - src/terminal/terminal/scrollbar.h | 1 - src/terminal/terminal/select.h | 1 - src/terminal/terminal/terminal-handlers.h | 1 + src/terminal/terminal/terminal-priv.h | 196 ++++++++++++- src/terminal/terminal/terminal.h | 342 +++++----------------- src/terminal/terminal/types.h | 1 - src/terminal/terminal/typescript.h | 1 - src/terminal/terminal/xparsecolor.h | 3 +- src/terminal/typescript.c | 1 - src/terminal/xparsecolor.c | 1 - 35 files changed, 298 insertions(+), 325 deletions(-) diff --git a/doc/libguac-terminal/Doxyfile.in b/doc/libguac-terminal/Doxyfile.in index 640ab48a..aab06575 100644 --- a/doc/libguac-terminal/Doxyfile.in +++ b/doc/libguac-terminal/Doxyfile.in @@ -51,8 +51,7 @@ SHOW_INCLUDE_FILES = NO CASE_SENSE_NAMES = YES FILE_PATTERNS = *.h STRIP_FROM_PATH = ../../src/terminal -INPUT = ../../src/terminal/terminal/ -EXCLUDE = ../../src/terminal/terminal/terminal_priv.h +INPUT = ../../src/terminal/terminal/terminal.h JAVADOC_AUTOBRIEF = YES TAB_SIZE = 4 TYPEDEF_HIDES_STRUCT = YES diff --git a/src/protocols/ssh/argv.c b/src/protocols/ssh/argv.c index 446d0169..a8f31f2e 100644 --- a/src/protocols/ssh/argv.c +++ b/src/protocols/ssh/argv.c @@ -27,6 +27,7 @@ #include #include +#include #include #include diff --git a/src/protocols/ssh/ssh.c b/src/protocols/ssh/ssh.c index e1a16541..847f4730 100644 --- a/src/protocols/ssh/ssh.c +++ b/src/protocols/ssh/ssh.c @@ -36,6 +36,8 @@ #include #include #include +#include +#include #include #include #include @@ -98,7 +100,7 @@ static guac_common_ssh_user* guac_ssh_get_user(guac_client* client) { guac_client_log(client, GUAC_LOG_DEBUG, "Initial import failed: %s", guac_common_ssh_key_error()); - + guac_client_log(client, GUAC_LOG_DEBUG, "Re-attempting private key import (WITH passphrase)"); @@ -148,23 +150,23 @@ static guac_common_ssh_user* guac_ssh_get_user(guac_client* client) { * A function used to generate a terminal prompt to gather additional * credentials from the guac_client during a connection, and using * the specified string to generate the prompt for the user. - * + * * @param client * The guac_client object associated with the current connection * where additional credentials are required. - * + * * @param cred_name * The prompt text to display to the screen when prompting for the * additional credentials. - * - * @return + * + * @return * The string of credentials gathered from the user. */ static char* guac_ssh_get_credential(guac_client *client, char* cred_name) { guac_ssh_client* ssh_client = (guac_ssh_client*) client->data; return guac_terminal_prompt(ssh_client->term, cred_name, false); - + } void* ssh_input_thread(void* data) { @@ -206,17 +208,17 @@ void* ssh_client_thread(void* data) { if (settings->wol_send_packet) { guac_client_log(client, GUAC_LOG_DEBUG, "Sending Wake-on-LAN packet, " "and pausing for %d seconds.", settings->wol_wait_time); - + /* Send the Wake-on-LAN request. */ if (guac_wol_wake(settings->wol_mac_addr, settings->wol_broadcast_addr, settings->wol_udp_port)) return NULL; - + /* If wait time is specified, sleep for that amount of time. */ if (settings->wol_wait_time > 0) guac_timestamp_msleep(settings->wol_wait_time * 1000); } - + /* Init SSH base libraries */ if (guac_common_ssh_init(client)) { guac_client_abort(client, GUAC_PROTOCOL_STATUS_SERVER_ERROR, @@ -360,7 +362,7 @@ void* ssh_client_thread(void* data) { if (!settings->sftp_disable_upload) guac_terminal_set_upload_path_handler(ssh_client->term, guac_sftp_set_upload_path); - + if (!settings->sftp_disable_download) guac_terminal_set_file_download_handler(ssh_client->term, guac_sftp_download_file); diff --git a/src/protocols/telnet/argv.c b/src/protocols/telnet/argv.c index 966584c6..3ea3095e 100644 --- a/src/protocols/telnet/argv.c +++ b/src/protocols/telnet/argv.c @@ -26,6 +26,7 @@ #include #include +#include #include #include diff --git a/src/protocols/telnet/client.c b/src/protocols/telnet/client.c index fcb7e7a2..752234b4 100644 --- a/src/protocols/telnet/client.c +++ b/src/protocols/telnet/client.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include diff --git a/src/protocols/telnet/telnet.c b/src/protocols/telnet/telnet.c index 242542e2..ced9df05 100644 --- a/src/protocols/telnet/telnet.c +++ b/src/protocols/telnet/telnet.c @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -559,17 +560,17 @@ void* guac_telnet_client_thread(void* data) { pthread_t input_thread; char buffer[8192]; int wait_result; - + /* If Wake-on-LAN is enabled, attempt to wake. */ if (settings->wol_send_packet) { guac_client_log(client, GUAC_LOG_DEBUG, "Sending Wake-on-LAN packet, " "and pausing for %d seconds.", settings->wol_wait_time); - + /* Send the Wake-on-LAN request. */ if (guac_wol_wake(settings->wol_mac_addr, settings->wol_broadcast_addr, settings->wol_udp_port)) return NULL; - + /* If wait time is specified, sleep for that amount of time. */ if (settings->wol_wait_time > 0) guac_timestamp_msleep(settings->wol_wait_time * 1000); diff --git a/src/terminal/Makefile.am b/src/terminal/Makefile.am index 4d704e7b..b2c93d64 100644 --- a/src/terminal/Makefile.am +++ b/src/terminal/Makefile.am @@ -23,17 +23,14 @@ # to you by the ASF under the Apache License, Version 2.0, as described above. # -AUTOMAKE_OPTIONS = foreign +AUTOMAKE_OPTIONS = foreign ACLOCAL_AMFLAGS = -I m4 lib_LTLIBRARIES = libguac-terminal.la libguac_terminalincdir = $(includedir)/guacamole/terminal -noinst_HEADERS = \ - terminal/terminal-priv.h - -libguac_terminalinc_HEADERS = \ +noinst_HEADERS = \ terminal/buffer.h \ terminal/char-mappings.h \ terminal/common.h \ @@ -43,12 +40,15 @@ libguac_terminalinc_HEADERS = \ terminal/palette.h \ terminal/scrollbar.h \ terminal/select.h \ - terminal/terminal.h \ + terminal/terminal-priv.h \ terminal/terminal-handlers.h \ terminal/types.h \ terminal/typescript.h \ terminal/xparsecolor.h +libguac_terminalinc_HEADERS = \ + terminal/terminal.h + libguac_terminal_la_SOURCES = \ buffer.c \ char-mappings.c \ diff --git a/src/terminal/buffer.c b/src/terminal/buffer.c index 4ecc5ba5..e8ad4b3c 100644 --- a/src/terminal/buffer.c +++ b/src/terminal/buffer.c @@ -17,7 +17,6 @@ * under the License. */ -#include "config.h" #include "terminal/buffer.h" #include "terminal/common.h" diff --git a/src/terminal/char-mappings.c b/src/terminal/char-mappings.c index 9b9bebcd..421bc388 100644 --- a/src/terminal/char-mappings.c +++ b/src/terminal/char-mappings.c @@ -17,7 +17,6 @@ * under the License. */ -#include "config.h" const int vt100_map[] = { ' ', '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/', diff --git a/src/terminal/color-scheme.c b/src/terminal/color-scheme.c index 5df181fa..c1a9e3ff 100644 --- a/src/terminal/color-scheme.c +++ b/src/terminal/color-scheme.c @@ -17,7 +17,6 @@ * under the License. */ -#include "config.h" #include "terminal/color-scheme.h" #include "terminal/palette.h" diff --git a/src/terminal/common.c b/src/terminal/common.c index 99137534..36675f31 100644 --- a/src/terminal/common.c +++ b/src/terminal/common.c @@ -17,7 +17,6 @@ * under the License. */ -#include "config.h" #include "terminal/types.h" #include diff --git a/src/terminal/display.c b/src/terminal/display.c index e35b8a74..a9d671f6 100644 --- a/src/terminal/display.c +++ b/src/terminal/display.c @@ -17,12 +17,13 @@ * under the License. */ -#include "config.h" #include "common/surface.h" #include "terminal/common.h" #include "terminal/display.h" #include "terminal/palette.h" +#include "terminal/terminal.h" +#include "terminal/terminal-priv.h" #include "terminal/types.h" #include diff --git a/src/terminal/named-colors.c b/src/terminal/named-colors.c index ab94153e..948982af 100644 --- a/src/terminal/named-colors.c +++ b/src/terminal/named-colors.c @@ -17,7 +17,6 @@ * under the License. */ -#include "config.h" #include "terminal/palette.h" #include diff --git a/src/terminal/palette.c b/src/terminal/palette.c index a6b2d5ae..d4975665 100644 --- a/src/terminal/palette.c +++ b/src/terminal/palette.c @@ -17,7 +17,6 @@ * under the License. */ -#include "config.h" #include "terminal/palette.h" const guac_terminal_color GUAC_TERMINAL_INITIAL_PALETTE[256] = { diff --git a/src/terminal/scrollbar.c b/src/terminal/scrollbar.c index ddff2997..a0eec8ec 100644 --- a/src/terminal/scrollbar.c +++ b/src/terminal/scrollbar.c @@ -17,7 +17,6 @@ * under the License. */ -#include "config.h" #include "terminal/scrollbar.h" #include diff --git a/src/terminal/select.c b/src/terminal/select.c index e2622e4d..1698e381 100644 --- a/src/terminal/select.c +++ b/src/terminal/select.c @@ -17,7 +17,6 @@ * under the License. */ -#include "config.h" #include "common/clipboard.h" #include "terminal/buffer.h" diff --git a/src/terminal/terminal-stdin-stream.c b/src/terminal/terminal-stdin-stream.c index 8498a161..9c1e9446 100644 --- a/src/terminal/terminal-stdin-stream.c +++ b/src/terminal/terminal-stdin-stream.c @@ -17,7 +17,6 @@ * under the License. */ -#include "config.h" #include "terminal/common.h" #include "terminal/terminal.h" #include "terminal/terminal-priv.h" diff --git a/src/terminal/terminal.c b/src/terminal/terminal.c index bfe8936a..cb21e93f 100644 --- a/src/terminal/terminal.c +++ b/src/terminal/terminal.c @@ -17,7 +17,6 @@ * under the License. */ -#include "config.h" #include "common/clipboard.h" #include "common/cursor.h" diff --git a/src/terminal/terminal/buffer.h b/src/terminal/terminal/buffer.h index fb5c77f8..00277cb9 100644 --- a/src/terminal/terminal/buffer.h +++ b/src/terminal/terminal/buffer.h @@ -28,7 +28,6 @@ */ -#include "config.h" #include "types.h" diff --git a/src/terminal/terminal/char-mappings.h b/src/terminal/terminal/char-mappings.h index 9af99a94..6d1dab0b 100644 --- a/src/terminal/terminal/char-mappings.h +++ b/src/terminal/terminal/char-mappings.h @@ -27,7 +27,6 @@ * @file char-mappings.h */ -#include "config.h" /** * VT100 graphics mapping. Each entry is the corresponding Unicode codepoint diff --git a/src/terminal/terminal/color-scheme.h b/src/terminal/terminal/color-scheme.h index 5b9a93db..02e24046 100644 --- a/src/terminal/terminal/color-scheme.h +++ b/src/terminal/terminal/color-scheme.h @@ -17,8 +17,8 @@ * under the License. */ -#ifndef GUAC_TERMINAL_GET_COLOR_SCHEME_H -#define GUAC_TERMINAL_GET_COLOR_SCHEME_H +#ifndef GUAC_TERMINAL_COLOR_SCHEME_H +#define GUAC_TERMINAL_COLOR_SCHEME_H /** * Definitions and functions related to color scheme handling. @@ -26,9 +26,8 @@ * @file color-scheme.h */ -#include "config.h" -#include "terminal/palette.h" +#include "palette.h" #include diff --git a/src/terminal/terminal/common.h b/src/terminal/terminal/common.h index 5ca8f37b..e50b702e 100644 --- a/src/terminal/terminal/common.h +++ b/src/terminal/terminal/common.h @@ -27,7 +27,6 @@ * @file common.h */ -#include "config.h" #include "types.h" #include diff --git a/src/terminal/terminal/display.h b/src/terminal/terminal/display.h index 456343da..db85b2ac 100644 --- a/src/terminal/terminal/display.h +++ b/src/terminal/terminal/display.h @@ -27,7 +27,6 @@ * @file display.h */ -#include "config.h" #include "common/surface.h" #include "palette.h" diff --git a/src/terminal/terminal/named-colors.h b/src/terminal/terminal/named-colors.h index ef51f8c0..4571e6e3 100644 --- a/src/terminal/terminal/named-colors.h +++ b/src/terminal/terminal/named-colors.h @@ -26,8 +26,7 @@ * @file named-colors.h */ -#include "config.h" -#include "terminal/palette.h" +#include "palette.h" /** * Searches for the color having the given name, storing that color within the diff --git a/src/terminal/terminal/palette.h b/src/terminal/terminal/palette.h index 88a6b923..b7dc1118 100644 --- a/src/terminal/terminal/palette.h +++ b/src/terminal/terminal/palette.h @@ -26,7 +26,6 @@ * @file palette.h */ -#include "config.h" #include diff --git a/src/terminal/terminal/scrollbar.h b/src/terminal/terminal/scrollbar.h index 9e6c5ebc..c3083377 100644 --- a/src/terminal/terminal/scrollbar.h +++ b/src/terminal/terminal/scrollbar.h @@ -26,7 +26,6 @@ * @file scrollbar.h */ -#include "config.h" #include #include diff --git a/src/terminal/terminal/select.h b/src/terminal/terminal/select.h index 8abdd019..f85eef3a 100644 --- a/src/terminal/terminal/select.h +++ b/src/terminal/terminal/select.h @@ -27,7 +27,6 @@ * @file select.h */ -#include "config.h" #include "terminal.h" #include diff --git a/src/terminal/terminal/terminal-handlers.h b/src/terminal/terminal/terminal-handlers.h index 7a5551d5..d983ae3e 100644 --- a/src/terminal/terminal/terminal-handlers.h +++ b/src/terminal/terminal/terminal-handlers.h @@ -29,6 +29,7 @@ #include "config.h" +#include "display.h" #include "terminal.h" /** diff --git a/src/terminal/terminal/terminal-priv.h b/src/terminal/terminal/terminal-priv.h index b4da851a..4fe85500 100644 --- a/src/terminal/terminal/terminal-priv.h +++ b/src/terminal/terminal/terminal-priv.h @@ -22,7 +22,12 @@ #define GUAC_TERMINAL_PRIV_H #include "common/clipboard.h" -#include "terminal/terminal.h" +#include "common/cursor.h" +#include "buffer.h" +#include "display.h" +#include "scrollbar.h" +#include "terminal.h" +#include "typescript.h" struct guac_terminal { @@ -442,5 +447,194 @@ struct guac_terminal { }; +/** + * Handles a scroll event received from the scrollbar associated with a + * terminal. + * + * @param scrollbar + * The scrollbar that has been scrolled. + * + * @param value + * The new value that should be stored within the scrollbar, and + * represented within the terminal display. + */ +void guac_terminal_scroll_handler(guac_terminal_scrollbar* scrollbar, int value); + +/** + * Sets the given range of columns within the given row to the given + * character. + */ +void guac_terminal_set_columns(guac_terminal* terminal, int row, + int start_column, int end_column, guac_terminal_char* character); + +/** + * Acquires exclusive access to the terminal. Note that enforcing this + * exclusive access requires that ALL users of the terminal call this + * function before making further calls to the terminal. + */ +void guac_terminal_lock(guac_terminal* terminal); + +/** + * Releases exclusive access to the terminal. + */ +void guac_terminal_unlock(guac_terminal* terminal); + +/** + * Resets the state of the given terminal, as if it were just allocated. + */ +void guac_terminal_reset(guac_terminal* term); + +/** + * Sets the character at the given row and column to the specified value. + */ +int guac_terminal_set(guac_terminal* term, int row, int col, int codepoint); + +/** + * Clears the given region within a single row. + */ +int guac_terminal_clear_columns(guac_terminal* term, + int row, int start_col, int end_col); + +/** + * Clears the given region from right-to-left, top-to-bottom, replacing + * all characters with the current background color and attributes. + */ +int guac_terminal_clear_range(guac_terminal* term, + int start_row, int start_col, + int end_row, int end_col); + +/** + * Scrolls the terminal's current scroll region up by one row. + */ +int guac_terminal_scroll_up(guac_terminal* term, + int start_row, int end_row, int amount); + +/** + * Scrolls the terminal's current scroll region down by one row. + */ +int guac_terminal_scroll_down(guac_terminal* term, + int start_row, int end_row, int amount); + +/** + * Commits the current cursor location, updating the visible cursor + * on the screen. + */ +void guac_terminal_commit_cursor(guac_terminal* term); + +/** + * Scroll down the display by the given amount, replacing the new space with + * data from the buffer. If not enough data is available, the maximum + * amount will be scrolled. + */ +void guac_terminal_scroll_display_down(guac_terminal* terminal, int amount); + +/** + * Scroll up the display by the given amount, replacing the new space with data + * from either the buffer or the terminal buffer. If not enough data is + * available, the maximum amount will be scrolled. + */ +void guac_terminal_scroll_display_up(guac_terminal* terminal, int amount); + +/** + * Opens a new pipe stream, redirecting all output from the given terminal to + * that pipe stream. If a pipe stream is already open, that pipe stream will + * be flushed and closed prior to opening the new pipe stream. + * + * @param term + * The terminal which should redirect output to a new pipe stream having + * the given name. + * + * @param name + * The name of the pipe stream to open. + * + * @param flags + * A bitwise OR of all integer flags which should apply to the new pipe + * stream. + * + * @see GUAC_TERMINAL_PIPE_INTERPRET_OUTPUT + * @see GUAC_TERMINAL_PIPE_AUTOFLUSH + */ +void guac_terminal_pipe_stream_open(guac_terminal* term, const char* name, + int flags); + +/** + * Writes a single byte of data to the pipe stream currently open and + * associated with the given terminal. The pipe stream must already have been + * opened via guac_terminal_pipe_stream_open(). If no pipe stream is currently + * open, this function has no effect. Data written through this function may + * be buffered. + * + * @param term + * The terminal whose currently-open pipe stream should be written to. + * + * @param c + * The byte of data to write to the pipe stream. + */ +void guac_terminal_pipe_stream_write(guac_terminal* term, char c); + +/** + * Flushes any data currently buffered for the currently-open pipe stream + * associated with the given terminal. The pipe stream must already have been + * opened via guac_terminal_pipe_stream_open(). If no pipe stream is currently + * open or no data is in the buffer, this function has no effect. + * + * @param term + * The terminal whose pipe stream buffer should be flushed. + */ +void guac_terminal_pipe_stream_flush(guac_terminal* term); + +/** + * Closes the currently-open pipe stream associated with the given terminal, + * redirecting all output back to the terminal display. Any data currently + * buffered for output to the pipe stream will be flushed prior to closure. The + * pipe stream must already have been opened via + * guac_terminal_pipe_stream_open(). If no pipe stream is currently open, this + * function has no effect. + * + * @param term + * The terminal whose currently-open pipe stream should be closed. + */ +void guac_terminal_pipe_stream_close(guac_terminal* term); + +/** + * Sets a tabstop in the given column. + */ +void guac_terminal_set_tab(guac_terminal* term, int column); + +/** + * Removes the tabstop at the given column. + */ +void guac_terminal_unset_tab(guac_terminal* term, int column); + +/** + * Removes all tabstops. + */ +void guac_terminal_clear_tabs(guac_terminal* term); + +/** + * Given a column within the given terminal, returns the location of the + * next tabstop (or the rightmost character, if no more tabstops exist). + */ +int guac_terminal_next_tab(guac_terminal* term, int column); + +/** + * Copies the given range of columns to a new location, offset from + * the original by the given number of columns. + */ +void guac_terminal_copy_columns(guac_terminal* terminal, int row, + int start_column, int end_column, int offset); + +/** + * Copies the given range of rows to a new location, offset from the + * original by the given number of rows. + */ +void guac_terminal_copy_rows(guac_terminal* terminal, + int start_row, int end_row, int offset); + +/** + * Flushes all pending operations within the given guac_terminal. + */ +void guac_terminal_flush(guac_terminal* terminal); + #endif diff --git a/src/terminal/terminal/terminal.h b/src/terminal/terminal/terminal.h index 50aa27dd..47f4d623 100644 --- a/src/terminal/terminal/terminal.h +++ b/src/terminal/terminal/terminal.h @@ -28,15 +28,6 @@ * @file terminal.h */ -#include "config.h" - -#include "buffer.h" -#include "common/cursor.h" -#include "display.h" -#include "scrollbar.h" -#include "types.h" -#include "typescript.h" - #include #include @@ -453,6 +444,52 @@ int guac_terminal_send_key(guac_terminal* term, int keysym, int pressed); int guac_terminal_send_mouse(guac_terminal* term, guac_user* user, int x, int y, int mask); +/** + * Sends the given string as if typed by the user. If terminal input is + * currently coming from a stream due to a prior call to + * guac_terminal_send_stream(), any input which would normally result from + * invoking this function is dropped. + * + * @param term + * The terminal which should receive the given data on STDIN. + * + * @param data + * The data the terminal should receive on STDIN. + * + * @param length + * The size of the given data, in bytes. + * + * @return + * The number of bytes written to STDIN, or a negative value if an error + * occurs preventing the data from being written. This should always be + * the size of the data given unless data is intentionally dropped. + */ +int guac_terminal_send_data(guac_terminal* term, const char* data, int length); + +/** + * Sends the given string as if typed by the user. If terminal input is + * currently coming from a stream due to a prior call to + * guac_terminal_send_stream(), any input which would normally result from + * invoking this function is dropped. + * + * @param term + * The terminal which should receive the given data on STDIN. + * + * @param data + * The data the terminal should receive on STDIN. + * + * @return + * The number of bytes written to STDIN, or a negative value if an error + * occurs preventing the data from being written. This should always be + * the size of the data given unless data is intentionally dropped. + */ +int guac_terminal_send_string(guac_terminal* term, const char* data); + +/** + * Writes the given string of characters to the terminal. + */ +int guac_terminal_write(guac_terminal* term, const char* c, int size); + /** * Initializes the handlers of the given guac_stream such that it serves as the * source of input to the terminal. Other input sources will be temporarily @@ -482,17 +519,27 @@ int guac_terminal_send_stream(guac_terminal* term, guac_user* user, guac_stream* stream); /** - * Handles a scroll event received from the scrollbar associated with a - * terminal. + * Sends data through STDIN as if typed by the user, using the format string + * given and any args (similar to printf). If terminal input is currently + * coming from a stream due to a prior call to guac_terminal_send_stream(), any + * input which would normally result from invoking this function is dropped. * - * @param scrollbar - * The scrollbar that has been scrolled. + * @param term + * The terminal which should receive the given data on STDIN. * - * @param value - * The new value that should be stored within the scrollbar, and - * represented within the terminal display. + * @param format + * A printf-style format string describing the data to be received on + * STDIN. + * + * @param ... + * Any srguments to use when filling the format string. + * + * @return + * The number of bytes written to STDIN, or a negative value if an error + * occurs preventing the data from being written. This should always be + * the size of the data given unless data is intentionally dropped. */ -void guac_terminal_scroll_handler(guac_terminal_scrollbar* scrollbar, int value); +int guac_terminal_sendf(guac_terminal* term, const char* format, ...); /** * Replicates the current display state to a user that has just joined the @@ -512,6 +559,11 @@ void guac_terminal_scroll_handler(guac_terminal_scrollbar* scrollbar, int value) void guac_terminal_dup(guac_terminal* term, guac_user* user, guac_socket* socket); +/** + * Resize the terminal to the given dimensions. + */ +int guac_terminal_resize(guac_terminal* term, int width, int height); + /** * Returns the number of rows within the buffer of the given terminal which are * not currently displayed on screen. Adjustments to the desired scrollback @@ -588,262 +640,6 @@ void guac_terminal_clipboard_append(guac_terminal* terminal, */ void guac_terminal_remove_user(guac_terminal* terminal, guac_user* user); -/* INTERNAL FUNCTIONS */ - - -/** - * Acquires exclusive access to the terminal. Note that enforcing this - * exclusive access requires that ALL users of the terminal call this - * function before making further calls to the terminal. - */ -void guac_terminal_lock(guac_terminal* terminal); - -/** - * Releases exclusive access to the terminal. - */ -void guac_terminal_unlock(guac_terminal* terminal); - -/** - * Resets the state of the given terminal, as if it were just allocated. - */ -void guac_terminal_reset(guac_terminal* term); - -/** - * Writes the given string of characters to the terminal. - */ -int guac_terminal_write(guac_terminal* term, const char* c, int size); - -/** - * Sets the character at the given row and column to the specified value. - */ -int guac_terminal_set(guac_terminal* term, int row, int col, int codepoint); - -/** - * Clears the given region within a single row. - */ -int guac_terminal_clear_columns(guac_terminal* term, - int row, int start_col, int end_col); - -/** - * Clears the given region from right-to-left, top-to-bottom, replacing - * all characters with the current background color and attributes. - */ -int guac_terminal_clear_range(guac_terminal* term, - int start_row, int start_col, - int end_row, int end_col); - -/** - * Scrolls the terminal's current scroll region up by one row. - */ -int guac_terminal_scroll_up(guac_terminal* term, - int start_row, int end_row, int amount); - -/** - * Scrolls the terminal's current scroll region down by one row. - */ -int guac_terminal_scroll_down(guac_terminal* term, - int start_row, int end_row, int amount); - -/** - * Commits the current cursor location, updating the visible cursor - * on the screen. - */ -void guac_terminal_commit_cursor(guac_terminal* term); - -/** - * Scroll down the display by the given amount, replacing the new space with - * data from the buffer. If not enough data is available, the maximum - * amount will be scrolled. - */ -void guac_terminal_scroll_display_down(guac_terminal* terminal, int amount); - -/** - * Scroll up the display by the given amount, replacing the new space with data - * from either the buffer or the terminal buffer. If not enough data is - * available, the maximum amount will be scrolled. - */ -void guac_terminal_scroll_display_up(guac_terminal* terminal, int amount); - -/* LOW-LEVEL TERMINAL OPERATIONS */ - - -/** - * Copies the given range of columns to a new location, offset from - * the original by the given number of columns. - */ -void guac_terminal_copy_columns(guac_terminal* terminal, int row, - int start_column, int end_column, int offset); - -/** - * Copies the given range of rows to a new location, offset from the - * original by the given number of rows. - */ -void guac_terminal_copy_rows(guac_terminal* terminal, - int start_row, int end_row, int offset); - -/** - * Sets the given range of columns within the given row to the given - * character. - */ -void guac_terminal_set_columns(guac_terminal* terminal, int row, - int start_column, int end_column, guac_terminal_char* character); - -/** - * Resize the terminal to the given dimensions. - */ -int guac_terminal_resize(guac_terminal* term, int width, int height); - -/** - * Flushes all pending operations within the given guac_terminal. - */ -void guac_terminal_flush(guac_terminal* terminal); - -/** - * Sends the given string as if typed by the user. If terminal input is - * currently coming from a stream due to a prior call to - * guac_terminal_send_stream(), any input which would normally result from - * invoking this function is dropped. - * - * @param term - * The terminal which should receive the given data on STDIN. - * - * @param data - * The data the terminal should receive on STDIN. - * - * @param length - * The size of the given data, in bytes. - * - * @return - * The number of bytes written to STDIN, or a negative value if an error - * occurs preventing the data from being written. This should always be - * the size of the data given unless data is intentionally dropped. - */ -int guac_terminal_send_data(guac_terminal* term, const char* data, int length); - -/** - * Sends the given string as if typed by the user. If terminal input is - * currently coming from a stream due to a prior call to - * guac_terminal_send_stream(), any input which would normally result from - * invoking this function is dropped. - * - * @param term - * The terminal which should receive the given data on STDIN. - * - * @param data - * The data the terminal should receive on STDIN. - * - * @return - * The number of bytes written to STDIN, or a negative value if an error - * occurs preventing the data from being written. This should always be - * the size of the data given unless data is intentionally dropped. - */ -int guac_terminal_send_string(guac_terminal* term, const char* data); - -/** - * Sends data through STDIN as if typed by the user, using the format string - * given and any args (similar to printf). If terminal input is currently - * coming from a stream due to a prior call to guac_terminal_send_stream(), any - * input which would normally result from invoking this function is dropped. - * - * @param term - * The terminal which should receive the given data on STDIN. - * - * @param format - * A printf-style format string describing the data to be received on - * STDIN. - * - * @param ... - * Any srguments to use when filling the format string. - * - * @return - * The number of bytes written to STDIN, or a negative value if an error - * occurs preventing the data from being written. This should always be - * the size of the data given unless data is intentionally dropped. - */ -int guac_terminal_sendf(guac_terminal* term, const char* format, ...); - -/** - * Sets a tabstop in the given column. - */ -void guac_terminal_set_tab(guac_terminal* term, int column); - -/** - * Removes the tabstop at the given column. - */ -void guac_terminal_unset_tab(guac_terminal* term, int column); - -/** - * Removes all tabstops. - */ -void guac_terminal_clear_tabs(guac_terminal* term); - -/** - * Given a column within the given terminal, returns the location of the - * next tabstop (or the rightmost character, if no more tabstops exist). - */ -int guac_terminal_next_tab(guac_terminal* term, int column); - -/** - * Opens a new pipe stream, redirecting all output from the given terminal to - * that pipe stream. If a pipe stream is already open, that pipe stream will - * be flushed and closed prior to opening the new pipe stream. - * - * @param term - * The terminal which should redirect output to a new pipe stream having - * the given name. - * - * @param name - * The name of the pipe stream to open. - * - * @param flags - * A bitwise OR of all integer flags which should apply to the new pipe - * stream. - * - * @see GUAC_TERMINAL_PIPE_INTERPRET_OUTPUT - * @see GUAC_TERMINAL_PIPE_AUTOFLUSH - */ -void guac_terminal_pipe_stream_open(guac_terminal* term, const char* name, - int flags); - -/** - * Writes a single byte of data to the pipe stream currently open and - * associated with the given terminal. The pipe stream must already have been - * opened via guac_terminal_pipe_stream_open(). If no pipe stream is currently - * open, this function has no effect. Data written through this function may - * be buffered. - * - * @param term - * The terminal whose currently-open pipe stream should be written to. - * - * @param c - * The byte of data to write to the pipe stream. - */ -void guac_terminal_pipe_stream_write(guac_terminal* term, char c); - -/** - * Flushes any data currently buffered for the currently-open pipe stream - * associated with the given terminal. The pipe stream must already have been - * opened via guac_terminal_pipe_stream_open(). If no pipe stream is currently - * open or no data is in the buffer, this function has no effect. - * - * @param term - * The terminal whose pipe stream buffer should be flushed. - */ -void guac_terminal_pipe_stream_flush(guac_terminal* term); - -/** - * Closes the currently-open pipe stream associated with the given terminal, - * redirecting all output back to the terminal display. Any data currently - * buffered for output to the pipe stream will be flushed prior to closure. The - * pipe stream must already have been opened via - * guac_terminal_pipe_stream_open(). If no pipe stream is currently open, this - * function has no effect. - * - * @param term - * The terminal whose currently-open pipe stream should be closed. - */ -void guac_terminal_pipe_stream_close(guac_terminal* term); - /** * Requests that the terminal write all output to a new pair of typescript * files within the given path and using the given base name. Terminal output diff --git a/src/terminal/terminal/types.h b/src/terminal/terminal/types.h index fbf9c646..24cf7723 100644 --- a/src/terminal/terminal/types.h +++ b/src/terminal/terminal/types.h @@ -28,7 +28,6 @@ * @file types.h */ -#include "config.h" #include "palette.h" #include diff --git a/src/terminal/terminal/typescript.h b/src/terminal/terminal/typescript.h index 9f8dff2d..5edf178f 100644 --- a/src/terminal/terminal/typescript.h +++ b/src/terminal/terminal/typescript.h @@ -28,7 +28,6 @@ * @file typescript.h */ -#include "config.h" #include diff --git a/src/terminal/terminal/xparsecolor.h b/src/terminal/terminal/xparsecolor.h index 398de758..4550ac3c 100644 --- a/src/terminal/terminal/xparsecolor.h +++ b/src/terminal/terminal/xparsecolor.h @@ -26,9 +26,8 @@ * @file xparsecolor.h */ -#include "config.h" -#include "terminal/palette.h" +#include "palette.h" /** * Parses an X11 color spec, as defined by Xlib's XParseColor(), storing the diff --git a/src/terminal/typescript.c b/src/terminal/typescript.c index 5dd0df80..180547c6 100644 --- a/src/terminal/typescript.c +++ b/src/terminal/typescript.c @@ -17,7 +17,6 @@ * under the License. */ -#include "config.h" #include "common/io.h" #include "terminal/typescript.h" diff --git a/src/terminal/xparsecolor.c b/src/terminal/xparsecolor.c index 779374d8..cb589f23 100644 --- a/src/terminal/xparsecolor.c +++ b/src/terminal/xparsecolor.c @@ -17,7 +17,6 @@ * under the License. */ -#include "config.h" #include "terminal/named-colors.h" #include "terminal/palette.h"