aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorRose Hogenson <rosehogenson@posteo.net>2023-12-27 10:32:06 -0800
committerRose Hogenson <rosehogenson@posteo.net>2023-12-27 10:32:06 -0800
commit38955a421bbf80ea0c2291c3a7b0a5f4034e8077 (patch)
treebcba966c6245cbc15abf420415a005132d7c3e33 /src/main.rs
parentPut the terminal in raw mode. (diff)
downloadeditor-38955a421bbf80ea0c2291c3a7b0a5f4034e8077.tar.zst
Print each line separately.
Now that the terminal is in raw mode, we need to also include \r after each line.
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 63ae538..79bff16 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -3,6 +3,7 @@ mod term;
use rope::Rope;
use std::ffi::{OsStr, OsString};
+use std::io::Write;
use std::path::Path;
fn edit(file: &OsStr) -> Result<(), String> {
@@ -21,8 +22,9 @@ fn edit(file: &OsStr) -> Result<(), String> {
}
};
let mut stdout = std::io::stdout();
- if let Err(err) = r.print_lines(&mut stdout, 0, usize::from(size.ws_row)) {
- return Err(format!("write: {}", err));
+ for i in 0..usize::from(size.ws_row) {
+ let _ = r.print_line(&mut stdout, i);
+ let _ = stdout.write(b"\r\n");
}
return Ok(());
}