terminal-handlers.h (7081B)
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_HANDLERS 22#define _GUAC_TERMINAL_HANDLERS 23 24/** 25 * Function definitions for terminal event handlers. 26 * 27 * @file terminal-handlers.h 28 */ 29 30#include "config.h" 31 32#include "display.h" 33#include "terminal.h" 34 35/** 36 * The default mode of the terminal. This character handler simply echoes 37 * received characters to the terminal display, entering other terminal modes 38 * if control characters are received. 39 * 40 * @param term 41 * The terminal that received the given character of data. 42 * 43 * @param c 44 * The character that was received by the given terminal. 45 */ 46int guac_terminal_echo(guac_terminal* term, unsigned char c); 47 48/** 49 * Handles any characters which follow an ANSI ESC (0x1B) character. 50 * 51 * @param term 52 * The terminal that received the given character of data. 53 * 54 * @param c 55 * The character that was received by the given terminal. 56 */ 57int guac_terminal_escape(guac_terminal* term, unsigned char c); 58 59/** 60 * Selects the G0 character mapping from the provided character mapping 61 * specifier (such as B, 0, U, or K). 62 * 63 * @param term 64 * The terminal that received the given character of data. 65 * 66 * @param c 67 * The character that was received by the given terminal. 68 */ 69int guac_terminal_g0_charset(guac_terminal* term, unsigned char c); 70 71/** 72 * Selects the G1 character mapping from the provided character mapping 73 * specifier (such as B, 0, U, or K). 74 * 75 * @param term 76 * The terminal that received the given character of data. 77 * 78 * @param c 79 * The character that was received by the given terminal. 80 */ 81int guac_terminal_g1_charset(guac_terminal* term, unsigned char c); 82 83/** 84 * Handles characters within a CSI sequence. CSI sequences are most often 85 * introduced with "ESC [". 86 * 87 * @param term 88 * The terminal that received the given character of data. 89 * 90 * @param c 91 * The character that was received by the given terminal. 92 */ 93int guac_terminal_csi(guac_terminal* term, unsigned char c); 94 95/** 96 * Parses the remainder of the download initiation OSC specific to the 97 * Guacamole terminal emulator. A download will be initiated for the specified 98 * file once the OSC sequence is complete. 99 * 100 * @param term 101 * The terminal that received the given character of data. 102 * 103 * @param c 104 * The character that was received by the given terminal. 105 */ 106int guac_terminal_download(guac_terminal* term, unsigned char c); 107 108/** 109 * Parses the remainder of the set directory OSC specific to the Guacamole 110 * terminal emulator. The upload directory will be set to the specified path 111 * once the OSC sequence is complete. 112 * 113 * @param term 114 * The terminal that received the given character of data. 115 * 116 * @param c 117 * The character that was received by the given terminal. 118 */ 119int guac_terminal_set_directory(guac_terminal* term, unsigned char c); 120 121/** 122 * Parses the remainder of the open pipe OSC specific to the 123 * Guacamole terminal emulator. Terminal output will be redirected to a new 124 * named pipe having the given name once the OSC sequence is complete. 125 * 126 * @param term 127 * The terminal that received the given character of data. 128 * 129 * @param c 130 * The character that was received by the given terminal. 131 */ 132int guac_terminal_open_pipe_stream(guac_terminal* term, unsigned char c); 133 134/** 135 * Parses the remainder of the close pipe OSC specific to the Guacamole 136 * terminal emulator. Terminal output will be redirected back to the terminal 137 * display and any open named pipe will be closed once the OSC sequence is 138 * complete. 139 * 140 * @param term 141 * The terminal that received the given character of data. 142 * 143 * @param c 144 * The character that was received by the given terminal. 145 */ 146int guac_terminal_close_pipe_stream(guac_terminal* term, unsigned char c); 147 148/** 149 * Parses the remainder of the OSC sequence specific to the Guacamole terminal 150 * emulator which requests that the scrollback buffer size be set to the given 151 * number of rows. The desired scrollback buffer size will immediately be set, 152 * however the manner in which that size is applied (or whether the size is 153 * applied at all) depends on (1) whether the requested size exceeds the 154 * maximum size set when the terminal emulator was created and (2) whether the 155 * size does not reduce the scrollback below the number of rows required for 156 * the current display. 157 * 158 * @param term 159 * The terminal that received the given character of data. 160 * 161 * @param c 162 * The character that was received by the given terminal. 163 */ 164int guac_terminal_set_scrollback(guac_terminal* term, unsigned char c); 165 166/** 167 * Parses the remainder of an OSC sequence setting the window title. The 168 * window title is everything after the window title sequence begins, up to 169 * the end of the OSC sequence itself. 170 * 171 * @param term 172 * The terminal that received the given character of data. 173 * 174 * @param c 175 * The character that was received by the given terminal. 176 */ 177int guac_terminal_window_title(guac_terminal* term, unsigned char c); 178 179/** 180 * Parses the remainder of xterm's OSC sequence for redefining the terminal 181 * emulator's palette. 182 * 183 * @param term 184 * The terminal that received the given character of data. 185 * 186 * @param c 187 * The character that was received by the given terminal. 188 */ 189int guac_terminal_xterm_palette(guac_terminal* term, unsigned char c); 190 191/** 192 * Handles the remaining characters of an Operating System Code (OSC) sequence, 193 * typically initiated with "ESC ]". 194 * 195 * @param term 196 * The terminal that received the given character of data. 197 * 198 * @param c 199 * The character that was received by the given terminal. 200 */ 201int guac_terminal_osc(guac_terminal* term, unsigned char c); 202 203/** 204 * Handles terminal control function sequences initiated with "ESC #". 205 * 206 * @param term 207 * The terminal that received the given character of data. 208 * 209 * @param c 210 * The character that was received by the given terminal. 211 */ 212int guac_terminal_ctrl_func(guac_terminal* term, unsigned char c); 213 214/** 215 * Handles terminal control function sequences initiated with "ESC _". 216 * 217 * @param term 218 * The terminal that received the given character of data. 219 * 220 * @param c 221 * The character that was received by the given terminal. 222 */ 223int guac_terminal_apc(guac_terminal* term, unsigned char c); 224 225#endif 226