Skip to content
Draft
Changes from 5 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
7aca316
Terminal I/O.
sunfishcode Feb 8, 2025
27fd0c1
Update wit-0.3.0-draft/terminal.wit
sunfishcode Feb 8, 2025
13ab8d5
Fill in the current TODO comments.
sunfishcode Feb 8, 2025
bb41d10
Better handling of input control codes.
sunfishcode Feb 9, 2025
cd345f6
Fix handling of U+D in non-immediate mode.
sunfishcode Feb 9, 2025
b2c66d4
Add a TODO about bare Escapes and stream lulls.
sunfishcode Feb 9, 2025
e13b66e
Say more about terminal settings.
sunfishcode Feb 9, 2025
1c73e9e
Give an example of a control key.
sunfishcode Feb 9, 2025
9fc6912
Elaborate on SGR syntax.
sunfishcode Feb 9, 2025
0cc5d84
Define Shift-Tab for input.
sunfishcode Feb 9, 2025
1db49ce
Put emphasis on mode names.
sunfishcode Feb 9, 2025
a80d9b9
Notify applications of resumptions in addition to size changes.
sunfishcode Feb 9, 2025
c150e79
Fix the name of the `color-desired-by-default` variable.
sunfishcode Feb 9, 2025
c4d72d7
fixup for mod<F5>es
sunfishcode Feb 9, 2025
d505a24
Fix the terminfo/termcap names for parameterized cursor movement.
sunfishcode Feb 9, 2025
ab17d03
Specify the default modes for input.
sunfishcode Feb 9, 2025
78f0bba
Clarify interpretations of ASCII names.
sunfishcode Feb 9, 2025
b8a0cb7
Say more about output settings.
sunfishcode Feb 9, 2025
020eeb7
Simplify the refresh key, and fix formatting.
sunfishcode Feb 9, 2025
a2e16d6
Support Bold, Faint, reset, and paste and invisible cursors in more m…
sunfishcode Feb 9, 2025
5530ddb
Add a note about `window-columns`.
sunfishcode Feb 9, 2025
5ca74cd
Add an attribute for the terminal's default colors.
sunfishcode Feb 9, 2025
7826668
Document the state on entry to full-screen mode.
sunfishcode Feb 9, 2025
a14f18b
Update wit-0.3.0-draft/terminal.wit
sunfishcode Feb 10, 2025
78b914e
More reorganization. Add more control codes for output in all modes.
sunfishcode Feb 10, 2025
ba8694d
Add reverse video.
sunfishcode Feb 10, 2025
ffe05de
Fix the terminfo name of End Paste.
sunfishcode Feb 10, 2025
37388d6
Iterate on wording.
sunfishcode Feb 10, 2025
02905b7
Don't trap on invalid output.
sunfishcode Feb 10, 2025
2a76ee6
Remove "may assign other meanings to other control codes".
sunfishcode Feb 10, 2025
e0ffa21
Add a TODO for some things that aren't described yet.
sunfishcode Feb 10, 2025
b6c1539
Describe the behavior of U+8 and U+9 more.
sunfishcode Feb 10, 2025
37522b6
Add support for light mode and dark mode.
sunfishcode Mar 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 37 additions & 6 deletions wit-0.3.0-draft/terminal.wit
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ interface terminal-input {
///
/// | Code | Meaning | terminfo | ti | tc |
/// | ---- | ------------------------------------------------------------ | --------- | ----- | -- |
/// | U+C | Request to refresh the screen | key_refresh krfr | &2 |
/// | U+C | Refresh the screen | key_refresh | krfr | &2 |
/// | U+1B | Escape | \* | \* | \* |
///
/// TODO: Should we say that, in immediate mode, every sequence is followed
Expand Down Expand Up @@ -189,8 +189,34 @@ interface terminal-output {
/// apply other output translations; output is recommended to
/// support lowercase (`stty -olcuc`).
///
/// The following control codes and escape sequences are defined for
/// terminal output:
///
/// | Sequence | Meaning | terminfo | ti | tc |
/// | -------- | ---------------------------------------------------- | --------- | ----- | -- |
/// | `␛[?25l` | Set the cursor as invisible | cursor_invisible | civis | vi |
/// | `␛[?25h` | Set the cursor as visible | cursor_visible | cvvis | vs |
/// | `␛[?2004h` | Begin *bracketed paste mode* | BE | BE | \* |
/// | `␛[?2004l` | End bracketed paste mode | BD | BD | \* |
/// | `␛[«attrs»m` | Set terminal attributes | set_attributes | sgr | sa |
///
/// `«attrs»` is a semicolon-separated list of decimal-formatted integer
/// values from the following list, identifying attributes:
///
/// | Attribute | Meaning |
/// | -------- | ------- |
/// | `0` | Reset all attributes to default settings |
/// | `1` | Bold |
/// | `2` | Faint |
///
/// An empty list also resets all attributes to default settings. This
/// includes reseting the colors to defaults, if colors are supported.
///
/// (Additional attributes for color are defined in the documentation for the `color`
/// function.)
///
/// By default, terminals are not in full-screen mode or bracketed paste
/// mode.
/// mode, the cursor is visible, and all attributes are set to defaults.
@since(version = 0.3.0)
resource terminal-output {
/// Return the current number of rows and columns in the terminal.
Expand All @@ -203,6 +229,8 @@ interface terminal-output {
///
/// Not all terminals have a set size, and not all that do know their
/// size, so this function may fail if the size cannot be determined.
/// This function may succeed when `window-size` fails, as the terminal
/// width may sometimes be known even when the height is not.
window-columns: func() -> result<u16>;

/// Return a `stream` listening for window size changes.
Expand Down Expand Up @@ -244,6 +272,7 @@ interface terminal-output {
/// | `35` | `45` | Magenta |
/// | `36` | `46` | Cyan |
/// | `37` | `47` | White |
/// | `39` | `49` | Default (terminal's choice) |
/// | `90` | `100` | Bright Black (Gray) |
/// | `91` | `101` | Bright Red |
/// | `92` | `102` | Bright Green |
Expand All @@ -253,6 +282,8 @@ interface terminal-output {
/// | `96` | `106` | Bright Cyan |
/// | `97` | `107` | Bright White |
///
/// As always, an empty list resets all attributes to default settings.
///
/// The following additional escape sequences are defined in
/// implementations which declare `truecolor` color support:
///
Expand Down Expand Up @@ -307,6 +338,10 @@ interface terminal-output {
/// reflects the functionality commonly used for interactive terminal
/// user interfaces.
///
/// When full-screen mode is entered, the contents of the screen are
/// saved and the screen is cleared. When exiting full-screen mode,
/// the saved contents are restored.
///
/// The following additional control codes and escape sequences are
/// defined in implementations which declare full-screen support:
///
Expand All @@ -332,12 +367,8 @@ interface terminal-output {
/// | `␛[2J` | Clear the whole screen | clear_screen | clear | cl |
/// | `␛[«n»d` | Move the cursor to row `«n»` | row_address | vpa | cv |
/// | `␛[«row»;«column»f` | Move the cursor to row `«row»` and column `«column»` | cursor_address | cup | cm |
/// | `␛[?25h` | Set the cursor as visible | cursor_visible | cvvis | vs |
/// | `␛[?1049h` | Clear the screen and reset full-screen settings to defaults | enter_ca_mode | smcup | ti |
/// | `␛[?2004h` | Begin *bracketed paste mode* | BE | BE | \* |
/// | `␛[?25l` | Set the cursor as invisible | cursor_invisible | civis | vi |
/// | `␛[?1049l` | Exit full-screen mode and restore the terminal to its prior state | exit_ca_mode | rmcup | te |
/// | `␛[?2004l` | End bracketed paste mode | BD | BD | \* |
/// | `␛[!p` | Reset the terminal to default settings, without clearing the screen | \* | \* | \* |
full-screen-supported: func() -> bool;
}
Expand Down