small software-rendered rust tty
-rw-r--r--src/render.rs7
-rw-r--r--src/term.rs16
-rw-r--r--x62
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> {
diff --git a/x b/x
index b2fee96..0bf6875 100644
--- a/x
+++ b/x
@@ -1,51 +1,11 @@
-[?2004h[os@klunk pattypan]$ cargo
-[?2004l Rust's package manager
-
-Usage: cargo [+toolchain] [OPTIONS] [COMMAND]
- cargo [+toolchain] [OPTIONS] -Zscript <MANIFEST_RS> [ARGS]...
-
-Options:
- -V, --version Print version info and exit
- --list List installed commands
- --explain <CODE> Provide a detailed explanation of a rustc error message
- -v, --verbose... Use verbose output (-vv very verbose/build.rs output)
- -q, --quiet Do not print cargo log messages
- --color <WHEN> Coloring [possible values: auto, always, never]
- -C <DIRECTORY> Change to DIRECTORY before doing anything (nightly-only)
- --locked Assert that `Cargo.lock` will remain unchanged
- --offline Run without accessing the network
- --frozen Equivalent to specifying both --locked and --offline
- --config <KEY=VALUE|PATH> Override a configuration value
- -Z <FLAG> Unstable (nightly-only) flags to Cargo, see 'cargo -Z help' for
- details
- -h, --help Print help
-
-Commands:
- build, b Compile the current package
- check, c Analyze the current package and report errors, but don't build object files
- clean Remove the target directory
- doc, d Build this package's and its dependencies' documentation
- new Create a new cargo package
- init Create a new cargo package in an existing directory
- add Add dependencies to a manifest file
- remove Remove dependencies from a manifest file
- run, r Run a binary or example of the local package
- test, t Run the tests
- bench Run the benchmarks
- update Update dependencies listed in Cargo.lock
- search Search registry for crates
- publish Package and upload this package to the registry
- install Install a Rust binary
- uninstall Uninstall a Rust binary
- ... See all commands with --list
-
-See 'cargo help <command>' 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 src
+-rw-r--r-- 1 os 50 May 29 11:55 x
+[?2004h[os@klunk pattypan]$ \ No newline at end of file