From 56f7fa712791b585960bdc0bfc1c0d7e01d65467 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Fri, 24 Nov 2017 13:03:05 -0500 Subject: [PATCH] add 0/$ for sol/eol motions --- src/core/Command.h | 2 ++ src/core/DefaultCommandMap.cc | 2 ++ src/gui/BufferPane.cc | 10 +++++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/core/Command.h b/src/core/Command.h index 5d4ff6c..1e0b880 100644 --- a/src/core/Command.h +++ b/src/core/Command.h @@ -62,6 +62,8 @@ public: FORWARD_ON_TO_CHAR, BACK_UP_TO_CHAR, BACK_ON_TO_CHAR, + START_OF_LINE, + END_OF_LINE, /* These motions aren't command-mode sequences but are used * internally. */ diff --git a/src/core/DefaultCommandMap.cc b/src/core/DefaultCommandMap.cc index c3e964c..23367df 100644 --- a/src/core/DefaultCommandMap.cc +++ b/src/core/DefaultCommandMap.cc @@ -13,6 +13,8 @@ void DefaultCommandMap::build() 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("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("0", Command::GO_START_OF_LINE, nullptr, false); diff --git a/src/gui/BufferPane.cc b/src/gui/BufferPane.cc index 7c80361..0662a28 100644 --- a/src/gui/BufferPane.cc +++ b/src/gui/BufferPane.cc @@ -494,8 +494,8 @@ void BufferPane::change_motion(const Command::Unit & motion) if (range) { m_buffer->push_operation(); - m_buffer->erase_range(*range); enter_insert_mode(Window::EnterInsertModeMode::START_OF_CHAR); + m_buffer->erase_range(*range); m_buffer->pop_operation(); m_buffer_view->update(); } @@ -543,6 +543,14 @@ std::shared_ptr BufferPane::get_range_for_motion(const Command::U } 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: start->go_start_of_line(); end->go_end_of_line(!will_insert);