Commit c2fdc98
authored
Draw Invisible Characters (#334)
### Description
Adds a configuration option to draw invisible characters.
By default, draws spaces as a small dot, with emphasis on spaces that
align with the user's selected indent width. Draws tabs as a small
arrow. Draws line endings (carriage returns and line feeds) as a `¬`
character.
Replacement characters are configurable using the config object.
Adds a configuration option to warn users about potentially
dangerous/unnecessary characters that may not be visible to the naked
eye. This could be used to warn about something like a zero-width space
being accidentally copied into a file.
#### Detailed changes
- Adds a new `InvisibleCharactersConfig` type that contains toggles for
certain whitespace characters, as well as a set of 'warning' characters
to draw warning boxes on.
- Adds a new `InvisibleCharactersCoordinator` that tells the text view
how to draw characters depending on the current configuration.
- Adds a new `invisibleCharacterConfig` option to `CodeEditSourceEditor`
and `TextViewController`.
- Adds a new `warningCharacters` option to `CodeEditSourceEditor` and
`TextViewController`.
- Updates `TextViewController` to correctly update the coordinator when
the user's theme, font, or indent option are updated.
### Related Issues
* CodeEditApp/CodeEditTextView#22
* #207
### Checklist
- [x] I read and understood the [contributing
guide](https://github.com/CodeEditApp/CodeEdit/blob/main/CONTRIBUTING.md)
as well as the [code of
conduct](https://github.com/CodeEditApp/CodeEdit/blob/main/CODE_OF_CONDUCT.md)
- [x] The issues this PR addresses are related to each other
- [x] My changes generate no new warnings
- [x] My code builds and runs on my machine
- [x] My changes are all related to the related issue above
- [x] I documented my code
### Screenshots
Example document with tabs, spaces, newlines, and a zero-width character
pasted in before the `1`. It responds to theme updates and live editing.
https://github.com/user-attachments/assets/29dc7585-c131-49a2-8ca8-afa2f3e2a5541 parent e955486 commit c2fdc98
File tree
11 files changed
+458
-31
lines changed- Example/CodeEditSourceEditorExample
- CodeEditSourceEditorExample/Views
- Sources/CodeEditSourceEditor
- CodeEditSourceEditor
- Controller
- InvisibleCharacters
- Minimap
- Tests/CodeEditSourceEditorTests/Controller
11 files changed
+458
-31
lines changedLines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 5 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
59 | | - | |
| 60 | + | |
| 61 | + | |
60 | 62 | | |
61 | 63 | | |
62 | 64 | | |
| |||
71 | 73 | | |
72 | 74 | | |
73 | 75 | | |
74 | | - | |
| 76 | + | |
| 77 | + | |
75 | 78 | | |
76 | 79 | | |
77 | 80 | | |
| |||
Lines changed: 28 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
53 | 81 | | |
54 | 82 | | |
55 | 83 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
Lines changed: 40 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
54 | | - | |
55 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
56 | 61 | | |
57 | 62 | | |
58 | 63 | | |
| |||
77 | 82 | | |
78 | 83 | | |
79 | 84 | | |
80 | | - | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
81 | 88 | | |
82 | 89 | | |
83 | 90 | | |
| |||
107 | 114 | | |
108 | 115 | | |
109 | 116 | | |
| 117 | + | |
| 118 | + | |
110 | 119 | | |
111 | 120 | | |
112 | 121 | | |
| |||
136 | 145 | | |
137 | 146 | | |
138 | 147 | | |
139 | | - | |
140 | | - | |
141 | | - | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
142 | 156 | | |
143 | 157 | | |
144 | 158 | | |
| |||
163 | 177 | | |
164 | 178 | | |
165 | 179 | | |
166 | | - | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
167 | 183 | | |
168 | 184 | | |
169 | 185 | | |
| |||
193 | 209 | | |
194 | 210 | | |
195 | 211 | | |
| 212 | + | |
| 213 | + | |
196 | 214 | | |
197 | 215 | | |
198 | 216 | | |
| |||
219 | 237 | | |
220 | 238 | | |
221 | 239 | | |
| 240 | + | |
| 241 | + | |
222 | 242 | | |
223 | 243 | | |
224 | 244 | | |
| |||
247 | 267 | | |
248 | 268 | | |
249 | 269 | | |
250 | | - | |
| 270 | + | |
| 271 | + | |
251 | 272 | | |
252 | 273 | | |
253 | 274 | | |
| |||
352 | 373 | | |
353 | 374 | | |
354 | 375 | | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
355 | 384 | | |
356 | 385 | | |
357 | 386 | | |
| |||
397 | 426 | | |
398 | 427 | | |
399 | 428 | | |
| 429 | + | |
| 430 | + | |
400 | 431 | | |
401 | 432 | | |
402 | 433 | | |
| |||
Lines changed: 58 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
30 | 39 | | |
31 | 40 | | |
32 | 41 | | |
| |||
35 | 44 | | |
36 | 45 | | |
37 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
38 | 51 | | |
39 | 52 | | |
40 | 53 | | |
| |||
52 | 65 | | |
53 | 66 | | |
54 | 67 | | |
| 68 | + | |
55 | 69 | | |
56 | 70 | | |
57 | 71 | | |
| |||
70 | 84 | | |
71 | 85 | | |
72 | 86 | | |
| 87 | + | |
73 | 88 | | |
74 | 89 | | |
75 | 90 | | |
| |||
86 | 101 | | |
87 | 102 | | |
88 | 103 | | |
| 104 | + | |
89 | 105 | | |
90 | 106 | | |
91 | 107 | | |
| |||
256 | 272 | | |
257 | 273 | | |
258 | 274 | | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
265 | 297 | | |
266 | 298 | | |
267 | 299 | | |
268 | 300 | | |
269 | 301 | | |
270 | | - | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
271 | 306 | | |
272 | 307 | | |
273 | 308 | | |
| |||
291 | 326 | | |
292 | 327 | | |
293 | 328 | | |
294 | | - | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
295 | 332 | | |
296 | 333 | | |
297 | 334 | | |
| |||
314 | 351 | | |
315 | 352 | | |
316 | 353 | | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
317 | 361 | | |
318 | 362 | | |
319 | 363 | | |
320 | | - | |
321 | | - | |
322 | | - | |
| 364 | + | |
| 365 | + | |
323 | 366 | | |
324 | | - | |
| 367 | + | |
325 | 368 | | |
326 | 369 | | |
327 | 370 | | |
| |||
342 | 385 | | |
343 | 386 | | |
344 | 387 | | |
| 388 | + | |
| 389 | + | |
345 | 390 | | |
346 | 391 | | |
347 | 392 | | |
| |||
391 | 436 | | |
392 | 437 | | |
393 | 438 | | |
394 | | - | |
| 439 | + | |
0 commit comments