Commit 90b88c36 authored by Ticki's avatar Ticki

Update todo, and optimize

parent 6eb63e20
- [ ] Fix `d<motion>`
- [ ] Add 't' command
- [ ] Clear up `let` borrowck bypassers
- [ ] Make editor.pos method and use that instead of
- [ ] Add word navigation
Known bugs:
- [ ] When using `t` with a char that isn't in the document, Sodium will crash.
- [ ] `d<motion>` does not do anything if: 1) the motion moves to the end of a line. 2) if the motion moves to the last line.
......@@ -30,8 +30,8 @@ impl Editor {
/// Get the char under the cursor
#[inline]
pub fn current(&self) -> char {
let curs = self.cursor();
self.text[curs.y][curs.x]
let (x, y) = self.pos();
self.text[y][x]
}
/// Get the current cursor
......
......@@ -4,8 +4,7 @@ impl Editor {
/// Delete char
#[inline]
pub fn delete(&mut self) {
let y = self.y();
let x = self.x();
let (x, y) = self.pos();
if self.text[y].is_empty() {
if self.text.len() != 1 {
self.text.remove(y);
......
......@@ -37,7 +37,7 @@ impl Editor {
let mut editor = Editor {
current_cursor: 0,
cursors: Vec::new(),
cursors: vec![Cursor::new()],
text: VecDeque::new(),
scroll_x: 0,
scroll_y: 0,
......@@ -48,10 +48,10 @@ impl Editor {
options: Options::new(),
};
editor.cursors.push(Cursor::new());
editor.text.push_back(VecDeque::new());
editor.redraw();
loop {
let inp = editor.next_inst();
editor.exec(inp);
......
......@@ -69,6 +69,7 @@ Navigation:
- <numeral>g : Go to <numeral> line
- g<motion> : Do <motion>
- G : Go to the end of the document
- t<char> : Go to the next occurence of <char>
Cursor management:
- b : Branch the cursor
......@@ -143,6 +144,7 @@ stated.
line
- <numeral>g : Go to <numeral> line
- G : Go to the end of the document
- t<char> : Go to the next occurence of <char>
Tips'n'tricks
-------------
......
......@@ -23,8 +23,7 @@ pub struct InsertOptions {
impl Editor {
/// Insert text
pub fn insert(&mut self, k: Key, InsertOptions { mode: mode }: InsertOptions) {
let mut x = self.x();
let mut y = self.y();
let (mut x, mut y) = self.pos();
match mode {
InsertMode::Insert => match k {
Key::Char('\n') => {
......
......@@ -131,6 +131,5 @@ impl Editor {
}
}
unreachable!()
}
}
......@@ -14,7 +14,7 @@ impl Editor {
pub fn x(&self) -> usize {
self.pos().0
}
#[inline]
/// Y coordinate
pub fn y(&self) -> usize {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment