From b2cff3f42086e3ab63f8d2d8df7dd48d42e25938 Mon Sep 17 00:00:00 2001 From: Zak Greant Date: Sat, 15 Aug 2015 12:45:10 +0200 Subject: [PATCH] Generate normal mode reference Parse entries out of the cmds array in normal.cc, then generate a sorted list of key bindings as an HTML table. --- contrib/kakmap.rb | 61 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100755 contrib/kakmap.rb diff --git a/contrib/kakmap.rb b/contrib/kakmap.rb new file mode 100755 index 00000000..33b61639 --- /dev/null +++ b/contrib/kakmap.rb @@ -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+)|(?.*?)(?