Repository navigation
Improve public rustdocs #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
the-mikedavis
merged 3 commits into
helix-editor:master
from
joshka:joshka/improve-rustdocs
May 30, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,70 @@ | ||
| //! ANSI escape sequences. | ||
|
|
||
| // CREDIT: this tree of modules is mostly yanked from the equivalents in TermWiz with some | ||
| // stylistic edits and additions/subtractions of some escape sequences. | ||
| //! Typed ANSI escape-sequence helpers. | ||
| //! | ||
| //! Termina models Control Sequence Introducer (CSI), Device Control String (DCS), and Operating | ||
| //! System Command (OSC) sequences it knows how to emit so callers can compose terminal control | ||
| //! payloads through [`Display`] instead of hand-written byte strings. | ||
| //! | ||
| //! # Examples | ||
| //! | ||
| //! ``` | ||
| //! use termina::{ | ||
| //! escape::{ | ||
| //! csi::{Csi, Cursor}, | ||
| //! CSI, | ||
| //! }, | ||
| //! OneBased, | ||
| //! }; | ||
| //! | ||
| //! let cursor_home = Csi::Cursor(Cursor::Position { | ||
| //! line: OneBased::new(1).unwrap(), | ||
| //! col: OneBased::new(1).unwrap(), | ||
| //! }); | ||
| //! | ||
| //! assert_eq!(cursor_home.to_string(), format!("{CSI}1;1H")); | ||
| //! ``` | ||
| //! | ||
| //! # Implementation Notes | ||
| //! | ||
| //! This module tree is adapted from [termwiz escape helpers]. It was originally yanked from TermWiz | ||
| //! equivalents and then trimmed into the set of escape sequences Termina needs. Most differences | ||
| //! are stylistic edits plus additions and subtractions in the modeled sequence set. | ||
| //! | ||
| //! [termwiz escape helpers]: https://docs.rs/termwiz/latest/termwiz/escape/index.html | ||
| //! [`Display`]: std::fmt::Display | ||
|
|
||
| pub mod csi; | ||
| pub mod dcs; | ||
| pub mod osc; | ||
|
|
||
| // Originally yanked from <https://github.com/wezterm/wezterm/blob/a87358516004a652ad840bc1661bdf65ffc89b43/term/src/lib.rs#L131-L135> | ||
| /// Control Sequence Introducer (`ESC [`), the prefix for parameterized terminal control functions. | ||
| /// | ||
| /// CSI sequences carry numeric parameters and a final byte. Termina models the supported CSI | ||
| /// families in [`csi::Csi`]. | ||
| pub const CSI: &str = "\x1b["; | ||
|
|
||
| /// Operating System Command introducer (`ESC ]`), used for terminal integration commands. | ||
| /// | ||
| /// OSC sequences are commonly used for window titles, clipboard integration, and color queries. | ||
| /// Termina models the supported commands in [`osc::Osc`]. | ||
| pub const OSC: &str = "\x1b]"; | ||
|
|
||
| /// String Terminator (`ESC \`), used to end OSC and DCS string controls. | ||
| /// | ||
| /// Most modern terminal string controls may also be terminated by [`BEL`], but Termina emits the | ||
| /// explicit string terminator form for the sequences it formats. | ||
| pub const ST: &str = "\x1b\\"; | ||
|
|
||
| /// Single Shift 3 (`ESC O`), the prefix used by SS3 key sequences. | ||
| /// | ||
| /// Application-keypad and function-key encodings commonly use this prefix instead of [`CSI`]. | ||
| pub const SS3: &str = "\x1bO"; | ||
|
|
||
| /// Device Control String introducer (`ESC P`), used for structured terminal queries. | ||
| /// | ||
| /// Termina models the supported request and response forms in [`dcs::Dcs`]. | ||
| pub const DCS: &str = "\x1bP"; | ||
|
|
||
| /// Bell control character (`BEL`, `0x07`). | ||
| /// | ||
| /// BEL can ring the terminal bell and is also accepted by many terminals as an OSC terminator. | ||
| pub const BEL: &str = "\x07"; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This got reformatted by markdown lint. I usually use 100 char lines and align tables. Hope that's ok here. It generally edits easier that way. (Easier diffs in github etc.). Happy to revert that part as I know it's fairly subjective choice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yeah I'd prefer to keep the style of the README mostly unchanged. I like to avoid hard wrapping in markdown. Making the table slimmer seems alright though, it's very wide right now. Maybe we can say "terminal dependent" and have a footnote or cross/star symbol that says that it depends on Kitty keyboard support below the table.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 05b5fe7