cscg24-guacamole

CSCG 2024 Challenge 'Guacamole Mashup'
git clone https://git.sinitax.com/sinitax/cscg24-guacamole
Log | Files | Refs | sfeed.txt

terminal.h (28314B)


      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
     24/**
     25 * Constants, structures, and function definitions defining the core
     26 * functionality for the terminal library.
     27 *
     28 * @file terminal.h
     29 */
     30
     31#include <pthread.h>
     32#include <stdbool.h>
     33
     34#include <guacamole/client.h>
     35#include <guacamole/stream.h>
     36
     37/**
     38 * The name of the font to use for the terminal if no name is specified.
     39 */
     40#define GUAC_TERMINAL_DEFAULT_FONT_NAME "monospace"
     41
     42/**
     43 * The size of the font to use for the terminal if no font size is specified,
     44 * in points.
     45 */
     46#define GUAC_TERMINAL_DEFAULT_FONT_SIZE 12
     47
     48/**
     49 * The default maximum scrollback size in rows.
     50 */
     51#define GUAC_TERMINAL_DEFAULT_MAX_SCROLLBACK 1000
     52
     53/**
     54 * The default ASCII code to use for the backspace key.
     55 */
     56#define GUAC_TERMINAL_DEFAULT_BACKSPACE 127
     57
     58/**
     59 * The default (unset) color scheme.
     60 */
     61#define GUAC_TERMINAL_DEFAULT_COLOR_SCHEME ""
     62
     63/**
     64 * The default value for the "disable copy" flag; by default copying is enabled.
     65 */
     66#define GUAC_TERMINAL_DEFAULT_DISABLE_COPY false
     67
     68/**
     69 * The absolute maximum number of rows to allow within the display.
     70 */
     71#define GUAC_TERMINAL_MAX_ROWS 1024
     72
     73/**
     74 * The absolute maximum number of columns to allow within the display. This
     75 * implicitly limits the number of columns allowed within the buffer.
     76 */
     77#define GUAC_TERMINAL_MAX_COLUMNS 1024
     78
     79/**
     80 * The maximum duration of a single frame, in milliseconds.
     81 */
     82#define GUAC_TERMINAL_FRAME_DURATION 40
     83
     84/**
     85 * The maximum amount of time to wait for more data before declaring a frame
     86 * complete, in milliseconds.
     87 */
     88#define GUAC_TERMINAL_FRAME_TIMEOUT 10
     89
     90/**
     91 * The maximum number of custom tab stops.
     92 */
     93#define GUAC_TERMINAL_MAX_TABS       16
     94
     95/**
     96 * The number of rows to scroll per scroll wheel event.
     97 */
     98#define GUAC_TERMINAL_WHEEL_SCROLL_AMOUNT 3
     99
    100/**
    101 * Flag which specifies that terminal output should be sent to both the current
    102 * pipe stream and the user's display. By default, terminal output will be sent
    103 * only to the open pipe.
    104 */
    105#define GUAC_TERMINAL_PIPE_INTERPRET_OUTPUT 1
    106
    107/**
    108 * Flag which forces the open pipe stream to be flushed automatically, whenever
    109 * a new frame would be rendered, with only minimal buffering performed between
    110 * frames. By default, the contents of the pipe stream will be flushed only
    111 * when the buffer is full or the pipe stream is being closed.
    112 */
    113#define GUAC_TERMINAL_PIPE_AUTOFLUSH 2
    114
    115/**
    116 * Represents a terminal emulator which uses a given Guacamole client to
    117 * render itself.
    118 */
    119typedef struct guac_terminal guac_terminal;
    120
    121/**
    122 * All possible mouse cursors used by the terminal emulator.
    123 */
    124typedef enum guac_terminal_cursor_type {
    125
    126    /**
    127     * A transparent (blank) cursor.
    128     */
    129    GUAC_TERMINAL_CURSOR_BLANK,
    130
    131    /**
    132     * A standard I-bar cursor for selecting text, etc.
    133     */
    134    GUAC_TERMINAL_CURSOR_IBAR,
    135
    136    /**
    137     * A standard triangular mouse pointer for manipulating non-text objects.
    138     */
    139    GUAC_TERMINAL_CURSOR_POINTER
    140
    141} guac_terminal_cursor_type;
    142
    143/**
    144 * Handler that is invoked whenever the necessary terminal codes are sent to
    145 * to the given terminal to change the path for future file uploads.
    146 *
    147 * @param client
    148 *     The guac_client associated with the terminal receiving the upload path
    149 *     change terminal code.
    150 *
    151 * @param path
    152 *     The requested path.
    153 */
    154typedef void guac_terminal_upload_path_handler(guac_client* client, char* path);
    155
    156/**
    157 * Handler that is invoked whenever the necessary terminal codes are sent to
    158 * initiate a download of a given remote file.
    159 *
    160 * @param client
    161 *     The guac_client associated with the terminal receiving the file download
    162 *     terminal code.
    163 *
    164 * @param filename
    165 *     The name of the requested file. This may be a relative or absolute path,
    166 *     and it is up to the implementation to define how this value is
    167 *     interpreted.
    168 *
    169 * @return
    170 *     The file stream created for the file download, already configured to
    171 *     properly handle "ack" responses, etc. from the client, or NULL if the
    172 *     stream could not be created.
    173 */
    174typedef guac_stream* guac_terminal_file_download_handler(guac_client* client, char* filename);
    175
    176/**
    177 * Configuration options that may be passed when creating a new guac_terminal.
    178 *
    179 * Note that guac_terminal_options should not be instantiated directly -
    180 * to create a new options struct, use guac_terminal_options_create.
    181 */
    182typedef struct guac_terminal_options {
    183
    184    /**
    185     * Whether copying from the terminal clipboard should be blocked. If set,
    186     * the contents of the terminal can still be copied, but will be usable
    187     * only within the terminal itself. The clipboard contents will not be
    188     * automatically streamed to the client.
    189     */
    190    bool disable_copy;
    191
    192    /**
    193     * The maximum number of rows to allow within the scrollback buffer. The
    194     * user may still alter the size of the scrollback buffer using terminal
    195     * codes, however the size can never exceed the maximum size given here.
    196     * Note that this space is shared with the display, with the scrollable
    197     * area actually only containing the given number of rows less the number
    198     * of rows currently displayed, and sufficient buffer space will always be
    199     * allocated to represent the display area of the terminal regardless of
    200     * the value given here.
    201     */
    202    int max_scrollback;
    203
    204    /**
    205     * The name of the font to use when rendering glyphs.
    206     */
    207    char* font_name;
    208
    209    /**
    210     * The size of each glyph, in points.
    211     */
    212    int font_size;
    213
    214    /**
    215     * The DPI of the display. The given font size will be adjusted to produce
    216     * glyphs at the given DPI.
    217     */
    218    int dpi;
    219
    220    /**
    221     * The width of the terminal, in pixels.
    222     */
    223    int width;
    224
    225    /**
    226     * The height of the terminal, in pixels.
    227     */
    228    int height;
    229
    230    /**
    231     * The name of the color scheme to use. This string must be in the format
    232     * accepted by guac_terminal_parse_color_scheme().
    233     */
    234    char* color_scheme;
    235
    236    /**
    237     * The integer ASCII code to send when backspace is pressed in
    238     * the terminal.
    239     */
    240    int backspace;
    241
    242} guac_terminal_options;
    243
    244/**
    245 * Creates a new guac_terminal, having the given width and height, and
    246 * rendering to the given client. As failover mechanisms and the Guacamole
    247 * client implementation typically use the receipt of a "sync" message to
    248 * denote successful connection, rendering of frames (sending of "sync") will
    249 * be withheld until guac_terminal_start() is called, and user input will be
    250 * ignored. The guac_terminal_start() function should be invoked only after
    251 * either the underlying connection has truly succeeded, or until visible
    252 * terminal output or user input is required.
    253 *
    254 * @param client
    255 *      The client to which the terminal will be rendered.
    256 *
    257 * @param terminal_options
    258 *     The configuration used for instantiating the terminal. For information
    259 *     about the options, see the guac_terminal_options definition.
    260 *
    261 * @return
    262 *     A new guac_terminal having the given font, dimensions, and attributes
    263 *     which renders all text to the given client.
    264 */
    265guac_terminal* guac_terminal_create(guac_client* client,
    266        guac_terminal_options* terminal_options);
    267
    268/**
    269 * Create a new guac_terminal_options struct. All parameters are required.
    270 * Any options that are not passed in this constructor will be set to
    271 * default values unless overriden.
    272 *
    273 * The guac_terminal_options struct should only be created using this
    274 * constructor.
    275 *
    276 * @param width
    277 *     The width of the terminal, in pixels.
    278 *
    279 * @param height
    280 *     The height of the terminal, in pixels.
    281 *
    282 * @param dpi
    283 *     The DPI of the display. The given font size will be adjusted to produce
    284 *     glyphs at the given DPI.
    285 *
    286 * @return
    287 *     A new terminal options struct with all required options populated,
    288 *     ready to have any defaults overriden as needed.
    289 */
    290guac_terminal_options* guac_terminal_options_create(
    291        int width, int height, int dpi);
    292
    293/**
    294 * Frees all resources associated with the given terminal.
    295 *
    296 * @param term
    297 *     The terminal to free.
    298 */
    299void guac_terminal_free(guac_terminal* term);
    300
    301/**
    302 * Sets the upload path handler for the given terminal. The upload path handler
    303 * is invoked whenever the terminal codes requesting an upload path change are
    304 * sent.
    305 *
    306 * @param terminal
    307 *     The terminal to set the upload path handler for.
    308 *
    309 * @param upload_path_handler
    310 *      The handler to be called whenever the necessary terminal codes are sent
    311 *      to the given terminal to change the path for future file uploads.
    312 */
    313void guac_terminal_set_upload_path_handler(guac_terminal* terminal,
    314        guac_terminal_upload_path_handler* upload_path_handler);
    315
    316/**
    317 * Sets the file download handler for the given terminal. The file download
    318 * handler is invoked whenever the terminal codes requesting download of a
    319 * given remote file are sent.
    320 *
    321 * @param terminal
    322 *     The terminal to set the file download handler for.
    323 *
    324 * @param file_download_handler
    325 *      The handler to be called whenever the necessary terminal codes are sent to
    326 *      the given terminal to initiate a download of a given remote file.
    327 */
    328void guac_terminal_set_file_download_handler(guac_terminal* terminal,
    329        guac_terminal_file_download_handler* file_download_handler);
    330
    331/**
    332 * Renders a single frame of terminal data. If data is not yet available,
    333 * this function will block until data is written.
    334 *
    335 * @param terminal
    336 *     The terminal that should be rendered.
    337 *
    338 * @return
    339 *     Zero if the frame was rendered successfully, non-zero if an error
    340 *     occurred.
    341 */
    342int guac_terminal_render_frame(guac_terminal* terminal);
    343
    344/**
    345 * Reads from this terminal's STDIN. Input comes from key and mouse events
    346 * supplied by calls to guac_terminal_send_key(),
    347 * guac_terminal_send_mouse(), and guac_terminal_send_stream(). If input is not
    348 * yet available, this function will block.
    349 *
    350 * @param terminal
    351 *     The terminal to read from.
    352 *
    353 * @param c
    354 *     The buffer that should receive the bytes read.
    355 *
    356 * @param size
    357 *     The number of bytes available within the buffer.
    358 *
    359 * @return
    360 *     The number of bytes read into the buffer, zero if end-of-file is reached
    361 *     (STDIN has been closed), or a negative value if an error occurs.
    362 */
    363int guac_terminal_read_stdin(guac_terminal* terminal, char* c, int size);
    364
    365/**
    366 * Notifies the terminal that rendering should begin and that user input should
    367 * now be accepted. This function must be invoked following terminal creation
    368 * for the end of frames to be signalled with "sync" messages. Until this
    369 * function is invoked, "sync" messages will be withheld.
    370 *
    371 * @param term
    372 *     The terminal to start.
    373 */
    374void guac_terminal_start(guac_terminal* term);
    375
    376/**
    377 * Manually stop the terminal to forcibly unblock any pending reads/writes,
    378 * e.g. forcing guac_terminal_read_stdin() to return and cease all terminal I/O.
    379 *
    380 * @param term
    381 *     The terminal to stop.
    382 */
    383void guac_terminal_stop(guac_terminal* term);
    384
    385/**
    386 * Notifies the terminal that an event has occurred and the terminal should
    387 * flush itself when reasonable.
    388 *
    389 * @param terminal
    390 *     The terminal to notify.
    391 */
    392void guac_terminal_notify(guac_terminal* terminal);
    393
    394/**
    395 * Reads a single line from this terminal's STDIN, storing the result in a
    396 * newly-allocated string. Input is retrieved in the same manner as
    397 * guac_terminal_read_stdin() and the same restrictions apply. As reading input
    398 * naturally requires user interaction, this function will implicitly invoke
    399 * guac_terminal_start().
    400 *
    401 * @param terminal
    402 *     The terminal to which the provided title should be output, and from
    403 *     whose STDIN the single line of input should be read.
    404 *
    405 * @param title
    406 *     The human-readable title to output to the terminal just prior to reading
    407 *     from STDIN.
    408 *
    409 * @param echo
    410 *     Non-zero if the characters read from STDIN should be echoed back as
    411 *     terminal output, or zero if asterisks should be displayed instead.
    412 *
    413 * @return
    414 *     A newly-allocated string containing a single line of input read from the
    415 *     provided terminal's STDIN. This string must eventually be manually
    416 *     freed with a call to guac_mem_free().
    417 */
    418char* guac_terminal_prompt(guac_terminal* terminal, const char* title,
    419        bool echo);
    420
    421/**
    422 * Writes the given format string and arguments to this terminal's STDOUT in
    423 * the same manner as printf(). The entire populated format string will always
    424 * be written unless an error occurs. This function may block until space is
    425 * freed in the output buffer by guac_terminal_render_frame().
    426 *
    427 * @param terminal
    428 *     The terminal to write to.
    429 *
    430 * @param format
    431 *     A printf-style format string describing the data to be written to
    432 *     STDOUT.
    433 *
    434 * @param ...
    435 *     Any arguments to use when filling the format string.
    436 *
    437 * @return
    438 *     The number of bytes written to STDOUT, or a negative value if an error
    439 *     occurs preventing the data from being written in its entirety.
    440 */
    441int guac_terminal_printf(guac_terminal* terminal, const char* format, ...);
    442
    443/**
    444 * Handles the given key event, sending data, scrolling, pasting clipboard
    445 * data, etc. as necessary. If terminal input is currently coming from a
    446 * stream due to a prior call to guac_terminal_send_stream(), any input
    447 * which would normally result from the key event is dropped.
    448 *
    449 * @param term
    450 *     The terminal which should receive the given data on STDIN.
    451 *
    452 * @param keysym
    453 *     The X11 keysym of the key that was pressed or released.
    454 *
    455 * @param pressed
    456 *     Non-zero if the key represented by the given keysym is currently
    457 *     pressed, zero if it is released.
    458 *
    459 * @return
    460 *     Zero if the key event was handled successfully, non-zero otherwise.
    461 */
    462int guac_terminal_send_key(guac_terminal* term, int keysym, int pressed);
    463
    464/**
    465 * Handles the given mouse event, sending data, scrolling, pasting clipboard
    466 * data, etc. as necessary. If terminal input is currently coming from a
    467 * stream due to a prior call to guac_terminal_send_stream(), any input
    468 * which would normally result from the mouse event is dropped.
    469 *
    470 * @param term
    471 *     The terminal which should receive the given data on STDIN.
    472 *
    473 * @param user
    474 *     The user that originated the mouse event.
    475 *
    476 * @param x
    477 *     The X coordinate of the mouse within the display when the event
    478 *     occurred, in pixels. This value is not guaranteed to be within the
    479 *     bounds of the display area.
    480 *
    481 * @param y
    482 *     The Y coordinate of the mouse within the display when the event
    483 *     occurred, in pixels. This value is not guaranteed to be within the
    484 *     bounds of the display area.
    485 *
    486 * @param mask
    487 *     An integer value representing the current state of each button, where
    488 *     the Nth bit within the integer is set to 1 if and only if the Nth mouse
    489 *     button is currently pressed. The lowest-order bit is the left mouse
    490 *     button, followed by the middle button, right button, and finally the up
    491 *     and down buttons of the scroll wheel.
    492 *
    493 *     @see GUAC_CLIENT_MOUSE_LEFT
    494 *     @see GUAC_CLIENT_MOUSE_MIDDLE
    495 *     @see GUAC_CLIENT_MOUSE_RIGHT
    496 *     @see GUAC_CLIENT_MOUSE_SCROLL_UP
    497 *     @see GUAC_CLIENT_MOUSE_SCROLL_DOWN
    498 *
    499 * @return
    500 *     Zero if the mouse event was handled successfully, non-zero otherwise.
    501 */
    502int guac_terminal_send_mouse(guac_terminal* term, guac_user* user,
    503        int x, int y, int mask);
    504
    505/**
    506 * Sends the given string as if typed by the user. If terminal input is
    507 * currently coming from a stream due to a prior call to
    508 * guac_terminal_send_stream(), any input which would normally result from
    509 * invoking this function is dropped.
    510 *
    511 * @param term
    512 *     The terminal which should receive the given data on STDIN.
    513 *
    514 * @param data
    515 *     The data the terminal should receive on STDIN.
    516 *
    517 * @param length
    518 *     The size of the given data, in bytes.
    519 *
    520 * @return
    521 *     The number of bytes written to STDIN, or a negative value if an error
    522 *     occurs preventing the data from being written. This should always be
    523 *     the size of the data given unless data is intentionally dropped.
    524 */
    525int guac_terminal_send_data(guac_terminal* term, const char* data, int length);
    526
    527/**
    528 * Sends the given string as if typed by the user. If terminal input is
    529 * currently coming from a stream due to a prior call to
    530 * guac_terminal_send_stream(), any input which would normally result from
    531 * invoking this function is dropped.
    532 *
    533 * @param term
    534 *     The terminal which should receive the given data on STDIN.
    535 *
    536 * @param data
    537 *     The data the terminal should receive on STDIN.
    538 *
    539 * @return
    540 *     The number of bytes written to STDIN, or a negative value if an error
    541 *     occurs preventing the data from being written. This should always be
    542 *     the size of the data given unless data is intentionally dropped.
    543 */
    544int guac_terminal_send_string(guac_terminal* term, const char* data);
    545
    546/**
    547 * Writes the given buffer to the given terminal's STDOUT. All requested bytes
    548 * will be written unless an error occurs. This function may block until space
    549 * is freed in the output buffer by guac_terminal_render_frame().
    550 *
    551 * @param term
    552 *     The terminal to write to.
    553 *
    554 * @param buffer
    555 *     A buffer containing the characters to be written to the terminal.
    556 *
    557 * @param length
    558 *     The number of bytes within the given string to write to the terminal.
    559 *
    560 * @return
    561 *     The number of bytes written to STDOUT, or a negative value if an error
    562 *     occurs preventing the data from being written in its entirety.
    563 */
    564int guac_terminal_write(guac_terminal* term, const char* buffer, int length);
    565
    566/**
    567 * Initializes the handlers of the given guac_stream such that it serves as the
    568 * source of input to the terminal. Other input sources will be temporarily
    569 * ignored until the stream is closed through receiving an "end" instruction.
    570 * If input is already being read from a stream due to a prior call to
    571 * guac_terminal_send_stream(), the prior call will remain in effect and this
    572 * call will fail.
    573 *
    574 * Calling this function will overwrite the data member of the given
    575 * guac_stream.
    576 *
    577 * @param term
    578 *     The terminal emulator which should receive input from the given stream.
    579 *
    580 * @param user
    581 *     The user that opened the stream.
    582 *
    583 * @param stream
    584 *     The guac_stream which should serve as the source of input for the
    585 *     terminal.
    586 *
    587 * @return
    588 *     Zero if the terminal input has successfully been configured to read from
    589 *     the given stream, non-zero otherwise.
    590 */
    591int guac_terminal_send_stream(guac_terminal* term, guac_user* user,
    592        guac_stream* stream);
    593
    594/**
    595 * Sends data through STDIN as if typed by the user, using the format string
    596 * given and any args (similar to printf). If terminal input is currently
    597 * coming from a stream due to a prior call to guac_terminal_send_stream(), any
    598 * input which would normally result from invoking this function is dropped.
    599 *
    600 * @param term
    601 *     The terminal which should receive the given data on STDIN.
    602 *
    603 * @param format
    604 *     A printf-style format string describing the data to be received on
    605 *     STDIN.
    606 *
    607 * @param ...
    608 *     Any arguments to use when filling the format string.
    609 *
    610 * @return
    611 *     The number of bytes written to STDIN, or a negative value if an error
    612 *     occurs preventing the data from being written. This should always be
    613 *     the size of the data given unless data is intentionally dropped.
    614 */
    615int guac_terminal_sendf(guac_terminal* term, const char* format, ...);
    616
    617/**
    618 * Replicates the current display state to a user that has just joined the
    619 * connection. All instructions necessary to replicate state are sent over the
    620 * given socket.
    621 *
    622 * @deprecated The guac_terminal_sync_users method should be used when
    623 * duplicating display state to a set of users.
    624 *
    625 * @param term
    626 *     The terminal emulator associated with the connection being joined.
    627 *
    628 * @param user
    629 *     The user joining the connection.
    630 *
    631 * @param socket
    632 *     The guac_socket specific to the joining user and across which messages
    633 *     synchronizing the current display state should be sent.
    634 */
    635void guac_terminal_dup(guac_terminal* term, guac_user* user,
    636        guac_socket* socket);
    637
    638/**
    639 * Replicates the current display state to one or more users that are joining
    640 * the connection. All instructions necessary to replicate state are sent over
    641 * the given socket. The set of users receiving these instructions is
    642 * determined solely by the socket chosen.
    643 *
    644 * @param term
    645 *     The terminal whose state should be synchronized to the users.
    646 *
    647 * @param client
    648 *     The client associated with the users to be synchronized.
    649 *
    650 * @param socket
    651 *     The socket to which the terminal state will be broadcast.
    652 */
    653void guac_terminal_sync_users(
    654        guac_terminal* term, guac_client* client, guac_socket* socket);
    655
    656/**
    657 * Resize the client display and terminal to the given pixel dimensions.
    658 *
    659 * @param term
    660 *     The terminal to resize.
    661 *
    662 * @param width
    663 *     The new terminal width, in pixels.
    664 *
    665 * @param height
    666 *     The new terminal height, in pixels.
    667 *
    668 * @return
    669 *     Zero if the terminal was successfully resized to the given dimensions,
    670 *     non-zero otherwise.
    671 */
    672int guac_terminal_resize(guac_terminal* term, int width, int height);
    673
    674/**
    675 * Returns the number of rows within the buffer of the given terminal which are
    676 * not currently displayed on screen. Adjustments to the desired scrollback
    677 * size are taken into account, and rows which are within the buffer but
    678 * unavailable due to being outside the desired scrollback range are ignored.
    679 *
    680 * @param term
    681 *     The terminal whose off-screen row count should be determined.
    682 *
    683 * @return
    684 *     The number of rows within the buffer which are not currently displayed
    685 *     on screen.
    686 */
    687int guac_terminal_get_available_scroll(guac_terminal* term);
    688
    689/**
    690 * Returns the height of the given terminal, in characters.
    691 *
    692 * @param term
    693 *     The terminal whose height should be determined.
    694 *
    695 * @return
    696 *     The height of the terminal, in characters.
    697 */
    698int guac_terminal_get_rows(guac_terminal* term);
    699
    700/**
    701 * Returns the width of the given terminal, in characters.
    702 *
    703 * @param term
    704 *     The terminal whose width should be determined.
    705 *
    706 * @return
    707 *     The width of the terminal, in characters.
    708 */
    709int guac_terminal_get_columns(guac_terminal* term);
    710
    711/**
    712 * Clears the clipboard contents for a given terminal, and assigns a new
    713 * mimetype for future data.
    714 *
    715 * @param terminal
    716 *      The terminal whose clipboard is being reset.
    717 * @param mimetype
    718 *      The mimetype of future data.
    719 */
    720void guac_terminal_clipboard_reset(guac_terminal* terminal,
    721        const char* mimetype);
    722
    723/**
    724 * Appends the given data to the contents of the clipboard for the given
    725 * terminal. The data must match the mimetype chosen for the clipboard data by
    726 * guac_terminal_clipboard_reset().
    727 *
    728 * @param terminal
    729 *      The terminal whose clipboard is being appended to.
    730 * @param data
    731 *      The data to append.
    732 * @param length
    733 *      The number of bytes to append from the data given.
    734 */
    735void guac_terminal_clipboard_append(guac_terminal* terminal,
    736        const char* data, int length);
    737
    738/**
    739 * Removes the given user from any user-specific resources internal to the
    740 * given terminal. This function must be called whenever a user leaves a
    741 * terminal connection.
    742 *
    743 * @param terminal
    744 *      The terminal that the given user is leaving.
    745 * @param user
    746 *      The user who is disconnecting.
    747 */
    748void guac_terminal_remove_user(guac_terminal* terminal, guac_user* user);
    749
    750/**
    751 * Requests that the terminal write all output to a new pair of typescript
    752 * files within the given path and using the given base name. Terminal output
    753 * will be written to these new files, along with timing information. If the
    754 * create_path flag is non-zero, the given path will be created if it does not
    755 * yet exist. If creation of the typescript files or path fails, error messages
    756 * will automatically be logged, and no typescript will be written. The
    757 * typescript will automatically be closed once the terminal is freed.
    758 *
    759 * @param term
    760 *     The terminal whose output should be written to a typescript.
    761 *
    762 * @param path
    763 *     The full absolute path to a directory in which the typescript files
    764 *     should be created.
    765 *
    766 * @param name
    767 *     The base name to use for the typescript files created within the
    768 *     specified path.
    769 *
    770 * @param create_path
    771 *     Zero if the specified path MUST exist for typescript files to be
    772 *     written, or non-zero if the path should be created if it does not yet
    773 *     exist.
    774 *
    775 * @return
    776 *     Zero if the typescript files have been successfully created and a
    777 *     typescript will be written, non-zero otherwise.
    778 */
    779int guac_terminal_create_typescript(guac_terminal* term, const char* path,
    780        const char* name, int create_path);
    781
    782/**
    783 * Immediately applies the given color scheme to the given terminal, overriding
    784 * the color scheme provided when the terminal was created. Valid color schemes
    785 * are those accepted by guac_terminal_parse_color_scheme().
    786 *
    787 * @param terminal
    788 *     The terminal to apply the color scheme to.
    789 *
    790 * @param color_scheme
    791 *     The color scheme to apply.
    792 */
    793void guac_terminal_apply_color_scheme(guac_terminal* terminal,
    794        const char* color_scheme);
    795
    796/**
    797 * Returns name of the color scheme currently in use by the given terminal.
    798 *
    799 * @param terminal
    800 *      The terminal whose color scheme should be returned.
    801 *
    802 * @return
    803 *     The name of the color scheme currently in use by the given terminal.
    804 */
    805const char* guac_terminal_get_color_scheme(guac_terminal* terminal);
    806
    807/**
    808 * Alters the font of the terminal. The terminal will automatically be redrawn
    809 * and resized as necessary. If the terminal size changes, the remote side of
    810 * the terminal session must be manually informed of that change or graphical
    811 * artifacts may result.
    812 *
    813 * @param terminal
    814 *     The terminal whose font family and/or size are being changed.
    815 *
    816 * @param font_name
    817 *     The name of the new font family, or NULL if the font family should
    818 *     remain unchanged.
    819 *
    820 * @param font_size
    821 *     The new font size, in points, or -1 if the font size should remain
    822 *     unchanged.
    823 *
    824 * @param dpi
    825 *     The resolution of the display in DPI. If the font size will not be
    826 *     changed (the font size given is -1), this value is ignored.
    827 */
    828void guac_terminal_apply_font(guac_terminal* terminal, const char* font_name,
    829        int font_size, int dpi);
    830
    831/**
    832 * Returns the font name currently in use by the given terminal.
    833 *
    834 * @param terminal
    835 *     The terminal whose font name is being retrieved.
    836 *
    837 * @return
    838 *     The name of the font in use by the given terminal.
    839 */
    840const char* guac_terminal_get_font_name(guac_terminal* terminal);
    841
    842/**
    843 * Returns the font size currently in use by the given terminal.
    844 *
    845 * @param terminal
    846 *     The terminal whose font size is being retrieved.
    847 *
    848 * @return
    849 *     The size of the font in use by the given terminal.
    850 */
    851int guac_terminal_get_font_size(guac_terminal* terminal);
    852
    853/**
    854 * Returns the current state of the mod_ctrl flag in the given terminal.
    855 *
    856 * @param terminal
    857 *     The terminal for which the mod_ctrl state is being checked.
    858 *
    859 * @return
    860 *     The current state of the mod_ctrl flag.
    861 */
    862int guac_terminal_get_mod_ctrl(guac_terminal* terminal);
    863
    864#endif