small software-rendered rust tty
| -rw-r--r-- | src/render.rs | 21 | ||||
| -rw-r--r-- | x | 16 |
2 files changed, 21 insertions, 16 deletions
diff --git a/src/render.rs b/src/render.rs index ca31270..1f86493 100644 --- a/src/render.rs +++ b/src/render.rs @@ -37,6 +37,20 @@ pub fn render( ) }; } + let mut color = cell.style.color; + if (cell.style.flags & crate::term::DIM) != 0 { + color = color.map(|x| x / 2); + } + if (cell.style.flags & crate::term::UNDERLINE) != 0 { + unsafe { + i.as_mut().overlay_at( + &Image::<_, 4>::build(sz.ceil() as u32, 2) + .fill(color.join(255)), + 4 + (j as f32 * sz) as u32, + (k as f32 * (ppem * 1.25)) as u32 + 5, + ) + }; + } if let Some(l) = cell.letter { let f = if (cell.style.flags & crate::term::ITALIC) != 0 { *IFONT @@ -67,10 +81,7 @@ pub fn render( if x.placement.width == 0 { continue; } - let mut c = cell.style.color; - if (cell.style.flags & crate::term::DIM) != 0 { - c = c.map(|x| x / 2); - } + let item = Image::<_, 4>::build( x.placement.width, x.placement.height, @@ -78,7 +89,7 @@ pub fn render( .buf( x.data .iter() - .flat_map(|&x| c.join(x)) + .flat_map(|&x| color.join(x)) .collect::<Vec<u8>>(), ); @@ -1,11 +1,5 @@ -[?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 +[?2004h[os@klunk pattypan]$ echo -e '\x1b[2;4;34m ya'
+[?2004l
[2;4;34m ya
+[?2004h[os@klunk pattypan]$ i guess that works.
+[?2004l
bash: i: command not found
+[?2004h[os@klunk pattypan]$ �
\ No newline at end of file |