Terminal Protocol Proposal Daniel Gustaw Category: Experimental 15 October 2026 Tactile: Touch, Gesture and Haptic Input for Terminal Applications Abstract Terminal applications receive pointer input through the mouse reporting modes of xterm, which encode scrolling as discrete wheel button presses. Graphical applications on the same machine receive pixel-precise scroll deltas, gesture phases, momentum, pinch and rotation, finger counts and pressure, and can trigger haptic feedback. This document specifies Tactile, an opt-in, backward- compatible extension through which a terminal emulator reports this information to the application running inside it, and through which the application can request haptic feedback. Tactile consists of a small core and independent modules. Status of This Memo This document proposes a protocol for terminal emulators and the applications that run in them. Terminals have no standards body or working group comparable to the IETF. Beyond the old ECMA-48 standard, extensions such as the xterm mouse modes or the kitty keyboard protocol were introduced by the authors of one terminal and adopted by others by agreement. This proposal is published in the same way, for open discussion among the authors of terminals, multiplexers, libraries and applications. Comments are welcome at https://github.com/gustawdaniel/tactile/discussions. Table of Contents 1. Introduction 1.1. Motivation 1.2. Goals 1.3. Non-goals 1.4. Core and modules 1.5. Conventions 2. Background: How Terminal Applications Receive Input 2.1. Terminal emulator and application 2.2. The pseudo-terminal 2.3. Escape sequences 2.4. Mouse reporting today 3. Architecture 3.1. Roles 3.2. Data flow 4. Core: Message Format 4.1. Syntax 4.2. Reading messages 4.3. Malformed messages 5. Core: Negotiation 5.1. Features and flags 5.2. Query 5.3. Enabling features: the stack 6. Core: Events 6.1. Common fields 6.2. Simultaneous gestures 6.3. Device changes 6.4. Devices 7. Core: Extensibility 8. Module: Scroll (Level 1) 8.1. Scroll events 8.2. Phases 8.3. Momentum 9. Module: Pinch (Level 1) 10. Module: Haptics (Level 1, optional) 11. Exploratory Modules 11.1. Rotate 11.2. Swipe 11.3. Hold 11.4. Touch 11.5. Pressure 12. no click, 1 = click, 2 = deep click), and p, the pressure within that 13. Example Session 14. Multiplexers 15. Encoding and Performance 15.1. Data volume 15.2. Why APC and named fields 15.3. Why text and not binary 15.4. Energy use 16. Security and Privacy Considerations 17. Open Questions Appendix A. Platform Mapping Appendix B. Prior Art Appendix C. Feature Registry Appendix D. Test Vectors Appendix E. Glossary References 1. Introduction 1.1. Motivation A trackpad measures how far and how fast fingers move, when a gesture begins and ends, and how hard the surface is pressed. Operating systems hand all of this to graphical applications. A terminal emulator receives the same events, but when it forwards them to the application running inside it, it can only say “the wheel moved up by one notch”. The size of the movement, the start and end of the gesture, the momentum after the fingers lift, and every multi-finger gesture are lost. As a result, terminal applications cannot tell one fast swipe from several slow ones, cannot scroll by pixels, cannot zoom with a pinch, and cannot give haptic confirmation. Developers work around this with timing heuristics that fail on different devices and terminals. The problem has been reported independently in several terminal emulators (see Appendix B). Tactile closes this gap. It follows the design of the kitty keyboard protocol [1], which solved the equivalent problem for keyboard input: an application asks for the extension explicitly, and terminals that do not implement it are unaffected. 1.2. Goals o Report the information that operating systems already provide to graphical applications, without inventing gestures the platform does not detect. o Keep legacy behavior unchanged for applications that do not ask for Tactile. o Let applications detect support reliably and fall back gracefully. o Allow new kinds of input to be added later without breaking existing implementations. o Work through terminal multiplexers that implement the protocol. o Let applications request haptic feedback, under user-protecting limits. 1.3. Non-goals o Gesture recognition beyond what the platform reports. Terminals forward platform gestures; they do not define new ones. o System gestures. Gestures the operating system reserves for itself (for example, three-finger swipes between desktops on macOS) are not delivered to any application and are out of scope. The same holds for gestures that a window manager captures: with the yabai window manager on macOS, most pinches never reached the application in our recordings. A terminal cannot detect this, so applications must not depend on any single gesture. o Touchscreen input. A future module may cover direct touch. 1.4. Core and modules Tactile is organized like CSS since its third version: a small core that every implementation needs, and independent modules that each add one kind of input or output. o The core (Section 4 to Section 7) defines the message format, how applications detect and enable features, the fields shared by all events, and the rules that let the protocol grow. o Each module (Section 8 to Section 11) defines one or more features. A terminal implements the modules it can support; an application enables the features it handles. o Every module has a status. Level 1 modules are proposed for the first stable version and have, or are about to have, an implementation in a terminal and an application. Exploratory modules describe input that platforms provide but no application uses yet; they will be revised when one does. As in CSS, there is no version number for the protocol as a whole. Support is detected feature by feature. 1.5. Conventions The key words “MUST”, “MUST NOT”, “SHOULD”, “SHOULD NOT” and “MAY” in this document are to be interpreted as described in BCP 14 [2], [3] when, and only when, they appear in all capitals. "ESC" denotes the byte 0x1B. "CSI" denotes "ESC [". "ST" denotes the string terminator "ESC \". In examples, spaces around ";" and line breaks are added for readability; they are not part of the messages. Readers new to terminals will find the necessary background in Section 2, and short definitions of all terms in Appendix E. 2. Background: How Terminal Applications Receive Input This section summarizes the existing mechanisms Tactile builds on. Readers familiar with terminal internals can skip it. 2.1. Terminal emulator and application A terminal emulator is a graphical program that draws a grid of character cells in a window. An application (a shell, an editor, a PDF viewer) runs as a separate process and does not draw anything itself: it writes text and instructions for the terminal, and the terminal draws them. 2.2. The pseudo-terminal The two processes are connected by a pseudo-terminal (PTY), a pair of connected devices provided by the operating system kernel. The terminal emulator holds one end and the application the other. A PTY carries bytes in two directions: o Application input. The terminal writes keystrokes and other input; the application reads them from its standard input. o Application output. The application writes to its standard output; the terminal reads the bytes and draws them. There is no other channel between them. Everything the terminal tells the application, and everything the application asks of the terminal, travels as bytes on these two streams. 2.3. Escape sequences To send instructions rather than plain text, both sides use escape sequences: byte strings that start with "ESC" and are interpreted instead of displayed. ECMA-48 [4] defines several kinds. Two matter here: o A control sequence starts with "CSI" ("ESC ["), continues with numeric parameters separated by ";", and ends with a single letter that names the command. Its grammar is fixed, so every terminal can skip a control sequence it does not know. Control sequences are short and numeric: "CSI 31 m" makes the following text red, "CSI 5 ; 10 H" moves the cursor to row 5, column 10, and "CSI A", sent by the terminal, reports that the up arrow key was pressed. o An Application Program Command (APC) starts with "ESC _" and ends with "ST". What lies between is a free-form string whose meaning ECMA-48 leaves to the application. APC strings can carry named fields and large payloads: the kitty graphics protocol uses them to send images, for example "ESC _ G a=T,f=100 ; ST". A terminal that does not understand an APC string ignores it. 2.4. Mouse reporting today An application that wants mouse input enables a mouse reporting mode [5], for example with "CSI ? 1000 h" (report button presses) and "CSI ? 1006 h" (encode reports in the SGR format). From then on, the terminal writes a control sequence to the application’s input for each mouse event. Scrolling is reported as presses of virtual buttons 64 to 67 (wheel up, down, left, right); for example, "CSI < 65 ; 102 ; 37 M" means “wheel down at column 102, row 37”. A trackpad does not have a wheel. The terminal converts finger movement into these button presses, typically one per line scrolled. Everything else the operating system reported is discarded. Mode 1016 (SGR-Pixels) reports the pointer position in pixels instead of cells, but scrolling is still a button press. 3. Architecture 3.1. Roles Five parties take part in Tactile: o The operating system detects input on the trackpad (motion, gesture phases, pinch, pressure) and delivers it to the window under the pointer, which is the terminal emulator. It also drives the haptic actuator of the trackpad, when there is one. o The terminal emulator (for example Ghostty or kitty) translates operating system input into Tactile events, and translates haptic requests into operating system calls. It is the only party that talks to the operating system. o The pseudo-terminal carries Tactile messages in both directions, together with all other input and output. Tactile adds no new channel. o The application reads Tactile events, usually through a terminal UI library that parses them. o A multiplexer (for example tmux), when present, is an application for the outer terminal and a terminal for the applications in its panes. It forwards Tactile in both directions, as described in Section 14. 3.2. Data flow trackpad ─► OS ─► terminal ─► PTY ─► application (encodes) input (reads stdin) actuator ◄─ OS ◄─ terminal ◄─ PTY ◄─ application (haptics) (parses) output (writes stdout) Tactile has these kinds of messages: Message | Sender | Receiver | Purpose query | application | terminal | Does the terminal implement Tactile, and what can it do? reply | terminal | application | These features are supported, these are available now, these are enabled push, pop, set | application | terminal | Change which features are enabled event | terminal | application | This just happened on the trackpad, or the input devices changed haptic request | application | terminal | Make the trackpad click now Messages from the application travel on the application output; messages from the terminal travel on the application input. The terminal consumes the messages it receives and never displays them. The application finds events in its input stream, interleaved with keystrokes and other replies. 4. Core: Message Format 4.1. Syntax Every Tactile message is an APC string whose payload starts with the identifier "tactile", followed by ";"-separated "key=value" pairs: ESC _ tactile ; key=value ; key=value ... ST The exact grammar, in ABNF [6], is: message = %x1B.5F identifier *( ";" pair ) %x1B.5C identifier = %x74.61.63.74.69.6C.65 ; "tactile", lowercase only pair = key "=" value key = name [ "." name ] ; with a dot: vendor name value = integer / name integer = [ "-" ] 1*DIGIT ; fits in a signed 64-bit integer name = lowalpha *( lowalpha / DIGIT / "-" ) lowalpha = %x61-7A ; a to z In words: keys and word values are lowercase ASCII letters, digits and "-", starting with a letter; a key may contain one dot, which separates a vendor name (Section 7). Values are integers or words. Nothing else, including spaces, may appear. Tactile uses integers only. Quantities that need fractions are sent in smaller units, stated with each field: for example, scroll distances are in hundredths of a pixel, so "dy=1225" means 12.25 pixels. Integers parse the same way in every language and leave no doubt about precision or rounding. Receivers MUST accept every integer that fits in a signed 64-bit integer. 4.2. Reading messages A message can arrive split across reads, even when the terminal wrote it at once: the PTY does not keep writes together. Receivers MUST keep an incomplete message until its "ST" arrives, and MUST NOT treat its bytes as key presses. In particular, an "ESC" at the end of a read is usually the start of the next message, not the escape key. Events come in quick succession, so this happens often with Tactile, while keyboard input alone rarely shows it; in one implementation, the remainder of split messages arrived as key presses that turned pages and toggled the status bar. 4.3. Malformed messages A receiver MUST ignore, as a whole, a message that does not match the grammar or is longer than 4096 bytes. Ignoring the whole message, rather than the part that looks wrong, prevents a receiver from acting on half an event. If a key appears more than once in a message, the receiver MUST use the first occurrence. An event without "e" is ignored. A key that an event type defines but the message lacks takes its default value, which is 0 for numbers and absent for words. 5. Core: Negotiation 5.1. Features and flags An application asks only for the kinds of input it can handle. Each kind is a feature, defined by a module, and each feature has a number that is a power of two, called its flag: Flag | Feature | Module | Meaning 1 | scroll | Scroll | Scrolling as events with pixel distances 2 | phases | Scroll | When fingers start and stop moving 4 | momentum | Scroll | Scrolling that continues after the fingers lift 8 | pinch | Pinch | Pinch (magnification) gestures 16 | haptics | Haptics | Haptic feedback requested by the application 32 | rotate | Exploratory | Rotation gestures 64 | swipe | Exploratory | Multi-finger swipe gestures 128 | hold | Exploratory | Fingers resting on the surface 256 | pressure | Exploratory | Pressure and click stages 512 | touch | Exploratory | Every contact on the surface, raw A set of features is written as the sum of their flags. Because every flag is a different power of two, the sum identifies the set exactly, in the same way as the bits of a binary number. For example: o 1 + 2 + 8 = 11 means scroll, phases and pinch. o 1023 is the sum of all ten flags, so it means every feature. o 511 is 1023 − 512, so it means every feature except touch. Features are separate so that an application takes over only the input it handles. Everything it does not enable stays with the terminal and keeps its legacy behavior: if an application enables scroll but not pinch, the terminal can still use pinch for its own purposes, such as changing the font size. 5.2. Query To detect support, the application sends: ESC _ tactile ; q=1 ST followed by a Primary Device Attributes request ("CSI c"), which every terminal answers. A terminal that implements Tactile MUST answer the query before answering the device attributes request: ESC _ tactile ; supported= ; available= ; enabled= ST o "supported" is the set of features the terminal implements. o "available" is the subset that the current input devices and settings can actually produce. For example, a terminal may support pressure while the attached trackpad has no force sensor, or support haptics while the user has not allowed them. o "enabled" is the set currently enabled for this application (see below). If the device attributes reply arrives without a Tactile reply before it, the terminal does not implement Tactile. 5.3. Enabling features: the stack A program often starts another program in the same terminal: a shell starts an editor, an editor starts a pager. Each of them may enable different features, and each must leave the terminal as it found it, even when the child exits without cleaning up. Tactile therefore keeps the enabled sets on a stack, as the kitty keyboard protocol does: ESC _ tactile ; push= ST ESC _ tactile ; pop= ST ESC _ tactile ; set= ST o "push" saves the current set on the stack and enables "". o "pop" restores the set saved by the last "" pushes (1 if "" is 0). Popping more entries than the stack holds leaves nothing enabled. o "set" replaces the current set without touching the stack. An application SHOULD "push" when it starts and "pop" when it exits. A terminal MUST keep separate stacks for the main and the alternate screen, MUST allow at least 8 entries per stack, and, when a stack is full, MUST drop the oldest entry to make room. A full reset ("RIS") empties both stacks. The terminal MUST ignore flags it does not support. Tactile events are pointer events. Unless a mouse reporting mode (1000, 1002 or 1003) is also enabled, the terminal MUST NOT send them. While a feature is enabled, the terminal reports the corresponding input as Tactile events instead of, not in addition to, the legacy encoding. Tactile covers what mouse reporting cannot express. Button presses and releases, pointer motion and dragging keep their legacy reports (modes 1000 to 1003, in the SGR or SGR-Pixels encoding), and applications combine both: a drawing application, for example, takes the stroke from drag reports and its width from Tactile pressure events. 6. Core: Events 6.1. Common fields Every event carries "e", the event type, and SHOULD carry: o "t": a monotonic timestamp in microseconds. Its origin is unspecified; only differences between timestamps are meaningful. Applications MUST NOT rely on the time at which they read an event, because events are often read in batches. o "x", "y": pointer position in whole pixels, in the same coordinate space as mode 1016: device pixels of the terminal’s text area, with the origin at its top-left corner. Positions are in pixels whatever mouse encoding the application enabled. An application that needs cells divides by the cell size, which mode 2048 [7] or "CSI 16 t" reports. o "mods": held modifier keys, encoded as in the kitty keyboard protocol: 1 plus the sum of shift=1, alt=2, ctrl=4 and super=8. Gestures go through phases: "begin" when they start, "update" while they continue, "end" when they finish and "cancel" when they are interrupted. Where the platform reports it, a gesture may start with "contact": the fingers touched the surface but have not moved yet. It is followed by "begin", or by "cancel" when the fingers lift without moving. On macOS it corresponds to the "mayBegin" phase. 6.2. Simultaneous gestures Platforms can report different gestures at the same time; on macOS, for example, fingers can scroll and pinch in one movement. Events of different types MAY therefore interleave, and applications MUST track phases separately for each event type. At most one gesture of each type is in progress at a time: a terminal MUST end or cancel a gesture before it begins another of the same type. 6.3. Device changes Input devices come and go: a wireless trackpad connects, a mouse is unplugged, the user turns haptics off. While any feature is enabled, the terminal MUST send ESC _ tactile ; e=devices ; available= ST whenever the set of available features changes, so that the "available" value from the reply never goes stale. 6.4. Devices Several input devices can be attached at once, for example a laptop’s trackpad and an external one. While any feature is enabled, the terminal SHOULD describe each device once, before its first event, and again when it changes: ESC _ tactile ; e=device ; dev=1 ; kind=trackpad ; w=11800 ; h=8000 ; contacts=5 ; pressure=1 ; haptics=1 ST o "dev": a number that identifies the device for as long as it is attached. Every event SHOULD carry the "dev" of the device that produced it. o "kind": "trackpad", "mouse", "touchscreen" or "pen". Future modules may add kinds; applications ignore kinds they do not know. o "w", "h": the size of the surface in hundredths of a millimeter, when known. o "contacts": the largest number of contacts the device tracks at once. o "pressure", "haptics": 1 when the device measures pressure or has a haptic actuator. The trackpad of an Apple M1 MacBook Air reports a surface of 334.5 by 226.8 points, about 118 by 80 millimeters, and tracks up to five contacts. 7. Core: Extensibility Like CSS, Tactile grows by addition: new modules, new features, new keys and new values. Every receiver follows these rules, so that additions never break existing implementations: o A receiver MUST ignore keys it does not recognize. o An application MUST ignore events whose type ("e") it does not recognize. o A receiver MUST treat a recognized key with a value it does not understand as absent. o A terminal MUST ignore flags it does not recognize. New features receive new flags. A 64-bit integer holds 63 flags, far more than the protocol is expected to need. Names without a dot are reserved for this specification. An implementation that wants to try a new key, value or event type before it is specified MUST put it in a vendor namespace: its project name, a dot and the name, for example "ghostty.velocity". When such a name is adopted, this specification gives it a name without a dot, and implementations MAY send both names during a transition. This avoids the problem of the “X-” convention, which RFC 6648 [8] deprecated: experimental names never need to become permanent, and two projects can never collide. Tactile has no protocol version. If an incompatible change is ever needed, it will use a new identifier instead of "tactile", so that old and new implementations never misread each other. 8. Module: Scroll (Level 1) Features: "scroll" (1), "phases" (2), "momentum" (4). 8.1. Scroll events With "scroll" enabled, scrolling is reported as: ESC _ tactile ; e=scroll ; dx=-150 ; dy=1225 ; src=finger ; ph=update ; mo=none ; t=50213250 ; x=812 ; y=440 ST "dx" and "dy" are the scroll distances in hundredths of a pixel, after the user’s scroll-direction preference (for example, macOS “natural scrolling”) has been applied. Positive "dy" scrolls toward the end of the content, like the legacy “wheel down” button. "src" is the source: "finger" (trackpad), "continuous" (devices without discrete steps) or "wheel" (a notched wheel; in that case "steps" MAY give the number of notches). 8.2. Phases With "phases" enabled, scroll events from fingers carry "ph", the phase of the fingers on the surface: "begin" when they start moving, "update" while they move, "end" when they lift, "cancel" when the gesture is interrupted. It is absent for wheel input. A single physical swipe therefore produces one "ph=begin", a series of updates and one "ph=end". Applications can implement “one page per swipe” exactly. 8.3. Momentum Momentum is the scrolling that continues after the fingers lift, slowing down like a sliding object. Platforms differ: macOS computes momentum and reports it as a separate phase; Wayland reports only the fingers and leaves momentum to each application. The "momentum" feature is available only when the platform computes momentum. With it enabled, the terminal forwards momentum scroll events, which carry "mo" ("begin", "update", "end") and no "ph". Without it, the terminal does not send momentum events. A terminal MUST NOT synthesize momentum that the platform does not provide, so that every application sees the platform’s own behavior. An application that wants momentum where it is not available computes it from the speed of the last events before "ph=end". 9. Module: Pinch (Level 1) Feature: "pinch" (8). ESC _ tactile ; e=pinch ; ph=update ; scale=1184 ; dx=0 ; dy=0 ; ... ST "scale" is the cumulative magnification relative to the start of the gesture, in thousandths: 1000 at "begin", 1184 when the content should be shown 1.184 times larger. "dx" and "dy" are the movement of the gesture’s center since the previous event, in hundredths of a pixel, when the platform reports it. Like every event, a pinch carries "x" and "y", the pointer position. A trackpad is an indirect device: the fingers have no place on the screen, and platforms zoom about the pointer (macOS applications, Wayland’s pointer gestures). Applications therefore SHOULD keep the content under "x", "y" still while zooming, so that a pinch in the terminal feels like a pinch anywhere else on the system. 10. Module: Haptics (Level 1, optional) Feature: "haptics" (16). Haptic feedback is a physical output, so this module is opt-in on both sides. A terminal MUST keep haptics disabled until the user turns them on in its settings; until then, "haptics" is supported but not available. With the feature enabled, the application MAY send: ESC _ tactile ; haptic=alignment ST with one of the patterns "generic", "alignment" or "level". These are the three trackpad patterns of macOS, the most restrictive platform; terminals on other platforms map them to the closest available effect (Appendix A). To protect the user, the terminal: o MUST ignore haptic requests unless a pointer gesture is in progress, or ended less than 100 ms earlier; o MUST ignore haptic requests from an application that is not in the focused pane or window; o SHOULD limit haptic requests to 30 per second. The terminal does not acknowledge haptic requests. 11. Exploratory Modules The features in this section describe input that operating systems provide but that no terminal application uses yet. They will be revised, and may be renamed or removed, once an application does. Implementations MAY support them to gather experience. 11.1. Rotate Feature: "rotate" (32). "e=rotate" carries "angle", the cumulative rotation since the start of the gesture in hundredths of a degree, positive clockwise. 11.2. Swipe Feature: "swipe" (64). "e=swipe" reports multi-finger swipes that the platform delivers to applications. It carries "fingers", and "dx", "dy" in hundredths of a pixel since the previous event. 11.3. Hold Feature: "hold" (128). "e=hold" with "ph=begin" reports fingers resting on the surface without moving, and "ph=end" or "ph=cancel" when they lift or start moving. It carries "fingers". Applications can use it, for example, to stop their own momentum scrolling when the user touches the trackpad. 11.4. Touch Feature: "touch" (512). This module passes on every contact on the surface, so that applications can recognize any gesture themselves, including ones the platform does not detect. Each contact is reported as its own event, about as often as the platform tracks it: ESC _ tactile ; e=touch ; dev=1 ; id=3 ; ph=update ; x=4521 ; y=3310 ; rest=0 ; t=50213250 ST o "id": a number that identifies the contact from "begin" to "end". o "ph": "begin", "update", "stationary" (still touching, not moving), "end" or "cancel". o "x", "y": the position on the surface in ten-thousandths of its width and height, from the top-left corner. For a device whose "kind" is "touchscreen", positions are window pixels, like the common "x" and "y". o "rest": 1 when the platform considers the contact resting (a thumb or a palm). It is a hint: in our recordings macOS did not mark a thumb resting while two other fingers scrolled. Events with the same "t" describe one moment. On an Apple M1 MacBook Air, contacts were reported about 120 times per second, twice as often as scroll events, for up to five fingers. Touchscreens and pens are expected to use this module, with their own "kind" and, for pens, additional keys such as tilt, defined by a future module. 11.5. Pressure Feature: "pressure" (256). "e=pressure" carries "stage", the click stage (0 12. no click, 1 = click, 2 = deep click), and "p", the pressure within that stage in thousandths (0 to 1000), when the device reports them: ESC _ tactile ; e=pressure ; p=494 ; stage=1 ; t=63481704 ST ESC _ tactile ; e=pressure ; p=0 ; stage=2 ; t=63502704 ST "p" starts again from 0 when the stage changes, as the platforms report it: in our recordings it rose to 494 in stage 1, fell to 0 on the deep click and rose to 980 in stage 2. For one continuous level during a press, applications compute "(stage - 1) * 1000 + p", from 0 to 2000. Terminals send an event whenever either value changes, about 60 times per second on an Apple M1 MacBook Air. Pressure does not replace button reports: the press and release still arrive as mouse reports, and pressure events arrive between them. 13. Example Session An application that handles scrolling with phases and pinch starts like this. It asks for features 1 + 2 + 8 = 11. The terminal supports every feature except touch (511), but the trackpad has no force sensor and the user has not turned on haptics, so 511 − 256 − 16 = 239 are available (see Section 5.1). app→term ESC _ tactile ; q=1 ST CSI c term→app ESC _ tactile ; supported=511 ; available=239 ; enabled=0 ST term→app CSI ? 62 ; 22 c app→term ESC _ tactile ; push=11 ST ... the user swipes with two fingers ... term→app ESC _ tactile ; e=scroll ; dy=450 ; ph=begin ; ... ST term→app ESC _ tactile ; e=scroll ; dy=1125 ; ph=update ; ... ST term→app ESC _ tactile ; e=scroll ; dy=0 ; ph=end ; ... ST app→term ESC _ tactile ; pop=1 ST The application did not enable "momentum", so no momentum events follow the swipe. The third line is the terminal’s ordinary answer to the device attributes request ("CSI c"); its content does not matter here, only that it comes after the Tactile reply. 14. Multiplexers A terminal multiplexer such as tmux sits between the terminal and the application. A multiplexer that implements Tactile: o MUST enable in the outer terminal the union of the features enabled by its panes; o MUST keep a separate stack for each pane; o MUST deliver events only to the pane under the pointer (or, for gestures that began in a pane, to that pane until the gesture ends); o MUST translate "x" and "y" to the pane’s coordinate space; o MUST convert events to the legacy encoding for panes that did not enable the corresponding feature; o MAY forward haptic requests from the focused pane. A multiplexer that does not implement Tactile does not enable it in the outer terminal, so applications inside it fall back to legacy input. 15. Encoding and Performance 15.1. Data volume The sizes below are for the messages exactly as sent, without the spaces used in examples. Message | Bytes scroll event with all fields ("dx", "dy", "src", "ph", "mo", "t", "x", "y", "mods") | 95 pinch event | 73 legacy wheel event, for comparison ("CSI < 65 ; 102 ; 37 M") | 13 query and device attributes request | 18 reply | 49 push / pop | 19 / 17 haptic request | 28 device change | 35 On an Apple M1 laptop with a 60 Hz display, macOS delivered 60 scroll events per second, both while the fingers moved and during momentum (a median of 16.6 ms between events). A quick swipe produced only 4 to 8 events from the fingers, over 34 to 117 ms, followed by 12 to 68 momentum events over 180 to 1100 ms. Pressure arrived 61 times per second while clicking. The recording and the tools are in "demos/trackpad-logger/". Displays that refresh 120 times per second can be expected to double these rates. Because terminals coalesce updates of a gesture to at most the display refresh rate (a requirement stated in Section 16), this is also the upper bound for one gesture: Load | Bandwidth one scrolling gesture at 60 Hz | about 5.7 KB/s one scrolling gesture at 120 Hz | about 11.4 KB/s four simultaneous gestures at 120 Hz | about 45.6 KB/s For comparison, a pseudo-terminal carries hundreds of megabytes per second, and a single page image sent with the kitty graphics protocol is several megabytes. Tactile uses well under 0.1% of the channel, and only while the user is touching the trackpad. Latency is dominated by the operating system’s input pipeline and the application’s next frame, as it is for keyboard input. Messages from the application are rarer still: a query, a push and a pop per program, and haptic requests limited to 30 per second. 15.2. Why APC and named fields Tactile could have used control sequences, like mouse and keyboard reports, instead of APC strings. Control sequences are shorter, and every input parser already splits them into numbers. But their parameters are numbers identified only by their position, so a new field can only be appended at the end, words such as "update" must be replaced by codes, and vendor experiments have no natural place. Trackpad input is richer than positions and buttons, and will keep growing. APC strings with named fields, like the kitty graphics protocol, keep each message self-describing and make the extensibility rules possible. Names are spelled out rather than shortened to single letters: the bytes saved do not matter (Section 15), while readable messages make implementations and debugging easier. 15.3. Why text and not binary Tactile messages are text. A binary encoding was considered and rejected, for these reasons: o The PTY is a byte stream shared with keystrokes and other escape sequences. Raw binary data could contain "ESC" or other bytes that end a sequence early, so a binary frame would have to be encoded as text anyway, usually in base64. The kitty graphics protocol does exactly that for image data. o The cost of text is negligible. On an Apple M1, parsing a complete scroll event of 95 bytes takes about 95 ns; decoding an equivalent 24-byte binary frame, base64-encoded into a 44-byte message, takes about 14 ns. At 120 events per second, text costs about 11 µs of processor time per second of gesture, which is 0.001% of one core. The benchmark is in "protocol/bench/bench.zig". o Text supports the extensibility rules directly: a new key is simply ignored by old receivers. A fixed binary layout would need explicit versioning for every addition. o Text can be inspected with standard tools (for example "cat -v"), and is easy to parse in every programming language. o If measurements on real hardware ever show that the encoding matters, a future module can add an optional binary encoding: numbered fields with lengths, which receivers skip when they do not recognize them, as Protocol Buffers do, carried in base64 inside the same APC strings. Applications that do not enable it would not notice. 15.4. Energy use Tactile costs nothing until an application asks for it. A terminal that implements Tactile sends no Tactile messages, and does no extra work per event, unless an application has enabled a feature with "push" or "set" and enabled mouse reporting. Users who never run such an application see no change. When a feature is enabled, the terminal does little extra work: it already receives every trackpad event from the operating system, whether or not it forwards them. The added cost is formatting each event and writing it to the PTY. Most of the energy goes into waking the application to read its input, and into the frame the application draws in response; both also happen with legacy wheel events. To keep this cost low: o Terminals coalesce updates of a gesture to at most the display refresh rate (Section 16), and SHOULD write all pending events at once. o Applications SHOULD read all available input at once, rather than one event at a time. o Applications receive momentum events only if they enable "momentum". With legacy mouse reporting, momentum always arrives as wheel events, so an application that does not need it is woken less often with Tactile. In the recording described above, momentum made up 259 of 422 scroll events, and up to 68 of 75 events in a single quick swipe. o Terminals SHOULD subscribe to platform input sources that only Tactile needs (for example touch tracking that the terminal does not use itself) only while an application has enabled the corresponding feature. The choice between text and binary encoding matters little by comparison. Assuming, generously, 30 minutes of trackpad gestures a day at 120 events per second, a binary encoding would save about 17.5 ms of processor time per user per day (216,000 events × about 81 ns). At about 2 W for a busy laptop core, that is about 35 mJ per user per day, or about 10 Wh per day for a million users together: roughly what one laptop uses in an hour. 16. Security and Privacy Considerations Pressure and fine-grained motion data could, in principle, help identify a user. Terminals MAY round values, and MUST NOT report input that did not occur over the terminal’s own window. Haptic feedback is a physical output. The Haptics module keeps it off until the user turns it on, and limits it so that an application cannot vibrate the user’s device on its own. Gesture updates can arrive at a high rate. Terminals SHOULD coalesce consecutive updates of the same gesture to at most the display refresh rate, summing distances, so that slow applications do not fall behind. Phase changes ("begin", "end", "cancel") MUST NOT be coalesced away. 17. Open Questions o Should pixel distances be device pixels or logical points? This draft follows mode 1016 (device pixels). o How should a terminal report a gesture that starts in one window or pane and ends in another? Appendix A. Platform Mapping Feature | macOS (AppKit) | Linux (Wayland) | Windows scroll | "scrollingDeltaX/Y", "hasPreciseScrollingDeltas" | "wl_pointer.axis", "axis_source", "axis_value120" | Precision Touchpad phases | "phase" (also "mayBegin", see hold) | "axis_stop" (end only) | DirectManipulation momentum | "momentumPhase" | not provided; computed by the client | DirectManipulation inertia pinch, rotate | "magnify", "rotate" | pointer-gestures v1 "pinch" | DirectManipulation swipe, hold | "swipe"; hold as scroll "phase" "mayBegin" then "cancel"; finger counts from "NSTouch" | pointer-gestures v1 "swipe", "hold" | WM_POINTER pressure | "pressureChange" (Force Touch) | not available | not available haptics | "NSHapticFeedbackManager" | force feedback on haptic touchpads (Linux 6.18+) | "InputHapticsManager" (Windows 11 24H2+) Appendix B. Prior Art o The xterm mouse reporting modes [5] and SGR-Pixels (mode 1016) report pointer position, but scrolling only as wheel buttons. o The kitty keyboard protocol [1] introduced opt-in progressive enhancement for keyboard input, with a stack of enabled flags; Tactile follows its negotiation model. o The in-band window resize report (mode 2048) [7] gives applications the size of the window in cells and pixels, which makes pixel coordinates usable. o CSS since its third version is split into independently versioned modules, and browsers ignore properties they do not understand; Tactile borrows this structure. o The W3C Pointer Events specification recently added a "momentum" attribute to wheel events, so that web pages can tell momentum from scrolling by the fingers; browsers are implementing it. The web platform is closing the same gap for pages that Tactile closes for terminals. o kitty 0.46 and 0.47 added smooth and momentum scrolling and hold gestures for the terminal’s own scrollback, without exposing them to applications. o Discrete wheel events for trackpads have been reported as a problem in WezTerm (issue 7645), xterm.js (issue 6181) and other terminals. Appendix C. Feature Registry Flag | Feature | Status | Events and keys 1 | scroll | Level 1 | "e=scroll": "dx", "dy", "src", "steps" 2 | phases | Level 1 | "ph" on scroll events 4 | momentum | Level 1 | "mo" on scroll events 8 | pinch | Level 1 | "e=pinch": "scale", "dx", "dy" 16 | haptics | Level 1, optional | "haptic=" request 32 | rotate | Exploratory | "e=rotate": "angle" 64 | swipe | Exploratory | "e=swipe": "fingers", "dx", "dy" 128 | hold | Exploratory | "e=hold": "fingers" 256 | pressure | Exploratory | "e=pressure": "p", "stage" 512 | touch | Exploratory | "e=touch": "id", "ph", "x", "y", "rest" All events also carry the common fields "t", "x", "y" and "mods". The core defines the events "e=devices" (key "available") and "e=device" (keys "dev", "kind", "w", "h", "contacts", "pressure", "haptics"), and every event may carry "dev". Appendix D. Test Vectors The file "protocol/tests/vectors.json" lists messages with the result a receiver must produce, and sequences of "push", "pop" and "set" with the features that must end up enabled. "protocol/tests/tactile_ref.py" is a reference parser that passes all of them. A selection: Message | Result "ESC _ tactile;e=scroll;dy=1225;ph=update ST" | scroll event, "dy" 12.25 px "ESC _ tactile;e=scroll;dy=5;dy=9 ST" | "dy" is 5 (first wins) "ESC _ tactile;e=scroll;dy=5;ghostty.velocity=812 ST" | vendor key, ignored unless known "ESC _ tactile;e=scroll;dy=12.25 ST" | ignored: not an integer "ESC _ tactile;e=scroll;DY=5 ST" | ignored: uppercase key "ESC _ tactile; e=scroll ST" | ignored: space "push=11", "push=1", "pop=1" | 11 enabled "push=11", "set=1", "pop=1" | nothing enabled Appendix E. Glossary APC Application Program Command, an escape sequence of the form "ESC _ ... ST" that carries a free-form string. Tactile messages are APC strings. Application A program running inside a terminal, such as a shell, an editor or a PDF viewer. CSI Control Sequence Introducer, "ESC [", the start of a control sequence: a short command with numeric parameters. Escape sequence Bytes starting with "ESC" that a terminal or an application interprets instead of displaying. Feature One kind of input or output that an application can enable, such as "scroll" or "pinch". Each feature has a flag. Flag The power of two that stands for a feature. A set of features is the sum of their flags. Haptic feedback A physical click or vibration produced by the trackpad. Module A part of this specification that defines related features, with its own status. Momentum Scrolling that continues after the fingers lift, slowing down like a sliding object. Multiplexer A program, such as tmux, that runs several applications in panes inside one terminal. Phase The stage of a gesture: "begin", "update", "end" or "cancel". PTY Pseudo-terminal, the pair of connected devices that carries bytes between a terminal emulator and an application. ST String Terminator, "ESC \", which ends an APC string. Terminal emulator The graphical program that draws the character grid and passes input to the application. References o [1] K. Goyal, “Comprehensive keyboard handling in terminals.” [Online]. Available: https://sw.kovidgoyal.net/kitty/keyboard- protocol/ o [2] S. Bradner, “Key words for use in RFCs to Indicate Requirement Levels,” RFC 2119, Mar. 1997. [Online]. Available: https://www.rfc-editor.org/rfc/rfc2119 o [3] B. Leiba, “Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words,” RFC 8174, May 2017. [Online]. Available: https://www.rfc- editor.org/rfc/rfc8174 o [4] Ecma International, “ECMA-48: Control Functions for Coded Character Sets,” Jun. 1991. [Online]. Available: https://ecma- international.org/publications-and-standards/standards/ecma-48/ o [5] T. E. Dickey, “XTerm Control Sequences.” [Online]. Available: https://invisible-island.net/xterm/ctlseqs/ctlseqs.html o [6] Crocker, D., Overell, and P., “Augmented BNF for Syntax Specifications: ABNF,” RFC 5234, Jan. 2008. [Online]. Available: https://www.rfc-editor.org/rfc/rfc5234 o [7] T. Culverhouse, “Private Mode for In-Band Window Resize Notifications.” [Online]. Available: https://gist.github.com/rocko rager/e695fb2924d36b2bcf1fff4a3704bd83 o [8] Saint-Andre, P., Crocker, D., Nottingham, and M., “Deprecating the "X-" Prefix and Similar Constructs in Application Protocols,” RFC 6648, Jun. 2012. [Online]. Available: https://www.rfc- editor.org/rfc/rfc6648