diff --git a/src/normal.cc b/src/normal.cc index 7b6b84d9..4496196a 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -182,7 +182,11 @@ void goto_commands(Context& context, NormalParams params) if (not buffer_dir.empty()) paths.insert(paths.begin(), buffer_dir.str()); + const auto& suffixes = context.options()["suffixes"].get>(); String path = find_file(filename, paths); + for (auto it = suffixes.begin(); path.empty() and it != suffixes.end(); ++it) + path = find_file(filename + *it, paths); + if (path.empty()) throw runtime_error(format("unable to find file '{}'", filename)); @@ -1015,24 +1019,22 @@ void select_object(Context& context, NormalParams params) ":: prompt for object \n"); } -template +template void scroll(Context& context, NormalParams) { - static_assert(key == Key::PageUp or key == Key::PageDown, - "scrool only implements PageUp and PageDown"); Window& window = context.window(); Buffer& buffer = context.buffer(); CharCoord position = window.position(); LineCount cursor_line = 0; - if (key == Key::PageUp) + if (direction == Backward) { - position.line -= (window.dimensions().line - 2); + position.line -= (window.dimensions().line - 2) / (half ? 2 : 1); cursor_line = position.line; } - else if (key == Key::PageDown) + else if (direction == Forward) { - position.line += (window.dimensions().line - 2); + position.line += (window.dimensions().line - 2) / (half ? 2 : 1); cursor_line = position.line + window.dimensions().line - 1; } auto cursor_pos = utf8::advance(buffer.iterator_at(position.line), @@ -1725,11 +1727,13 @@ static NormalCmdDesc cmds[] = { Key::Up, "move up", move }, { Key::Right, "move right", move }, - { ctrl('b'), "scroll one page up", scroll }, - { ctrl('f'), "scroll one page down", scroll }, + { ctrl('b'), "scroll one page up", scroll }, + { ctrl('f'), "scroll one page down", scroll }, + { ctrl('u'), "scroll half a page up", scroll }, + { ctrl('d'), "scroll half a page down", scroll }, - { Key::PageUp, "scroll one page up", scroll }, - { Key::PageDown, "scroll one page down", scroll }, + { Key::PageUp, "scroll one page up", scroll }, + { Key::PageDown, "scroll one page down", scroll }, { 'z', "restore selections", restore_selections }, { alt('z'), "append saved selections", restore_selections },