add Ctrl+Home and Ctrl+End command-mode mappings

This commit is contained in:
josh committed 2018-01-03 17:05:16 -05:00
1 parent 154db8dab3
commit 0d9d160464
6 files changed
+54 -1

No files matched your search

+18
View File
@@ -131,6 +131,7 @@ bool BufferView::cursor_move(CursorMovement which, uint32_t c, bool allow_eol)
m_target_screen_column = INT_MAX;
m_target_virtual_column = INT_MAX;
break;
case CursorMovement::START_OF_FILE:
case CursorMovement::FIRST_LINE:
{
auto it = m_buffer->begin();
@@ -143,6 +144,21 @@ bool BufferView::cursor_move(CursorMovement which, uint32_t c, bool allow_eol)
m_target_screen_column = 0;
m_target_virtual_column = 0;
break;
case CursorMovement::END_OF_FILE:
{
auto it = m_buffer->end();
it.go_back();
/* TODO: optimize this */
it.go_start_of_line();
it.go_end_of_line(allow_eol);
if (it != *m_iterator)
{
*m_iterator = it;
moved = true;
}
}
m_update_target_column = true;
break;
case CursorMovement::LAST_LINE:
{
auto it = m_buffer->end();
@@ -199,9 +215,11 @@ bool BufferView::cursor_move(CursorMovement which, uint32_t c, bool allow_eol)
case CursorMovement::BACK_ON_TO_CHAR:
determine_new_cursor_screen_row();
break;
case CursorMovement::START_OF_FILE:
case CursorMovement::FIRST_LINE:
m_cursor_screen_row = 0;
break;
case CursorMovement::END_OF_FILE:
case CursorMovement::LAST_LINE:
m_cursor_screen_row = m_height - 1;
break;
+2
View File
@@ -22,6 +22,8 @@ public:
DOWN,
SOL,
EOL,
START_OF_FILE,
END_OF_FILE,
FIRST_LINE,
LAST_LINE,
SCREEN_ROW_UP,
+2
View File
@@ -32,6 +32,8 @@ public:
PUT,
PUT_BEFORE,
CHANGE_CHAR,
GO_START_OF_FILE,
GO_END_OF_FILE,
GO_TO_LINE,
GO_TO_LAST_LINE,
GO_LEFT,
+2
View File
@@ -60,7 +60,9 @@ void DefaultCommandMap::build()
dcm->add("N", Command::PREV, nullptr, false);
dcm->add({JES_KEY_HOME}, Command::GO_START_OF_LINE, nullptr, false);
dcm->add({JES_KEY_MODS_CTRL + JES_KEY_HOME}, Command::GO_START_OF_FILE, nullptr, false);
dcm->add({JES_KEY_END}, Command::GO_END_OF_LINE, nullptr, false);
dcm->add({JES_KEY_MODS_CTRL + JES_KEY_END}, Command::GO_END_OF_FILE, nullptr, false);
dcm->add({JES_KEY_PAGE_UP}, Command::SCROLL_WINDOW_UP_WHOLE_SCREEN, nullptr, false);
dcm->add({JES_KEY_PAGE_DOWN}, Command::SCROLL_WINDOW_DOWN_WHOLE_SCREEN, nullptr, false);