small software-rendered rust tty
| -rw-r--r-- | src/render.rs | 7 | ||||
| -rw-r--r-- | src/term.rs | 16 | ||||
| -rw-r--r-- | x | 62 |
3 files changed, 32 insertions, 53 deletions
diff --git a/src/render.rs b/src/render.rs index debe5e0..7b9578c 100644 --- a/src/render.rs +++ b/src/render.rs @@ -42,6 +42,13 @@ pub fn render( let x = Render::new(&[Source::Outline]) .format(Format::Alpha) + .embolden( + if (cell.style.flags & crate::term::BOLD) != 0 { + 0.5 + } else { + 0.0 + }, + ) .render( &mut ScaleContext::new() .builder(*FONT) diff --git a/src/term.rs b/src/term.rs index 9fa8e40..c978840 100644 --- a/src/term.rs +++ b/src/term.rs @@ -23,14 +23,14 @@ pub enum Mode { pub struct Style { pub bg: [u8; 3], pub color: [u8; 3], - pub style: u8, + pub flags: u8, } use crate::colors; impl std::default::Default for Style { fn default() -> Self { Self { bg: colors::BACKGROUND, - style: 0, + flags: 0, color: colors::FOREGROUND, } } @@ -114,6 +114,12 @@ impl Terminal { Reset => self.style = Style::default(), SetFg(c) => self.style.color = c, SetBg(c) => self.style.bg = c, + ModeSet(1) => self.style.flags |= BOLD, + ModeSet(2) => self.style.flags |= DIM, + ModeSet(3) => self.style.flags |= ITALIC, + ModeSet(4) => self.style.flags |= UNDERLINE, + ModeSet(9) => self.style.flags |= STRIKETHROUGH, + ModeSet(22) => self.style.flags &= !(BOLD | DIM), _ => {} } } @@ -202,6 +208,12 @@ enum StyleAction { SetFg([u8; 3]), SetBg([u8; 3]), } +pub const BOLD: u8 = 1; +pub const DIM: u8 = 1 << 1; +pub const ITALIC: u8 = 1 << 2; +pub const UNDERLINE: u8 = 1 << 3; +pub const STRIKETHROUGH: u8 = 1 << 4; + fn value<'a>( r: impl std::ops::RangeBounds<u16>, ) -> impl Parser<'a, &'a [u16], u16> { @@ -1,51 +1,11 @@ -[?2004h[os@klunk pattypan]$ cargo
-[?2004l
Rust's package manager
-
-[32m[1mUsage:[39m[22m [36m[1mcargo[39m[22m [36m[+toolchain] [OPTIONS] [COMMAND][39m
- [36m[1mcargo[39m[22m [36m[+toolchain] [OPTIONS][39m [36m[1m-Zscript[39m[22m [36m<MANIFEST_RS> [ARGS]...[39m
-
-[32m[1mOptions:[39m[22m
- [1m[36m-V[0m, [1m[36m--version[0m Print version info and exit
- [1m[36m--list[0m List installed commands
- [1m[36m--explain[0m[36m [0m[36m<CODE>[0m Provide a detailed explanation of a rustc error message
- [1m[36m-v[0m, [1m[36m--verbose[0m[36m...[0m Use verbose output (-vv very verbose/build.rs output)
- [1m[36m-q[0m, [1m[36m--quiet[0m Do not print cargo log messages
- [1m[36m--color[0m[36m [0m[36m<WHEN>[0m Coloring [possible values: auto, always, never]
- [1m[36m-C[0m[36m [0m[36m<DIRECTORY>[0m Change to DIRECTORY before doing anything (nightly-only)
- [1m[36m--locked[0m Assert that `Cargo.lock` will remain unchanged
- [1m[36m--offline[0m Run without accessing the network
- [1m[36m--frozen[0m Equivalent to specifying both --locked and --offline
- [1m[36m--config[0m[36m [0m[36m<KEY=VALUE|PATH>[0m Override a configuration value
- [1m[36m-Z[0m[36m [0m[36m<FLAG>[0m Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for
- details
- [1m[36m-h[0m, [1m[36m--help[0m Print help
-
-[32m[1mCommands:[39m[22m
- [36m[1mbuild[39m[22m, [36m[1mb[39m[22m Compile the current package
- [36m[1mcheck[39m[22m, [36m[1mc[39m[22m Analyze the current package and report errors, but don't build object files
- [36m[1mclean[39m[22m Remove the target directory
- [36m[1mdoc[39m[22m, [36m[1md[39m[22m Build this package's and its dependencies' documentation
- [36m[1mnew[39m[22m Create a new cargo package
- [36m[1minit[39m[22m Create a new cargo package in an existing directory
- [36m[1madd[39m[22m Add dependencies to a manifest file
- [36m[1mremove[39m[22m Remove dependencies from a manifest file
- [36m[1mrun[39m[22m, [36m[1mr[39m[22m Run a binary or example of the local package
- [36m[1mtest[39m[22m, [36m[1mt[39m[22m Run the tests
- [36m[1mbench[39m[22m Run the benchmarks
- [36m[1mupdate[39m[22m Update dependencies listed in Cargo.lock
- [36m[1msearch[39m[22m Search registry for crates
- [36m[1mpublish[39m[22m Package and upload this package to the registry
- [36m[1minstall[39m[22m Install a Rust binary
- [36m[1muninstall[39m[22m Uninstall a Rust binary
- [36m...[39m See all commands with [36m[1m--list[39m[22m
-
-See '[36m[1mcargo help[39m[22m [36m<command>[39m' for more information on a specific command.
-[?2004h[os@klunk pattypan]$
-[?2004l
[?2004h[os@klunk pattypan]$
-[?2004l
[?2004h[os@klunk pattypan]$
-[?2004l
[?2004h[os@klunk pattypan]$
-[?2004l
[?2004h[os@klunk pattypan]$
-[?2004l
[?2004h[os@klunk pattypan]$
-[?2004l
[?2004h[os@klunk pattypan]$
-[?2004l
[?2004h[os@klunk pattypan]$
-[?2004l
[?2004h[os@klunk pattypan]$
\ No newline at end of file +[?2004h[os@klunk pattypan]$ ls --color
+[?2004l
total 21M
+-rw-r--r-- 1 os 37K May 27 14:02 Cargo.lock
+-rw-r--r-- 1 os 517 May 27 14:02 Cargo.toml
+-rw-r--r-- 1 os 2.5M May 20 12:31 CascadiaCodeNF.ttf
+-rw-r--r-- 1 os 634K May 13 13:44 CascadiaCode.ttf
+-rw-r--r-- 1 os 18M May 22 11:58 cjk.ttc
+-rw-r--r-- 1 os 81 May 13 13:18 rustfmt.toml
+drwxr-xr-x 2 os 4.0K May 22 13:45 [0m[1;34msrc[0m
+-rw-r--r-- 1 os 50 May 29 11:55 x
+[?2004h[os@klunk pattypan]$
\ No newline at end of file |