libguac-terminal  1.5.4
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 
21 #ifndef _GUAC_TERMINAL_H
22 #define _GUAC_TERMINAL_H
23 
31 #include <pthread.h>
32 #include <stdbool.h>
33 
34 #include <guacamole/client.h>
35 #include <guacamole/stream.h>
36 
40 #define GUAC_TERMINAL_DEFAULT_FONT_NAME "monospace"
41 
46 #define GUAC_TERMINAL_DEFAULT_FONT_SIZE 12
47 
51 #define GUAC_TERMINAL_DEFAULT_MAX_SCROLLBACK 1000
52 
56 #define GUAC_TERMINAL_DEFAULT_BACKSPACE 127
57 
61 #define GUAC_TERMINAL_DEFAULT_COLOR_SCHEME ""
62 
66 #define GUAC_TERMINAL_DEFAULT_DISABLE_COPY false
67 
71 #define GUAC_TERMINAL_MAX_ROWS 1024
72 
77 #define GUAC_TERMINAL_MAX_COLUMNS 1024
78 
82 #define GUAC_TERMINAL_FRAME_DURATION 40
83 
88 #define GUAC_TERMINAL_FRAME_TIMEOUT 10
89 
93 #define GUAC_TERMINAL_MAX_TABS 16
94 
98 #define GUAC_TERMINAL_WHEEL_SCROLL_AMOUNT 3
99 
105 #define GUAC_TERMINAL_PIPE_INTERPRET_OUTPUT 1
106 
113 #define GUAC_TERMINAL_PIPE_AUTOFLUSH 2
114 
120 
125 
130 
135 
140 
142 
154 typedef void guac_terminal_upload_path_handler(guac_client* client, char* path);
155 
174 typedef guac_stream* guac_terminal_file_download_handler(guac_client* client, char* filename);
175 
182 typedef struct guac_terminal_options {
183 
191 
203 
207  char* font_name;
208 
213 
218  int dpi;
219 
223  int width;
224 
228  int height;
229 
235 
241 
243 
265 guac_terminal* guac_terminal_create(guac_client* client,
266  guac_terminal_options* terminal_options);
267 
291  int width, int height, int dpi);
292 
300 
314  guac_terminal_upload_path_handler* upload_path_handler);
315 
329  guac_terminal_file_download_handler* file_download_handler);
330 
343 
363 int guac_terminal_read_stdin(guac_terminal* terminal, char* c, int size);
364 
375 
384 
392 void guac_terminal_notify(guac_terminal* terminal);
393 
418 char* guac_terminal_prompt(guac_terminal* terminal, const char* title,
419  bool echo);
420 
441 int guac_terminal_printf(guac_terminal* terminal, const char* format, ...);
442 
462 int guac_terminal_send_key(guac_terminal* term, int keysym, int pressed);
463 
502 int guac_terminal_send_mouse(guac_terminal* term, guac_user* user,
503  int x, int y, int mask);
504 
525 int guac_terminal_send_data(guac_terminal* term, const char* data, int length);
526 
544 int guac_terminal_send_string(guac_terminal* term, const char* data);
545 
564 int guac_terminal_write(guac_terminal* term, const char* buffer, int length);
565 
591 int guac_terminal_send_stream(guac_terminal* term, guac_user* user,
592  guac_stream* stream);
593 
615 int guac_terminal_sendf(guac_terminal* term, const char* format, ...);
616 
635 void guac_terminal_dup(guac_terminal* term, guac_user* user,
636  guac_socket* socket);
637 
654  guac_terminal* term, guac_client* client, guac_socket* socket);
655 
672 int guac_terminal_resize(guac_terminal* term, int width, int height);
673 
688 
699 
710 
721  const char* mimetype);
722 
736  const char* data, int length);
737 
748 void guac_terminal_remove_user(guac_terminal* terminal, guac_user* user);
749 
779 int guac_terminal_create_typescript(guac_terminal* term, const char* path,
780  const char* name, int create_path);
781 
794  const char* color_scheme);
795 
805 const char* guac_terminal_get_color_scheme(guac_terminal* terminal);
806 
828 void guac_terminal_apply_font(guac_terminal* terminal, const char* font_name,
829  int font_size, int dpi);
830 
840 const char* guac_terminal_get_font_name(guac_terminal* terminal);
841 
852 
863 
864 #endif
bool disable_copy
Whether copying from the terminal clipboard should be blocked.
Definition: terminal.h:190
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_notify(guac_terminal *terminal)
Notifies the terminal that an event has occurred and the terminal should flush itself when reasonable...
A transparent (blank) cursor.
Definition: terminal.h:129
char * font_name
The name of the font to use when rendering glyphs.
Definition: terminal.h:207
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 font_size
The size of each glyph, in points.
Definition: terminal.h:212
A standard I-bar cursor for selecting text, etc.
Definition: terminal.h:134
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_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 backspace
The integer ASCII code to send when backspace is pressed in the terminal.
Definition: terminal.h:240
void guac_terminal_free(guac_terminal *term)
Frees all resources associated with the given terminal.
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.
A standard triangular mouse pointer for manipulating non-text objects.
Definition: terminal.h:139
int dpi
The DPI of the display.
Definition: terminal.h:218
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.
int guac_terminal_send_string(guac_terminal *term, const char *data)
Sends the given string as if typed by the user.
const char * guac_terminal_get_font_name(guac_terminal *terminal)
Returns the font name currently in use by the given terminal.
Configuration options that may be passed when creating a new guac_terminal.
Definition: terminal.h:182
int height
The height of the terminal, in pixels.
Definition: terminal.h:228
int guac_terminal_read_stdin(guac_terminal *terminal, char *c, int size)
Reads from this terminal&#39;s STDIN.
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...
int guac_terminal_get_rows(guac_terminal *term)
Returns the height of the given terminal, in characters.
int guac_terminal_get_font_size(guac_terminal *terminal)
Returns the font size currently in use by the given terminal.
void guac_terminal_start(guac_terminal *term)
Notifies the terminal that rendering should begin and that user input should now be accepted...
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_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...
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.
int guac_terminal_resize(guac_terminal *term, int width, int height)
Resize the client display and terminal to the given pixel dimensions.
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:154
int guac_terminal_send_key(guac_terminal *term, int keysym, int pressed)
Handles the given key event, sending data, scrolling, pasting clipboard data, etc.
guac_terminal_cursor_type
All possible mouse cursors used by the terminal emulator.
Definition: terminal.h:124
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...
int guac_terminal_get_mod_ctrl(guac_terminal *terminal)
Returns the current state of the mod_ctrl flag in the given terminal.
const char * guac_terminal_get_color_scheme(guac_terminal *terminal)
Returns name of the color scheme currently in use by the given terminal.
char * color_scheme
The name of the color scheme to use.
Definition: terminal.h:234
int width
The width of the terminal, in pixels.
Definition: terminal.h:223
int guac_terminal_render_frame(guac_terminal *terminal)
Renders a single frame of terminal data.
void guac_terminal_stop(guac_terminal *term)
Manually stop the terminal to forcibly unblock any pending reads/writes, e.g.
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:174
int guac_terminal_send_data(guac_terminal *term, const char *data, int length)
Sends the given string as if typed by the user.
int max_scrollback
The maximum number of rows to allow within the scrollback buffer.
Definition: terminal.h:202
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...
int guac_terminal_printf(guac_terminal *terminal, const char *format,...)
Writes the given format string and arguments to this terminal&#39;s STDOUT in the same manner as printf()...
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 ...
char * guac_terminal_prompt(guac_terminal *terminal, const char *title, bool echo)
Reads a single line from this terminal&#39;s STDIN, storing the result in a newly-allocated string...
int guac_terminal_get_columns(guac_terminal *term)
Returns the width of the given terminal, in characters.
guac_terminal_options * guac_terminal_options_create(int width, int height, int dpi)
Create a new guac_terminal_options struct.
int guac_terminal_write(guac_terminal *term, const char *buffer, int length)
Writes the given buffer to the given terminal&#39;s STDOUT.
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...
struct guac_terminal guac_terminal
Represents a terminal emulator which uses a given Guacamole client to render itself.
Definition: terminal.h:119