1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-11-29 10:02:57 +03:00

Merge remote-tracking branch 'zakgreant/reference-sheet-scripts'

This commit is contained in:
Maxime Coste 2015-08-20 20:13:48 +01:00
commit 564ab7d942
2 changed files with 65 additions and 4 deletions

61
contrib/kakmap.rb Executable file
View File

@ -0,0 +1,61 @@
#!/usr/bin/env ruby
# Generate a reference sheet for Kakoune's normal mode
# Use: ./kakmap.rb ../src/normal.cc
require 'markaby'
# Relies on the cmds array assignment ending with };
raw = ARGF.read.split( /cmds\[\] =\s+{\s*/m ).last.split( /^};$/ ).first
commands = {}
# break code into lines
raw.split( /\n+/ ).each{ |line|
line.gsub!( /(^\s*{\s*|\s*},?\*$)/, '' ) # discard wrapping for array elements
mod = (line.scan( /^alt|^ctrl/ ).first || 'none').to_sym
key = line.scan(/(?:^Key::(\w+)|(?<!\\)'\\?(.*?)(?<!\\)')/).flatten.compact.first
des = line.scan(/(?<!\\)"(?<desc>.*?)(?<!\\)"/).flatten.first
key = 'Space' if key == ' '
commands[key] ||= {}
commands[key][mod] = des
}
# sort, showing single characters first, symbols next and spelled out keys last
commands = commands.sort_by{ |key, _|
case key
when /^\w$/
key.upcase + key.swapcase
when /^\W$/
'_' + key
else
'~~' + key
end
}
puts Markaby::Builder.new {
table do
thead do
tr do
th "Key"
th "Description"
th "ALT + key"
th "CTRL + key"
end
end
tbody do
for key, binding in commands
tr do
th key
td binding[:none]
td binding[:alt]
td binding[:ctrl]
end
end
end
end
}

View File

@ -1522,17 +1522,17 @@ static NormalCmdDesc cmds[] =
{ 'w', "select to next word start", repeated<&select<SelectMode::Replace, select_to_next_word<Word>>> },
{ 'e', "select to next word end", repeated<select<SelectMode::Replace, select_to_next_word_end<Word>>> },
{ 'b', "select to prevous word start", repeated<select<SelectMode::Replace, select_to_previous_word<Word>>> },
{ 'b', "select to previous word start", repeated<select<SelectMode::Replace, select_to_previous_word<Word>>> },
{ 'W', "extend to next word start", repeated<select<SelectMode::Extend, select_to_next_word<Word>>> },
{ 'E', "extend to next word end", repeated<select<SelectMode::Extend, select_to_next_word_end<Word>>> },
{ 'B', "extend to prevous word start", repeated<select<SelectMode::Extend, select_to_previous_word<Word>>> },
{ 'B', "extend to previous word start", repeated<select<SelectMode::Extend, select_to_previous_word<Word>>> },
{ alt('w'), "select to next WORD start", repeated<select<SelectMode::Replace, select_to_next_word<WORD>>> },
{ alt('e'), "select to next WORD end", repeated<select<SelectMode::Replace, select_to_next_word_end<WORD>>> },
{ alt('b'), "select to prevous WORD start", repeated<select<SelectMode::Replace, select_to_previous_word<WORD>>> },
{ alt('b'), "select to previous WORD start", repeated<select<SelectMode::Replace, select_to_previous_word<WORD>>> },
{ alt('W'), "extend to next WORD start", repeated<select<SelectMode::Extend, select_to_next_word<WORD>>> },
{ alt('E'), "extend to next WORD end", repeated<select<SelectMode::Extend, select_to_next_word_end<WORD>>> },
{ alt('B'), "extend to prevous WORD start", repeated<select<SelectMode::Extend, select_to_previous_word<WORD>>> },
{ alt('B'), "extend to previous WORD start", repeated<select<SelectMode::Extend, select_to_previous_word<WORD>>> },
{ alt('l'), "select to line end", repeated<select<SelectMode::Replace, select_to_line_end<false>>> },
{ Key::End, "select to line end", repeated<select<SelectMode::Replace, select_to_line_end<false>>> },