| 1 | Terminal Emulator Multimedia Standard - Proposed Design |
| 2 | ======================================================= |
| 3 | |
| 4 | Version: 1 |
| 5 | |
| 6 | |
| 7 | |
| 8 | Purpose |
| 9 | ------- |
| 10 | |
| 11 | Multiple standards exist to incorporate image data in text-based |
| 12 | terminals and terminal emulators. Few standards have wide adoption |
| 13 | despite frequent user requests for these features and hardware support |
| 14 | for several of the standards. |
| 15 | |
| 16 | A group including developers of several widely-used terminal emulators |
| 17 | has been working on defining the needs and limitations for a standard |
| 18 | that can be implemented in current-gen terminal emulators. The |
| 19 | discussion has been primarily captured here: |
| 20 | https://gitlab.freedesktop.org/terminal-wg/specifications/issues/12 |
| 21 | |
| 22 | This document collects many of the reported desires and practical |
| 23 | constraints of that discussion into a proposed standard that |
| 24 | encompasses three independent new features: |
| 25 | |
| 26 | 1. A method to transfer multimedia data for immediate display within |
| 27 | the screen cell grid ("Direct Multimedia"). |
| 28 | |
| 29 | 2. A method to transfer multimedia data to a terminal-managed cache, |
| 30 | and later display that data within the screen cell grid ("Cached |
| 31 | Multimedia"). |
| 32 | |
| 33 | 3. A method to assign cell data to different layers with options for |
| 34 | both layer and cell transparency ("Layers"). |
| 35 | |
| 36 | A terminal may implement any combination of these features |
| 37 | independently of each other. If all features are supported, then all |
| 38 | of the design goals outlined in this document can be met. |
| 39 | |
| 40 | The same mechanisms that can put raster-based images on the screen are |
| 41 | also readily generalizable to other media types such as vector-based |
| 42 | images and animations. This document is thus a "multimedia" proposal |
| 43 | rather than a "simple images" proposal. |
| 44 | |
| 45 | |
| 46 | |
| 47 | Acknowledgements |
| 48 | ---------------- |
| 49 | |
| 50 | This proposal has been informed from the following prior work: |
| 51 | |
| 52 | * DEC VT300 series sixel graphics standard: |
| 53 | https://vt100.net/docs/vt3xx-gp/chapter14.html |
| 54 | |
| 55 | * iTerm2 image protocol: |
| 56 | https://iterm2.com/documentation-images.html |
| 57 | |
| 58 | * Kitty image protocol: |
| 59 | https://sw.kovidgoyal.net/kitty/graphics-protocol.html |
| 60 | |
| 61 | * Jexer Terminal User Interface: |
| 62 | https://gitlab.com/klamonte/jexer |
| 63 | |
| 64 | |
| 65 | |
| 66 | Design Goals - Core |
| 67 | ------------------- |
| 68 | |
| 69 | The core ("must-have") design goals are: |
| 70 | |
| 71 | * Be easy to implement in existing terminals and applications: |
| 72 | |
| 73 | - Sacrifice "10%" of potential function to eliminate "90%" of |
| 74 | implementation pain. "Less is more." |
| 75 | |
| 76 | - Be a strict superset of the existing iTerm2 and DEC sixel image |
| 77 | solutions. One should be able to take an existing terminal or |
| 78 | application that emits/consumes iTerm2 or sixel sequences, and |
| 79 | only change the control sequence introducer/termination to achieve |
| 80 | the same effect as a terminal/application that conforms with this |
| 81 | standard. |
| 82 | |
| 83 | * Have no ambiguity. If two terminal or application developers can |
| 84 | read this document and reach different conclusions on what should be |
| 85 | on the screen, then an error exists in this document that must be |
| 86 | corrected. |
| 87 | |
| 88 | - Every feature must be straightforward to validate via automated |
| 89 | unit testing. |
| 90 | |
| 91 | - Every conformant terminal must produce the same output (pixels on |
| 92 | screen) given the same input (terminal font, terminal sequences). |
| 93 | |
| 94 | - Every option must have a defined default value. |
| 95 | |
| 96 | - Erroneous sequences must have defined expected results. |
| 97 | |
| 98 | - Every operation must act atomically: either everything worked |
| 99 | (image is on screen, cursor has moved, terminal state has changed, |
| 100 | etc.) or nothing did. |
| 101 | |
| 102 | * Integrate with existing ECMA-48 / ANSI X3.64 defined sequences: |
| 103 | |
| 104 | - Operations on Tiles/Cells containing text will have the same |
| 105 | effect when applied to Tiles/Cells containing image data. |
| 106 | |
| 107 | - Existing sequences are given new parameters to cover needed |
| 108 | features rather than entirely new sequences introduced. |
| 109 | |
| 110 | * Be straightforward to implement in non-"physical" terminals, |
| 111 | including: |
| 112 | |
| 113 | - Future versions of terminal control libraries such as ncurses and |
| 114 | termbox. |
| 115 | |
| 116 | - Terminal multiplexers that support "headless" terminals (no |
| 117 | physical screen) and "multi-head" terminals (many different |
| 118 | physical screens). |
| 119 | |
| 120 | * Be platform-agnostic, and easy to implement on (at the least): |
| 121 | POSIX, Windows, and web. |
| 122 | |
| 123 | - All features must be available even if the only means of |
| 124 | communication between the application and terminal is control |
| 125 | sequences (e.g. no shared disk, no shared memory, no shared DOM, |
| 126 | etc.). |
| 127 | |
| 128 | * Support graceful fallback: |
| 129 | |
| 130 | - Terminal emulators and physical terminals that do not support this |
| 131 | standard should remain usable with no undefined screen artifacts, |
| 132 | even when the application blindly emits these sequences to those |
| 133 | terminals. |
| 134 | |
| 135 | - This standard must able to be versioned for future enhancements. |
| 136 | |
| 137 | - An application must be able to detect that its terminal supports |
| 138 | this standard, and at what version. |
| 139 | |
| 140 | * Support secure programming practices: |
| 141 | |
| 142 | - Applications must not be able to obtain unauthorized data from |
| 143 | terminal memory, such as: images emitted by other applications |
| 144 | still present in the terminal's scrollback buffer, terminal or |
| 145 | system memory limits. |
| 146 | |
| 147 | - Applications must not be able to compromise the terminal through |
| 148 | denial-of-service such as: excessive memory usage, unterminated |
| 149 | control sequences. Similarly, terminals must not be able to |
| 150 | compromise application through their responses to application |
| 151 | queries. |
| 152 | |
| 153 | - Applications must not be able to manipulate the terminal into |
| 154 | performing an insecure operation such as: reading arbitrary shared |
| 155 | memory regions, reading arbitrary files on disk, deleting |
| 156 | arbitrary files on disk, etc. Similarly, terminals must not be |
| 157 | able to manipulate applications into performing insecure |
| 158 | operations. |
| 159 | |
| 160 | - This standard must be implementable when the terminal has a fixed |
| 161 | maximum memory, such as a kernel-level device driver. |
| 162 | |
| 163 | |
| 164 | |
| 165 | Design Goals - Secondary |
| 166 | ------------------------ |
| 167 | |
| 168 | The secondary ("nice-to-have") design goals are listed below. These |
| 169 | might not all be possible, but will kept in mind: |
| 170 | |
| 171 | * Minimal redundant network traffic for on-screen data that is |
| 172 | repeated: either on screen in multiple places, or in the same place |
| 173 | but refreshed multiple times. |
| 174 | |
| 175 | * Asynchronous notification from terminal to application that the |
| 176 | screen has been changed by outside or user action. Examples: font |
| 177 | change, session detach/attach, user changed image preferences. |
| 178 | |
| 179 | * The ability for a multiplexer to "pass-thru" the image drawing |
| 180 | sequence to its "outer" terminal, with some support for limited |
| 181 | clipping. |
| 182 | |
| 183 | |
| 184 | |
| 185 | Out Of Scope |
| 186 | ------------ |
| 187 | |
| 188 | The following items are out of scope: |
| 189 | |
| 190 | * Bidirectional output. Applications are expected to generate Tiles |
| 191 | and place them on screen where they need. The cursor response to |
| 192 | image sequences are defined as left-to-right-top-to-bottom, |
| 193 | consistent with ECMA-48 / ANSI X3.64 sequences. An independent BIDI |
| 194 | standard is free to apply whatever solution will work for ECMA-48 / |
| 195 | ANSI X3.64 sequences to the sequences described in this document. |
| 196 | |
| 197 | * Capabilities. This standard defines a limited number of new |
| 198 | terminal reports and responses. These are not intended to be used |
| 199 | as a general-purpose capabilities model. |
| 200 | |
| 201 | * Terminal Cache Management. This standard defines a means for |
| 202 | applications and terminals to communicate around cached multimedia |
| 203 | items, but terminals are free to implement whatever cache management |
| 204 | strategies they deem fit. |
| 205 | |
| 206 | * Reliable Transport. This standard defines a two-way |
| 207 | command/response protocol that may get out of order on unreliable |
| 208 | channels such as 3-wire RS232. Applictions that require reliable |
| 209 | transport on unreliable links may choose to use one of the many |
| 210 | successful standards available for this purpose. |
| 211 | |
| 212 | |
| 213 | |
| 214 | Definitions |
| 215 | ----------- |
| 216 | |
| 217 | Terminal - The hardware, or a program that simulates hardware, |
| 218 | comprising a keyboard, screen, and mouse. |
| 219 | |
| 220 | Application - A program that utilizes the terminal for its |
| 221 | input/output with the user. |
| 222 | |
| 223 | Multiplexer - A special case of an application that simulates one or |
| 224 | more "inner" terminals for other applications to use, |
| 225 | and composes these inner terminals into a combined |
| 226 | screen to emit to one or more "outer" terminals that |
| 227 | obtain input/output from the user. Multiplexers are |
| 228 | thus both applications and terminals. |
| 229 | |
| 230 | X - The column coordinate of a cell. This standard is 1-based (like |
| 231 | ECMA-48): the left-most column of the screen is numbered 1. |
| 232 | |
| 233 | Y - The row coordinate of a cell. This standard is 1-based (like |
| 234 | ECMA-48): the top-most row of the screen is numbered 1. |
| 235 | |
| 236 | Z - The layer that text or multimedia is placed on. This proposal |
| 237 | uses a right-hand coordinate system with (X, Y, Z) = (1, 1, 1) |
| 238 | defined as the top-left corner on the default layer; positive Z |
| 239 | projects "away" from the user and "into" or "behind" the screen. |
| 240 | Rendering the Cells on the screen must produce the same result as |
| 241 | painter's algorithm (see "Layers - Rendering" section below). |
| 242 | |
| 243 | Cell - A fixed-width-and-height rectangle on the screen. The cells of |
| 244 | the screen are arranged in a grid of X columns and Y rows. A |
| 245 | Cell has dimensions of cellWidth and cellHeight pixels. Every |
| 246 | Cell has a coordinate of (X, Y) (or (X, Y, Z) when the terminal |
| 247 | supports the layers feature). |
| 248 | |
| 249 | Tile - One or more contiguous Cells with data to be displayed. The |
| 250 | data can be text or image data, but not both. A Tile has width |
| 251 | of 1, 2, or more, and a coordinate of (X, Y, Z) that is the |
| 252 | same as its left-most (first) Cell's (X, Y, Z). In practice, |
| 253 | Tiles are typically one Cell wide for ASCII and Latin language |
| 254 | glyphs, and two Cells wide for "fullwidth" glyphs as used in |
| 255 | Asian langauges, emojis, and symbols. This standard does not |
| 256 | preclude Tiles from encompassing entire grapheme clusters. |
| 257 | Note that ECMA-48 / ANSI X3.64 operations are performed against |
| 258 | Tiles, not Cells: if a 2-Cell-wide Tile is deleted via |
| 259 | backspace, then the cursor will decrement on screen by two |
| 260 | columns. |
| 261 | |
| 262 | Layer - A screen-sized grid of Cells that have the same Z coordinate. |
| 263 | Layers are drawn to the screen in descending Z order. Layers |
| 264 | may have optional additional attributes such as transparency. |
| 265 | Layer support is an orthogonal (independent) option to |
| 266 | multimedia support. It is acceptable for terminals to support |
| 267 | multimedia without layers and vice versa. |
| 268 | |
| 269 | |
| 270 | |
| 271 | All Features - Detection |
| 272 | ------------------------ |
| 273 | |
| 274 | Applications can detect support for these features using Primary |
| 275 | Device Attributes (DA) and DECID (ESC Z, or 0x9A). |
| 276 | |
| 277 | Terminals that support this standard will repond with additional |
| 278 | parameter(s): "224" for direct multimedia, "225" for cached |
| 279 | multimedia, and "226" for layers. A recap of the parameters xterm |
| 280 | supports is listed below, with these new feature responses included: |
| 281 | |
| 282 | | VT220 (and higher) Response | Description | |
| 283 | |-----------------------------|--------------------------------------------| |
| 284 | | 1 | 132-columns | |
| 285 | | 2 | Printer | |
| 286 | | 3 | ReGIS graphics | |
| 287 | | 4 | Sixel graphics | |
| 288 | | 6 | Selective erase | |
| 289 | | 8 | User-defined keys | |
| 290 | | 9 | National Replacement Character sets | |
| 291 | | 1 5 | Technical characters | |
| 292 | | 1 6 | Locator port | |
| 293 | | 1 7 | Terminal state interrogation | |
| 294 | | 1 8 | User windows | |
| 295 | | 2 1 | Horizontal scrolling | |
| 296 | | 2 2 | ANSI color, e.g., VT525 | |
| 297 | | 2 8 | Rectangular editing | |
| 298 | | 2 9 | ANSI text locator (i.e., DEC Locator mode) | |
| 299 | | 2 2 4 | Direct Multimedia Version 1 | |
| 300 | | 2 2 5 | Cached Multimedia Version 1 | |
| 301 | | 2 2 6 | Layers | |
| 302 | |
| 303 | |
| 304 | |
| 305 | Direct Multimedia - Summary |
| 306 | --------------------------- |
| 307 | |
| 308 | Non-text data (multimedia) can be sent to the terminal for immediate |
| 309 | display in a rectangular (single-layer) region of text Cells. |
| 310 | Multimedia data is transmitted to the terminal using one of two wire |
| 311 | formats described later in this document. |
| 312 | |
| 313 | Setting a Cell to multimedia is a destructive operation: the Cell's |
| 314 | original text is lost. Multimedia pixels will not overlap rendered |
| 315 | text in the same Cell. To achieve pixels overlaid on text, the layers |
| 316 | feature can be used. |
| 317 | |
| 318 | Setting any part of a multi-Cell Tile to multimedia also "breaks up" |
| 319 | the Tile into a range of single Cells. In other words, multimedia can |
| 320 | only be carried by a Cell, not a Tile. |
| 321 | |
| 322 | The pixels of a multimedia Cell are assigned to the Cell's foreground; |
| 323 | multimedia Cells have no background. If a terminal supports the |
| 324 | layers feature, setting a multimedia Cell's foreground transparency to |
| 325 | true/enabled causes that Cell to not be displayed at all; setting its |
| 326 | background transparency to either true/enabled or false/disabled has |
| 327 | no visible effect. |
| 328 | |
| 329 | The pixels of multimedia Cells can come from two sources: |
| 330 | |
| 331 | 1. The application can generate pixels and send them to the terminal |
| 332 | for display at the current cursor position. |
| 333 | |
| 334 | 2. The application can specify a source for the multimedia and the |
| 335 | terminal will generate the pixels for display at the current |
| 336 | cursor position. |
| 337 | |
| 338 | |
| 339 | |
| 340 | Direct Multimedia - Required Support For Existing Sequences |
| 341 | ----------------------------------------------------------- |
| 342 | |
| 343 | A terminal with direct multimedia feature must support the following |
| 344 | defined xterm sequences: |
| 345 | |
| 346 | | Sequence | Description | |
| 347 | |----------------|-----------------------------------------------------| |
| 348 | | CSI 16 t | Responds with CSI 6 ; cellHeight ; cellWidth t | |
| 349 | | CSI 18 t | Responds with CSI 8 ; rows ; columns t | |
| 350 | |
| 351 | |
| 352 | |
| 353 | Direct Multimedia - New Sequences |
| 354 | --------------------------------- |
| 355 | |
| 356 | A terminal with direct multimedia feature must support the following |
| 357 | new sequences: |
| 358 | |
| 359 | | Sequence | Command | Description | |
| 360 | |--------------------------------------|-------------|-------------------------| |
| 361 | | OSC 1 3 3 8 ; s i x e l : {data} BEL | SIXEL | Display sixel at (x, y) | |
| 362 | | OSC 1 3 3 8 ; s i x e l : {data} ST | SIXEL | Display sixel at (x, y) | |
| 363 | | OSC 1 3 3 8 ; F i l e = {args} : {data} BEL | DMDISPLAY | Display media at (x, y) | |
| 364 | | OSC 1 3 3 8 ; F i l e = {args} : {data} ST | DMDISPLAY | Display media at (x, y) | |
| 365 | | CSI ? 3 0 0 0 h | DECSET 3000 | Enable SCRCHANGE notification | |
| 366 | | CSI ? 3 0 0 0 l | DECRST 3000 | Disable SCRCHANGE notification | |
| 367 | | OSC 1 3 3 9 ; Pe ; {args} ST | DMRESP | Terminal response to DMDISPLAY | |
| 368 | | CSI ? 3 0 0 1 h | DECSET 3001 | Enable DMDISPLAY responses | |
| 369 | | CSI ? 3 0 0 1 l | DECRST 3001 | Disable DMDISPLAY responses | |
| 370 | |
| 371 | |
| 372 | |
| 373 | If SCRCHANGE is set/enabled, then the terminal will send the "CSI 6 ; |
| 374 | cellHeight ; cellWidth t" when the font size has changed, and "CSI 8 ; |
| 375 | rows ; columns t" when the number of rows/columns on the screen has |
| 376 | changed. |
| 377 | |
| 378 | |
| 379 | |
| 380 | For the SIXEL command: |
| 381 | |
| 382 | * The {data} is a sixel sequence as described in the VT330/340 |
| 383 | Programmer Reference Manual, Chapter 14, available online at: |
| 384 | http://vt100.net/docs/vt3xx-gp/chapter14.html . The {data} is the |
| 385 | "P1 ; P2 ; P3 ; q s..s" portion of the Device Control String, i.e. a |
| 386 | complete sixel sequence minus the leading DCS and trailing ST. |
| 387 | |
| 388 | * The sixel image is processed as shown below. Note that this |
| 389 | behavior is equivalent to Sixel Scrolling mode enabled. |
| 390 | |
| 391 | - The sixel active position starts at the upper-left corner of the |
| 392 | text cursor position. |
| 393 | |
| 394 | - The screen is scrolled up if the image overflows into the bottom |
| 395 | text row. |
| 396 | |
| 397 | - Pixels that would be drawn to the right of the visible region on |
| 398 | screen are discarded. |
| 399 | |
| 400 | - The cursor's final position is on the same column as the starting |
| 401 | cursor position, and on the row immediately below the image. |
| 402 | |
| 403 | |
| 404 | For the DMDISPLAY command: |
| 405 | |
| 406 | * The {args} is a set of key-value pairs (each pair separated by |
| 407 | semicolon (';')), followed by a colon (':'), followed by a base-64 |
| 408 | encoded string ({data}). |
| 409 | |
| 410 | * A key can be any alpha-numeric ASCII string ('0' - '9', 'A' - 'Z', |
| 411 | 'a' - 'z'). |
| 412 | |
| 413 | * A value is any printable ASCII string not containing whitespace, |
| 414 | colon, or semicolon ('!' - '9', '<' - '~'). |
| 415 | |
| 416 | * Any alpha-numeric key may be specified. A key that is not supported |
| 417 | by the terminal is ignored without error. |
| 418 | |
| 419 | * The multimedia pixels are processed as shown below. |
| 420 | |
| 421 | - The pixel are drawn starting at the upper-left corner of the text |
| 422 | cursor position. |
| 423 | |
| 424 | - If scroll is specified as 1 (enabled), then: |
| 425 | |
| 426 | a. The screen is scrolled up if the image overflows into the |
| 427 | bottom text row. |
| 428 | |
| 429 | b. The cursor's final position is on the same column as the |
| 430 | starting cursor position, and on the row immediately below the |
| 431 | image. |
| 432 | |
| 433 | - If scroll is omitted or specified as 0 (disabled), then: |
| 434 | |
| 435 | a. The screen is never scrolled. |
| 436 | |
| 437 | b. Pixels that would be drawn below the visible region on screen |
| 438 | are discarded. |
| 439 | |
| 440 | c. The cursor's final position is at the same column and row as |
| 441 | the starting cursor position, i.e. the cursor does not move at |
| 442 | all. |
| 443 | |
| 444 | - Pixels that would be drawn to the right of the visible region on |
| 445 | screen are discarded. |
| 446 | |
| 447 | |
| 448 | |
| 449 | The keys for the key-value pairs that must be supported by the |
| 450 | terminal are listed below: |
| 451 | |
| 452 | | Key | Default Value | Description | |
| 453 | |--------------|---------------|----------------------------------------------| |
| 454 | | type | "image/rgb" | mime-type describing data field | |
| 455 | | url | "" | If set, a location containing the media data | |
| 456 | | width | 1 | Number of Cells or pixels wide to display in | |
| 457 | | height | 1 | Number of Cells or pixels high to display in | |
| 458 | | scale | "none" | Scale/zoom option, see below | |
| 459 | | align | "nw" | Align image to edge option, see below | |
| 460 | | sourceX | 0 | Media source X position to display | |
| 461 | | sourceY | 0 | Media source Y position to display | |
| 462 | | sourceWidth | "auto" | Media width in pixels to display | |
| 463 | | sourceHeight | "auto" | Media height in pixels to display | |
| 464 | | scroll | 1 | If 1, scroll the display if needed | |
| 465 | |
| 466 | A terminal may support additional keys. If a key is specified but not |
| 467 | supported by the terminal, then it is ignored without error. |
| 468 | |
| 469 | |
| 470 | |
| 471 | The "type" value is a mime-type string describing the format of the |
| 472 | base64-encoded binary data. The terminal must support at mimunum these |
| 473 | mime-types: |
| 474 | |
| 475 | | Type String | Description | |
| 476 | |---------------|--------------------------------------------------------------| |
| 477 | | "image/rgb" | Big-endian-encoded 24-bit red, green, blue values | |
| 478 | | "image/rgba" | Big-endian-encoded 32-bit red, green, blue, alpha values | |
| 479 | | "image/png" | PNG file data as described by (reference to PNG format) | |
| 480 | |
| 481 | A terminal may support additional types. An application can detect |
| 482 | terminal support for a format by: enabling terminal responses (DECSET |
| 483 | 3001), sending a DMDISPLAY command, and examining the terminal's |
| 484 | response sequence for success or error. |
| 485 | |
| 486 | |
| 487 | |
| 488 | The "url" value is a RFC-XXXX defined Universal Resource Located, |
| 489 | encoded in RFC-XXXX form as a printable ASCII string not containing: |
| 490 | whitespace, colon (':'), semicolon (';'), or equals ('='). |
| 491 | |
| 492 | A terminal is not required to support any URLs. |
| 493 | |
| 494 | |
| 495 | |
| 496 | The "width" and "height" values can take the following forms: |
| 497 | |
| 498 | | Value | Meaning | |
| 499 | |-------------------------------|---------------------------| |
| 500 | | N (a positive integer) | Number of Cells | |
| 501 | | Npx (positive integer + "px") | Number of pixels | |
| 502 | | N% (positive integer + "%") | Percent of screen width or height | |
| 503 | | "auto" | Number of pixels as defined by the multimedia data | |
| 504 | |
| 505 | |
| 506 | |
| 507 | The "scale" value can take the following values: |
| 508 | |
| 509 | | Value | Meaning | |
| 510 | |------------|---------------------------------------------------------------| |
| 511 | | "none" | No scaling along either axis. | |
| 512 | | "scale" | Stretch image, preserving aspect ratio, to maximum size in the target area without cropping | |
| 513 | | "stretch" | Stretch along both axes, distorting aspect ratio, to fill the target area | |
| 514 | | "crop" | Stretch along both axes, preserving aspect ration, to completely fill the target area, cropping pixels that will not fit | |
| 515 | |
| 516 | |
| 517 | |
| 518 | The "align" value can take the following values: |
| 519 | |
| 520 | | Value | Meaning | |
| 521 | |------------|-----------------------------------------------------------------| |
| 522 | | "nw" | Media is placed at the top-left corner (northwest) | |
| 523 | | "n" | Media is placed on the top and centered horizontally (north) | |
| 524 | | "ne" | Media is placed at the top-right corner (northest) | |
| 525 | | "w" | Media is placed on the left and centered vertically (west) | |
| 526 | | "c" | Media is centered in the target area (center) | |
| 527 | | "e" | Media is placed on the right and centered vertically (east) | |
| 528 | | "sw" | Media is placed on the bottom-left corner (southwest) | |
| 529 | | "s" | Media is placed on the bottom and centered horizontally (south) | |
| 530 | | "se" | Media is placed on the bottom-right corner (southeast) | |
| 531 | |
| 532 | |
| 533 | |
| 534 | "sourceX", "sourceY", "sourceWidth", and "sourceHeight" define the |
| 535 | rectangle of pixels from the media that will be displayed on the |
| 536 | screen. The ranges for these values is shown below: |
| 537 | |
| 538 | | Key | Minimum Value | Maximum Value | Default Value | |
| 539 | |--------------|---------------|-------------------------------|---------------| |
| 540 | | sourceX | 0 | Media's full width - 1 | 0 | |
| 541 | | sourceY | 0 | Media's full height - 1 | 0 | |
| 542 | | sourceWidth | 1 | Media's full width - sourceX | "auto" | |
| 543 | | sourceHeight | 1 | Media's full height - sourceY | "auto" | |
| 544 | |
| 545 | If any of these values are specified and outside the range, no image |
| 546 | is displayed, and the cursor does not move. "sourceWidth" and |
| 547 | "sourceHeight" can be "auto", which means use the maximum available |
| 548 | width/height (given sourceX/sourceY) from the media's inherent |
| 549 | dimensions. |
| 550 | |
| 551 | |
| 552 | |
| 553 | Direct Multimedia - Terminal Responses / Error Handling |
| 554 | ------------------------------------------------------- |
| 555 | |
| 556 | If DMDISPLAY reponses are enabled, then a terminal will respond to the |
| 557 | DMDISPLAY display with DMRESP. DMRESP responses must be sent in the |
| 558 | same sequential order as the DMDISPLAY commands they are responses to: |
| 559 | the terminal may not re-order responses. |
| 560 | |
| 561 | No provision is made for reliable delivery. On unreliable links |
| 562 | (example: 3-wire RS232), the DMDISPLAY and DMRESP command/response |
| 563 | sequence may get out of order. |
| 564 | |
| 565 | |
| 566 | |
| 567 | The format of DMRESP is: |
| 568 | |
| 569 | * Pe - a non-negative integer error code. |
| 570 | |
| 571 | * The {args} is a set of key-value pairs (each pair separated by |
| 572 | semicolon (';')). |
| 573 | |
| 574 | * A key can be any alpha-numeric ASCII string ('0' - '9', 'A' - 'Z', |
| 575 | 'a' - 'z'). |
| 576 | |
| 577 | * A value is any printable ASCII string not containing whitespace, |
| 578 | colon, or semicolon ('!' - '9', '<' - '~'). |
| 579 | |
| 580 | |
| 581 | |
| 582 | The Pe error codes are defined as: |
| 583 | |
| 584 | | Value | Meaning | {args} containts | |
| 585 | |-------|------------------------------------|--------------------------| |
| 586 | | 0 | No error occurred, i.e. success | nothing | |
| 587 | | 1 | Unsupported "type" | "type" value that was incorrect | |
| 588 | | 2 | Invalid value - no media displayed | "key" that was incorrect | |
| 589 | | 3 | Unsupported key - media displayed | "key" that unsupported | |
| 590 | | 4 | Insufficient memory | nothing | |
| 591 | | 5 | Other error - no media displayed | nothing | |
| 592 | | 6 | Other - media displayed | nothing | |
| 593 | | 7 | Conflicting keys - no media displayed | nothing | |
| 594 | | 8 | RESERVED FOR FUTURE USE | RESERVED FOR FUTURE USE | |
| 595 | |
| 596 | Additional Pe error codes may be returned; any Pe value except 0, 3, |
| 597 | and 6 must mean that the media was not displayed, and the cursor was |
| 598 | not moved. |
| 599 | |
| 600 | If both "type" and "url" are set, no media is diaplyed, the cursor is |
| 601 | not moved, and the DMRESP error code is 7. |
| 602 | |
| 603 | |
| 604 | |
| 605 | Direct Multimedia - Examples |
| 606 | ---------------------------- |
| 607 | |
| 608 | |
| 609 | |
| 610 | Cached Multimedia - Summary |
| 611 | --------------------------- |
| 612 | |
| 613 | Non-text data (multimedia) can be sent to the terminal for later |
| 614 | display in a rectangular (single-layer) region of text Cells. |
| 615 | Multimedia data is transmitted to the terminal using the CMCACHE |
| 616 | command described below, and displayed on screen using the CMDISPLAY |
| 617 | command. A single CMCACHE command can support many CMDISPLAY |
| 618 | commands. |
| 619 | |
| 620 | Upon display, setting a Cell to multimedia is a destructive operation: |
| 621 | the Cell's original text is lost. Multimedia pixels will not overlap |
| 622 | rendered text in the same Cell. To achieve pixels overlaid on text, |
| 623 | the layers feature can be used. |
| 624 | |
| 625 | Setting any part of a multi-Cell Tile to multimedia also "breaks up" |
| 626 | the Tile into a range of single Cells. In other words, multimedia can |
| 627 | only be carried by a Cell, not a Tile. |
| 628 | |
| 629 | The pixels of a multimedia Cell are assigned to the Cell's foreground; |
| 630 | multimedia Cells have no background. If a terminal supports the |
| 631 | layers feature, setting a multimedia Cell's foreground transparency to |
| 632 | true/enabled causes that Cell to not be displayed at all; setting its |
| 633 | background transparency to either true/enabled or false/disabled has |
| 634 | no visible effect. |
| 635 | |
| 636 | The pixels of multimedia Cells can come from two sources: |
| 637 | |
| 638 | 1. The application can generate pixels and send them to the terminal |
| 639 | for display at the current cursor position. |
| 640 | |
| 641 | 2. The application can specify a source for the multimedia and the |
| 642 | terminal will generate the pixels for display at the current |
| 643 | cursor position. |
| 644 | |
| 645 | |
| 646 | |
| 647 | |
| 648 | Cached Multimedia - Cache/Memory Management |
| 649 | ------------------------------------------- |
| 650 | |
| 651 | The terminal manages a cache of multimedia data on behalf of one or |
| 652 | more applications. Applications request media be stored in the cache, |
| 653 | and if successful the terminal provides an identification number that |
| 654 | applications must use to request display from the cache to the screen. |
| 655 | |
| 656 | The amount of memory and retention/eviction strategy for the cache is |
| 657 | wholly managed by the terminal, with the following restrictions: |
| 658 | |
| 659 | * The terminal may not remove items from the cache that have any |
| 660 | portion being actively displayed on the primary or alternate |
| 661 | screens. |
| 662 | |
| 663 | * The terminal must respond to every CMCACHE command with a new unique |
| 664 | ID. |
| 665 | |
| 666 | The scrollback buffer is permitted, and recommended, to contain only a |
| 667 | few (or zero) multimedia images. Terminals should consider retaining |
| 668 | only the last 2-5 screens' worth of pixel data in the scrollback |
| 669 | buffer. |
| 670 | |
| 671 | |
| 672 | |
| 673 | Cached Multimedia - Required Support For Existing Sequences |
| 674 | ----------------------------------------------------------- |
| 675 | |
| 676 | A terminal with cached multimedia feature must support the following |
| 677 | defined xterm sequences: |
| 678 | |
| 679 | | Sequence | Description | |
| 680 | |----------------|-----------------------------------------------------| |
| 681 | | CSI 16 t | Responds with CSI 6 ; cellHeight ; cellWidth t | |
| 682 | | CSI 18 t | Responds with CSI 8 ; rows ; columns t | |
| 683 | |
| 684 | |
| 685 | |
| 686 | Cached Multimedia - New Sequences |
| 687 | --------------------------------- |
| 688 | |
| 689 | A terminal with cached multimedia feature must support the following new |
| 690 | sequences: |
| 691 | |
| 692 | | Sequence | Command | Description | |
| 693 | |--------------------------------------|-----------|-------------------------| |
| 694 | | CSI ? 3 0 0 0 h | DECSET 3000 | Enable SCRCHANGE notification | |
| 695 | | CSI ? 3 0 0 0 l | DECRST 3000 | Disable SCRCHANGE notification | |
| 696 | | OSC 1 3 4 0 ; F i l e = {args} : {data} BEL | CMCACHE | Display media at (x, y) | |
| 697 | | OSC 1 3 4 1 ; Pi ; {args} ST | CMDISPLAY | Display media at (x, y) | |
| 698 | | OSC 1 3 4 2 ; Pi ; Pe ; {args} ST | CMCRESP | Terminal response to CMCACHE | |
| 699 | | OSC 1 3 4 3 ; Pi ; Pe ; {args} ST | CMDRESP | Terminal response to CMDISPLAY | |
| 700 | |
| 701 | |
| 702 | |
| 703 | If SCRCHANGE is set/enabled, then the terminal will send the "CSI 6 ; |
| 704 | cellHeight ; cellWidth t" when the font size has changed, and "CSI 8 ; |
| 705 | rows ; columns t" when the number of rows/columns on the screen |
| 706 | changes. |
| 707 | |
| 708 | |
| 709 | |
| 710 | Cached Multimedia - CMCACHE |
| 711 | --------------------------- |
| 712 | |
| 713 | For the CMCACHE command: |
| 714 | |
| 715 | * The {args} is a set of key-value pairs (each pair separated by |
| 716 | semicolon (';')), followed by a colon (':'), followed by a base-64 |
| 717 | encoded string ({data}). |
| 718 | |
| 719 | * A key can be any alpha-numeric ASCII string ('0' - '9', 'A' - 'Z', |
| 720 | 'a' - 'z'). |
| 721 | |
| 722 | * A value is any printable ASCII string not containing whitespace, |
| 723 | colon, or semicolon ('!' - '9', '<' - '~'). |
| 724 | |
| 725 | |
| 726 | |
| 727 | The keys for the key-value pairs that must be supported by the |
| 728 | terminal are listed below: |
| 729 | |
| 730 | | Key | Default Value | Description | |
| 731 | |--------------|---------------|----------------------------------------------| |
| 732 | | type | "image/rgb" | mime-type describing data field | |
| 733 | | url | "" | If set, a location containing the media data | |
| 734 | |
| 735 | |
| 736 | |
| 737 | The "type" value is a mime-type string describing the format of the |
| 738 | base64-encoded binary data. The terminal must support at mimunum these |
| 739 | mime-types: |
| 740 | |
| 741 | | Type String | Description | |
| 742 | |---------------|--------------------------------------------------------------| |
| 743 | | "image/rgb" | Big-endian-encoded 24-bit red, green, blue values | |
| 744 | | "image/rgba" | Big-endian-encoded 32-bit red, green, blue, alpha values | |
| 745 | | "image/png" | PNG file data as described by (reference to PNG format) | |
| 746 | |
| 747 | A terminal may support additional types. An application can detect |
| 748 | terminal support for a format by: sending a CMCACHE command, and |
| 749 | examining the terminal's CMCRESP sequence for success or error. |
| 750 | |
| 751 | |
| 752 | |
| 753 | The "url" value is a RFC-XXXX defined Universal Resource Located, |
| 754 | encoded in RFC-XXXX form as a printable ASCII string not containing: |
| 755 | whitespace, colon (':'), semicolon (';'), or equals ('='). |
| 756 | |
| 757 | A terminal is not required to support any URLs. |
| 758 | |
| 759 | |
| 760 | |
| 761 | Cached Multimedia - CMDISPLAY |
| 762 | ----------------------------- |
| 763 | |
| 764 | For the CMDISPLAY command: |
| 765 | |
| 766 | * Pi - a non-negative integer media ID that was returned by a CMCRESP |
| 767 | response to a previous CMCACHE command. |
| 768 | |
| 769 | * The {args} is a set of key-value pairs (each pair separated by |
| 770 | semicolon (';')), followed by a colon (':'), followed by a base-64 |
| 771 | encoded string. |
| 772 | |
| 773 | * A key can be any alpha-numeric ASCII string ('0' - '9', 'A' - 'Z', |
| 774 | 'a' - 'z'). |
| 775 | |
| 776 | * A value is any printable ASCII string not containing whitespace, |
| 777 | colon, or semicolon ('!' - '9', '<' - '~'). |
| 778 | |
| 779 | * Any alpha-numeric key may be specified. A key that is not supported |
| 780 | by the terminal is ignored without error. |
| 781 | |
| 782 | * The multimedia pixels are processed as shown below. |
| 783 | |
| 784 | - The pixel are drawn starting at the upper-left corner of the text |
| 785 | cursor position. |
| 786 | |
| 787 | - If scroll is specified as 1 (enabled), then: |
| 788 | |
| 789 | a. The screen is scrolled up if the image overflows into the |
| 790 | bottom text row. |
| 791 | |
| 792 | b. The cursor's final position is on the same column as the |
| 793 | starting cursor position, and on the row immediately below the |
| 794 | image. |
| 795 | |
| 796 | - If scroll is omitted or specified as 0 (disabled), then: |
| 797 | |
| 798 | a. The screen is never scrolled. |
| 799 | |
| 800 | b. Pixels that would be drawn below the visible region on screen |
| 801 | are discarded. |
| 802 | |
| 803 | c. The cursor's final position is at the same column and row as |
| 804 | the starting cursor position, i.e. the cursor does not move at |
| 805 | all. |
| 806 | |
| 807 | - Pixels that would be drawn to the right of the visible region on |
| 808 | screen are discarded. |
| 809 | |
| 810 | |
| 811 | |
| 812 | The keys for the key-value pairs that must be supported by the |
| 813 | terminal are listed below: |
| 814 | |
| 815 | | Key | Default Value | Description | |
| 816 | |--------------|---------------|----------------------------------------------| |
| 817 | | width | 1 | Number of Cells or pixels wide to display in | |
| 818 | | height | 1 | Number of Cells or pixels high to display in | |
| 819 | | scale | "none" | Scale/zoom option, see below | |
| 820 | | align | "nw" | Align image to edge option, see below | |
| 821 | | sourceX | 0 | Media source X position to display | |
| 822 | | sourceY | 0 | Media source Y position to display | |
| 823 | | sourceWidth | "auto" | Media width in pixels to display | |
| 824 | | sourceHeight | "auto" | Media height in pixels to display | |
| 825 | | scroll | 1 | If 1, scroll the display if needed | |
| 826 | |
| 827 | A terminal may support additional keys. If a key is specified but not |
| 828 | supported by the terminal, then it is ignored without error. |
| 829 | |
| 830 | |
| 831 | |
| 832 | The "width" and "height" values can take the following forms: |
| 833 | |
| 834 | | Value | Meaning | |
| 835 | |-------------------------------|---------------------------| |
| 836 | | N (a positive integer) | Number of Cells | |
| 837 | | Npx (positive integer + "px") | Number of pixels | |
| 838 | | N% (positive integer + "%") | Percent of screen width or height | |
| 839 | | "auto" | Number of pixels as defined by the multimedia data | |
| 840 | |
| 841 | |
| 842 | |
| 843 | The "scale" value can take the following values: |
| 844 | |
| 845 | | Value | Meaning | |
| 846 | |------------|---------------------------------------------------------------| |
| 847 | | "none" | No scaling along either axis. | |
| 848 | | "scale" | Stretch image, preserving aspect ratio, to maximum size in the target area without cropping | |
| 849 | | "stretch" | Stretch along both axes, distorting aspect ratio, to fill the target area | |
| 850 | | "crop" | Stretch along both axes, preserving aspect ration, to completely fill the target area, cropping pixels that will not fit | |
| 851 | |
| 852 | |
| 853 | |
| 854 | The "align" value can take the following values: |
| 855 | |
| 856 | | Value | Meaning | |
| 857 | |------------|-----------------------------------------------------------------| |
| 858 | | "nw" | Media is placed at the top-left corner (northwest) | |
| 859 | | "n" | Media is placed on the top and centered horizontally (north) | |
| 860 | | "ne" | Media is placed at the top-right corner (northest) | |
| 861 | | "w" | Media is placed on the left and centered vertically (west) | |
| 862 | | "c" | Media is centered in the target area (center) | |
| 863 | | "e" | Media is placed on the right and centered vertically (east) | |
| 864 | | "sw" | Media is placed on the bottom-left corner (southwest) | |
| 865 | | "s" | Media is placed on the bottom and centered horizontally (south) | |
| 866 | | "se" | Media is placed on the bottom-right corner (southeast) | |
| 867 | |
| 868 | |
| 869 | |
| 870 | "sourceX", "sourceY", "sourceWidth", and "sourceHeight" define the |
| 871 | rectangle of pixels from the media that will be displayed on the |
| 872 | screen. The ranges for these values is shown below: |
| 873 | |
| 874 | | Key | Minimum Value | Maximum Value | Default Value | |
| 875 | |--------------|---------------|-------------------------------|---------------| |
| 876 | | sourceX | 0 | Media's full width - 1 | 0 | |
| 877 | | sourceY | 0 | Media's full height - 1 | 0 | |
| 878 | | sourceWidth | 1 | Media's full width - sourceX | "auto" | |
| 879 | | sourceHeight | 1 | Media's full height - sourceY | "auto" | |
| 880 | |
| 881 | If any of these values are specified and outside the range, no image |
| 882 | is displayed, and the cursor does not move. "sourceWidth" and |
| 883 | "sourceHeight" can be "auto", which means use the maximum available |
| 884 | width/height (given sourceX/sourceY) from the media's inherent |
| 885 | dimensions. |
| 886 | |
| 887 | |
| 888 | |
| 889 | Cached Multimedia - Error Handling |
| 890 | ---------------------------------- |
| 891 | |
| 892 | A terminal will always respond to the CMCACHE command with CMCRESP, |
| 893 | and to the CMDISPLAY command with CMDRESP. Responses must be sent in |
| 894 | the same sequential order as the CMCACHE/CMDISPLAY commands they are |
| 895 | responses to: the terminal may not re-order responses. |
| 896 | |
| 897 | No provision is made for reliable delivery. On unreliable links |
| 898 | (example: 3-wire RS232), the command/response sequence may get out of |
| 899 | order. |
| 900 | |
| 901 | |
| 902 | |
| 903 | Cached Multimedia - Error Handling - CMCRESP |
| 904 | -------------------------------------------- |
| 905 | |
| 906 | The format of CMCRESP is: |
| 907 | |
| 908 | * Pi - a non-negative integer media ID. The terminal will generate a |
| 909 | new ID for every image successfully loaded into the cache. The |
| 910 | application must use this ID for CMDISPLAY commands. |
| 911 | |
| 912 | * Pe - a non-negative integer error code. |
| 913 | |
| 914 | * The {args} is a set of key-value pairs (each pair separated by |
| 915 | semicolon (';')). |
| 916 | |
| 917 | * A key can be any alpha-numeric ASCII string ('0' - '9', 'A' - 'Z', |
| 918 | 'a' - 'z'). |
| 919 | |
| 920 | * A value is any printable ASCII string not containing whitespace, |
| 921 | colon, or semicolon ('!' - '9', '<' - '~'). |
| 922 | |
| 923 | |
| 924 | |
| 925 | The Pe error codes are defined as: |
| 926 | |
| 927 | | Value | Meaning | {args} containts | |
| 928 | |-------|----------------------------------------|--------------------------| |
| 929 | | 0 | No error occurred, i.e. success | nothing | |
| 930 | | 1 | Unsupported "type" | "type" value that was incorrect | |
| 931 | | 2 | Invalid value - no media stored | "key" that was incorrect | |
| 932 | | 3 | Unsupported key - media stored | "key" that unsupported | |
| 933 | | 4 | Insufficient memory - no media stored | nothing | |
| 934 | | 5 | Other error - no media stored | nothing | |
| 935 | | 6 | Other - media stored | nothing | |
| 936 | | 7 | Conflicting keys - no media stored | nothing | |
| 937 | | 8 | RESERVED FOR FUTURE USE | RESERVED FOR FUTURE USE | |
| 938 | |
| 939 | Additional Pe error codes may be returned; any Pe value except 0, 3, |
| 940 | and 6 must mean that the media was not stored in the cache. |
| 941 | |
| 942 | If both "type" and "url" are set, no media is diaplyed, the cursor is |
| 943 | not moved, and the CMCRESP error code is 7. |
| 944 | |
| 945 | |
| 946 | |
| 947 | Cached Multimedia - Error Handling - CMDRESP |
| 948 | -------------------------------------------- |
| 949 | |
| 950 | The format of CMDRESP is: |
| 951 | |
| 952 | * Pi - a non-negative integer media ID. |
| 953 | |
| 954 | * Pe - a non-negative integer error code. |
| 955 | |
| 956 | * The {args} is a set of key-value pairs (each pair separated by |
| 957 | semicolon (';')). |
| 958 | |
| 959 | * A key can be any alpha-numeric ASCII string ('0' - '9', 'A' - 'Z', |
| 960 | 'a' - 'z'). |
| 961 | |
| 962 | * A value is any printable ASCII string not containing whitespace, |
| 963 | colon, or semicolon ('!' - '9', '<' - '~'). |
| 964 | |
| 965 | |
| 966 | |
| 967 | The Pe error codes are defined as: |
| 968 | |
| 969 | | Value | Meaning | {args} containts | |
| 970 | |-------|----------------------------------------|--------------------------| |
| 971 | | 0 | No error occurred, i.e. success | nothing | |
| 972 | | 1 | RESERVED FOR FUTURE USE | RESERVED FOR FUTURE USE | |
| 973 | | 2 | Invalid value - no media displayed | "key" that was incorrect | |
| 974 | | 3 | Unsupported key - media displayed | "key" that unsupported | |
| 975 | | 4 | Insufficient memory - no media displayed | nothing | |
| 976 | | 5 | Other error - no media displayed | nothing | |
| 977 | | 6 | Other - media displayed | nothing | |
| 978 | | 7 | RESERVED FOR FUTURE USE | RESERVED FOR FUTURE USE | |
| 979 | | 8 | Media was evicted - no media displayed | nothing | |
| 980 | |
| 981 | Additional Pe error codes may be returned; any Pe value except 0, 3, |
| 982 | and 6 must mean that the media was not displayed. |
| 983 | |
| 984 | |
| 985 | |
| 986 | Cached Multimedia - Examples |
| 987 | ---------------------------- |
| 988 | |
| 989 | |
| 990 | |
| 991 | |
| 992 | Layers - Summary |
| 993 | ---------------- |
| 994 | |
| 995 | Layers introduce the concept of a layer "Z" coordinate to the existing |
| 996 | rows ("Y") by columns ("X") grid. Put another way, the |
| 997 | two-dimensional grid of columns-by-rows becomes a three-dimensional |
| 998 | cube of columns-by-rows-by-layers. For this document, the column, |
| 999 | row, and layer coordinates are referred to as X, Y, and Z. This |
| 1000 | cartesian coordinate system is right-handed, with the Z axis pointing |
| 1001 | "away" from the user "into" the screen. |
| 1002 | |
| 1003 | An application treats the Z coordinate exactly as it does X and Y |
| 1004 | (rows and columns) coordinates: |
| 1005 | |
| 1006 | * If it attemps to set Z to a value less than 1, then Z is set to 1. |
| 1007 | |
| 1008 | * If it attempts to set Z to a value greater than the number of |
| 1009 | layers, then Z is set to the number of layers. |
| 1010 | |
| 1011 | New sequences are provided to set and query Z, Y, X; to set and query |
| 1012 | the screen cube size; and control visibility of Cells in-front-of |
| 1013 | other Cells. |
| 1014 | |
| 1015 | Operations that can act on more than one Cell are defined such to act |
| 1016 | on all layers simultaneously by default; most of these operations can |
| 1017 | also be set to act only on the current layer. |
| 1018 | |
| 1019 | |
| 1020 | |
| 1021 | Layers - Number of Layers |
| 1022 | ------------------------- |
| 1023 | |
| 1024 | A terminal is required to provide between 1 and a finite number of |
| 1025 | layers. |
| 1026 | |
| 1027 | The number of layers may be different between the primary and |
| 1028 | alternate screens. |
| 1029 | |
| 1030 | An application may request that the terminal allocate additional |
| 1031 | layers. The terminal is free to honor or ignore such requests as it |
| 1032 | sees fit. |
| 1033 | |
| 1034 | The scrollback buffer is permitted, and recommended, to contain only a |
| 1035 | "flattened" single layer. |
| 1036 | |
| 1037 | |
| 1038 | |
| 1039 | Layers - Terminal State |
| 1040 | ----------------------- |
| 1041 | |
| 1042 | The terminal maintains a complex state at all times. This state |
| 1043 | includes variables such as cursor position, foreground/background |
| 1044 | color, attributes to apply to the next displayed character, and so on. |
| 1045 | The layers feature adds more variables to the state, and these |
| 1046 | variables are required to be stored with DECSC (ESC 7) and restored |
| 1047 | with DECRC (ESC 8). The new variables are listed below: |
| 1048 | |
| 1049 | | Mnemonic | Description | Default value | |
| 1050 | |----------|-----------------------------|----------------| |
| 1051 | | Z | Cursor position Z | 1 | |
| 1052 | | MSL | Manipulate single layer | off / disabled | |
| 1053 | | TFT | Text foreground transparent | false | |
| 1054 | | TBT | Text background transparent | false | |
| 1055 | |
| 1056 | |
| 1057 | |
| 1058 | Layers - Required Support For Existing Sequences |
| 1059 | ------------------------------------------------ |
| 1060 | |
| 1061 | A terminal with layers feature must support the standard VT100/VT102 |
| 1062 | sequences defined in their respective manuals. |
| 1063 | |
| 1064 | |
| 1065 | |
| 1066 | Layers - New Sequences |
| 1067 | ---------------------- |
| 1068 | |
| 1069 | A terminal with layer feature must support the following new |
| 1070 | sequences: |
| 1071 | |
| 1072 | | Sequence | Command | Description | |
| 1073 | |-------------------|-------------|----------------------------------------| |
| 1074 | | CSI ? z ; y ; x H | CUPZ | Move cursor to (x, y, z) | |
| 1075 | | CSI 2 2 5 ; 1 ; Pa t | SLA | Set layer alpha | |
| 1076 | | CSI ? 3 0 0 2 h | DECSET 3002 | Enable Manupulate Single Layer (MSL) | |
| 1077 | | CSI ? 3 0 0 2 l | DECRST 3002 | Disable Manupulate Single Layer (MSL) | |
| 1078 | | CSI ? l ; h ; w t | RSZCUBE | Resize cube to (layers, height, width) | |
| 1079 | |
| 1080 | Default parameters and ranges are listed below: |
| 1081 | |
| 1082 | | Command | Position / Variable | Default Value | Minumum | Maximum | |
| 1083 | |---------|---------------------|---------------|---------|-----------| |
| 1084 | | CUPZ | 1 / z | 1 | 1 | # layers | |
| 1085 | | CUPZ | 2 / y | 1 | 1 | # rows | |
| 1086 | | CUPZ | 3 / x | 1 | 1 | # columns | |
| 1087 | | SLA | 1 / alpha | 255 | 0 | 255 | |
| 1088 | | RSZCUBE | 1 / l | 1 | 1 | varies | |
| 1089 | | RSZCUBE | 2 / h | 24 | 1 | varies | |
| 1090 | | RSZCUBE | 3 / w | 80 | 1 | varies | |
| 1091 | |
| 1092 | The terminal must also support the following new queries: |
| 1093 | |
| 1094 | | Query | Response | Description | |
| 1095 | |-----------------|-----------------------|--------------------------------| |
| 1096 | | CSI ? 1 0 0 n | CSI ? z ; y ; x n | Report cursor Z, Y, X position | |
| 1097 | | CSI ? 1 8 t | CSI ? 8 ; l ; h ; w t | Report the text area cube layers, height, width | |
| 1098 | |
| 1099 | The terminal must support the following new Set Graphics Rendition |
| 1100 | (SGR) character attributes commands: |
| 1101 | |
| 1102 | | SGR Parameter | Description | |
| 1103 | |---------------|---------------------------------------------| |
| 1104 | | 2 3 0 | Set text foreground color to transparent | |
| 1105 | | 2 3 9 | Set text foreground color to solid (opaque) | |
| 1106 | | 2 4 0 | Set text background color to transparent | |
| 1107 | | 2 4 9 | Set text background color to solid (opaque) | |
| 1108 | |
| 1109 | |
| 1110 | |
| 1111 | Layers - Error Handling |
| 1112 | ----------------------- |
| 1113 | |
| 1114 | No additional error reporting is provided for layer feature. |
| 1115 | |
| 1116 | |
| 1117 | |
| 1118 | Layers - Rendering |
| 1119 | ------------------ |
| 1120 | |
| 1121 | A terminal with layer feature will display its Cells such that the |
| 1122 | screen will appear as if it was rendered in the manner of the |
| 1123 | pseudo-code below: |
| 1124 | |
| 1125 | ``` |
| 1126 | for each layer Z, in descending order from maxZ to minZ: |
| 1127 | |
| 1128 | for each row Y, in ascending order from minY to maxY: |
| 1129 | |
| 1130 | for each column X, in ascending order from minX to maxX: |
| 1131 | |
| 1132 | if tile at (X, Y, Z) background color is solid: |
| 1133 | draw rectangle of background color with layer alpha |
| 1134 | |
| 1135 | if tile at (X, Y, Z) foreground color is solid: |
| 1136 | if tile at (X, Y, Z) is glyph: |
| 1137 | draw glyph with foreground color with layer alpha |
| 1138 | else |
| 1139 | draw pixel data of tile as red/green/blue/alpha pixels with |
| 1140 | layer alpha |
| 1141 | |
| 1142 | advance X by tile width |
| 1143 | next column |
| 1144 | |
| 1145 | advance Y by 1 |
| 1146 | next row |
| 1147 | |
| 1148 | decrease Z by 1 |
| 1149 | next layer |
| 1150 | ``` |
| 1151 | |
| 1152 | A terminal is free to optimize its rendering as it sees fit, so long |
| 1153 | as the final screen output looks equivalent to the above method. |
| 1154 | |
| 1155 | |
| 1156 | |
| 1157 | Layers - Integration With Existing Sequences |
| 1158 | -------------------------------------------- |
| 1159 | |
| 1160 | Sequences that insert characters/lines, delete characters/lines, or |
| 1161 | modify larger regions are changed to act upon multiple layers as |
| 1162 | defined below. By default, MSL (Manipulate Single Layer) is |
| 1163 | off/unset, and Z is 1, so if the application never changes MSL or Z |
| 1164 | then these sequences will produce the same visible output as a |
| 1165 | terminal without layer support. |
| 1166 | |
| 1167 | A terminal is not required to support all of these sequences; however, |
| 1168 | for those sequences it does support, if it supports the layers feature |
| 1169 | then the sequences must behave as shown below: |
| 1170 | |
| 1171 | | Sequence | Command | Additional behavior | |
| 1172 | |------------|-------------|------------------------------------------| |
| 1173 | | BS (0x08) | Backspace | Only current layer affected if MSL=on | |
| 1174 | | DEL (0x7F) | Delete | Only current layer affected if MSL=on | |
| 1175 | | IND (0x84) | Index | Only current layer affected if MSL=on | |
| 1176 | | RI (0x8D | Reverse Index | Only current layer affected if MSL=on | |
| 1177 | | ESC # 3 | DECDHL | Cells on all layers always affected | |
| 1178 | | ESC # 4 | DECDHL | Cells on all layers always affected | |
| 1179 | | ESC # 5 | DECSWL | Cells on all layers always affected | |
| 1180 | | ESC # 6 | DECDWL | Cells on all layers always affected | |
| 1181 | | ESC # 8 | DECALN | All layers > 1 cleared; Z, MSL, TFT, TBT reset to default | |
| 1182 | | ESC 7 | DECSC | Also store Z, MSL, TFT, TBT | |
| 1183 | | ESC 8 | DECRC | Also restore Z, MSL, TFT, TBT | |
| 1184 | | ESC c | RIS | All layers > 1 cleared; Z, MSL, TFT, TBT reset to default | |
| 1185 | | CSI @ | ICH | Only current layer affected if MSL=on | |
| 1186 | | CSI J | ED | Only current layer affected if MSL=on | |
| 1187 | | CSI K | EL | Only current layer affected if MSL=on | |
| 1188 | | CSI ? K | DECSEL | Only current layer affected if MSL=on | |
| 1189 | | CSI L | IL | Only current layer affected if MSL=on | |
| 1190 | | CSI M | DL | Only current layer affected if MSL=on | |
| 1191 | | CSI X | ECH | Only current layer affected if MSL=on | |
| 1192 | | CSI M | DL | Only current layer affected if MSL=on | |
| 1193 | | CSI P | DCH | Only current layer affected if MSL=on | |
| 1194 | | CSI R | DECSTBM | Cells on all layers always affected | |
| 1195 | | CSI $ t | DECARA | Only current layer affected if MSL=on | |
| 1196 | | CSI $ v | DECCRA | Only current layer affected if MSL=on | |
| 1197 | | CSI x | DECSACE | Cells on all layers always affected | |
| 1198 | | CSI $ x | DECFRA | Only current layer affected if MSL=on | |
| 1199 | | CSI $ z | DECERA | Only current layer affected if MSL=on | |
| 1200 | |
| 1201 | (( TODO: add many more to the above table... )) |
| 1202 | |
| 1203 | The VT52 sub-mode commands: |
| 1204 | |
| 1205 | | Sequence | Command | Additional behavior | |
| 1206 | |------------|-------------|------------------------------------------| |
| 1207 | | ESC J | ED | Only current layer affected if MSL=on | |
| 1208 | | ESC K | EL | Only current layer affected if MSL=on | |
| 1209 | |
| 1210 | |
| 1211 | |
| 1212 | Layers - Use With Multiplexers |
| 1213 | ------------------------------ |
| 1214 | |
| 1215 | Layers are inteded to provide a means for multiplexers to pass on the |
| 1216 | job of multimedia support to the "outer" or host terminal. The |
| 1217 | proposed mechanics of that is outlined in the pseudo-code below: |
| 1218 | |
| 1219 | ``` |
| 1220 | for each inner terminal in descending order from maxZ to minZ: |
| 1221 | |
| 1222 | emit CUPZ(inner terminal Z, inner terminal Y, inner terminal X) |
| 1223 | |
| 1224 | draw inner terminal text with standard VT100/VT102/xterm sequences |
| 1225 | |
| 1226 | for each multimedia sequence emitted by the inner terminal: |
| 1227 | emit CUP(inner terminal Y, inner terminal X) |
| 1228 | emit multimedia sequences to outer terminal |
| 1229 | next multimedia sequence |
| 1230 | |
| 1231 | decrease Z by 1 |
| 1232 | next inner terminal |
| 1233 | ``` |
| 1234 | |
| 1235 | The method above may not be effective for complex multi-terminal |
| 1236 | screen layouts, but is hoped to work well for many simple cases. |
| 1237 | |
| 1238 | |
| 1239 | |
| 1240 | Layers - Examples |
| 1241 | ----------------- |
| 1242 | |
| 1243 | |
| 1244 | |
| 1245 | |
| 1246 | References |
| 1247 | ---------- |
| 1248 | |
| 1249 | * xterm control sequences: |
| 1250 | |
| 1251 | |
| 1252 | * ECMA-48: |