Skip to content

Commit e55dadb

Browse files
Improved the spec and also provide some example sections, and some textual cleanups.
1 parent 816286a commit e55dadb

File tree

1 file changed

+145
-39
lines changed

1 file changed

+145
-39
lines changed

spec/vt-good-image-protocol.tex

Lines changed: 145 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,23 @@ \section{Motivation} % {{{
5858
\section{Requirements} % {{{
5959

6060
\begin{enumerate}
61-
\item Headless, multi-headed.
62-
\item Deterministic emulation.
63-
\item Grid cells as the only unit size except for the actual image to be uploaded
64-
\item Remote-terminal capable (no dependency on the local host, such as the local file system)
65-
\item Synchronous operations only (no asynchronous operations unless explicitly requested)
66-
\item Aspect ratio must be kept by default (and support customization)
67-
\item Image upload must be decoupled from image display
68-
\item Ability to render sub-rectangles of the uploaded image
69-
\item Future-reusability of uploaded images for other uses (such as
70-
icon-display, desktop-notifications, background images)
61+
\item \textbf{Deterministic emulation} - The image rendering must not be affected by font size or similar properties.
62+
\item \textbf{Synchronous operations by default} - No asynchronous operations unless explicitly requested.
63+
\item \textbf{Remote-terminal capable} - No dependency on the local host, such as the local file system.
64+
\item \textbf{Preserve aspect ratio by default}
65+
\item \textbf{Upload and Render seperation} - Image upload must be decoupled from image display
66+
\item \textbf{Support for rendering tiles of an image} - Adding the ability to only render tiles
67+
of an image greatly assists client applications when only rendering parts of an image is
68+
needed (such as in multiplexers).
69+
\item \textbf{Protocol forward-compatibility} - the protocol must be easily extendable in input
70+
parameters as well as reusability of the image storage pool
71+
(such as icon-display, desktop-notifications, background images)
72+
\item \textbf{Feature detectability} - The image protocl must be easily detectable by well known techniques.
7173
\end{enumerate}
7274

7375
\paragraph*{}
7476

75-
The document at \ref{ref:twg-gip} suggests cell based masking for rendering to help rendering more
77+
The document at [\ref{ref:twg-gip}] suggests cell based masking for rendering to help rendering more
7678
complex scenes such as in windowed TUI applications or terminal multiplexers.
7779
However, the same can be achieved with a sequence of Image-Render commands specifying a
7880
sub-rectangle to be rendered of the referenced image.
@@ -97,6 +99,7 @@ \subsection{Sixel graphics}
9799
\item It is pixel based and positions the graphics cursor in a way it is most optimal for dot printers,
98100
that could print 6 pixels in height per line.
99101
\item Specialized image format optimized for 6-pin printers.
102+
\item Supports scrolling the screen if the image does not fit the current screen.
100103
\item implemented by: xterm, mlterm, wezterm, contour, VTE
101104
\end{itemize}
102105

@@ -240,10 +243,10 @@ \subsubsection{Storage Management}
240243

241244
\subsection{Render Image}
242245

243-
Renders an image that has either been previously uploaded and thus is being referenced
244-
with a unique Id, or with the image data provided inline.
246+
Renders an image that has been previously uploaded.
245247

246-
Providing an upload Id along with inline image data is invalid.
248+
The image will be rendered with the top-left matching the current ANSI cursor position.
249+
The cursor will not be moved by this operation.
247250

248251
\begin{itemize}
249252
\item Id; unique identifier referencing a previously uploaded image
@@ -266,11 +269,27 @@ \subsection{Render Image}
266269

267270
\subsection{Upload and Render Image}
268271

269-
This uploads and renders the image via a single VT sequence. Therefore no image Id is required and
270-
there won't be any way to reference that image after either.
272+
This uploads and renders the image via a single VT sequence. Therefore no image Id
273+
is required and there won't be any way to reference that image after either.
271274

272275
The parameters of this function is the sum of the image upload and image render parameters excluding the unique
273-
identifier.
276+
identifier and excluding sub-rectangle rendering parameters.
277+
278+
The image will be rendered with the top-left matching the current ANSI cursor position.
279+
The cursor will not be moved by this operation.
280+
281+
\begin{itemize}
282+
\item format; a value that determines the image format. See section \ref{sec:supported-image-formtats}
283+
\item data; image data in the given input format
284+
\item width; optional pixel width of the given image (only required for RGB/RGBA format)
285+
\item height; optional pixel height of the given image (only required for RGB/RGBA format)
286+
\item resizePolicy; optional, mandates how to resize the image within the grid cells (default NoResize)
287+
\item alignmentPolicy; optional, mandates how to align the image within the grid cells (default: MiddleCenter)
288+
\item grid-width; number of grid cells to render horizontally
289+
\item grid-height; number of grid cells to render vertically
290+
\end{itemize}
291+
292+
\todo{Specify how auto-scroll can be achieved in primary screen for Render and Upload-and-Render actions.}
274293

275294
\subsection{Release Image}
276295

@@ -308,44 +327,83 @@ \section{Syntax} % {{{
308327

309328
\subsection{Upload Image}
310329

311-
Syntax: \code{DCS id:ID ; fmt:ID ; u payload ST}
330+
Syntax: \code{DCS <numerical parameters> u <named parameters> ST}
331+
332+
\subsubsection*{Numerical Parameters}
312333

313334
\begin{tabular}{ |c|c|l| }
314335
\hline
315-
parameter & Key & Value \\
336+
\textbf{parameter} & \textbf{Key} & \textbf{Value} \\
316337
\hline
317-
Id & 1 & UInt32 \\
318-
fmt & 2 & enum (see section \ref{sec:supported-image-formtats}) \\
319-
width & 3 & Uint32 \\
320-
height & 4 & Uint32 \\
338+
fmt & 1 & enum (see section \ref{sec:supported-image-formtats}) \\
339+
width & 2 & Uint32 \\
340+
height & 3 & Uint32 \\
321341
\hline
322342
\end{tabular}
323343

324344
The payload's format is mandated by the \code{fmt}'s value. However, since it must not contain
325345
any C0 or C1 escape codes, the transport is further protected by encoding it via Base64.
326346

347+
\subsubsection*{Named Parameters}
348+
349+
\begin{tabular}{ |c|c|l| }
350+
\hline
351+
\textbf{parameter} & \textbf{Value} \\
352+
\hline
353+
id & image Id \\
354+
payload & Base64 encoded image data \\
355+
\hline
356+
\end{tabular}
357+
358+
\subsubsection*{Example}
359+
360+
This is a small Bash shell example that is uploading a PNG image with a fixed ID.
361+
362+
\begin{verbatim}
363+
# Shell function demonstrating how to upload an image:
364+
function send_image() {
365+
local ImageId=$(echo -ne "org.binutils.ls.$1" | base64 -)
366+
local ImageData=$(base64 "$2")
367+
local ImageFormat=3 # 3=PNG
368+
echo -ne "\033P1:${ImageFormat};2:640;3:480u;id=${ImageId};p=${ImageData}\033\\"
369+
}
370+
\end{verbatim}
371+
327372
\subsection{Render Image}
328373

329-
Syntax: \code{DCS id:ID ; x:NUM ; y:NUM ; w:NUM ; h:NUM ; resize:RESIZE ; alignment:ALIGNMENT ; status:VAL r ST}
374+
Syntax: \code{DCS <numerical parameters> r <named parameters> ST}
375+
376+
\subsubsection*{Numerical parameters}
330377

331378
\begin{tabular}{ |c|c|l| }
332379
\hline
333-
parameter & Key & Value \\
380+
\textbf{parameter} & \textbf{Key} & \textbf{Value} \\
334381
\hline
335-
Id & 1 & UInt32 \\
336-
x & 2 & UInt32 \\
337-
y & 2 & UInt32 \\
338-
width & 3 & UInt32 \\
339-
height & 4 & UInt32 \\
340-
resize & 5 & 1 (NoResize), 2 (ResizeToFit), 3 (ResizeToFill), 4 (StretchToFill) \\
341-
alignment & 6 & 1 (MiddleCenter), 2 (MiddleStart), 3 (MiddleEnd), \\
382+
grid-width & 1 & UInt32 \\
383+
grid-height & 2 & UInt32 \\
384+
x & 3 & UInt32 \\
385+
y & 4 & UInt32 \\
386+
width & 5 & UInt32 \\
387+
height & 6 & UInt32 \\
388+
resize & 7 & 1 (NoResize), 2 (ResizeToFit), 3 (ResizeToFill), 4 (StretchToFill) \\
389+
alignment & 8 & 1 (MiddleCenter), 2 (MiddleStart), 3 (MiddleEnd), \\
342390
& & 4 (TopStart), 5 (TopCenter), 6 (TopEnd), \\
343391
& & 7 (BottomStart), 8 (BottomCenter), 9 (BottomEnd) \\
344-
reqStatus & 7 & 0 (Success), 1 (Image not available) \\
392+
reqStatus & 9 & 0 (Success), 1 (Image not available) \\
345393
\hline
346394
\end{tabular}
347395

348-
\paragraph*{}
396+
\subsubsection*{Named parameters}
397+
398+
\begin{tabular}{ |c|c|l| }
399+
\hline
400+
\textbf{parameter} & \textbf{Value} \\
401+
\hline
402+
Id & String \\
403+
\hline
404+
\end{tabular}
405+
406+
\subsubsection*{Response Sequence}
349407

350408
When a response status code was requested, the syntax will be as follows:
351409

@@ -358,27 +416,75 @@ \subsection{Render Image}
358416
\hline
359417
\end{tabular}
360418

419+
\subsubsection*{Example}
420+
421+
\begin{verbatim}
422+
# Shell function demonstrating how to render an image:
423+
function render_image() {
424+
# Rendering the given PNG image at the current cursor position with a 20x10 size.
425+
local ImageId=$(echo -ne "org.binutils.ls.$1" | base64 -)
426+
local GridWidth="20"
427+
local GridHeight="10"
428+
echo -ne "\033P1:${GridWidth};2:${GridHeight}rid=${ImageId}\033\\"
429+
}
430+
\end{verbatim}
431+
361432
\subsection{Upload and Render Image}
362433

363-
Syntax: \code{DCS id:ID ; x:NUM ; y:NUM ; w:NUM ; h:NUM ; resize:RESIZE ; alignment:ALIGNMENT s payload ST}
434+
Syntax: \code{DCS <numerical parameters> s <payload> ST}
435+
436+
\subsubsection*{Numerical parameters}
437+
438+
\begin{tabular}{ |c|c|l| }
439+
\hline
440+
\textbf{parameter} & \textbf{Key} & \textbf{Value} \\
441+
\hline
442+
fmt & 1 & enum (see section \ref{sec:supported-image-formtats}) \\
443+
grid-width & 2 & UInt32 \\
444+
grid-height & 3 & UInt32 \\
445+
image-width & 4 & UInt32 \\
446+
image-height& 5 & UInt32 \\
447+
resize & 6 & 1 (NoResize), 2 (ResizeToFit), 3 (ResizeToFill), 4 (StretchToFill) \\
448+
alignment & 7 & 1 (MiddleCenter), 2 (MiddleStart), 3 (MiddleEnd), \\
449+
& & 4 (TopStart), 5 (TopCenter), 6 (TopEnd), \\
450+
& & 7 (BottomStart), 8 (BottomCenter), 9 (BottomEnd) \\
451+
\hline
452+
\end{tabular}
453+
454+
\subsubsection*{Example}
455+
456+
This is a small Bash shell example that is uploading a PNG image with a fixed ID.
457+
458+
\begin{verbatim}
459+
# Shell function demonstrating how to render a oneshot image:
460+
function send_image_once() {
461+
local ImageData=$(base64 "$1")
462+
local ImageFormat=3 # 3=PNG
463+
local GridWidth="20"
464+
local GridHeight="10"
465+
echo -ne "\033P1:${ImageFormat};2:${GridWidth};3:${GridHeight}s${ImageData}\033\\"
466+
}
467+
\end{verbatim}
364468

365469
\subsection{Release Image}
366470

367-
Syntax: \code{DCS id:ID d ST}
471+
Syntax: \code{DCS d <named parameters> ST}
472+
473+
\subsubsection*{Named Parameters}
368474

369475
\begin{tabular}{ |c|c|l| }
370476
\hline
371-
parameter & Key & Value \\
477+
\textbf{parameter} & \textbf{Value} \\
372478
\hline
373-
Id & 1 & UInt32 \\
479+
Id & String \\
374480
\hline
375481
\end{tabular}
376482

377483
\subsection{Feature Detection}
378484

379485
Syntax: \DA
380486

381-
\DA's response code for detecting support for an implementation of this specification is 11
487+
\DA's response code for detecting support for an implementation of this specification is \code{11}.
382488

383489
% }}}
384490
\section{Support Image Formats} % {{{

0 commit comments

Comments
 (0)