Add support for Home/End keys in normal and insert mode

Fixes #260
This commit is contained in:
Maxime Coste 2015-03-27 13:33:14 +00:00
parent 0fbbd64681
commit 195b813b73
2 changed files with 20 additions and 0 deletions

View File

@ -950,6 +950,24 @@ public:
move(1_line);
moved = true;
}
else if (key == Key::Home)
{
auto& selections = context().selections();
for (auto& sel : selections)
sel.anchor() = sel.cursor() = ByteCoord{sel.cursor().line, 0};
selections.sort_and_merge_overlapping();
}
else if (key == Key::End)
{
auto& buffer = context().buffer();
auto& selections = context().selections();
for (auto& sel : selections)
{
const LineCount line = sel.cursor().line;
sel.anchor() = sel.cursor() = buffer.clamp({line, buffer[line].length()});
}
selections.sort_and_merge_overlapping();
}
else if (key.modifiers == Key::Modifiers::None)
insert(key.key);
else if (key == ctrl('r'))

View File

@ -1481,8 +1481,10 @@ static NormalCmdDesc cmds[] =
{ alt('B'), "extend to prevous WORD start", repeated<select<SelectMode::Extend, select_to_previous_word<WORD>>> },
{ alt('l'), "select to line end", repeated<select<SelectMode::Replace, select_to_eol>> },
{ Key::End, "select to line end", repeated<select<SelectMode::Replace, select_to_eol>> },
{ alt('L'), "extend to line end", repeated<select<SelectMode::Extend, select_to_eol>> },
{ alt('h'), "select to line begin", repeated<select<SelectMode::Replace, select_to_eol_reverse>> },
{ Key::Home, "select to line begin", repeated<select<SelectMode::Replace, select_to_eol_reverse>> },
{ alt('H'), "extend to line begin", repeated<select<SelectMode::Extend, select_to_eol_reverse>> },
{ 'x', "select line", repeated<select<SelectMode::Replace, select_line>> },