GUACAMOLE-169: Move terminal headers to namespaced directory.
Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/commit/3f7ccb6b Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/tree/3f7ccb6b Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/diff/3f7ccb6b Branch: refs/heads/staging/0.9.12-incubating Commit: 3f7ccb6b9a6212c7e3c6fde57ccd4dbb5b3b6ab7 Parents: d371f2d Author: Michael Jumper <[email protected]> Authored: Mon Feb 27 14:34:46 2017 -0800 Committer: Michael Jumper <[email protected]> Committed: Mon Feb 27 14:34:46 2017 -0800 ---------------------------------------------------------------------- src/protocols/ssh/client.c | 2 +- src/protocols/ssh/clipboard.c | 2 +- src/protocols/ssh/input.c | 2 +- src/protocols/ssh/ssh.c | 2 +- src/protocols/ssh/ssh.h | 2 +- src/protocols/telnet/client.c | 2 +- src/protocols/telnet/client.h | 2 +- src/protocols/telnet/clipboard.c | 2 +- src/protocols/telnet/input.c | 2 +- src/protocols/telnet/telnet.c | 2 +- src/protocols/telnet/telnet.h | 2 +- src/protocols/telnet/user.c | 2 +- src/terminal/Makefile.am | 20 +- src/terminal/buffer.c | 4 +- src/terminal/buffer.h | 129 ---- src/terminal/char_mappings.h | 48 -- src/terminal/common.c | 2 +- src/terminal/common.h | 53 -- src/terminal/display.c | 6 +- src/terminal/display.h | 363 ----------- src/terminal/scrollbar.c | 2 +- src/terminal/scrollbar.h | 357 ----------- src/terminal/terminal.c | 14 +- src/terminal/terminal.h | 839 ------------------------- src/terminal/terminal/buffer.h | 129 ++++ src/terminal/terminal/char_mappings.h | 48 ++ src/terminal/terminal/common.h | 53 ++ src/terminal/terminal/display.h | 363 +++++++++++ src/terminal/terminal/scrollbar.h | 357 +++++++++++ src/terminal/terminal/terminal.h | 839 +++++++++++++++++++++++++ src/terminal/terminal/terminal_handlers.h | 165 +++++ src/terminal/terminal/types.h | 124 ++++ src/terminal/terminal/typescript.h | 184 ++++++ src/terminal/terminal_handlers.c | 8 +- src/terminal/terminal_handlers.h | 165 ----- src/terminal/types.h | 124 ---- src/terminal/typescript.c | 2 +- src/terminal/typescript.h | 184 ------ 38 files changed, 2303 insertions(+), 2303 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/3f7ccb6b/src/protocols/ssh/client.c ---------------------------------------------------------------------- diff --git a/src/protocols/ssh/client.c b/src/protocols/ssh/client.c index 2110ba9..c0a26b9 100644 --- a/src/protocols/ssh/client.c +++ b/src/protocols/ssh/client.c @@ -22,7 +22,7 @@ #include "client.h" #include "common-ssh/sftp.h" #include "ssh.h" -#include "terminal.h" +#include "terminal/terminal.h" #include "user.h" #include <langinfo.h> http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/3f7ccb6b/src/protocols/ssh/clipboard.c ---------------------------------------------------------------------- diff --git a/src/protocols/ssh/clipboard.c b/src/protocols/ssh/clipboard.c index 72a2b6c..0e23632 100644 --- a/src/protocols/ssh/clipboard.c +++ b/src/protocols/ssh/clipboard.c @@ -20,7 +20,7 @@ #include "config.h" #include "clipboard.h" #include "ssh.h" -#include "terminal.h" +#include "terminal/terminal.h" #include <guacamole/client.h> #include <guacamole/stream.h> http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/3f7ccb6b/src/protocols/ssh/input.c ---------------------------------------------------------------------- diff --git a/src/protocols/ssh/input.c b/src/protocols/ssh/input.c index e0267e2..95e0188 100644 --- a/src/protocols/ssh/input.c +++ b/src/protocols/ssh/input.c @@ -22,7 +22,7 @@ #include "common/cursor.h" #include "common/display.h" #include "ssh.h" -#include "terminal.h" +#include "terminal/terminal.h" #include <guacamole/client.h> #include <guacamole/user.h> http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/3f7ccb6b/src/protocols/ssh/ssh.c ---------------------------------------------------------------------- diff --git a/src/protocols/ssh/ssh.c b/src/protocols/ssh/ssh.c index dd0a30f..43e66f8 100644 --- a/src/protocols/ssh/ssh.c +++ b/src/protocols/ssh/ssh.c @@ -25,7 +25,7 @@ #include "settings.h" #include "sftp.h" #include "ssh.h" -#include "terminal.h" +#include "terminal/terminal.h" #ifdef ENABLE_SSH_AGENT #include "ssh_agent.h" http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/3f7ccb6b/src/protocols/ssh/ssh.h ---------------------------------------------------------------------- diff --git a/src/protocols/ssh/ssh.h b/src/protocols/ssh/ssh.h index d6dbdaf..032e920 100644 --- a/src/protocols/ssh/ssh.h +++ b/src/protocols/ssh/ssh.h @@ -26,7 +26,7 @@ #include "common-ssh/ssh.h" #include "common-ssh/user.h" #include "settings.h" -#include "terminal.h" +#include "terminal/terminal.h" #ifdef ENABLE_SSH_AGENT #include "ssh_agent.h" http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/3f7ccb6b/src/protocols/telnet/client.c ---------------------------------------------------------------------- diff --git a/src/protocols/telnet/client.c b/src/protocols/telnet/client.c index a039322..2a53d26 100644 --- a/src/protocols/telnet/client.c +++ b/src/protocols/telnet/client.c @@ -21,7 +21,7 @@ #include "client.h" #include "settings.h" #include "telnet.h" -#include "terminal.h" +#include "terminal/terminal.h" #include "user.h" #include <langinfo.h> http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/3f7ccb6b/src/protocols/telnet/client.h ---------------------------------------------------------------------- diff --git a/src/protocols/telnet/client.h b/src/protocols/telnet/client.h index a7141e0..8921a9f 100644 --- a/src/protocols/telnet/client.h +++ b/src/protocols/telnet/client.h @@ -21,7 +21,7 @@ #define GUAC_TELNET__CLIENT_H #include "config.h" -#include "terminal.h" +#include "terminal/terminal.h" #include <pthread.h> #include <regex.h> http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/3f7ccb6b/src/protocols/telnet/clipboard.c ---------------------------------------------------------------------- diff --git a/src/protocols/telnet/clipboard.c b/src/protocols/telnet/clipboard.c index 44bcf1c..08d28b1 100644 --- a/src/protocols/telnet/clipboard.c +++ b/src/protocols/telnet/clipboard.c @@ -20,7 +20,7 @@ #include "config.h" #include "clipboard.h" #include "telnet.h" -#include "terminal.h" +#include "terminal/terminal.h" #include <guacamole/client.h> #include <guacamole/stream.h> http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/3f7ccb6b/src/protocols/telnet/input.c ---------------------------------------------------------------------- diff --git a/src/protocols/telnet/input.c b/src/protocols/telnet/input.c index bb88751..be50360 100644 --- a/src/protocols/telnet/input.c +++ b/src/protocols/telnet/input.c @@ -19,7 +19,7 @@ #include "config.h" #include "input.h" -#include "terminal.h" +#include "terminal/terminal.h" #include "telnet.h" #include <guacamole/client.h> http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/3f7ccb6b/src/protocols/telnet/telnet.c ---------------------------------------------------------------------- diff --git a/src/protocols/telnet/telnet.c b/src/protocols/telnet/telnet.c index b80c959..0bf4bbb 100644 --- a/src/protocols/telnet/telnet.c +++ b/src/protocols/telnet/telnet.c @@ -20,7 +20,7 @@ #include "config.h" #include "common/recording.h" #include "telnet.h" -#include "terminal.h" +#include "terminal/terminal.h" #include <guacamole/client.h> #include <guacamole/protocol.h> http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/3f7ccb6b/src/protocols/telnet/telnet.h ---------------------------------------------------------------------- diff --git a/src/protocols/telnet/telnet.h b/src/protocols/telnet/telnet.h index 3a48a80..8259507 100644 --- a/src/protocols/telnet/telnet.h +++ b/src/protocols/telnet/telnet.h @@ -22,7 +22,7 @@ #include "config.h" #include "settings.h" -#include "terminal.h" +#include "terminal/terminal.h" #include <libtelnet.h> http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/3f7ccb6b/src/protocols/telnet/user.c ---------------------------------------------------------------------- diff --git a/src/protocols/telnet/user.c b/src/protocols/telnet/user.c index aab8f62..d5458e2 100644 --- a/src/protocols/telnet/user.c +++ b/src/protocols/telnet/user.c @@ -23,7 +23,7 @@ #include "input.h" #include "settings.h" #include "telnet.h" -#include "terminal.h" +#include "terminal/terminal.h" #include "user.h" #include <guacamole/client.h> http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/3f7ccb6b/src/terminal/Makefile.am ---------------------------------------------------------------------- diff --git a/src/terminal/Makefile.am b/src/terminal/Makefile.am index 59bcd12..53bc74d 100644 --- a/src/terminal/Makefile.am +++ b/src/terminal/Makefile.am @@ -22,16 +22,16 @@ ACLOCAL_AMFLAGS = -I m4 noinst_LTLIBRARIES = libguac_terminal.la -noinst_HEADERS = \ - buffer.h \ - char_mappings.h \ - common.h \ - display.h \ - scrollbar.h \ - terminal.h \ - terminal_handlers.h \ - types.h \ - typescript.h +noinst_HEADERS = \ + terminal/buffer.h \ + terminal/char_mappings.h \ + terminal/common.h \ + terminal/display.h \ + terminal/scrollbar.h \ + terminal/terminal.h \ + terminal/terminal_handlers.h \ + terminal/types.h \ + terminal/typescript.h libguac_terminal_la_SOURCES = \ buffer.c \ http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/3f7ccb6b/src/terminal/buffer.c ---------------------------------------------------------------------- diff --git a/src/terminal/buffer.c b/src/terminal/buffer.c index e536d92..2985592 100644 --- a/src/terminal/buffer.c +++ b/src/terminal/buffer.c @@ -19,8 +19,8 @@ #include "config.h" -#include "buffer.h" -#include "common.h" +#include "terminal/buffer.h" +#include "terminal/common.h" #include <stdlib.h> #include <string.h> http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/3f7ccb6b/src/terminal/buffer.h ---------------------------------------------------------------------- diff --git a/src/terminal/buffer.h b/src/terminal/buffer.h deleted file mode 100644 index db2a4a1..0000000 --- a/src/terminal/buffer.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - * 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_BUFFER_H -#define _GUAC_TERMINAL_BUFFER_H - -#include "config.h" - -#include "types.h" - -/** - * A single variable-length row of terminal data. - */ -typedef struct guac_terminal_buffer_row { - - /** - * Array of guac_terminal_char representing the contents of the row. - */ - guac_terminal_char* characters; - - /** - * The length of this row in characters. This is the number of initialized - * characters in the buffer, usually equal to the number of characters - * in the screen width at the time this row was created. - */ - int length; - - /** - * The number of elements in the characters array. After the length - * equals this value, the array must be resized. - */ - int available; - -} guac_terminal_buffer_row; - -/** - * A buffer containing a constant number of arbitrary-length rows. - * New rows can be appended to the buffer, with the oldest row replaced with - * the new row. - */ -typedef struct guac_terminal_buffer { - - /** - * The character to assign to newly-allocated cells. - */ - guac_terminal_char default_character; - - /** - * Array of buffer rows. This array functions as a ring buffer. - * When a new row needs to be appended, the top reference is moved down - * and the old top row is replaced. - */ - guac_terminal_buffer_row* rows; - - /** - * The row to replace when adding a new row to the buffer. - */ - int top; - - /** - * The number of rows currently stored in the buffer. - */ - int length; - - /** - * The number of rows in the buffer. This is the total capacity - * of the buffer. - */ - int available; - -} guac_terminal_buffer; - -/** - * Allocates a new buffer having the given maximum number of rows. New character cells will - * be initialized to the given character. - */ -guac_terminal_buffer* guac_terminal_buffer_alloc(int rows, guac_terminal_char* default_character); - -/** - * Frees the given buffer. - */ -void guac_terminal_buffer_free(guac_terminal_buffer* buffer); - -/** - * Returns the row at the given location. The row returned is guaranteed to be at least the given - * width. - */ -guac_terminal_buffer_row* guac_terminal_buffer_get_row(guac_terminal_buffer* buffer, int row, int width); - -/** - * Copies the given range of columns to a new location, offset from - * the original by the given number of columns. - */ -void guac_terminal_buffer_copy_columns(guac_terminal_buffer* buffer, 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_buffer_copy_rows(guac_terminal_buffer* buffer, - 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_buffer_set_columns(guac_terminal_buffer* buffer, int row, - int start_column, int end_column, guac_terminal_char* character); - -#endif - http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/3f7ccb6b/src/terminal/char_mappings.h ---------------------------------------------------------------------- diff --git a/src/terminal/char_mappings.h b/src/terminal/char_mappings.h deleted file mode 100644 index 5e0e474..0000000 --- a/src/terminal/char_mappings.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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_CHAR_MAPPINGS_H -#define _GUAC_TERMINAL_CHAR_MAPPINGS_H - -#include "config.h" - -/** - * VT100 graphics mapping. Each entry is the corresponding Unicode codepoint - * for the character N+32, where N is the index of the element in the array. - * All characters less than 32 are universally mapped to themselves. - */ -extern const int vt100_map[]; - -/** - * Null graphics mapping. Each entry is the corresponding Unicode codepoint - * for the character N+32, where N is the index of the element in the array. - * All characters less than 32 are universally mapped to themselves. - */ -extern const int null_map[]; - -/** - * User graphics mapping. Each entry is the corresponding Unicode codepoint - * for the character N+32, where N is the index of the element in the array. - * All characters less than 32 are universally mapped to themselves. - */ -extern const int user_map[]; - -#endif - http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/3f7ccb6b/src/terminal/common.c ---------------------------------------------------------------------- diff --git a/src/terminal/common.c b/src/terminal/common.c index 4018e77..9913753 100644 --- a/src/terminal/common.c +++ b/src/terminal/common.c @@ -18,7 +18,7 @@ */ #include "config.h" -#include "types.h" +#include "terminal/types.h" #include <stdbool.h> #include <unistd.h> http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/3f7ccb6b/src/terminal/common.h ---------------------------------------------------------------------- diff --git a/src/terminal/common.h b/src/terminal/common.h deleted file mode 100644 index f7eda61..0000000 --- a/src/terminal/common.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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_COMMON_H -#define _GUAC_TERMINAL_COMMON_H - -#include "config.h" - -#include <stdbool.h> - -/** - * Returns the closest value to the value given that is also - * within the given range. - */ -int guac_terminal_fit_to_range(int value, int min, int max); - -/** - * Encodes the given codepoint as UTF-8, storing the result within the - * provided buffer, and returning the number of bytes stored. - */ -int guac_terminal_encode_utf8(int codepoint, char* utf8); - -/** - * Returns whether a codepoint has a corresponding glyph, or is rendered - * as a blank space. - */ -bool guac_terminal_has_glyph(int codepoint); - -/** - * Similar to write, but automatically retries the write operation until - * an error occurs. - */ -int guac_terminal_write_all(int fd, const char* buffer, int size); - -#endif - http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/3f7ccb6b/src/terminal/display.c ---------------------------------------------------------------------- diff --git a/src/terminal/display.c b/src/terminal/display.c index e671c60..1a0aeb5 100644 --- a/src/terminal/display.c +++ b/src/terminal/display.c @@ -19,10 +19,10 @@ #include "config.h" -#include "common.h" #include "common/surface.h" -#include "display.h" -#include "types.h" +#include "terminal/common.h" +#include "terminal/display.h" +#include "terminal/types.h" #include <math.h> #include <stdlib.h> http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/3f7ccb6b/src/terminal/display.h ---------------------------------------------------------------------- diff --git a/src/terminal/display.h b/src/terminal/display.h deleted file mode 100644 index 655d1aa..0000000 --- a/src/terminal/display.h +++ /dev/null @@ -1,363 +0,0 @@ -/* - * 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_DISPLAY_H -#define _GUAC_TERMINAL_DISPLAY_H - -#include "config.h" - -#include "common/surface.h" -#include "types.h" - -#include <guacamole/client.h> -#include <guacamole/layer.h> -#include <pango/pangocairo.h> - -#include <stdbool.h> - -/** - * The maximum width of any character, in columns. - */ -#define GUAC_TERMINAL_MAX_CHAR_WIDTH 2 - -/** - * The index of black within the terminal color palette. - */ -#define GUAC_TERMINAL_COLOR_BLACK 0 - -/** - * The index of low-intensity red within the terminal color palette. - */ -#define GUAC_TERMINAL_COLOR_DARK_RED 1 - -/** - * The index of low-intensity green within the terminal color palette. - */ -#define GUAC_TERMINAL_COLOR_DARK_GREEN 2 - -/** - * The index of brown within the terminal color palette. - */ -#define GUAC_TERMINAL_COLOR_BROWN 3 - -/** - * The index of low-intensity blue within the terminal color palette. - */ -#define GUAC_TERMINAL_COLOR_DARK_BLUE 4 - -/** - * The index of low-intensity magenta (purple) within the terminal color - * palette. - */ -#define GUAC_TERMINAL_COLOR_PURPLE 5 - -/** - * The index of low-intensity cyan (teal) within the terminal color palette. - */ -#define GUAC_TERMINAL_COLOR_TEAL 6 - -/** - * The index of low-intensity white (gray) within the terminal color palette. - */ -#define GUAC_TERMINAL_COLOR_GRAY 7 - -/** - * The index of bright black (dark gray) within the terminal color palette. - */ -#define GUAC_TERMINAL_COLOR_DARK_GRAY 8 - -/** - * The index of bright red within the terminal color palette. - */ -#define GUAC_TERMINAL_COLOR_RED 9 - -/** - * The index of bright green within the terminal color palette. - */ -#define GUAC_TERMINAL_COLOR_GREEN 10 - -/** - * The index of bright brown (yellow) within the terminal color palette. - */ -#define GUAC_TERMINAL_COLOR_YELLOW 11 - -/** - * The index of bright blue within the terminal color palette. - */ -#define GUAC_TERMINAL_COLOR_BLUE 12 - -/** - * The index of bright magenta within the terminal color palette. - */ -#define GUAC_TERMINAL_COLOR_MAGENTA 13 - -/** - * The index of bright cyan within the terminal color palette. - */ -#define GUAC_TERMINAL_COLOR_CYAN 14 - -/** - * The index of bright white within the terminal color palette. - */ -#define GUAC_TERMINAL_COLOR_WHITE 15 - -/** - * The available color palette. All integer colors within structures - * here are indices into this palette. - */ -extern const guac_terminal_color guac_terminal_palette[16]; - -/** - * All available terminal operations which affect character cells. - */ -typedef enum guac_terminal_operation_type { - - /** - * Operation which does nothing. - */ - GUAC_CHAR_NOP, - - /** - * Operation which copies a character from a given row/column coordinate. - */ - GUAC_CHAR_COPY, - - /** - * Operation which sets the character and attributes. - */ - GUAC_CHAR_SET - -} guac_terminal_operation_type; - -/** - * A pairing of a guac_terminal_operation_type and all parameters required by - * that operation type. - */ -typedef struct guac_terminal_operation { - - /** - * The type of operation to perform. - */ - guac_terminal_operation_type type; - - /** - * The character (and attributes) to set the current location to. This is - * only applicable to GUAC_CHAR_SET. - */ - guac_terminal_char character; - - /** - * The row to copy a character from. This is only applicable to - * GUAC_CHAR_COPY. - */ - int row; - - /** - * The column to copy a character from. This is only applicable to - * GUAC_CHAR_COPY. - */ - int column; - -} guac_terminal_operation; - -/** - * Set of all pending operations for the currently-visible screen area. - */ -typedef struct guac_terminal_display { - - /** - * The Guacamole client this display will use for rendering. - */ - guac_client* client; - - /** - * Array of all operations pending for the visible screen area. - */ - guac_terminal_operation* operations; - - /** - * The width of the screen, in characters. - */ - int width; - - /** - * The height of the screen, in characters. - */ - int height; - - /** - * The description of the font to use for rendering. - */ - PangoFontDescription* font_desc; - - /** - * The width of each character, in pixels. - */ - int char_width; - - /** - * The height of each character, in pixels. - */ - int char_height; - - /** - * Default foreground color for all glyphs. - */ - int default_foreground; - - /** - * Default background color for all glyphs and the terminal itself. - */ - int default_background; - - /** - * Color of glyphs in copy buffer - */ - int glyph_foreground; - - /** - * Color of glyphs in copy buffer - */ - int glyph_background; - - /** - * The surface containing the actual terminal. - */ - guac_common_surface* display_surface; - - /** - * Layer which contains the actual terminal. - */ - guac_layer* display_layer; - - /** - * Sub-layer of display layer which highlights selected text. - */ - guac_layer* select_layer; - - /** - * Whether text is being 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 when the display changes. - */ - 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 row that the selection ends at. - */ - int selection_end_row; - - /** - * The column that the selection ends at. - */ - int selection_end_column; - -} guac_terminal_display; - -/** - * Allocates a new display having the given default foreground and background - * colors. - */ -guac_terminal_display* guac_terminal_display_alloc(guac_client* client, - const char* font_name, int font_size, int dpi, - int foreground, int background); - -/** - * Frees the given display. - */ -void guac_terminal_display_free(guac_terminal_display* display); - -/** - * Copies the given range of columns to a new location, offset from - * the original by the given number of columns. - */ -void guac_terminal_display_copy_columns(guac_terminal_display* display, 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_display_copy_rows(guac_terminal_display* display, - 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_display_set_columns(guac_terminal_display* display, int row, - int start_column, int end_column, guac_terminal_char* character); - -/** - * Resize the terminal to the given dimensions. - */ -void guac_terminal_display_resize(guac_terminal_display* display, int width, int height); - -/** - * Flushes all pending operations within the given guac_terminal_display. - */ -void guac_terminal_display_flush(guac_terminal_display* display); - -/** - * Initializes and syncs the current terminal display state for the given user - * that has just joined the connection, sending the necessary instructions to - * completely recreate and redraw the terminal rendering over the given socket. - * - * @param display - * The terminal display to sync to the given user. - * - * @param user - * The user that has just joined the connection. - * - * @param socket - * The socket over which any necessary instructions should be sent. - */ -void guac_terminal_display_dup(guac_terminal_display* display, guac_user* user, - guac_socket* socket); - -/** - * Draws the text selection rectangle from the given coordinates to the given end coordinates. - */ -void guac_terminal_display_select(guac_terminal_display* display, - int start_row, int start_col, int end_row, int end_col); - -/** - * Commits the select rectangle, allowing the display to clear it when - * necessary. - */ -void guac_terminal_display_commit_select(guac_terminal_display* display); - -#endif - http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/3f7ccb6b/src/terminal/scrollbar.c ---------------------------------------------------------------------- diff --git a/src/terminal/scrollbar.c b/src/terminal/scrollbar.c index f8cd99d..ddff299 100644 --- a/src/terminal/scrollbar.c +++ b/src/terminal/scrollbar.c @@ -18,7 +18,7 @@ */ #include "config.h" -#include "scrollbar.h" +#include "terminal/scrollbar.h" #include <guacamole/client.h> #include <guacamole/layer.h> http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/3f7ccb6b/src/terminal/scrollbar.h ---------------------------------------------------------------------- diff --git a/src/terminal/scrollbar.h b/src/terminal/scrollbar.h deleted file mode 100644 index bf0da87..0000000 --- a/src/terminal/scrollbar.h +++ /dev/null @@ -1,357 +0,0 @@ -/* - * 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_SCROLLBAR_H -#define GUAC_TERMINAL_SCROLLBAR_H - -#include "config.h" - -#include <guacamole/client.h> -#include <guacamole/layer.h> - -/** - * The width of the scrollbar, in pixels. - */ -#define GUAC_TERMINAL_SCROLLBAR_WIDTH 16 - -/** - * The number of pixels between the draggable handle of the scrollbar and the - * boundary of the containing layer. - */ -#define GUAC_TERMINAL_SCROLLBAR_PADDING 2 - -/** - * The minimum height of the draggable handle of the scrollbar, in pixels. - */ -#define GUAC_TERMINAL_SCROLLBAR_MIN_HEIGHT 64 - -/** - * The state of all scrollbar components, describing all variable aspects of - * the scrollbar's appearance. - */ -typedef struct guac_terminal_scrollbar_render_state { - - /** - * The current X-coordinate of the upper-left corner of the scrollbar's - * handle. This value will be relative to the scrollbar's containing layer. - */ - int handle_x; - - /** - * The current Y-coordinate of the upper-left corner of the scrollbar's - * handle. This value will be relative to the scrollbar's containing layer. - */ - int handle_y; - - /** - * The width of the scrollbar's handle. - */ - int handle_width; - - /** - * The height of the scrollbar's handle. - */ - int handle_height; - - /** - * The current X-coordinate of the upper-left corner of the scrollbar's - * containing layer. - */ - int container_x; - - /** - * The current Y-coordinate of the upper-left corner of the scrollbar's - * containing layer. - */ - int container_y; - - /** - * The width of the scrollbar's containing layer. - */ - int container_width; - - /** - * The height of the scrollbar's containing layer. - */ - int container_height; - -} guac_terminal_scrollbar_render_state; - -typedef struct guac_terminal_scrollbar guac_terminal_scrollbar; - -/** - * Handler which is called whenever the scrollbar value changes outside a call - * to guac_terminal_scrollbar_set_value(). - */ -typedef void guac_terminal_scrollbar_scroll_handler( - guac_terminal_scrollbar* scrollbar, int value); - -/** - * A scrollbar, made up of a containing layer and inner draggable handle. The - * position of the handle within the layer represents the value of the - * scrollbar. - */ -struct guac_terminal_scrollbar { - - /** - * The client associated with this scrollbar. - */ - guac_client* client; - - /** - * The layer containing the scrollbar. - */ - const guac_layer* parent; - - /** - * The width of the parent layer, in pixels. - */ - int parent_width; - - /** - * The height of the parent layer, in pixels. - */ - int parent_height; - - /** - * The scrollbar itself. - */ - guac_layer* container; - - /** - * The draggable handle within the scrollbar, representing the current - * scroll value. - */ - guac_layer* handle; - - /** - * The minimum scroll value. - */ - int min; - - /** - * The maximum scroll value. - */ - int max; - - /** - * The size of the visible area, in the same units as min and max. - */ - int visible_area; - - /** - * The current scroll value. - */ - int value; - - /** - * The current state of all variable, visible parts of the scrollbar. - */ - guac_terminal_scrollbar_render_state render_state; - - /** - * Whether the scrollbar handle is currently being dragged. - */ - int dragging_handle; - - /** - * The offset of the Y location of the mouse pointer when the dragging - * began, relative to the top of the scrollbar handle. If dragging is not - * in progress, this value is undefined. - */ - int drag_offset_y; - - /** - * The current Y location of the mouse pointer if dragging is in progress. - * If dragging is not in progress, this value is undefined. - */ - int drag_current_y; - - /** - * The function to call when the scrollbar handle is being dragged, and - * the new scrollbar value needs to be handled and assigned. - */ - guac_terminal_scrollbar_scroll_handler* scroll_handler; - - /** - * Arbitrary reference to data related to this scrollbar. - */ - void* data; - -}; - -/** - * Allocates a new scrollbar, associating that scrollbar with the given client - * and parent layer. The dimensions of the parent layer dictate the initial - * position of the scrollbar. Currently, the scrollbar is always anchored to - * the right edge of the parent layer. - * - * This will cause instructions to be written to the client's socket, but the - * client's socket will not be automatically flushed. - * - * @param client - * The client to associate with the new scrollbar. - * - * @param parent - * The layer which will contain the newly-allocated scrollbar. - * - * @param parent_width - * The width of the parent layer, in pixels. - * - * @param parent_height - * The height of the parent layer, in pixels. - * - * @param visible_area - * The amount of scrollable data that can be shown within the parent layer - * at any given time. This value uses the same units as min, max, and the - * current scroll value. - * - * @return - * A newly allocated scrollbar. - */ -guac_terminal_scrollbar* guac_terminal_scrollbar_alloc(guac_client* client, - const guac_layer* parent, int parent_width, int parent_height, - int visible_area); - -/** - * Frees the given scrollbar. - * - * @param scrollbar - * The scrollbar to free. - */ -void guac_terminal_scrollbar_free(guac_terminal_scrollbar* scrollbar); - -/** - * Flushes the render state of the given scrollbar, updating the remote display - * accordingly. - * - * This may cause instructions to be written to the client's socket, but the - * client's socket will not be automatically flushed. - * - * @param scrollbar - * The scrollbar whose render state is to be flushed. - */ -void guac_terminal_scrollbar_flush(guac_terminal_scrollbar* scrollbar); - -/** - * Forces a complete redraw / resync of scrollbar state for the given user that - * has just joined the connection, sending the necessary instructions to - * completely recreate and redraw the scrollbar rendering over the given - * socket. - * - * @param scrollbar - * The scrollbar to sync to the given user. - * - * @param user - * The user that has just joined the connection. - * - * @param socket - * The socket over which any necessary instructions should be sent. - */ -void guac_terminal_scrollbar_dup(guac_terminal_scrollbar* scrollbar, - guac_user* user, guac_socket* socket); - -/** - * Sets the minimum and maximum allowed scroll values of the given scrollbar - * to the given values. If necessary, the current value of the scrollbar will - * be adjusted to fit within the new bounds. - * - * This may cause instructions to be written to the client's socket, but the - * client's socket will not be automatically flushed. - * - * @param scrollbar - * The scrollbar whose bounds are changing. - * - * @param min - * The new minimum value of the scrollbar. - * - * @param max - * The new maximum value of the scrollbar. - */ -void guac_terminal_scrollbar_set_bounds(guac_terminal_scrollbar* scrollbar, - int min, int max); - -/** - * Sets the current value of the given scrollbar. If the value specified does - * not fall within the scrollbar's defined minimum and maximum values, the - * value will be adjusted to fit. - * - * This may cause instructions to be written to the client's socket, but the - * client's socket will not be automatically flushed. - * - * @param scrollbar - * The scrollbar whose value is changing. - * - * @param value - * The value to assign to the scrollbar. If the value if out of bounds, it - * will be automatically adjusted to fit. - */ -void guac_terminal_scrollbar_set_value(guac_terminal_scrollbar* scrollbar, - int value); - -/** - * Notifies the scrollbar that the parent layer has been resized, and that the - * scrollbar may need to be repositioned or resized accordingly. - * - * This may cause instructions to be written to the client's socket, but the - * client's socket will not be automatically flushed. - * - * @param scrollbar - * The scrollbar whose parent layer has been resized. - * - * @param parent_width - * The new width of the parent layer, in pixels. - * - * @param parent_height - * The new height of the parent layer, in pixels. - * - * @param visible_area - * The amount of scrollable data that can be shown within the parent layer - * at any given time. This value uses the same units as min, max, and the - * current scroll value. - */ -void guac_terminal_scrollbar_parent_resized(guac_terminal_scrollbar* scrollbar, - int parent_width, int parent_height, int visible_area); - -/** - * Notifies the scrollbar of the current mouse state, allowing it to update - * itself with respect to button state and dragging. - * - * @param scrollbar - * The scrollbar to notify of the current mouse state. - * - * @param x - * The X coordinate of the mouse pointer. - * - * @param y - * The Y coordinate of the mouse pointer. - * - * @param mask - * The button mask, where the Nth bit of the button mask represents the - * pressed state of the Nth mouse button, where button 0 is the left - * mouse button, button 1 is the middle button, etc. - * - * @return - * Zero if the mouse event was not handled by the scrollbar, non-zero - * otherwise. - */ -int guac_terminal_scrollbar_handle_mouse(guac_terminal_scrollbar* scrollbar, - int x, int y, int mask); - -#endif http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/3f7ccb6b/src/terminal/terminal.c ---------------------------------------------------------------------- diff --git a/src/terminal/terminal.c b/src/terminal/terminal.c index 5c32774..c5df648 100644 --- a/src/terminal/terminal.c +++ b/src/terminal/terminal.c @@ -19,15 +19,15 @@ #include "config.h" -#include "buffer.h" -#include "common.h" #include "common/clipboard.h" #include "common/cursor.h" -#include "display.h" -#include "terminal.h" -#include "terminal_handlers.h" -#include "types.h" -#include "typescript.h" +#include "terminal/buffer.h" +#include "terminal/common.h" +#include "terminal/display.h" +#include "terminal/terminal.h" +#include "terminal/terminal_handlers.h" +#include "terminal/types.h" +#include "terminal/typescript.h" #include <errno.h> #include <pthread.h> http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/3f7ccb6b/src/terminal/terminal.h ---------------------------------------------------------------------- diff --git a/src/terminal/terminal.h b/src/terminal/terminal.h deleted file mode 100644 index f37e870..0000000 --- a/src/terminal/terminal.h +++ /dev/null @@ -1,839 +0,0 @@ -/* - * 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_H -#define _GUAC_TERMINAL_H - -#include "config.h" - -#include "buffer.h" -#include "common/clipboard.h" -#include "common/cursor.h" -#include "display.h" -#include "scrollbar.h" -#include "types.h" -#include "typescript.h" - -#include <pthread.h> -#include <stdbool.h> - -#include <guacamole/client.h> -#include <guacamole/stream.h> - -/** - * The maximum duration of a single frame, in milliseconds. - */ -#define GUAC_TERMINAL_FRAME_DURATION 40 - -/** - * The maximum amount of time to wait for more data before declaring a frame - * complete, in milliseconds. - */ -#define GUAC_TERMINAL_FRAME_TIMEOUT 10 - -/** - * The maximum number of custom tab stops. - */ -#define GUAC_TERMINAL_MAX_TABS 16 - -/** - * The number of rows to scroll per scroll wheel event. - */ -#define GUAC_TERMINAL_WHEEL_SCROLL_AMOUNT 3 - -/** - * The maximum number of bytes to allow within the clipboard. - */ -#define GUAC_TERMINAL_CLIPBOARD_MAX_LENGTH 262144 - -/** - * The name of the color scheme having black foreground and white background. - */ -#define GUAC_TERMINAL_SCHEME_BLACK_WHITE "black-white" - -/** - * The name of the color scheme having gray foreground and black background. - */ -#define GUAC_TERMINAL_SCHEME_GRAY_BLACK "gray-black" - -/** - * The name of the color scheme having green foreground and black background. - */ -#define GUAC_TERMINAL_SCHEME_GREEN_BLACK "green-black" - -/** - * The name of the color scheme having white foreground and black background. - */ -#define GUAC_TERMINAL_SCHEME_WHITE_BLACK "white-black" - -typedef struct guac_terminal guac_terminal; - -/** - * All possible mouse cursors used by the terminal emulator. - */ -typedef enum guac_terminal_cursor_type { - - /** - * A transparent (blank) cursor. - */ - GUAC_TERMINAL_CURSOR_BLANK, - - /** - * A standard I-bar cursor for selecting text, etc. - */ - GUAC_TERMINAL_CURSOR_IBAR, - - /** - * A standard triangular mouse pointer for manipulating non-text objects. - */ - GUAC_TERMINAL_CURSOR_POINTER - -} guac_terminal_cursor_type; - -/** - * Handler for characters printed to the terminal. When a character is printed, - * the current char handler for the terminal is called and given that - * character. - */ -typedef int guac_terminal_char_handler(guac_terminal* term, unsigned char c); - -/** - * Handler for setting the destination path for file uploads. - */ -typedef void guac_terminal_upload_path_handler(guac_client* client, char* path); - -/** - * Handler for creating an outbound file download stream for a specified file. - */ -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; - - /** - * 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 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; - - /** - * 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 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 row of the rendered cursor. - */ - int visible_cursor_row; - - /** - * The column of the rendered cursor. - */ - 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. - */ - 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 being selected. - */ - bool text_selected; - - /** - * 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. - */ - guac_common_clipboard* clipboard; - -}; - -/** - * Creates a new guac_terminal, having the given width and height, and - * rendering to the given client. - * - * @param client - * The client to which the terminal will be rendered. - * - * @param font_name - * The name of the font to use when rendering glyphs. - * - * @param font_size - * The size of each glyph, in points. - * - * @param dpi - * The DPI of the display. The given font size will be adjusted to produce - * glyphs at the given DPI. - * - * @param width - * The width of the terminal, in pixels. - * - * @param height - * The height of the terminal, in pixels. - * - * @param color_scheme - * The name of the color scheme to use. This string must be one of the - * names defined by the GUAC_TERMINAL_SCHEME_* constants. If blank or NULL, - * the default scheme of GUAC_TERMINAL_SCHEME_GRAY_BLACK will be used. If - * invalid, a warning will be logged, and the terminal will fall back on - * GUAC_TERMINAL_SCHEME_GRAY_BLACK. - * - * @return - * A new guac_terminal having the given font, dimensions, and attributes - * which renders all text to the given client. - */ -guac_terminal* guac_terminal_create(guac_client* client, - const char* font_name, int font_size, int dpi, - int width, int height, const char* color_scheme); - -/** - * Frees all resources associated with the given terminal. - */ -void guac_terminal_free(guac_terminal* term); - -/** - * Renders a single frame of terminal data. If data is not yet available, - * this function will block until data is written. - */ -int guac_terminal_render_frame(guac_terminal* terminal); - -/** - * Reads from this terminal's STDIN. Input comes from key and mouse events - * supplied by calls to guac_terminal_send_key() and - * guac_terminal_send_mouse(). If input is not yet available, this function - * will block. - */ -int guac_terminal_read_stdin(guac_terminal* terminal, char* c, int size); - -/** - * Notifies the terminal that an event has occurred and the terminal should - * flush itself when reasonable. - * - * @param terminal - * The terminal to notify. - */ -void guac_terminal_notify(guac_terminal* terminal); - -/** - * Reads a single line from this terminal's STDIN, storing the result in a - * newly-allocated string. Input is retrieved in the same manner as - * guac_terminal_read_stdin() and the same restrictions apply. - * - * @param terminal - * The terminal to which the provided title should be output, and from - * whose STDIN the single line of input should be read. - * - * @param title - * The human-readable title to output to the terminal just prior to reading - * from STDIN. - * - * @param echo - * Non-zero if the characters read from STDIN should be echoed back as - * terminal output, or zero if asterisks should be displayed instead. - * - * @return - * A newly-allocated string containing a single line of input read from the - * provided terminal's STDIN. This string must eventually be manually - * freed with a call to free(). - */ -char* guac_terminal_prompt(guac_terminal* terminal, const char* title, - bool echo); - -/** - * Writes the given format string and arguments to this terminal's STDOUT in - * the same manner as printf(). This function may block until space is - * freed in the output buffer by guac_terminal_render_frame(). - */ -int guac_terminal_printf(guac_terminal* terminal, const char* format, ...); - -/** - * Handles the given key event, sending data, scrolling, pasting clipboard - * data, etc. as necessary. - */ -int guac_terminal_send_key(guac_terminal* term, int keysym, int pressed); - -/** - * Handles the given mouse event, sending data, scrolling, pasting clipboard - * data, etc. as necessary. - */ -int guac_terminal_send_mouse(guac_terminal* term, guac_user* user, - int x, int y, int mask); - -/** - * 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); - -/** - * Clears the current clipboard contents and sets the mimetype for future - * contents. - */ -void guac_terminal_clipboard_reset(guac_terminal* term, const char* mimetype); - -/** - * Appends the given data to the current clipboard. - */ -void guac_terminal_clipboard_append(guac_terminal* term, const void* data, int length); - -/** - * Replicates the current display state to a user that has just joined the - * connection. All instructions necessary to replicate state are sent over the - * given socket. - * - * @param term - * The terminal emulator associated with the connection being joined. - * - * @param user - * The user joining the connection. - * - * @param socket - * The guac_socket specific to the joining user and across which messages - * synchronizing the current display state should be sent. - */ -void guac_terminal_dup(guac_terminal* term, guac_user* user, - guac_socket* socket); - -/* 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); - -/** - * Marks the start of text selection at the given row and column. - */ -void guac_terminal_select_start(guac_terminal* terminal, int row, int column); - -/** - * Updates the end of text selection at the given row and column. - */ -void guac_terminal_select_update(guac_terminal* terminal, int row, int column); - -/** - * Ends text selection, removing any highlight. Character data is stored in the - * string buffer provided. - */ -void guac_terminal_select_end(guac_terminal* terminal, char* string); - - -/* 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. - */ -int guac_terminal_send_data(guac_terminal* term, const char* data, int length); - -/** - * Sends the given string as if typed by the user. - */ -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). - */ -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. - */ -void guac_terminal_pipe_stream_open(guac_terminal* term, const char* name); - -/** - * 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 - * will be written to these new files, along with timing information. If the - * create_path flag is non-zero, the given path will be created if it does not - * yet exist. If creation of the typescript files or path fails, error messages - * will automatically be logged, and no typescript will be written. The - * typescript will automatically be closed once the terminal is freed. - * - * @param term - * The terminal whose output should be written to a typescript. - * - * @param path - * The full absolute path to a directory in which the typescript files - * should be created. - * - * @param name - * The base name to use for the typescript files created within the - * specified path. - * - * @param create_path - * Zero if the specified path MUST exist for typescript files to be - * written, or non-zero if the path should be created if it does not yet - * exist. - * - * @return - * Zero if the typescript files have been successfully created and a - * typescript will be written, non-zero otherwise. - */ -int guac_terminal_create_typescript(guac_terminal* term, const char* path, - const char* name, int create_path); - -#endif - http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/3f7ccb6b/src/terminal/terminal/buffer.h ---------------------------------------------------------------------- diff --git a/src/terminal/terminal/buffer.h b/src/terminal/terminal/buffer.h new file mode 100644 index 0000000..db2a4a1 --- /dev/null +++ b/src/terminal/terminal/buffer.h @@ -0,0 +1,129 @@ +/* + * 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_BUFFER_H +#define _GUAC_TERMINAL_BUFFER_H + +#include "config.h" + +#include "types.h" + +/** + * A single variable-length row of terminal data. + */ +typedef struct guac_terminal_buffer_row { + + /** + * Array of guac_terminal_char representing the contents of the row. + */ + guac_terminal_char* characters; + + /** + * The length of this row in characters. This is the number of initialized + * characters in the buffer, usually equal to the number of characters + * in the screen width at the time this row was created. + */ + int length; + + /** + * The number of elements in the characters array. After the length + * equals this value, the array must be resized. + */ + int available; + +} guac_terminal_buffer_row; + +/** + * A buffer containing a constant number of arbitrary-length rows. + * New rows can be appended to the buffer, with the oldest row replaced with + * the new row. + */ +typedef struct guac_terminal_buffer { + + /** + * The character to assign to newly-allocated cells. + */ + guac_terminal_char default_character; + + /** + * Array of buffer rows. This array functions as a ring buffer. + * When a new row needs to be appended, the top reference is moved down + * and the old top row is replaced. + */ + guac_terminal_buffer_row* rows; + + /** + * The row to replace when adding a new row to the buffer. + */ + int top; + + /** + * The number of rows currently stored in the buffer. + */ + int length; + + /** + * The number of rows in the buffer. This is the total capacity + * of the buffer. + */ + int available; + +} guac_terminal_buffer; + +/** + * Allocates a new buffer having the given maximum number of rows. New character cells will + * be initialized to the given character. + */ +guac_terminal_buffer* guac_terminal_buffer_alloc(int rows, guac_terminal_char* default_character); + +/** + * Frees the given buffer. + */ +void guac_terminal_buffer_free(guac_terminal_buffer* buffer); + +/** + * Returns the row at the given location. The row returned is guaranteed to be at least the given + * width. + */ +guac_terminal_buffer_row* guac_terminal_buffer_get_row(guac_terminal_buffer* buffer, int row, int width); + +/** + * Copies the given range of columns to a new location, offset from + * the original by the given number of columns. + */ +void guac_terminal_buffer_copy_columns(guac_terminal_buffer* buffer, 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_buffer_copy_rows(guac_terminal_buffer* buffer, + 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_buffer_set_columns(guac_terminal_buffer* buffer, int row, + int start_column, int end_column, guac_terminal_char* character); + +#endif + http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/3f7ccb6b/src/terminal/terminal/char_mappings.h ---------------------------------------------------------------------- diff --git a/src/terminal/terminal/char_mappings.h b/src/terminal/terminal/char_mappings.h new file mode 100644 index 0000000..5e0e474 --- /dev/null +++ b/src/terminal/terminal/char_mappings.h @@ -0,0 +1,48 @@ +/* + * 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_CHAR_MAPPINGS_H +#define _GUAC_TERMINAL_CHAR_MAPPINGS_H + +#include "config.h" + +/** + * VT100 graphics mapping. Each entry is the corresponding Unicode codepoint + * for the character N+32, where N is the index of the element in the array. + * All characters less than 32 are universally mapped to themselves. + */ +extern const int vt100_map[]; + +/** + * Null graphics mapping. Each entry is the corresponding Unicode codepoint + * for the character N+32, where N is the index of the element in the array. + * All characters less than 32 are universally mapped to themselves. + */ +extern const int null_map[]; + +/** + * User graphics mapping. Each entry is the corresponding Unicode codepoint + * for the character N+32, where N is the index of the element in the array. + * All characters less than 32 are universally mapped to themselves. + */ +extern const int user_map[]; + +#endif + http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/3f7ccb6b/src/terminal/terminal/common.h ---------------------------------------------------------------------- diff --git a/src/terminal/terminal/common.h b/src/terminal/terminal/common.h new file mode 100644 index 0000000..f7eda61 --- /dev/null +++ b/src/terminal/terminal/common.h @@ -0,0 +1,53 @@ +/* + * 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_COMMON_H +#define _GUAC_TERMINAL_COMMON_H + +#include "config.h" + +#include <stdbool.h> + +/** + * Returns the closest value to the value given that is also + * within the given range. + */ +int guac_terminal_fit_to_range(int value, int min, int max); + +/** + * Encodes the given codepoint as UTF-8, storing the result within the + * provided buffer, and returning the number of bytes stored. + */ +int guac_terminal_encode_utf8(int codepoint, char* utf8); + +/** + * Returns whether a codepoint has a corresponding glyph, or is rendered + * as a blank space. + */ +bool guac_terminal_has_glyph(int codepoint); + +/** + * Similar to write, but automatically retries the write operation until + * an error occurs. + */ +int guac_terminal_write_all(int fd, const char* buffer, int size); + +#endif + http://git-wip-us.apache.org/repos/asf/incubator-guacamole-server/blob/3f7ccb6b/src/terminal/terminal/display.h ---------------------------------------------------------------------- diff --git a/src/terminal/terminal/display.h b/src/terminal/terminal/display.h new file mode 100644 index 0000000..655d1aa --- /dev/null +++ b/src/terminal/terminal/display.h @@ -0,0 +1,363 @@ +/* + * 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_DISPLAY_H +#define _GUAC_TERMINAL_DISPLAY_H + +#include "config.h" + +#include "common/surface.h" +#include "types.h" + +#include <guacamole/client.h> +#include <guacamole/layer.h> +#include <pango/pangocairo.h> + +#include <stdbool.h> + +/** + * The maximum width of any character, in columns. + */ +#define GUAC_TERMINAL_MAX_CHAR_WIDTH 2 + +/** + * The index of black within the terminal color palette. + */ +#define GUAC_TERMINAL_COLOR_BLACK 0 + +/** + * The index of low-intensity red within the terminal color palette. + */ +#define GUAC_TERMINAL_COLOR_DARK_RED 1 + +/** + * The index of low-intensity green within the terminal color palette. + */ +#define GUAC_TERMINAL_COLOR_DARK_GREEN 2 + +/** + * The index of brown within the terminal color palette. + */ +#define GUAC_TERMINAL_COLOR_BROWN 3 + +/** + * The index of low-intensity blue within the terminal color palette. + */ +#define GUAC_TERMINAL_COLOR_DARK_BLUE 4 + +/** + * The index of low-intensity magenta (purple) within the terminal color + * palette. + */ +#define GUAC_TERMINAL_COLOR_PURPLE 5 + +/** + * The index of low-intensity cyan (teal) within the terminal color palette. + */ +#define GUAC_TERMINAL_COLOR_TEAL 6 + +/** + * The index of low-intensity white (gray) within the terminal color palette. + */ +#define GUAC_TERMINAL_COLOR_GRAY 7 + +/** + * The index of bright black (dark gray) within the terminal color palette. + */ +#define GUAC_TERMINAL_COLOR_DARK_GRAY 8 + +/** + * The index of bright red within the terminal color palette. + */ +#define GUAC_TERMINAL_COLOR_RED 9 + +/** + * The index of bright green within the terminal color palette. + */ +#define GUAC_TERMINAL_COLOR_GREEN 10 + +/** + * The index of bright brown (yellow) within the terminal color palette. + */ +#define GUAC_TERMINAL_COLOR_YELLOW 11 + +/** + * The index of bright blue within the terminal color palette. + */ +#define GUAC_TERMINAL_COLOR_BLUE 12 + +/** + * The index of bright magenta within the terminal color palette. + */ +#define GUAC_TERMINAL_COLOR_MAGENTA 13 + +/** + * The index of bright cyan within the terminal color palette. + */ +#define GUAC_TERMINAL_COLOR_CYAN 14 + +/** + * The index of bright white within the terminal color palette. + */ +#define GUAC_TERMINAL_COLOR_WHITE 15 + +/** + * The available color palette. All integer colors within structures + * here are indices into this palette. + */ +extern const guac_terminal_color guac_terminal_palette[16]; + +/** + * All available terminal operations which affect character cells. + */ +typedef enum guac_terminal_operation_type { + + /** + * Operation which does nothing. + */ + GUAC_CHAR_NOP, + + /** + * Operation which copies a character from a given row/column coordinate. + */ + GUAC_CHAR_COPY, + + /** + * Operation which sets the character and attributes. + */ + GUAC_CHAR_SET + +} guac_terminal_operation_type; + +/** + * A pairing of a guac_terminal_operation_type and all parameters required by + * that operation type. + */ +typedef struct guac_terminal_operation { + + /** + * The type of operation to perform. + */ + guac_terminal_operation_type type; + + /** + * The character (and attributes) to set the current location to. This is + * only applicable to GUAC_CHAR_SET. + */ + guac_terminal_char character; + + /** + * The row to copy a character from. This is only applicable to + * GUAC_CHAR_COPY. + */ + int row; + + /** + * The column to copy a character from. This is only applicable to + * GUAC_CHAR_COPY. + */ + int column; + +} guac_terminal_operation; + +/** + * Set of all pending operations for the currently-visible screen area. + */ +typedef struct guac_terminal_display { + + /** + * The Guacamole client this display will use for rendering. + */ + guac_client* client; + + /** + * Array of all operations pending for the visible screen area. + */ + guac_terminal_operation* operations; + + /** + * The width of the screen, in characters. + */ + int width; + + /** + * The height of the screen, in characters. + */ + int height; + + /** + * The description of the font to use for rendering. + */ + PangoFontDescription* font_desc; + + /** + * The width of each character, in pixels. + */ + int char_width; + + /** + * The height of each character, in pixels. + */ + int char_height; + + /** + * Default foreground color for all glyphs. + */ + int default_foreground; + + /** + * Default background color for all glyphs and the terminal itself. + */ + int default_background; + + /** + * Color of glyphs in copy buffer + */ + int glyph_foreground; + + /** + * Color of glyphs in copy buffer + */ + int glyph_background; + + /** + * The surface containing the actual terminal. + */ + guac_common_surface* display_surface; + + /** + * Layer which contains the actual terminal. + */ + guac_layer* display_layer; + + /** + * Sub-layer of display layer which highlights selected text. + */ + guac_layer* select_layer; + + /** + * Whether text is being 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 when the display changes. + */ + 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 row that the selection ends at. + */ + int selection_end_row; + + /** + * The column that the selection ends at. + */ + int selection_end_column; + +} guac_terminal_display; + +/** + * Allocates a new display having the given default foreground and background + * colors. + */ +guac_terminal_display* guac_terminal_display_alloc(guac_client* client, + const char* font_name, int font_size, int dpi, + int foreground, int background); + +/** + * Frees the given display. + */ +void guac_terminal_display_free(guac_terminal_display* display); + +/** + * Copies the given range of columns to a new location, offset from + * the original by the given number of columns. + */ +void guac_terminal_display_copy_columns(guac_terminal_display* display, 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_display_copy_rows(guac_terminal_display* display, + 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_display_set_columns(guac_terminal_display* display, int row, + int start_column, int end_column, guac_terminal_char* character); + +/** + * Resize the terminal to the given dimensions. + */ +void guac_terminal_display_resize(guac_terminal_display* display, int width, int height); + +/** + * Flushes all pending operations within the given guac_terminal_display. + */ +void guac_terminal_display_flush(guac_terminal_display* display); + +/** + * Initializes and syncs the current terminal display state for the given user + * that has just joined the connection, sending the necessary instructions to + * completely recreate and redraw the terminal rendering over the given socket. + * + * @param display + * The terminal display to sync to the given user. + * + * @param user + * The user that has just joined the connection. + * + * @param socket + * The socket over which any necessary instructions should be sent. + */ +void guac_terminal_display_dup(guac_terminal_display* display, guac_user* user, + guac_socket* socket); + +/** + * Draws the text selection rectangle from the given coordinates to the given end coordinates. + */ +void guac_terminal_display_select(guac_terminal_display* display, + int start_row, int start_col, int end_row, int end_col); + +/** + * Commits the select rectangle, allowing the display to clear it when + * necessary. + */ +void guac_terminal_display_commit_select(guac_terminal_display* display); + +#endif +
