add 0/$ for sol/eol motions

This commit is contained in:
Josh Holtrop 2017-11-24 13:03:05 -05:00
parent 05f745d3f2
commit 56f7fa7127
3 changed files with 13 additions and 1 deletions

View File

@ -62,6 +62,8 @@ public:
FORWARD_ON_TO_CHAR, FORWARD_ON_TO_CHAR,
BACK_UP_TO_CHAR, BACK_UP_TO_CHAR,
BACK_ON_TO_CHAR, BACK_ON_TO_CHAR,
START_OF_LINE,
END_OF_LINE,
/* These motions aren't command-mode sequences but are used /* These motions aren't command-mode sequences but are used
* internally. */ * internally. */

View File

@ -13,6 +13,8 @@ void DefaultCommandMap::build()
motion_map->add("f", Command::Motion::FORWARD_ON_TO_CHAR, nullptr, true); motion_map->add("f", Command::Motion::FORWARD_ON_TO_CHAR, nullptr, true);
motion_map->add("T", Command::Motion::BACK_UP_TO_CHAR, nullptr, true); motion_map->add("T", Command::Motion::BACK_UP_TO_CHAR, nullptr, true);
motion_map->add("F", Command::Motion::BACK_ON_TO_CHAR, nullptr, true); motion_map->add("F", Command::Motion::BACK_ON_TO_CHAR, nullptr, true);
motion_map->add("0", Command::Motion::START_OF_LINE, nullptr, false);
motion_map->add("$", Command::Motion::END_OF_LINE, nullptr, false);
dcm->add("$", Command::GO_END_OF_LINE, nullptr, false); dcm->add("$", Command::GO_END_OF_LINE, nullptr, false);
dcm->add("0", Command::GO_START_OF_LINE, nullptr, false); dcm->add("0", Command::GO_START_OF_LINE, nullptr, false);

View File

@ -494,8 +494,8 @@ void BufferPane::change_motion(const Command::Unit & motion)
if (range) if (range)
{ {
m_buffer->push_operation(); m_buffer->push_operation();
m_buffer->erase_range(*range);
enter_insert_mode(Window::EnterInsertModeMode::START_OF_CHAR); enter_insert_mode(Window::EnterInsertModeMode::START_OF_CHAR);
m_buffer->erase_range(*range);
m_buffer->pop_operation(); m_buffer->pop_operation();
m_buffer_view->update(); m_buffer_view->update();
} }
@ -543,6 +543,14 @@ std::shared_ptr<Buffer::Range> BufferPane::get_range_for_motion(const Command::U
} }
break; break;
case Command::Motion::START_OF_LINE:
start->go_start_of_line();
break;
case Command::Motion::END_OF_LINE:
end->go_end_of_line(true);
break;
case Command::Motion::THIS_LINE: case Command::Motion::THIS_LINE:
start->go_start_of_line(); start->go_start_of_line();
end->go_end_of_line(!will_insert); end->go_end_of_line(!will_insert);