libguac-terminal  1.5.5
terminal.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
20 #ifndef _GUAC_TERMINAL_H
21 #define _GUAC_TERMINAL_H
22 
30 #include <pthread.h>
31 #include <stdbool.h>
32 
33 #include <guacamole/client.h>
34 #include <guacamole/stream.h>
35 
39 #define GUAC_TERMINAL_DEFAULT_FONT_NAME "monospace"
40 
45 #define GUAC_TERMINAL_DEFAULT_FONT_SIZE 12
46 
50 #define GUAC_TERMINAL_DEFAULT_MAX_SCROLLBACK 1000
51 
55 #define GUAC_TERMINAL_DEFAULT_BACKSPACE 127
56 
60 #define GUAC_TERMINAL_DEFAULT_COLOR_SCHEME ""
61 
65 #define GUAC_TERMINAL_DEFAULT_DISABLE_COPY false
66 
70 #define GUAC_TERMINAL_MAX_ROWS 1024
71 
76 #define GUAC_TERMINAL_MAX_COLUMNS 1024
77 
81 #define GUAC_TERMINAL_FRAME_DURATION 40
82 
87 #define GUAC_TERMINAL_FRAME_TIMEOUT 10
88 
92 #define GUAC_TERMINAL_MAX_TABS 16
93 
97 #define GUAC_TERMINAL_WHEEL_SCROLL_AMOUNT 3
98 
104 #define GUAC_TERMINAL_PIPE_INTERPRET_OUTPUT 1
105 
112 #define GUAC_TERMINAL_PIPE_AUTOFLUSH 2
113 
118 typedef struct guac_terminal guac_terminal;
119 
124 
129 
134 
139 
141 
153 typedef void guac_terminal_upload_path_handler(guac_client* client, char* path);
154 
173 typedef guac_stream* guac_terminal_file_download_handler(guac_client* client, char* filename);
174 
181 typedef struct guac_terminal_options {
182 
190 
202 
206  char* font_name;
207 
212 
217  int dpi;
218 
222  int width;
223 
227  int height;
228 
234 
240 
242 
264 guac_terminal* guac_terminal_create(guac_client* client,
265  guac_terminal_options* terminal_options);
266 
290  int width, int height, int dpi);
291 
299 
313  guac_terminal_upload_path_handler* upload_path_handler);
314 
328  guac_terminal_file_download_handler* file_download_handler);
329 
342 
362 int guac_terminal_read_stdin(guac_terminal* terminal, char* c, int size);
363 
374 
383 
392 
417 char* guac_terminal_prompt(guac_terminal* terminal, const char* title,
418  bool echo);
419 
440 int guac_terminal_printf(guac_terminal* terminal, const char* format, ...);
441 
461 int guac_terminal_send_key(guac_terminal* term, int keysym, int pressed);
462 
501 int guac_terminal_send_mouse(guac_terminal* term, guac_user* user,
502  int x, int y, int mask);
503 
524 int guac_terminal_send_data(guac_terminal* term, const char* data, int length);
525 
543 int guac_terminal_send_string(guac_terminal* term, const char* data);
544 
563 int guac_terminal_write(guac_terminal* term, const char* buffer, int length);
564 
590 int guac_terminal_send_stream(guac_terminal* term, guac_user* user,
591  guac_stream* stream);
592 
614 int guac_terminal_sendf(guac_terminal* term, const char* format, ...);
615 
634 void guac_terminal_dup(guac_terminal* term, guac_user* user,
635  guac_socket* socket);
636 
653  guac_terminal* term, guac_client* client, guac_socket* socket);
654 
671 int guac_terminal_resize(guac_terminal* term, int width, int height);
672 
687 
698 
709 
720  const char* mimetype);
721 
735  const char* data, int length);
736 
747 void guac_terminal_remove_user(guac_terminal* terminal, guac_user* user);
748 
778 int guac_terminal_create_typescript(guac_terminal* term, const char* path,
779  const char* name, int create_path);
780 
793  const char* color_scheme);
794 
805 
827 void guac_terminal_apply_font(guac_terminal* terminal, const char* font_name,
828  int font_size, int dpi);
829 
840 
851 
862 
863 #endif
Configuration options that may be passed when creating a new guac_terminal.
Definition: terminal.h:181
int dpi
The DPI of the display.
Definition: terminal.h:217
int height
The height of the terminal, in pixels.
Definition: terminal.h:227
char * color_scheme
The name of the color scheme to use.
Definition: terminal.h:233
int backspace
The integer ASCII code to send when backspace is pressed in the terminal.
Definition: terminal.h:239
int width
The width of the terminal, in pixels.
Definition: terminal.h:222
int font_size
The size of each glyph, in points.
Definition: terminal.h:211
int max_scrollback
The maximum number of rows to allow within the scrollback buffer.
Definition: terminal.h:201
bool disable_copy
Whether copying from the terminal clipboard should be blocked.
Definition: terminal.h:189
char * font_name
The name of the font to use when rendering glyphs.
Definition: terminal.h:206
void guac_terminal_clipboard_reset(guac_terminal *terminal, const char *mimetype)
Clears the clipboard contents for a given terminal, and assigns a new mimetype for future data.
guac_stream * guac_terminal_file_download_handler(guac_client *client, char *filename)
Handler that is invoked whenever the necessary terminal codes are sent to initiate a download of a gi...
Definition: terminal.h:173
void guac_terminal_notify(guac_terminal *terminal)
Notifies the terminal that an event has occurred and the terminal should flush itself when reasonable...
const char * guac_terminal_get_color_scheme(guac_terminal *terminal)
Returns name of the color scheme currently in use by the given terminal.
int guac_terminal_create_typescript(guac_terminal *term, const char *path, const char *name, int create_path)
Requests that the terminal write all output to a new pair of typescript files within the given path a...
int guac_terminal_send_stream(guac_terminal *term, guac_user *user, guac_stream *stream)
Initializes the handlers of the given guac_stream such that it serves as the source of input to the t...
void guac_terminal_sync_users(guac_terminal *term, guac_client *client, guac_socket *socket)
Replicates the current display state to one or more users that are joining the connection.
void guac_terminal_upload_path_handler(guac_client *client, char *path)
Handler that is invoked whenever the necessary terminal codes are sent to to the given terminal to ch...
Definition: terminal.h:153
void guac_terminal_set_upload_path_handler(guac_terminal *terminal, guac_terminal_upload_path_handler *upload_path_handler)
Sets the upload path handler for the given terminal.
const char * guac_terminal_get_font_name(guac_terminal *terminal)
Returns the font name currently in use by the given terminal.
void guac_terminal_apply_color_scheme(guac_terminal *terminal, const char *color_scheme)
Immediately applies the given color scheme to the given terminal, overriding the color scheme provide...
struct guac_terminal guac_terminal
Represents a terminal emulator which uses a given Guacamole client to render itself.
Definition: terminal.h:118
void guac_terminal_stop(guac_terminal *term)
Manually stop the terminal to forcibly unblock any pending reads/writes, e.g.
void guac_terminal_start(guac_terminal *term)
Notifies the terminal that rendering should begin and that user input should now be accepted.
int guac_terminal_write(guac_terminal *term, const char *buffer, int length)
Writes the given buffer to the given terminal's STDOUT.
int guac_terminal_printf(guac_terminal *terminal, const char *format,...)
Writes the given format string and arguments to this terminal's STDOUT in the same manner as printf()...
guac_terminal_cursor_type
All possible mouse cursors used by the terminal emulator.
Definition: terminal.h:123
@ GUAC_TERMINAL_CURSOR_IBAR
A standard I-bar cursor for selecting text, etc.
Definition: terminal.h:133
@ GUAC_TERMINAL_CURSOR_BLANK
A transparent (blank) cursor.
Definition: terminal.h:128
@ GUAC_TERMINAL_CURSOR_POINTER
A standard triangular mouse pointer for manipulating non-text objects.
Definition: terminal.h:138
int guac_terminal_sendf(guac_terminal *term, const char *format,...)
Sends data through STDIN as if typed by the user, using the format string given and any args (similar...
void guac_terminal_clipboard_append(guac_terminal *terminal, const char *data, int length)
Appends the given data to the contents of the clipboard for the given terminal.
int guac_terminal_get_mod_ctrl(guac_terminal *terminal)
Returns the current state of the mod_ctrl flag in the given terminal.
int guac_terminal_get_font_size(guac_terminal *terminal)
Returns the font size currently in use by the given terminal.
int guac_terminal_send_data(guac_terminal *term, const char *data, int length)
Sends the given string as if typed by the user.
guac_terminal * guac_terminal_create(guac_client *client, guac_terminal_options *terminal_options)
Creates a new guac_terminal, having the given width and height, and rendering to the given client.
void guac_terminal_dup(guac_terminal *term, guac_user *user, guac_socket *socket)
Replicates the current display state to a user that has just joined the connection.
int guac_terminal_resize(guac_terminal *term, int width, int height)
Resize the client display and terminal to the given pixel dimensions.
int guac_terminal_render_frame(guac_terminal *terminal)
Renders a single frame of terminal data.
int guac_terminal_get_rows(guac_terminal *term)
Returns the height of the given terminal, in characters.
void guac_terminal_set_file_download_handler(guac_terminal *terminal, guac_terminal_file_download_handler *file_download_handler)
Sets the file download handler for the given terminal.
int guac_terminal_send_key(guac_terminal *term, int keysym, int pressed)
Handles the given key event, sending data, scrolling, pasting clipboard data, etc.
int guac_terminal_send_mouse(guac_terminal *term, guac_user *user, int x, int y, int mask)
Handles the given mouse event, sending data, scrolling, pasting clipboard data, etc.
guac_terminal_options * guac_terminal_options_create(int width, int height, int dpi)
Create a new guac_terminal_options struct.
void guac_terminal_free(guac_terminal *term)
Frees all resources associated with the given terminal.
int guac_terminal_read_stdin(guac_terminal *terminal, char *c, int size)
Reads from this terminal's STDIN.
char * guac_terminal_prompt(guac_terminal *terminal, const char *title, bool echo)
Reads a single line from this terminal's STDIN, storing the result in a newly-allocated string.
void guac_terminal_remove_user(guac_terminal *terminal, guac_user *user)
Removes the given user from any user-specific resources internal to the given terminal.
void guac_terminal_apply_font(guac_terminal *terminal, const char *font_name, int font_size, int dpi)
Alters the font of the terminal.
int guac_terminal_get_columns(guac_terminal *term)
Returns the width of the given terminal, in characters.
int guac_terminal_get_available_scroll(guac_terminal *term)
Returns the number of rows within the buffer of the given terminal which are not currently displayed ...
int guac_terminal_send_string(guac_terminal *term, const char *data)
Sends the given string as if typed by the user.