+ Layer support is an orthogonal (independent) option to
+ multimedia support. It is acceptable for terminals to support
+ multimedia without layers and vice versa.
+
+
+
+All Features - Detection
+------------------------
+
+Applications can detect support for these features using Primary
+Device Attributes (DA) and DECID (ESC Z, or 0x9A).
+
+Terminals that support this standard will repond with additional
+parameter(s): "224" for direct multimedia, "225" for cached
+multimedia, and "226" for layers. A recap of the parameters xterm
+supports is listed below, with these new feature responses included:
+
+| VT220 (and higher) Response | Description |
+|-----------------------------|--------------------------------------------|
+| 1 | 132-columns |
+| 2 | Printer |
+| 3 | ReGIS graphics |
+| 4 | Sixel graphics |
+| 6 | Selective erase |
+| 8 | User-defined keys |
+| 9 | National Replacement Character sets |
+| 1 5 | Technical characters |
+| 1 6 | Locator port |
+| 1 7 | Terminal state interrogation |
+| 1 8 | User windows |
+| 2 1 | Horizontal scrolling |
+| 2 2 | ANSI color, e.g., VT525 |
+| 2 8 | Rectangular editing |
+| 2 9 | ANSI text locator (i.e., DEC Locator mode) |
+| 2 2 4 | Direct Multimedia Version 1 |
+| 2 2 5 | Cached Multimedia Version 1 |
+| 2 2 6 | Layers |
+
+
+
+Direct Multimedia - Summary
+---------------------------
+
+Non-text data (multimedia) can be sent to the terminal for immediate
+display in a rectangular (single-layer) region of text Cells.
+Multimedia data is transmitted to the terminal using one of two wire
+formats described later in this document.
+
+Setting a Cell to multimedia is a destructive operation: the Cell's
+original text is lost. Multimedia pixels will not overlap rendered
+text in the same Cell. To achieve pixels overlaid on text, the layers
+feature can be used.
+
+Setting any part of a multi-Cell Tile to multimedia also "breaks up"
+the Tile into a range of single Cells. In other words, multimedia can
+only be carried by a Cell, not a Tile.
+
+The pixels of a multimedia Cell are assigned to the Cell's foreground;
+multimedia Cells have no background. If a terminal supports the
+layers feature, setting a multimedia Cell's foreground transparency to
+true/enabled causes that Cell to not be displayed at all; setting its
+background transparency to either true/enabled or false/disabled has
+no visible effect.
+
+The pixels of multimedia Cells can come from two sources:
+
+ 1. The application can generate pixels and send them to the terminal
+ for display at the current cursor position.
+
+ 2. The application can specify a source for the multimedia and the
+ terminal will generate the pixels for display at the current
+ cursor position.
+
+
+
+Direct Multimedia - Required Support For Existing Sequences
+-----------------------------------------------------------
+
+A terminal with direct multimedia feature must support the following
+defined xterm sequences:
+
+| Sequence | Description |
+|----------------|-----------------------------------------------------|
+| CSI 16 t | Responds with CSI 6 ; cellHeight ; cellWidth t |
+| CSI 18 t | Responds with CSI 8 ; rows ; columns t |
+
+
+
+Direct Multimedia - New Sequences
+---------------------------------
+
+A terminal with direct multimedia feature must support the following
+new sequences:
+
+| Sequence | Command | Description |
+|--------------------------------------|-------------|-------------------------|
+| OSC 1 3 3 8 ; s i x e l : {data} BEL | SIXEL | Display sixel at (x, y) |
+| OSC 1 3 3 8 ; s i x e l : {data} ST | SIXEL | Display sixel at (x, y) |
+| OSC 1 3 3 8 ; F i l e = {args} : {data} BEL | DMDISPLAY | Display media at (x, y) |
+| OSC 1 3 3 8 ; F i l e = {args} : {data} ST | DMDISPLAY | Display media at (x, y) |
+| CSI ? 3 0 0 0 h | DECSET 3000 | Enable SCRCHANGE notification |
+| CSI ? 3 0 0 0 l | DECRST 3000 | Disable SCRCHANGE notification |
+| OSC 1 3 3 9 ; Pe ; {args} ST | DMRESP | Terminal response to DMDISPLAY |
+| CSI ? 3 0 0 1 h | DECSET 3001 | Enable DMDISPLAY responses |
+| CSI ? 3 0 0 1 l | DECRST 3001 | Disable DMDISPLAY responses |
+
+
+
+If SCRCHANGE is set/enabled, then the terminal will send the "CSI 6 ;
+cellHeight ; cellWidth t" when the font size has changed, and "CSI 8 ;
+rows ; columns t" when the number of rows/columns on the screen has
+changed.
+
+
+
+For the SIXEL command:
+
+* The {data} is a sixel sequence as described in the VT330/340
+ Programmer Reference Manual, Chapter 14, available online at:
+ http://vt100.net/docs/vt3xx-gp/chapter14.html . The {data} is the
+ "P1 ; P2 ; P3 ; q s..s" portion of the Device Control String, i.e. a
+ complete sixel sequence minus the leading DCS and trailing ST.
+
+* The sixel image is processed as shown below. Note that this
+ behavior is equivalent to Sixel Scrolling mode enabled.
+
+ - The sixel active position starts at the upper-left corner of the
+ text cursor position.
+
+ - The screen is scrolled up if the image overflows into the bottom
+ text row.
+
+ - Pixels that would be drawn to the right of the visible region on
+ screen are discarded.
+
+ - The cursor's final position is on the same column as the starting
+ cursor position, and on the row immediately below the image.
+
+
+For the DMDISPLAY command:
+
+* The {args} is a set of key-value pairs (each pair separated by
+ semicolon (';')), followed by a colon (':'), followed by a base-64
+ encoded string ({data}).
+
+* A key can be any alpha-numeric ASCII string ('0' - '9', 'A' - 'Z',
+ 'a' - 'z').
+
+* A value is any printable ASCII string not containing whitespace,
+ colon, or semicolon ('!' - '9', '<' - '~').
+
+* Any alpha-numeric key may be specified. A key that is not supported
+ by the terminal is ignored without error.
+
+* The multimedia pixels are processed as shown below.
+
+ - The pixel are drawn starting at the upper-left corner of the text
+ cursor position.
+
+ - If scroll is specified as 1 (enabled), then:
+
+ a. The screen is scrolled up if the image overflows into the
+ bottom text row.
+
+ b. The cursor's final position is on the same column as the
+ starting cursor position, and on the row immediately below the
+ image.
+
+ - If scroll is omitted or specified as 0 (disabled), then:
+
+ a. The screen is never scrolled.
+
+ b. Pixels that would be drawn below the visible region on screen
+ are discarded.
+
+ c. The cursor's final position is at the same column and row as
+ the starting cursor position, i.e. the cursor does not move at
+ all.
+
+ - Pixels that would be drawn to the right of the visible region on
+ screen are discarded.
+
+
+
+The keys for the key-value pairs that must be supported by the
+terminal are listed below:
+
+| Key | Default Value | Description |
+|--------------|---------------|----------------------------------------------|
+| type | "image/rgb" | mime-type describing data field |
+| url | "" | If set, a location containing the media data |
+| width | 1 | Number of Cells or pixels wide to display in |
+| height | 1 | Number of Cells or pixels high to display in |
+| scale | "none" | Scale/zoom option, see below |
+| align | "nw" | Align image to edge option, see below |
+| sourceX | 0 | Media source X position to display |
+| sourceY | 0 | Media source Y position to display |
+| sourceWidth | "auto" | Media width in pixels to display |
+| sourceHeight | "auto" | Media height in pixels to display |
+| scroll | 1 | If 1, scroll the display if needed |
+
+A terminal may support additional keys. If a key is specified but not
+supported by the terminal, then it is ignored without error.
+
+
+
+The "type" value is a mime-type string describing the format of the
+base64-encoded binary data. The terminal must support at mimunum these
+mime-types:
+
+| Type String | Description |
+|---------------|--------------------------------------------------------------|
+| "image/rgb" | Big-endian-encoded 24-bit red, green, blue values |
+| "image/rgba" | Big-endian-encoded 32-bit red, green, blue, alpha values |
+| "image/png" | PNG file data as described by (reference to PNG format) |
+
+A terminal may support additional types. An application can detect
+terminal support for a format by: enabling terminal responses (DECSET
+3001), sending a DMDISPLAY command, and examining the terminal's
+response sequence for success or error.
+
+
+
+The "url" value is a RFC-XXXX defined Universal Resource Located,
+encoded in RFC-XXXX form as a printable ASCII string not containing:
+whitespace, colon (':'), semicolon (';'), or equals ('=').
+
+A terminal is not required to support any URLs.
+
+
+
+The "width" and "height" values can take the following forms:
+
+| Value | Meaning |
+|-------------------------------|---------------------------|
+| N (a positive integer) | Number of Cells |
+| Npx (positive integer + "px") | Number of pixels |
+| N% (positive integer + "%") | Percent of screen width or height |
+| "auto" | Number of pixels as defined by the multimedia data |
+
+
+
+The "scale" value can take the following values:
+
+| Value | Meaning |
+|------------|---------------------------------------------------------------|
+| "none" | No scaling along either axis. |
+| "scale" | Stretch image, preserving aspect ratio, to maximum size in the target area without cropping |
+| "stretch" | Stretch along both axes, distorting aspect ratio, to fill the target area |
+| "crop" | Stretch along both axes, preserving aspect ration, to completely fill the target area, cropping pixels that will not fit |
+
+
+
+The "align" value can take the following values:
+
+| Value | Meaning |
+|------------|-----------------------------------------------------------------|
+| "nw" | Media is placed at the top-left corner (northwest) |
+| "n" | Media is placed on the top and centered horizontally (north) |
+| "ne" | Media is placed at the top-right corner (northest) |
+| "w" | Media is placed on the left and centered vertically (west) |
+| "c" | Media is centered in the target area (center) |
+| "e" | Media is placed on the right and centered vertically (east) |
+| "sw" | Media is placed on the bottom-left corner (southwest) |
+| "s" | Media is placed on the bottom and centered horizontally (south) |
+| "se" | Media is placed on the bottom-right corner (southeast) |
+
+
+
+"sourceX", "sourceY", "sourceWidth", and "sourceHeight" define the
+rectangle of pixels from the media that will be displayed on the
+screen. The ranges for these values is shown below:
+
+| Key | Minimum Value | Maximum Value | Default Value |
+|--------------|---------------|-------------------------------|---------------|
+| sourceX | 0 | Media's full width - 1 | 0 |
+| sourceY | 0 | Media's full height - 1 | 0 |
+| sourceWidth | 1 | Media's full width - sourceX | "auto" |
+| sourceHeight | 1 | Media's full height - sourceY | "auto" |
+
+If any of these values are specified and outside the range, no image
+is displayed, and the cursor does not move. "sourceWidth" and
+"sourceHeight" can be "auto", which means use the maximum available
+width/height (given sourceX/sourceY) from the media's inherent
+dimensions.
+
+
+
+Direct Multimedia - Terminal Responses / Error Handling
+-------------------------------------------------------
+
+If DMDISPLAY reponses are enabled, then a terminal will respond to the
+DMDISPLAY display with DMRESP. DMRESP responses must be sent in the
+same sequential order as the DMDISPLAY commands they are responses to:
+the terminal may not re-order responses.
+
+No provision is made for reliable delivery. On unreliable links
+(example: 3-wire RS232), the DMDISPLAY and DMRESP command/response
+sequence may get out of order.
+
+
+
+The format of DMRESP is:
+
+* Pe - a non-negative integer error code.
+
+* The {args} is a set of key-value pairs (each pair separated by
+ semicolon (';')).
+
+* A key can be any alpha-numeric ASCII string ('0' - '9', 'A' - 'Z',
+ 'a' - 'z').
+
+* A value is any printable ASCII string not containing whitespace,
+ colon, or semicolon ('!' - '9', '<' - '~').
+
+
+
+The Pe error codes are defined as:
+
+| Value | Meaning | {args} containts |
+|-------|------------------------------------|--------------------------|
+| 0 | No error occurred, i.e. success | nothing |
+| 1 | Unsupported "type" | "type" value that was incorrect |
+| 2 | Invalid value - no media displayed | "key" that was incorrect |
+| 3 | Unsupported key - media displayed | "key" that unsupported |
+| 4 | Insufficient memory | nothing |
+| 5 | Other error - no media displayed | nothing |
+| 6 | Other - media displayed | nothing |
+| 7 | Conflicting keys - no media displayed | nothing |
+| 8 | RESERVED FOR FUTURE USE | RESERVED FOR FUTURE USE |
+
+Additional Pe error codes may be returned; any Pe value except 0, 3,
+and 6 must mean that the media was not displayed, and the cursor was
+not moved.
+
+If both "type" and "url" are set, no media is diaplyed, the cursor is
+not moved, and the DMRESP error code is 7.
+
+
+
+Direct Multimedia - Examples
+----------------------------
+
+
+
+Cached Multimedia - Summary
+---------------------------
+
+Non-text data (multimedia) can be sent to the terminal for later
+display in a rectangular (single-layer) region of text Cells.
+Multimedia data is transmitted to the terminal using the CMCACHE
+command described below, and displayed on screen using the CMDISPLAY
+command. A single CMCACHE command can support many CMDISPLAY
+commands.
+
+Upon display, setting a Cell to multimedia is a destructive operation:
+the Cell's original text is lost. Multimedia pixels will not overlap
+rendered text in the same Cell. To achieve pixels overlaid on text,
+the layers feature can be used.
+
+Setting any part of a multi-Cell Tile to multimedia also "breaks up"
+the Tile into a range of single Cells. In other words, multimedia can
+only be carried by a Cell, not a Tile.
+
+The pixels of a multimedia Cell are assigned to the Cell's foreground;
+multimedia Cells have no background. If a terminal supports the
+layers feature, setting a multimedia Cell's foreground transparency to
+true/enabled causes that Cell to not be displayed at all; setting its
+background transparency to either true/enabled or false/disabled has
+no visible effect.
+
+The pixels of multimedia Cells can come from two sources:
+
+ 1. The application can generate pixels and send them to the terminal
+ for display at the current cursor position.
+
+ 2. The application can specify a source for the multimedia and the
+ terminal will generate the pixels for display at the current
+ cursor position.
+
+
+
+
+Cached Multimedia - Cache/Memory Management
+-------------------------------------------
+
+The terminal manages a cache of multimedia data on behalf of one or
+more applications. Applications request media be stored in the cache,
+and if successful the terminal provides an identification number that
+applications must use to request display from the cache to the screen.
+
+The amount of memory and retention/eviction strategy for the cache is
+wholly managed by the terminal, with the following restrictions:
+
+* The terminal may not remove items from the cache that have any
+ portion being actively displayed on the primary or alternate
+ screens.
+
+* The terminal must respond to every CMCACHE command with a new unique
+ ID.
+
+The scrollback buffer is permitted, and recommended, to contain only a
+few (or zero) multimedia images. Terminals should consider retaining
+only the last 2-5 screens' worth of pixel data in the scrollback
+buffer.
+
+
+
+Cached Multimedia - Required Support For Existing Sequences
+-----------------------------------------------------------
+
+A terminal with cached multimedia feature must support the following
+defined xterm sequences:
+
+| Sequence | Description |
+|----------------|-----------------------------------------------------|
+| CSI 16 t | Responds with CSI 6 ; cellHeight ; cellWidth t |
+| CSI 18 t | Responds with CSI 8 ; rows ; columns t |
+
+
+
+Cached Multimedia - New Sequences
+---------------------------------
+
+A terminal with cached multimedia feature must support the following new
+sequences:
+
+| Sequence | Command | Description |
+|--------------------------------------|-----------|-------------------------|
+| CSI ? 3 0 0 0 h | DECSET 3000 | Enable SCRCHANGE notification |
+| CSI ? 3 0 0 0 l | DECRST 3000 | Disable SCRCHANGE notification |
+| OSC 1 3 4 0 ; F i l e = {args} : {data} BEL | CMCACHE | Display media at (x, y) |
+| OSC 1 3 4 1 ; Pi ; {args} ST | CMDISPLAY | Display media at (x, y) |
+| OSC 1 3 4 2 ; Pi ; Pe ; {args} ST | CMCRESP | Terminal response to CMCACHE |
+| OSC 1 3 4 3 ; Pi ; Pe ; {args} ST | CMDRESP | Terminal response to CMDISPLAY |
+
+
+
+If SCRCHANGE is set/enabled, then the terminal will send the "CSI 6 ;
+cellHeight ; cellWidth t" when the font size has changed, and "CSI 8 ;
+rows ; columns t" when the number of rows/columns on the screen
+changes.
+