Compare commits
2 Commits
06c60f51c9
...
70a2e9a729
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
70a2e9a729 | ||
|
|
b51d2a4f12 |
BIN
fonts/Miracode.ttf
Normal file
BIN
fonts/Miracode.ttf
Normal file
Binary file not shown.
20
src/main.rs
20
src/main.rs
@@ -15,9 +15,7 @@ use vte::{Params, Parser, Perform};
|
||||
|
||||
use zeno::{Mask, Transform};
|
||||
|
||||
// params
|
||||
const SHELL: &str = "/home/andromeda/.nix-profile/bin/sh";
|
||||
const FONT: &str = "/home/andromeda/.nix-profile/share/fonts/truetype/Miracode.ttf";
|
||||
const FONT: &[u8] = std::include_bytes!("../fonts/Miracode.ttf");
|
||||
|
||||
struct Buffer<T: std::clone::Clone> {
|
||||
buffer: Vec<T>,
|
||||
@@ -160,8 +158,7 @@ impl OutlineBuilder for Builder {
|
||||
|
||||
fn main() {
|
||||
// initialize the font
|
||||
let font_data = std::fs::read(FONT).unwrap();
|
||||
let face = Face::parse(&font_data, 0).unwrap();
|
||||
let face = Face::parse(FONT, 0).unwrap();
|
||||
let font = generate_font(&face);
|
||||
|
||||
let mut model = Model::new(
|
||||
@@ -186,7 +183,7 @@ fn main() {
|
||||
.unwrap();
|
||||
window.set_target_fps(60);
|
||||
|
||||
let pty = spawn_pty(&SHELL).unwrap();
|
||||
let pty = spawn_pty().unwrap();
|
||||
fcntl(
|
||||
&pty,
|
||||
F_SETFL(OFlag::from_bits_truncate(fcntl(&pty, F_GETFL).unwrap()) | OFlag::O_NONBLOCK),
|
||||
@@ -257,7 +254,7 @@ fn main() {
|
||||
}
|
||||
|
||||
// forks a new pty and returns file descriptor of the master
|
||||
fn spawn_pty(shell: &str) -> Option<PtyMaster> {
|
||||
fn spawn_pty() -> Option<PtyMaster> {
|
||||
// SAFETY safe unless os out of PTYs; incredibly unlikely
|
||||
match unsafe { forkpty(None, None) } {
|
||||
Ok(fork_pty_res) => match fork_pty_res {
|
||||
@@ -266,7 +263,14 @@ fn spawn_pty(shell: &str) -> Option<PtyMaster> {
|
||||
return Some(unsafe { PtyMaster::from_owned_fd(master) });
|
||||
}
|
||||
ForkptyResult::Child => {
|
||||
let _ = execv::<CString>(&CString::new(shell).unwrap(), &[]);
|
||||
let _ = execv::<CString>(
|
||||
&CString::new("/usr/bin/env").unwrap(),
|
||||
&[ CString::new("/usr/bin/env").unwrap(),
|
||||
CString::new("-i").unwrap(),
|
||||
CString::new("sh").unwrap(),
|
||||
CString::new("--norc").unwrap(),
|
||||
CString::new("--noprofile").unwrap() ],
|
||||
);
|
||||
return None;
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user