Implement X command

This commit is contained in:
Josh Holtrop 2017-11-15 21:05:12 -05:00
parent bb5bf6a13a
commit c77be4c482
3 changed files with 16 additions and 3 deletions

View File

@ -325,7 +325,7 @@ void BufferPane::insert_code_point(uint32_t code_point)
}
}
void BufferPane::kill_character_at_cursor()
void BufferPane::kill_character_forward()
{
if (**m_iterator != '\n')
{
@ -339,6 +339,17 @@ void BufferPane::kill_character_at_cursor()
}
}
void BufferPane::kill_character_backward()
{
Buffer::Iterator it = *m_iterator;
if (it.go_left_in_line())
{
m_buffer->erase_code_point(it);
m_buffer_view->update();
m_window->request_redraw();
}
}
size_t BufferPane::display_column() const
{
if (!m_iterator->valid())

View File

@ -35,7 +35,8 @@ public:
void enter_insert_mode(Window::EnterInsertModeMode which);
void insert_code_point(uint32_t code_point);
void exit_insert_mode();
void kill_character_at_cursor();
void kill_character_forward();
void kill_character_backward();
bool insert_mode() const { return m_buffer->insert_mode(); }
void scroll_window_up(Window::ScrollMode scroll_mode);
void scroll_window_down(Window::ScrollMode scroll_mode);

View File

@ -340,9 +340,10 @@ void Window::execute_command(const Command & command)
case Command::DELETE_LINE:
break;
case Command::DELETE_CHAR:
m_focused_buffer_pane->kill_character_at_cursor();
m_focused_buffer_pane->kill_character_forward();
break;
case Command::DELETE_CHAR_BACK:
m_focused_buffer_pane->kill_character_backward();
break;
case Command::CHANGE_MOTION:
break;