Add left/right cursor mvments to execute bar
parent
c88d1cae51
commit
44da24fc96
|
@ -814,7 +814,7 @@ impl StatusBar {
|
||||||
|
|
||||||
fn draw_execute_bar(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
|
fn draw_execute_bar(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context) {
|
||||||
clear_area(grid, area, crate::conf::value(context, "theme_default"));
|
clear_area(grid, area, crate::conf::value(context, "theme_default"));
|
||||||
let (x, y) = write_string_to_grid(
|
let (_, y) = write_string_to_grid(
|
||||||
self.ex_buffer.as_str(),
|
self.ex_buffer.as_str(),
|
||||||
grid,
|
grid,
|
||||||
Color::Byte(219),
|
Color::Byte(219),
|
||||||
|
@ -823,7 +823,12 @@ impl StatusBar {
|
||||||
area,
|
area,
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
grid[(x, y)].set_attrs(Attr::Underline);
|
if let Some(ref mut cell) = grid.get_mut(
|
||||||
|
pos_inc(upper_left!(area), (self.ex_buffer.cursor(), 0)).0,
|
||||||
|
y,
|
||||||
|
) {
|
||||||
|
cell.set_attrs(Attr::Underline);
|
||||||
|
}
|
||||||
change_colors(grid, area, Color::Byte(219), Color::Byte(88));
|
change_colors(grid, area, Color::Byte(219), Color::Byte(88));
|
||||||
context.dirty_areas.push_back(area);
|
context.dirty_areas.push_back(area);
|
||||||
}
|
}
|
||||||
|
@ -1154,6 +1159,26 @@ impl Component for StatusBar {
|
||||||
self.auto_complete.inc_cursor();
|
self.auto_complete.inc_cursor();
|
||||||
self.dirty = true;
|
self.dirty = true;
|
||||||
}
|
}
|
||||||
|
UIEvent::ExInput(Key::Left) => {
|
||||||
|
if let Field::Text(ref mut utext, _) = self.ex_buffer {
|
||||||
|
utext.cursor_dec();
|
||||||
|
} else {
|
||||||
|
unsafe {
|
||||||
|
std::hint::unreachable_unchecked();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.dirty = true;
|
||||||
|
}
|
||||||
|
UIEvent::ExInput(Key::Right) => {
|
||||||
|
if let Field::Text(ref mut utext, _) = self.ex_buffer {
|
||||||
|
utext.cursor_inc();
|
||||||
|
} else {
|
||||||
|
unsafe {
|
||||||
|
std::hint::unreachable_unchecked();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.dirty = true;
|
||||||
|
}
|
||||||
UIEvent::ExInput(Key::Ctrl('p')) => {
|
UIEvent::ExInput(Key::Ctrl('p')) => {
|
||||||
let pos = self.ex_buffer_cmd_history_pos.map(|p| p + 1).unwrap_or(0);
|
let pos = self.ex_buffer_cmd_history_pos.map(|p| p + 1).unwrap_or(0);
|
||||||
let pos = Some(std::cmp::min(pos, self.cmd_history.len().saturating_sub(1)));
|
let pos = Some(std::cmp::min(pos, self.cmd_history.len().saturating_sub(1)));
|
||||||
|
|
|
@ -74,6 +74,14 @@ impl Field {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn cursor(&self) -> usize {
|
||||||
|
match self {
|
||||||
|
Text(ref s, _) => s.grapheme_pos(),
|
||||||
|
Choice(_, ref cursor) => *cursor,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn is_empty(&self) -> bool {
|
pub fn is_empty(&self) -> bool {
|
||||||
self.as_str().is_empty()
|
self.as_str().is_empty()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue