fixed some bugs in c versiosn

This commit is contained in:
FantasyPvP
2024-11-05 09:32:36 +00:00
parent 83a71ae0a1
commit b40ecc5bb1
9 changed files with 136 additions and 76 deletions
+12 -2
View File
@@ -7,6 +7,16 @@ use std::{
io::Write,
};
fn somefunc() {
let c = "hello";
println!("{}", c);
let c2 = String::from("hello world");
}
struct EditorData {
buffer: Vec<Vec<char>>, // outer vec is the line, inner is col;
file_line: i32,
@@ -92,14 +102,14 @@ impl EditorData {
/// Insert a character at the cursor,
/// then update the cursor position.
fn addchar(&mut self, c: char) {
ncurses::insch(keystroke as u32);
ncurses::insch(c as u32);
if let Some(line) = self.buffer.get_mut(self.screen_line as usize) {
line.insert(self.screen_col as usize, c);
} else {
self.buffer.push(Vec::new());
self.buffer.get_mut(self.screen_line as usize).unwrap().push(c);
}
data.mv_cursor(0, 1);
self.mv_cursor(0, 1);
}
}