hex-patch 1.12.5

HexPatch is a binary patcher and editor with terminal user interface (TUI), it's capable of disassembling instructions and assembling patches. It supports a variety of architectures and file formats. Also, it can edit remote files via SSH.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
# Plugin API

This document describes the API that plugins can use to interact with HexPatch.

## Functions

For the explanation of the types used in the functions, see the [Types](#types) section.

### Initialization

```lua
function init(context) end
```

This function is called when the plugin is loaded.

| Argument | Type | Description |
|----------|------|-------------|
|`context`|`Context`|The application context.|

### Events

#### On Open

```lua
function on_open(context) end
```

This function is called when a file is opened.

| Argument | Type | Description |
|----------|------|-------------|
|`context`|`Context`|The application context.|

#### On Close

```lua
function on_save(context) end
```

This function is called when a file is saved (both save and save as).

| Argument | Type | Description |
|----------|------|-------------|
|`context`|`Context`|The application context.|

#### On Edit

```lua
function on_edit(new_bytes, context) end
```

This function is called when the user edits the file, either directly or through a command.

| Argument | Type | Description |
|----------|------|-------------|
|`new_bytes`|`Data`|The new bytes of the file.|
|`context`|`Context`|The application context.|

#### On Key

```lua
function on_key(key_event, context) end
```

This function is called when a key is pressed.

| Argument | Type | Description |
|----------|------|-------------|
|`key_event`|`KeyEvent`|The key event.|
|`context`|`Context`|The application context.|

#### On Mouse

```lua
function on_mouse(mouse_event, context) end
```

This function is called when an action is performed with the mouse.

| Argument | Type | Description |
|----------|------|-------------|
|`mouse_event`|`MouseEvent`|The mouse event.|
|`context`|`Context`|The application context.|

#### On Focus

```lua
function on_focus(context) end
```

This function is called when the terminal gains focus.

| Argument | Type | Description |
|----------|------|-------------|
|`context`|`Context`|The application context.|

#### On Blur

```lua
function on_blur(context) end
```

This function is called when the terminal loses focus.

| Argument | Type | Description |
|----------|------|-------------|
|`context`|`Context`|The application context.|

#### On Paste

```lua
function on_paste(text, context) end
```

This function is called when text is pasted into the terminal.

| Argument | Type | Description |
|----------|------|-------------|
|`text`|`String`|The text that was pasted.|
|`context`|`Context`|The application context.|

#### On Resize

```lua
function on_resize(width, height, context) end
```

This function is called when the terminal is resized.
The size stored in the context is the old size, before the resize.

| Argument | Type | Description |
|----------|------|-------------|
|`width`|`usize`|The new width of the terminal.|
|`height`|`usize`|The new height of the terminal.|
|`context`|`Context`|The application context.|

### Commands

```lua
function COMMAND_NAME(context) end
```

This function is called when the user runs the command `COMMAND_NAME`.
The command must be registered using `context.add_command("COMMAND_NAME", "COMMAND_DESCRIPTION")`.

| Argument | Type | Description |
|----------|------|-------------|
|`context`|`Context`|The application context.|

### Popups

```lua
function FILL_POPUP_NAME(popup_context, context) end
```

This function is called each time the popup `FILL_POPUP_NAME` is drawn.
The popup must be opened using `context.open_popup("FILL_POPUP_NAME")`.

| Argument | Type | Description |
|----------|------|-------------|
|`popup_context`|`PopupContext`|The popup context.|
|`context`|`Context`|The application context.|

### Custom Headers

```lua
function HEADER_PARSER_NAME(header_context, context) end
```

This function is called whenever a new header is parsed, the first parser that returns a valid header will be used.
If during the parsing you decide that the header is not valid, you can raise an error or avoid setting values in the `header_context`.
The parser must be registered using `context.add_header_parser("HEADER_PARSER_NAME")`.

| Argument | Type | Description |
|----------|------|-------------|
|`header_context`|`HeaderContext`|The header context.|
|`context`|`Context`|The application context.|

## Types

### Context

This table contains the following fields:
| Field | Type | Description |
|-------|------|-------------|
|`screen_height`|`usize`|The height of the screen.|
|`screen_width`|`usize`|The width of the screen.|
|`data`|`Data`|The current file's data.|
|`offset`|`usize`|The current offset in the file.|
|`settings`|`Settings`|The settings of the application.|
|`current_instruction`|`Option<InstructionInfo>`|The current instruction at the current offset. `nil` if the current offset is not in an instruction or in a data section. The InstructionInfo type is explained at [InstructionInfo]#instructioninfo.|
|`header`|`Header`|The header of the file, if not valid or present, the default header will be used.|

And the following functions:
| Function | Arguments | Description |
|----------|-----------|-------------|
|`log`|`(level: u8, message: String)`|Logs a message in the UI.|
|`add_command`|`(command_name: String)`|Registers a command, this must be called to make the command appear in the command list.|
|`remove_command`|`(command_name: String)`|Removes a command, this removes the command from the command list.|
|`add_header_parser`|`(parser_name: String)`|Registers a header parser, this must be called to make the parser be used when a new file is opened.|
|`remove_header_parser`|`(parser_name: String)`|Removes a header parser, this removes the parser from the list of parsers.|
|`open_popup`|`(popup_handler: String)`|Opens a popup, each time the popup is drawn the handler function is called|
|`get_popup`|`() -> Option<String>`|Returns the name of the `popup_handler` of the currently open popup if there is one opened by this plugin. `nil` otherwise.|
|`close_popup`|`(popup_handler: Option<String>)`|Closes a popup opened by this plugin. If `popup_handler` is not `nil` it will also check if that is the currently open popup. If no popup is open, this plugin does not own the currently open popup, or the provided handler does not match the function will raise an error.|
|`get_instant_now`|`() -> Instant`|Gets an instant relative to the time this function was called. The Instant type is explained at [Instant]#instant.|
|`jump_to`|`(file_address: usize)`|Makes the UI jump to the specified file address.|
|`get_fullscreen`|`() -> bool`|Gets whether the UI is in fullscreen mode.|
|`set_fullscreen`|`(fullscreen: bool)`|Sets whether the UI is in fullscreen mode.|
|`get_selected_pane`|`() -> String`|Gets the selected pane. The possible values are `"hex"` if the HexView is selected and `"view"` if TextView or AssemblyView are selected.|
|`set_selected_pane`|`(pane: String)`|Sets the selected pane. The possible values are `"hex"` to select the HexView and `"view"` to select TextView or AssemblyView.|
|`get_comments`|`() -> Table`|Gets the comments as a table, the keys are the file addresses and the values are the comments.|
|`get_comment`|`(file_address: usize) -> Option<String>`|Gets the comment at the specified file address. `nil` if there is no comment.|
|`set_comment`|`(file_address: usize, comment: Option<String>)`|Sets the comment at the specified file address. If `comment` is `nil` or an empty string, the comment will be removed.|

For more information on the types, see the following sections.

### Settings

This type contains the settings of the application.
A setting can be accessed using the `.` operator with its full name (dots are replaced with underscores).
e.g. `context.settings.color_address_selected`, `context.settings.key_up`, `context.settings.app_history_limit`.

WARNING: You should get and set the setting altogether, e.g. `context.settings.color_address_selected = {fg = "Red"}`. Trying to set a single field will not work.

To access custom settings, use the following functions:
| Function | Arguments | Description |
|----------|-----------|-------------|
|`get_custom`|`(setting_name: String) -> CustomSetting`|Gets the value of a custom setting.|
|`set_custom`|`(setting_name: String, value: CustomSetting)`|Sets the value of a custom setting.|

### Data

A mutable vector of bytes.

The following functions are available:
| Function | Arguments | Description |
|----------|-----------|-------------|
|`get`|`(index: usize) -> u8`|Gets the byte at the specified index. THE INDEX IS 0 BASED!|
|`set`|`(index: usize, value: u8)`|Sets the byte at the specified index. THE INDEX IS 0 BASED!|
|`len`|`() -> usize`|Gets the length of the vector.|

### KeyEvent

This table contains the following fields:
| Field | Type | Description |
|-------|------|-------------|
|`code`|`String`|The key that was pressed, a list of possible values is available at [KeyEvent.code]#keyeventcode|
|`modifiers`|`Table`|A table containing the modifiers that were pressed, the entries are explained at [KeyEvent.modifiers]#keyeventmodifiers|
|`kind`|`String`|The kind of key event, either `Press`, `Repeat` or `Release`|
|`state`|`Table`|A table containing the state of the keys, the entries are explained at [KeyEvent.state]#keyeventstate|

#### KeyEvent.code

The following values are possible for the `code` field:

- `Backspace`
- `Enter`
- `Left`
- `Right`
- `Up`
- `Down`
- `Home`
- `End`
- `PageUp`
- `PageDown`
- `Tab`
- `BackTab`
- `Delete`
- `Insert`
- `Fn` where `n` is the function key number.
- `c` where `c` is the character that was pressed (can be either lower or upper case).
- `Null`
- `Esc`
- `CapsLock`
- `ScrollLock`
- `NumLock`
- `PrintScreen`
- `Pause`
- `Menu`
- `KeypadBegin`
- `Media(Play)`
- `Media(Pause)`
- `Media(PlayPause)`
- `Media(Reverse)`
- `Media(Stop)`
- `Media(FastForward)`
- `Media(Rewind)`
- `Media(TrackNext)`
- `Media(TrackPrevious)`
- `Media(Record)`
- `Media(LowerVolume)`
- `Media(RaiseVolume)`
- `Media(MuteVolume)`
- `Modifier(LeftShift)`
- `Modifier(LeftControl)`
- `Modifier(LeftAlt)`
- `Modifier(LeftSuper)`
- `Modifier(LeftHyper)`
- `Modifier(LeftMeta)`
- `Modifier(RightShift)`
- `Modifier(RightControl)`
- `Modifier(RightAlt)`
- `Modifier(RightSuper)`
- `Modifier(RightHyper)`
- `Modifier(RightMeta)`
- `Modifier(IsoLevel3Shift)`
- `Modifier(IsoLevel5Shift)`

#### KeyEvent.modifiers

The table contains the following fields:
| Field | Type | Description |
|-------|------|-------------|
|`alt`|`bool`|Whether the alt key was pressed.|
|`control`|`bool`|Whether the control key was pressed.|
|`hyper`|`bool`|Whether the hyper key was pressed.|
|`meta`|`bool`|Whether the meta key was pressed.|
|`shift`|`bool`|Whether the shift key was pressed.|
|`super`|`bool`|Whether the super key was pressed.|

#### KeyEvent.state

The table contains the following fields:
| Field | Type | Description |
|-------|------|-------------|
|`caps_lock`|`bool`|Whether the caps lock key is active.|
|`keypad`|`bool`|Whether the event origins from the keypad.|
|`num_lock`|`bool`|Whether the num lock key is active.|

### MouseEvent

This table contains the following fields:
| Field | Type | Description |
|-------|------|-------------|
|`kind`|`String`|The kind of mouse event, a list of possible values is available at [MouseEvent.kind]#mouseeventkind|
|`column`|`usize`|The column of the terminal where the event happened.|
|`row`|`usize`|The row of the terminal where the event happened.|
|`modifiers`|`Table`|A table containing the modifiers that were pressed, the entries are explained at [KeyEvent.modifiers]#keyeventmodifiers (This is the same table of the KeyEvent).|
|`location`|`Option<Table>`|A table containing the location of the mouse event, the entries are explained at [MouseEvent.location]#mouseeventlocation. This can be `nil` if the event is not on a specific component of the UI.|

#### MouseEvent.kind

The following values are possible for the `kind` field:

- `Down(Left)`
- `Down(Right)`
- `Down(Middle)`
- `Up(Left)`
- `Up(Right)`
- `Up(Middle)`
- `Drag(Left)`
- `Drag(Right)`
- `Drag(Middle)`
- `Moved`
- `ScrollDown`
- `ScrollUp`
- `ScrollLeft`
- `ScrollRight`

#### MouseEvent.location

This table contains the following fields:
| Field | Type | Description |
|-------|------|-------------|
|`info`|`Table`|A table containing info about the location of the mouse event, the entries are explained at [MouseEvent.location.info]#mouseeventlocationinfo.|
|`relative_location`|`Table`|A table containing the position of the event relative to the UI section (e.g. the offset from the top left corner of a popup when the popup window is clicked). The contents of this table are just `x` and `y` integer offsets from the top left corner of the container.|

##### MouseEvent.location.info

This table has different values depending on which component of the UI is involved with the event.
The table always contains the `type` key and depending on the corresponding value, it may contain other keys. These are the possible values for the `type` key and the corresponding additional keys:

- `"AddressView"`
  | Field | Type | Description |
  |-------|------|-------------|
  |`file_address`|`Option<u64>`|The file address pointed by the mouse during the event. `nil` if the event is not on an address.|
- `"HexView"`
  | Field | Type | Description |
  |-------|------|-------------|
  |`file_address`|`Option<u64>`|The file address of the byte pointed by the mouse during the event. `nil` if the event is not on a byte.|
  |`high`|`Option<bool>`|Whether the mouse is on the high or low half of the byte. `nil` if the event is not on a byte.|
  |`virtual_address`|`Option<u64>`|The virtual address of the byte pointed by the mouse during the event. `nil` if the event is not on a byte.|
  |`byte`|`Option<u8>`|The byte pointed by the mouse during the event. `nil` if the event is not on a byte.|
- `"TextView"`
  | Field | Type | Description |
  |-------|------|-------------|
  |`file_address`|`Option<u64>`|The file address of the character pointed by the mouse during the event. `nil` if the event is not on a character.|
  |`virtual_address`|`Option<u64>`|The virtual address of the character pointed by the mouse during the event. `nil` if the event is not on a character.|
  |`byte`|`Option<u8>`|The byte pointed by the mouse during the event. `nil` if the event is not on a character.|
  |`character`|`Option<char>`|The character pointed by the mouse during the event. `nil` if the event is not on a character or the byte is not a valid ASCII character.|
- `"AssemblyView"`
  | Field | Type | Description |
  |-------|------|-------------|
  |`section`|`Option<String>`|The section of the instruction pointed by the mouse during the event or the section pointed by the mouse during the event. `nil` if the event is not on an instruction nor on a section.|
  |`file_address`|`Option<u64>`|The file address of the instruction or section pointed by the mouse during the event. `nil` if the event is not on an instruction nor on a section.|
  |`virtual_address`|`Option<u64>`|The virtual address of the instruction or section pointed by the mouse during the event. `nil` if the event is not on an instruction nor on a section.|
  |`instruction`|`Option<String>`|The instruction pointed by the mouse during the event. `nil` if the event is not on an instruction.|
- `"StatusBar"`
- `"ScrollBar"`
- `"Popup"`
  | Field | Type | Description |
  |-------|------|-------------|
  |`name`|`String`|The name of the popup, possible names are listed below.|
  
  The possible names for popups are:

  - `"Open"`
  - `"Run"`
  - `"FindText"`
  - `"FindSymbol"`
  - `"Log"`
  - `"InsertText"`
  - `"Patch"`
  - `"JumpToAddress"`
  - `"QuitDirtySave"`
  - `"SaveAndQuit"`
  - `"SaveAs"`
  - `"Save"`
  - `"Help"`
  - `"Custom"`

### PopupContext

This table contains the following fields:
| Field | Type | Description |
|-------|------|-------------|
|`text`|`Text`|The content of the popup.|
|`title`|`MutString`|The title of the popup.|
|`height`|`MutUsize`|The height of the popup.|
|`width`|`MutUsize`|The width of the popup.|

### Text

To add text to a popup, use the following functions:
| Function | Arguments | Description |
|----------|-----------|-------------|
|`push_line`|`(line: String)`|Adds a line of text to the popup.|
|`push_span`|`(span: String)`|Adds text without a newline to the popup.|
|`set_style`|`(style: Style)`|Sets the style of the text, this will be applied to every line or span until another style is set or `reset_style` is used.|
|`reset_style`|`()`|Resets the style to the default one. If this function is not called before the end of the FILL_POPUP function, the previously set style will replace the default style for the popup.|
|`set_alignment`|`(alignment: String)`|Sets the alignment of the text, the possible values are `left`, `center` and `right`, this will be applied to every line until another alignment is set or `reset_alignment` is used.|
|`reset_alignment`|`()`|Resets the alignment to the default one. If this function is not called before the end of the FILL_POPUP function, the previously set alignment will replace the default alignment for the popup.|

### MutString

This type is a mutable string, it can be manipulated using the following functions:
| Function | Arguments | Description |
|----------|-----------|-------------|
|`get`|`() -> String`|Gets the string.|
|`set`|`(value: String)`|Sets the string.|

### MutUsize

This type is a mutable usize, it can be manipulated using the following functions:
| Function | Arguments | Description |
|----------|-----------|-------------|
|`get`|`() -> usize`|Gets the value.|
|`set`|`(value: usize)`|Sets the value.|

### InstructionInfo

This table contains the following fields:
| Field | Type | Description |
|-------|------|-------------|
|`instruction`|`String`|The line of assembly code, the format depends on the architecture.|
|`physical_address`|`u64`|The offset in the file where the instruction starts.|
|`virtual_address`|`u64`|The virtual address at which the instruction will be mapped.|
|`size`|`usize`|The size of the instruction in bytes.|

### Header

This type has the following fields:
| Field | Type | Description |
|-------|------|-------------|
|`bitness`|`u32`|The bitness of the file. (The default value is 64)|
|`entry_point`|`u64`|The virtual address of the entry point. (The default value is 0)|
|`architecture`|`String`|The architecture of the file, the possible values are listed in [Header.architecture]#headerarchitecture.|
|`sections`|`Vec<Section>`|The sections of the file, the vector is a lua vector. The Section type is explained at [Section]#section. (The default value is an empty vector.)|
|`text_section`|`Option<Section>`|The text section of the file. `nil` if not present. The Section type is explained at [Section]#section. (The default value is `nil`)|
|`symbols`|`Vec<String>`|The symbols of the file. (The default value is an empty vector.)|

And the following functions:
| Function | Arguments | Description |
|----------|-----------|-------------|
|`symbol_to_address`|`(symbol: String) -> Option<u64>`|Gets the virtual address of a symbol. `nil` if no such symbol is found.|
|`virtual_to_physical_address`|`(virtual_address: u64) -> Option<u64>`|Gets the file offset of a virtual address. `nil` if no section contains the virtual address specified.|

#### Header.architecture

The following values are possible for the `architecture` field:

- `Unknown` (default value)
- `Aarch64`
- `Aarch64_Ilp32`
- `Arm`
- `Avr`
- `Bpf`
- `Csky`
- `I386`
- `X86_64`
- `X86_64_X32`
- `Hexagon`
- `LoongArch64`
- `Mips`
- `Mips64`
- `Msp430`
- `PowerPc`
- `PowerPc64`
- `Riscv32`
- `Riscv64`
- `S390x`
- `Sbf`
- `Sharc`
- `Sparc64`
- `Wasm32`
- `Wasm64`
- `Xtensa`

### Section

This type has the following fields:
| Field | Type | Description |
|-------|------|-------------|
|`name`|`String`|The name of the section.|
|`virtual_address`|`u64`|The starting virtual address of the section.|
|`file_offset`|`u64`|The starting file offset of the section.|
|`size`|`usize`|The size of the section.|

### HeaderContext

This table contains the following fields:
| Function | Arguments | Description | Required |
|----------|-----------|-------------|----------|
|`set_bitness`|`(bitness: u8)`|Sets the bitness of the file. `bitness` must be either `32` or `64`| Yes |
|`set_entry`|`(entry_point: u64)`|Sets the virtual address of the entry point.| Yes |
|`set_endianness`|`(endianness: String)`|Sets the endianness of the file. `endianness` mut be either `little` or `big`.| Yes |
|`set_architecture`|`(architecture: String)`|Sets the architecture of the file. The possible values are listed in [Header.architecture]#headerarchitecture.| Yes |
|`add_section`|`(name: String, virtual_address: u64, file_offset: u64, size: u64)`|Adds a section to the file.| No |
|`add_symbol`|`(address: u64, name: String)`|Adds a symbol to the file.| No |

A function marked as required must be called to create a valid header. Those functions can only be called once.

### Style

This table contains the following fields:
| Field | Type | Description |
|-------|------|-------------|
|`fg`|`Option<Color>`|The foreground color. `nil` if transparent. The Color type is explained at [Color]#color.|
|`bg`|`Option<Color>`|The background color. `nil` if transparent. The Color type is explained at [Color]#color.|
|`underline`|`Option<Color>`|The underline color. `nil` if transparent. The Color type is explained at [Color]#color.|
|`add_modifier`|`u16`|A bitflag of the modifiers to add. The possible values are listed in [Style.modifier]#stylemodifier.|
|`sub_modifier`|`u16`|A bitflag of the modifiers to remove. The possible values are listed in [Style.modifier]#stylemodifier.|

### Style.modifier

The bitflags work as follows:
| Attribute | Bitflag |
|-----------|---------|
|`BOLD`|0b0000_0000_0001|
|`DIM`|0b0000_0000_0010|
|`ITALIC`|0b0000_0000_0100|
|`UNDERLINED`|0b0000_0000_1000|
|`SLOW_BLINK`|0b0000_0001_0000|
|`RAPID_BLINK`|0b0000_0010_0000|
|`REVERSED`|0b0000_0100_0000|
|`HIDDEN`|0b0000_1000_0000|
|`CROSSED_OUT`|0b0001_0000_0000|

### Color

This type is serialized and deserialized as a string.
The following values are possible:

- Standard colors:
  - `Black`
  - `Red`
  - `Green`
  - `Yellow`
  - `Blue`
  - `Magenta`
  - `Cyan`
  - `Gray` this is sometimes called `silver` or `white`, in this case `White` means bright white.
  - `DarkGray` this is sometimes called `light black` or `bright black`, in this case we use `DarkGray`
  - `LightRed`
  - `LightGreen`
  - `LightYellow`
  - `LightBlue`
  - `LightMagenta`
  - `LightCyan`
  - `White`
- Indexed 8-bit colors:
  - `#I` where I is an index from 0 to 255.
- RBG colors:
  - `#RRGGBB` where RR, GG and BB are hexadecimal values from 00 to FF.

### CustomSetting

A custom setting can be one of the following types:

- `bool`
- `i64`
- `f64`
- `String`
- `Style`
- `KeyEvent`

In the case of a `Style` or `KeyEvent`, the value is effectively a table with the same fields as the type.

### Instant

This type represents a point in time.

This type has the following functions:
| Function | Arguments | Description |
|----------|-----------|-------------|
|`elapsed`|`() -> f64`|Gets the time elapsed in seconds since the instant was created. This is a float so the precision should go up to nanoseconds.|