Cleanup
This commit is contained in:
parent
1dba0f2b1c
commit
8098279676
|
@ -261,20 +261,11 @@ pub fn move_selection(
|
||||||
granularity: Granularity,
|
granularity: Granularity,
|
||||||
count: usize,
|
count: usize,
|
||||||
) -> Selection {
|
) -> Selection {
|
||||||
// TODO: move all selections according to normal cursor move semantics by collapsing it
|
// move all selections according to normal cursor move semantics by collapsing it
|
||||||
// into cursors and moving them vertically
|
// into cursors and moving them vertically
|
||||||
|
|
||||||
self.selection.transform(|range| {
|
self.selection.transform(|range| {
|
||||||
// let pos = if !range.is_empty() {
|
|
||||||
// // if selection already exists, bump it to the start or end of current select first
|
|
||||||
// if dir == Direction::Backward {
|
|
||||||
// range.from()
|
|
||||||
// } else {
|
|
||||||
// range.to()
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
let pos = self.move_pos(range.head, dir, granularity, count);
|
let pos = self.move_pos(range.head, dir, granularity, count);
|
||||||
// };
|
|
||||||
Range::new(pos, pos)
|
Range::new(pos, pos)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,12 +45,7 @@ pub fn new(doc: &Rope) -> Self {
|
||||||
/// In other words, If `this` goes `docA` → `docB` and `other` represents `docB` → `docC`, the
|
/// In other words, If `this` goes `docA` → `docB` and `other` represents `docB` → `docC`, the
|
||||||
/// returned value will represent the change `docA` → `docC`.
|
/// returned value will represent the change `docA` → `docC`.
|
||||||
pub fn compose(self, other: ChangeSet) -> Result<Self, ()> {
|
pub fn compose(self, other: ChangeSet) -> Result<Self, ()> {
|
||||||
// TODO: len before should match len after
|
// TODO: len before b should match len after a
|
||||||
|
|
||||||
// if self.len != other.len {
|
|
||||||
// // length mismatch
|
|
||||||
// return Err(());
|
|
||||||
// }
|
|
||||||
|
|
||||||
let len = self.changes.len();
|
let len = self.changes.len();
|
||||||
|
|
||||||
|
@ -335,9 +330,6 @@ pub fn map_pos(&self, pos: usize, assoc: Assoc) -> usize {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// trait Transaction
|
|
||||||
// trait StrictTransaction
|
|
||||||
|
|
||||||
/// Transaction represents a single undoable unit of changes. Several changes can be grouped into
|
/// Transaction represents a single undoable unit of changes. Several changes can be grouped into
|
||||||
/// a single transaction.
|
/// a single transaction.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
|
|
@ -52,7 +52,6 @@ pub fn new(mut args: Args) -> Result<Self, Error> {
|
||||||
size,
|
size,
|
||||||
surface: Surface::empty(area),
|
surface: Surface::empty(area),
|
||||||
cache: Surface::empty(area),
|
cache: Surface::empty(area),
|
||||||
// TODO; move to state
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(file) = args.values_of_t::<PathBuf>("files").unwrap().pop() {
|
if let Some(file) = args.values_of_t::<PathBuf>("files").unwrap().pop() {
|
||||||
|
@ -225,15 +224,7 @@ fn render(&mut self) {
|
||||||
// lavender
|
// lavender
|
||||||
}
|
}
|
||||||
|
|
||||||
// let lines = state
|
|
||||||
// .doc
|
|
||||||
// .lines_at(self.first_line as usize)
|
|
||||||
// .take(self.size.1 as usize)
|
|
||||||
// .map(|x| x.as_str().unwrap());
|
|
||||||
|
|
||||||
// // iterate over selections and render them
|
// // iterate over selections and render them
|
||||||
// let select = Style::default().bg(tui::style::Color::LightBlue);
|
|
||||||
// let text = state.doc.slice(..);
|
|
||||||
// for range in state.selection.ranges() {
|
// for range in state.selection.ranges() {
|
||||||
// // get terminal coords for x,y for each range pos
|
// // get terminal coords for x,y for each range pos
|
||||||
// // TODO: this won't work with multiline
|
// // TODO: this won't work with multiline
|
||||||
|
@ -246,8 +237,6 @@ fn render(&mut self) {
|
||||||
// (y2 - y1 + 1) as u16,
|
// (y2 - y1 + 1) as u16,
|
||||||
// );
|
// );
|
||||||
// self.surface.set_style(area, select);
|
// self.surface.set_style(area, select);
|
||||||
|
|
||||||
// // TODO: don't highlight next char in append mode
|
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// statusline
|
// statusline
|
||||||
|
@ -330,13 +319,13 @@ pub async fn event_loop(&mut self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(Ok(Event::Key(event))) => {
|
Some(Ok(Event::Key(event))) => {
|
||||||
|
// TODO: sequences (`gg`)
|
||||||
|
// TODO: handle count other than 1
|
||||||
if let Some(view) = &mut self.view {
|
if let Some(view) = &mut self.view {
|
||||||
match view.state.mode() {
|
match view.state.mode() {
|
||||||
Mode::Insert => {
|
Mode::Insert => {
|
||||||
// TODO: handle modes and sequences (`gg`)
|
|
||||||
let keys = vec![event];
|
let keys = vec![event];
|
||||||
if let Some(command) = keymap[&Mode::Insert].get(&keys) {
|
if let Some(command) = keymap[&Mode::Insert].get(&keys) {
|
||||||
// TODO: handle count other than 1
|
|
||||||
command(view, 1);
|
command(view, 1);
|
||||||
} else if let KeyEvent {
|
} else if let KeyEvent {
|
||||||
code: KeyCode::Char(c),
|
code: KeyCode::Char(c),
|
||||||
|
@ -350,10 +339,8 @@ pub async fn event_loop(&mut self) {
|
||||||
self.render();
|
self.render();
|
||||||
}
|
}
|
||||||
Mode::Normal => {
|
Mode::Normal => {
|
||||||
// TODO: handle modes and sequences (`gg`)
|
|
||||||
let keys = vec![event];
|
let keys = vec![event];
|
||||||
if let Some(command) = keymap[&Mode::Normal].get(&keys) {
|
if let Some(command) = keymap[&Mode::Normal].get(&keys) {
|
||||||
// TODO: handle count other than 1
|
|
||||||
command(view, 1);
|
command(view, 1);
|
||||||
|
|
||||||
// TODO: simplistic ensure cursor in view for now
|
// TODO: simplistic ensure cursor in view for now
|
||||||
|
|
|
@ -25,7 +25,7 @@ pub fn open(path: PathBuf, size: (u16, u16)) -> Result<Self, Error> {
|
||||||
let view = Self {
|
let view = Self {
|
||||||
state,
|
state,
|
||||||
first_line: 0,
|
first_line: 0,
|
||||||
size, // TODO: pass in from term
|
size,
|
||||||
theme,
|
theme,
|
||||||
history: History::default(),
|
history: History::default(),
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue