Add docstring for normal mode commands and display them if autoinfo >= 2
This commit is contained in:
parent
4c3bd68876
commit
b6979e2d2c
|
@ -106,7 +106,16 @@ public:
|
||||||
}
|
}
|
||||||
auto it = keymap.find(key);
|
auto it = keymap.find(key);
|
||||||
if (it != keymap.end())
|
if (it != keymap.end())
|
||||||
it->second(context(), m_count);
|
{
|
||||||
|
if (context().options()["autoinfo"].get<int>() >= 2 and context().has_ui())
|
||||||
|
{
|
||||||
|
ColorPair col = get_color("Information");
|
||||||
|
CharCoord pos = context().window().dimensions();
|
||||||
|
pos.column -= 1;
|
||||||
|
context().ui().info_show(key_to_str(key), it->second.docstring, pos, col, MenuStyle::Prompt);
|
||||||
|
}
|
||||||
|
it->second.func(context(), m_count);
|
||||||
|
}
|
||||||
m_count = 0;
|
m_count = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
230
src/normal.cc
230
src/normal.cc
|
@ -1231,150 +1231,150 @@ void move(Context& context, int count)
|
||||||
|
|
||||||
KeyMap keymap =
|
KeyMap keymap =
|
||||||
{
|
{
|
||||||
{ 'h', move<CharCount, Backward> },
|
{ 'h', { "move left", move<CharCount, Backward> } },
|
||||||
{ 'j', move<LineCount, Forward> },
|
{ 'j', { "move down", move<LineCount, Forward> } },
|
||||||
{ 'k', move<LineCount, Backward> },
|
{ 'k', { "move up", move<LineCount, Backward> } },
|
||||||
{ 'l', move<CharCount, Forward> },
|
{ 'l', { "move right", move<CharCount, Forward> } },
|
||||||
|
|
||||||
{ 'H', move<CharCount, Backward, SelectMode::Extend> },
|
{ 'H', { "extend left", move<CharCount, Backward, SelectMode::Extend> } },
|
||||||
{ 'J', move<LineCount, Forward, SelectMode::Extend> },
|
{ 'J', { "extend down", move<LineCount, Forward, SelectMode::Extend> } },
|
||||||
{ 'K', move<LineCount, Backward, SelectMode::Extend> },
|
{ 'K', { "extend up", move<LineCount, Backward, SelectMode::Extend> } },
|
||||||
{ 'L', move<CharCount, Forward, SelectMode::Extend> },
|
{ 'L', { "extend right", move<CharCount, Forward, SelectMode::Extend> } },
|
||||||
|
|
||||||
{ 't', select_to_next_char<SelectFlags::None> },
|
{ 't', { "select to next character", select_to_next_char<SelectFlags::None> } },
|
||||||
{ 'f', select_to_next_char<SelectFlags::Inclusive> },
|
{ 'f', { "select to next character included", select_to_next_char<SelectFlags::Inclusive> } },
|
||||||
{ 'T', select_to_next_char<SelectFlags::Extend> },
|
{ 'T', { "extend to next character", select_to_next_char<SelectFlags::Extend> } },
|
||||||
{ 'F', select_to_next_char<SelectFlags::Inclusive | SelectFlags::Extend> },
|
{ 'F', { "extend to next character included", select_to_next_char<SelectFlags::Inclusive | SelectFlags::Extend> } },
|
||||||
{ alt('t'), select_to_next_char<SelectFlags::Reverse> },
|
{ alt('t'), { "select to previous character", select_to_next_char<SelectFlags::Reverse> } },
|
||||||
{ alt('f'), select_to_next_char<SelectFlags::Inclusive | SelectFlags::Reverse> },
|
{ alt('f'), { "select to previous character included", select_to_next_char<SelectFlags::Inclusive | SelectFlags::Reverse> } },
|
||||||
{ alt('T'), select_to_next_char<SelectFlags::Extend | SelectFlags::Reverse> },
|
{ alt('T'), { "extend to previous character", select_to_next_char<SelectFlags::Extend | SelectFlags::Reverse> } },
|
||||||
{ alt('F'), select_to_next_char<SelectFlags::Inclusive | SelectFlags::Extend | SelectFlags::Reverse> },
|
{ alt('F'), { "extend to previous character included", select_to_next_char<SelectFlags::Inclusive | SelectFlags::Extend | SelectFlags::Reverse> } },
|
||||||
|
|
||||||
{ 'd', erase_selections },
|
{ 'd', { "erase selected text", erase_selections } },
|
||||||
{ 'c', change },
|
{ 'c', { "change selected text", change } },
|
||||||
{ 'i', enter_insert_mode<InsertMode::Insert> },
|
{ 'i', { "insert before selected text", enter_insert_mode<InsertMode::Insert> } },
|
||||||
{ 'I', enter_insert_mode<InsertMode::InsertAtLineBegin> },
|
{ 'I', { "insert at line begin", enter_insert_mode<InsertMode::InsertAtLineBegin> } },
|
||||||
{ 'a', enter_insert_mode<InsertMode::Append> },
|
{ 'a', { "insert after selected text", enter_insert_mode<InsertMode::Append> } },
|
||||||
{ 'A', enter_insert_mode<InsertMode::AppendAtLineEnd> },
|
{ 'A', { "insert at line end", enter_insert_mode<InsertMode::AppendAtLineEnd> } },
|
||||||
{ 'o', enter_insert_mode<InsertMode::OpenLineBelow> },
|
{ 'o', { "insert on new line below", enter_insert_mode<InsertMode::OpenLineBelow> } },
|
||||||
{ 'O', enter_insert_mode<InsertMode::OpenLineAbove> },
|
{ 'O', { "insert on new line above", enter_insert_mode<InsertMode::OpenLineAbove> } },
|
||||||
{ 'r', replace_with_char },
|
{ 'r', { "replace with character", replace_with_char } },
|
||||||
|
|
||||||
{ 'g', goto_commands<SelectMode::Replace> },
|
{ 'g', { "go to location", goto_commands<SelectMode::Replace> } },
|
||||||
{ 'G', goto_commands<SelectMode::Extend> },
|
{ 'G', { "extend to location", goto_commands<SelectMode::Extend> } },
|
||||||
|
|
||||||
{ 'v', view_commands },
|
{ 'v', { "move view", view_commands } },
|
||||||
|
|
||||||
{ 'y', yank },
|
{ 'y', { "yank selected text", yank } },
|
||||||
{ 'p', repeated(paste<InsertMode::Append>) },
|
{ 'p', { "paste after selected text", repeated(paste<InsertMode::Append>) } },
|
||||||
{ 'P', repeated(paste<InsertMode::Insert>) },
|
{ 'P', { "paste before selected text", repeated(paste<InsertMode::Insert>) } },
|
||||||
{ alt('p'), paste_all<InsertMode::Append> },
|
{ alt('p'), { "paste every yanked selection after selected text", paste_all<InsertMode::Append> } },
|
||||||
{ alt('P'), paste_all<InsertMode::Insert> },
|
{ alt('P'), { "paste every yanked selection before selected text", paste_all<InsertMode::Insert> } },
|
||||||
{ 'R', paste<InsertMode::Replace> },
|
{ 'R', { "replace selected text with yanked text", paste<InsertMode::Replace> } },
|
||||||
|
|
||||||
{ 's', select_regex },
|
{ 's', { "select regex matches in selected text", select_regex } },
|
||||||
{ 'S', split_regex },
|
{ 'S', { "split selected text on regex matches", split_regex } },
|
||||||
{ alt('s'), split_lines },
|
{ alt('s'), { "split selected text on line ends", split_lines } },
|
||||||
|
|
||||||
{ '.', repeat_last_insert },
|
{ '.', { "repeat last insert command", repeat_last_insert } },
|
||||||
|
|
||||||
{ '%', [](Context& context, int) { select_buffer(context.selections()); } },
|
{ '%', { "select whole buffer", [](Context& context, int) { select_buffer(context.selections()); } } },
|
||||||
|
|
||||||
{ ':', command },
|
{ ':', { "enter command prompt", command } },
|
||||||
{ '|', pipe<InsertMode::Replace> },
|
{ '|', { "pipe each selection through filter and replace with output", pipe<InsertMode::Replace> } },
|
||||||
{ alt('|'), pipe<InsertMode::Append> },
|
{ alt('|'), { "pipe each selection through filter and append with output", pipe<InsertMode::Append> } },
|
||||||
{ ' ', [](Context& context, int count) { keep_selection(context.selections(), count ? count-1 : context.selections().main_index()); } },
|
{ ' ', { "remove all selection except main", [](Context& context, int count) { keep_selection(context.selections(), count ? count-1 : context.selections().main_index()); } } },
|
||||||
{ alt(' '), [](Context& context, int count) { remove_selection(context.selections(), count ? count-1 : context.selections().main_index()); } },
|
{ alt(' '), { "remove main selection", [](Context& context, int count) { remove_selection(context.selections(), count ? count-1 : context.selections().main_index()); } } },
|
||||||
{ ';', [](Context& context, int count) { clear_selections(context.selections()); } },
|
{ ';', { "reduce selections to their cursor", [](Context& context, int count) { clear_selections(context.selections()); } } },
|
||||||
{ alt(';'), [](Context& context, int count) { flip_selections(context.selections()); } },
|
{ alt(';'), { "swap selections cursor and anchor", [](Context& context, int count) { flip_selections(context.selections()); } } },
|
||||||
|
|
||||||
{ 'w', repeated(make_select<SelectMode::Replace>(select_to_next_word<Word>)) },
|
{ 'w', { "select to next word start", repeated(make_select<SelectMode::Replace>(select_to_next_word<Word>)) } },
|
||||||
{ 'e', repeated(make_select<SelectMode::Replace>(select_to_next_word_end<Word>)) },
|
{ 'e', { "select to next word end", repeated(make_select<SelectMode::Replace>(select_to_next_word_end<Word>)) } },
|
||||||
{ 'b', repeated(make_select<SelectMode::Replace>(select_to_previous_word<Word>)) },
|
{ 'b', { "select to prevous word start", repeated(make_select<SelectMode::Replace>(select_to_previous_word<Word>)) } },
|
||||||
{ 'W', repeated(make_select<SelectMode::Extend>(select_to_next_word<Word>)) },
|
{ 'W', { "extend to next word start", repeated(make_select<SelectMode::Extend>(select_to_next_word<Word>)) } },
|
||||||
{ 'E', repeated(make_select<SelectMode::Extend>(select_to_next_word_end<Word>)) },
|
{ 'E', { "extend to next word end", repeated(make_select<SelectMode::Extend>(select_to_next_word_end<Word>)) } },
|
||||||
{ 'B', repeated(make_select<SelectMode::Extend>(select_to_previous_word<Word>)) },
|
{ 'B', { "extend to prevous word start", repeated(make_select<SelectMode::Extend>(select_to_previous_word<Word>)) } },
|
||||||
|
|
||||||
{ alt('w'), repeated(make_select<SelectMode::Replace>(select_to_next_word<WORD>)) },
|
{ alt('w'), { "select to next WORD start", repeated(make_select<SelectMode::Replace>(select_to_next_word<WORD>)) } },
|
||||||
{ alt('e'), repeated(make_select<SelectMode::Replace>(select_to_next_word_end<WORD>)) },
|
{ alt('e'), { "select to next WORD end", repeated(make_select<SelectMode::Replace>(select_to_next_word_end<WORD>)) } },
|
||||||
{ alt('b'), repeated(make_select<SelectMode::Replace>(select_to_previous_word<WORD>)) },
|
{ alt('b'), { "select to prevous WORD start", repeated(make_select<SelectMode::Replace>(select_to_previous_word<WORD>)) } },
|
||||||
{ alt('W'), repeated(make_select<SelectMode::Extend>(select_to_next_word<WORD>)) },
|
{ alt('W'), { "extend to next WORD start", repeated(make_select<SelectMode::Extend>(select_to_next_word<WORD>)) } },
|
||||||
{ alt('E'), repeated(make_select<SelectMode::Extend>(select_to_next_word_end<WORD>)) },
|
{ alt('E'), { "extend to next WORD end", repeated(make_select<SelectMode::Extend>(select_to_next_word_end<WORD>)) } },
|
||||||
{ alt('B'), repeated(make_select<SelectMode::Extend>(select_to_previous_word<WORD>)) },
|
{ alt('B'), { "extend to prevous WORD start", repeated(make_select<SelectMode::Extend>(select_to_previous_word<WORD>)) } },
|
||||||
|
|
||||||
{ alt('l'), repeated(make_select<SelectMode::Replace>(select_to_eol)) },
|
{ alt('l'), { "select to line end", repeated(make_select<SelectMode::Replace>(select_to_eol)) } },
|
||||||
{ alt('L'), repeated(make_select<SelectMode::Extend>(select_to_eol)) },
|
{ alt('L'), { "extend to line end", repeated(make_select<SelectMode::Extend>(select_to_eol)) } },
|
||||||
{ alt('h'), repeated(make_select<SelectMode::Replace>(select_to_eol_reverse)) },
|
{ alt('h'), { "select to line begin", repeated(make_select<SelectMode::Replace>(select_to_eol_reverse)) } },
|
||||||
{ alt('H'), repeated(make_select<SelectMode::Extend>(select_to_eol_reverse)) },
|
{ alt('H'), { "extend to line begin", repeated(make_select<SelectMode::Extend>(select_to_eol_reverse)) } },
|
||||||
|
|
||||||
{ 'x', repeated(make_select<SelectMode::Replace>(select_line)) },
|
{ 'x', { "select line", repeated(make_select<SelectMode::Replace>(select_line)) } },
|
||||||
{ 'X', repeated(make_select<SelectMode::Extend>(select_line)) },
|
{ 'X', { "extend line", repeated(make_select<SelectMode::Extend>(select_line)) } },
|
||||||
{ alt('x'), make_select<SelectMode::Replace>(select_lines) },
|
{ alt('x'), { "extend selections to whole lines", make_select<SelectMode::Replace>(select_lines) } },
|
||||||
{ alt('X'), make_select<SelectMode::Replace>(trim_partial_lines) },
|
{ alt('X'), { "crop selections to whole lines", make_select<SelectMode::Replace>(trim_partial_lines) } },
|
||||||
|
|
||||||
{ 'm', make_select<SelectMode::Replace>(select_matching) },
|
{ 'm', { "select to matching character", make_select<SelectMode::Replace>(select_matching) } },
|
||||||
{ 'M', make_select<SelectMode::Extend>(select_matching) },
|
{ 'M', { "extend to matching character", make_select<SelectMode::Extend>(select_matching) } },
|
||||||
|
|
||||||
{ '/', search<SelectMode::Replace, Forward> },
|
{ '/', { "select next given regex match", search<SelectMode::Replace, Forward> } },
|
||||||
{ '?', search<SelectMode::Extend, Forward> },
|
{ '?', { "extend with next given regex match", search<SelectMode::Extend, Forward> } },
|
||||||
{ alt('/'), search<SelectMode::Replace, Backward> },
|
{ alt('/'), { "select previous given regex match", search<SelectMode::Replace, Backward> } },
|
||||||
{ alt('?'), search<SelectMode::Extend, Backward> },
|
{ alt('?'), { "extend with previous given regex match", search<SelectMode::Extend, Backward> } },
|
||||||
{ 'n', search_next<SelectMode::Replace, Forward> },
|
{ 'n', { "select next current search pattern match", search_next<SelectMode::Replace, Forward> } },
|
||||||
{ 'N', search_next<SelectMode::Append, Forward> },
|
{ 'N', { "extend with next current search pattern match", search_next<SelectMode::Append, Forward> } },
|
||||||
{ alt('n'), search_next<SelectMode::Replace, Backward> },
|
{ alt('n'), { "select previous current search pattern match", search_next<SelectMode::Replace, Backward> } },
|
||||||
{ alt('N'), search_next<SelectMode::Append, Backward> },
|
{ alt('N'), { "extend with previous current search pattern match", search_next<SelectMode::Append, Backward> } },
|
||||||
{ '*', use_selection_as_search_pattern<true> },
|
{ '*', { "set search pattern to main selection content", use_selection_as_search_pattern<true> } },
|
||||||
{ alt('*'), use_selection_as_search_pattern<false> },
|
{ alt('*'), { "set search pattern to main selection content, do not detect words", use_selection_as_search_pattern<false> } },
|
||||||
|
|
||||||
{ 'u', undo },
|
{ 'u', { "undo", undo } },
|
||||||
{ 'U', redo },
|
{ 'U', { "redo", redo } },
|
||||||
|
|
||||||
{ alt('i'), select_object<ObjectFlags::ToBegin | ObjectFlags::ToEnd | ObjectFlags::Inner> },
|
{ alt('i'), { "select inner object", select_object<ObjectFlags::ToBegin | ObjectFlags::ToEnd | ObjectFlags::Inner> } },
|
||||||
{ alt('a'), select_object<ObjectFlags::ToBegin | ObjectFlags::ToEnd> },
|
{ alt('a'), { "select whole object", select_object<ObjectFlags::ToBegin | ObjectFlags::ToEnd> } },
|
||||||
{ ']', select_object<ObjectFlags::ToEnd> },
|
{ ']', { "select to object end", select_object<ObjectFlags::ToEnd> } },
|
||||||
{ '[', select_object<ObjectFlags::ToBegin> },
|
{ '[', { "select to object start", select_object<ObjectFlags::ToBegin> } },
|
||||||
{ '{', select_object<ObjectFlags::ToBegin, SelectMode::Extend> },
|
{ '}', { "extend to object end", select_object<ObjectFlags::ToEnd, SelectMode::Extend> } },
|
||||||
{ '}', select_object<ObjectFlags::ToEnd, SelectMode::Extend> },
|
{ '{', { "extend to object start", select_object<ObjectFlags::ToBegin, SelectMode::Extend> } },
|
||||||
|
|
||||||
{ alt('j'), join },
|
{ alt('j'), { "join lines", join } },
|
||||||
{ alt('J'), join_select_spaces },
|
{ alt('J'), { "join lines and select spaces", join_select_spaces } },
|
||||||
|
|
||||||
{ alt('k'), keep<true> },
|
{ alt('k'), { "keep selections matching given regex", keep<true> } },
|
||||||
{ alt('K'), keep<false> },
|
{ alt('K'), { "keep selections not matching given regex", keep<false> } },
|
||||||
{ '$', keep_pipe },
|
{ '$', { "pipe each selection through shell command and keep the ones whose command succeed", keep_pipe } },
|
||||||
|
|
||||||
{ '<', deindent<true> },
|
{ '<', { "deindent", deindent<true> } },
|
||||||
{ '>', indent<false> },
|
{ '>', { "indent", indent<false> } },
|
||||||
{ alt('>'), indent<true> },
|
{ alt('>'), { "indent, including empty lines", indent<true> } },
|
||||||
{ alt('<'), deindent<false> },
|
{ alt('<'), { "deindent, not including incomplete indent", deindent<false> } },
|
||||||
|
|
||||||
{ ctrl('i'), jump<Forward> },
|
{ ctrl('i'), { "jump forward in jump list",jump<Forward> } },
|
||||||
{ ctrl('o'), jump<Backward> },
|
{ ctrl('o'), { "jump backward in jump list", jump<Backward> } },
|
||||||
{ ctrl('s'), save_selections },
|
{ ctrl('s'), { "push current selections in jump list", save_selections } },
|
||||||
|
|
||||||
{ alt('r'), rotate_selections },
|
{ alt('r'), { "rotate main selection", rotate_selections } },
|
||||||
{ alt('R'), rotate_selections_content },
|
{ alt('R'), { "rotate selections content", rotate_selections_content } },
|
||||||
|
|
||||||
{ 'q', replay_macro },
|
{ 'q', { "replay recorded macro", replay_macro } },
|
||||||
{ 'Q', start_or_end_macro_recording },
|
{ 'Q', { "start or end macro recording", start_or_end_macro_recording } },
|
||||||
|
|
||||||
{ '`', for_each_char<to_lower> },
|
{ '`', { "convert to lower case in selections", for_each_char<to_lower> } },
|
||||||
{ '~', for_each_char<to_upper> },
|
{ '~', { "convert to upper case in selections", for_each_char<to_upper> } },
|
||||||
{ alt('`'), for_each_char<swap_case> },
|
{ alt('`'), { "swap case in selections", for_each_char<swap_case> } },
|
||||||
|
|
||||||
{ '&', align },
|
{ '&', { "align selection cursors", align } },
|
||||||
{ alt('&'), copy_indent },
|
{ alt('&'), { "copy indentation", copy_indent } },
|
||||||
|
|
||||||
{ '@', tabs_to_spaces },
|
{ '@', { "convert tabs to spaces in selections", tabs_to_spaces } },
|
||||||
{ alt('@'), spaces_to_tabs },
|
{ alt('@'), { "convert spaces to tabs in selections", spaces_to_tabs } },
|
||||||
|
|
||||||
{ Key::Left, move<CharCount, Backward> },
|
{ Key::Left, { "move left", move<CharCount, Backward> } },
|
||||||
{ Key::Down, move<LineCount, Forward> },
|
{ Key::Down, { "move down", move<LineCount, Forward> } },
|
||||||
{ Key::Up, move<LineCount, Backward> },
|
{ Key::Up, { "move up", move<LineCount, Backward> } },
|
||||||
{ Key::Right, move<CharCount, Forward> },
|
{ Key::Right, { "move right", move<CharCount, Forward> } },
|
||||||
|
|
||||||
{ Key::PageUp, scroll<Key::PageUp> },
|
{ Key::PageUp, { "scroll one page up", scroll<Key::PageUp> } },
|
||||||
{ Key::PageDown, scroll<Key::PageDown> },
|
{ Key::PageDown, { "scroll one page down", scroll<Key::PageDown> } },
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,13 @@ namespace Kakoune
|
||||||
|
|
||||||
class Context;
|
class Context;
|
||||||
|
|
||||||
using KeyMap = std::unordered_map<Key, std::function<void (Context& context, int param)>>;
|
struct NormalCmdDesc
|
||||||
|
{
|
||||||
|
const char* docstring;
|
||||||
|
std::function<void (Context& context, int param)> func;
|
||||||
|
};
|
||||||
|
|
||||||
|
using KeyMap = std::unordered_map<Key, NormalCmdDesc>;
|
||||||
extern KeyMap keymap;
|
extern KeyMap keymap;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user