fixed some bugs in c versiosn
This commit is contained in:
+12
-2
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user