@@ -150,7 +150,7 @@ following for each pair::
150
150
... repeat for each pair of characters
151
151
152
152
153
- Finally fixing the character width issue for the terminal ecosystem
153
+ Fixing the character width issue for the terminal ecosystem
154
154
---------------------------------------------------------------------
155
155
156
156
Terminals create user interfaces using text displayed in a cell grid. For
@@ -174,14 +174,49 @@ Expecting all terminals and all terminal programs to have both up-to-date
174
174
character databases and a bug free implementation of this algorithm is not
175
175
realistic.
176
176
177
- So instead, this protocol solves this issue robustly by removing the
177
+ So instead, this protocol solves the issue robustly by removing the
178
178
co-ordination problem and putting only one actor in charge of determining
179
179
string width. The client becomes responsible for doing whatever level of
180
180
grapheme segmentation it is comfortable with using whatever Unicode database is
181
181
at its disposal and then it can transmit the segmented string to the terminal
182
182
with the appropriate ``w `` values so that the terminal renders the text in the
183
183
exact number of cells the client expects.
184
184
185
+ Wrapping and overwriting behavior
186
+ -------------------------------------
187
+
188
+ If the multicell block (``s * w by s `` cells) is larger than the screen size in either
189
+ dimension, the terminal must discard the character. Note that in particular
190
+ this means that resizing a terminal screen so that it is too small to fit a
191
+ multicell character can cause the character to be lost.
192
+
193
+ When drawing a multicell character, if wrapping is enabled (DECAWM is set) and
194
+ the character's width (``s * w ``) does not fit on the current line, the cursor is
195
+ moved to the start of the next line and the character is drawn there.
196
+ If wrapping is disabled and the character's width does not fit on the current
197
+ line, the cursor is moved back as far as needed to fit ``s * w `` cells and then
198
+ the character is drawn, following the overwriting rules described below.
199
+
200
+ When drawing text either normal text or text specified via this escape code,
201
+ and this text would overwrite an existing multicell character, the following
202
+ rules must be followed, in decreasing order of precedence:
203
+
204
+ #. If the text is a combining character it is added to the existing multicell
205
+ character
206
+ #. If the text will overwrite the top-left cell of the multicell character, the
207
+ entire multicell character must be erased
208
+ #. If the text will overwrite any cell in the topmost row of the multicell
209
+ character, the entire multicell character must be replaced by spaces (this
210
+ rule is present for backwards compatibility with how overwriting works for
211
+ two cell characters)
212
+ #. If the text will overwrite cells from a row after the first row, then cursor should be moved past the
213
+ cells of the multicell character on that row and only then the text should be
214
+ written. Note that this behavior is independent of the value of DECAWM. This
215
+ is done for simplicity of implementation.
216
+
217
+ The skipping behavior of the last rule can be complex requiring the terminal to
218
+ skip over lots of cells, but it is needed to allow wrapping in the presence of
219
+ multicell characters that extend over more than a single line.
185
220
186
221
Detecting if the terminal supports this protocol
187
222
-----------------------------------------------------
@@ -197,3 +232,33 @@ has a different cursor position then it is supported.
197
232
198
233
Interaction with other terminal controls
199
234
--------------------------------------------------
235
+
236
+ This protocol does not change the character grid based nature of the terminal.
237
+ Most terminal controls assume one character per cell so it is important to
238
+ specify how these controls interact with the multicell characters created by
239
+ this protocol.
240
+
241
+ Cursor movement
242
+ ^^^^^^^^^^^^^^^^^^^
243
+
244
+ Cursor movement is unaffected by multicell characters, all cursor movement
245
+ commands move the cursor position by single cell increments, as has always been
246
+ the case for terminals. This means that the cursor can be placed at any
247
+ individual single cell inside a larger multicell character.
248
+
249
+ When a multicell character is created using this protocol, the cursor moves
250
+ `s * w ` cells to the right, in the same row it was in.
251
+
252
+ Terminals *should * display a large cursor covering the entire multicell block
253
+ when the actual cursor position is on any cell within the block. Block cursors
254
+ cover all the cells of the multicell character, bar cursors appear in all the
255
+ cells in the first column of the character and so on.
256
+
257
+
258
+ Editing controls
259
+ ^^^^^^^^^^^^^^^^^^^^^^^^^
260
+
261
+ There are many controls used to edit existing screen content such as
262
+ inserting characters, deleting characters and lines, etc. These were all
263
+ originally specified for the one character per cell paradigm. Here we specify
264
+ their interactions with multicell characters.
0 commit comments