diff options
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 39 |
1 files changed, 38 insertions, 1 deletions
@@ -8,7 +8,7 @@ use std::collections::HashMap; use std::ffi::OsStr; use std::fs::{self, File}; -use std::io::{self, Read, Write}; +use std::io::{self, BufRead, Read, Write}; use std::os::unix::ffi::OsStrExt; use std::os::unix::io::AsRawFd; use std::path::Path; @@ -35,6 +35,7 @@ pub mod rw; pub mod serialization; pub mod wait; +use libc::BS0; use linebuf::LineBuf; use raw::*; @@ -545,3 +546,39 @@ pub fn event_loop() { session.lock().unwrap().raw_disable(); } + +pub fn icon() -> BString { + const DATA: &[u8] = include_bytes!("icon.txt"); + const COLOR0: &[u8] = b"\x1b[100m"; + const COLOR1: &[u8] = b"\x1b[47m"; + const COLOR_RESET: &[u8] = b"\x1b[0m"; + let mut color = COLOR0; + let mut buf = BString::new(); + + for line in DATA.split(|x| *x == b'\n') { + if line.starts_with(b"-") { + color = COLOR1; + continue; + } + + let mut colored = false; + for &b in line { + if b == b'#' { + if !colored { + buf.push_all(color); + colored = true; + } + } else if colored { + buf.push_all(COLOR_RESET); + colored = false; + } + buf.push_all(b" "); + } + if colored { + buf.push_all(COLOR_RESET); + } + buf.push_all(b"\r\n"); + } + + buf +} |
