mirror of
https://github.com/rkd77/elinks.git
synced 2024-11-04 08:17:17 -05:00
290 lines
6.5 KiB
Bash
Executable File
290 lines
6.5 KiB
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# Generate the elinkskeys(5) manpage.
|
|
# Copyright (c) Jonas Fonseca <fonseca@diku.dk>, 2005
|
|
#
|
|
|
|
# FIXME:
|
|
#
|
|
# - You may prefix each of these keys with a number, telling its repeat
|
|
# count (how many times to do it). You can also re-bind keys, see
|
|
# elinkskeys(5) for documentation and a more complete list of keys bound by
|
|
# default.
|
|
#
|
|
# - The following keys can be used while editing a line/jumping to a URL
|
|
|
|
DOCTYPE=$(echo "$1" | sed 's/.*elinkskeys.5.//' | sed 's/.txt.*//')
|
|
KBDBIND=$2
|
|
CONFIGDIR=$(dirname "$2")
|
|
|
|
link()
|
|
{
|
|
target="$1"; shift
|
|
|
|
[ "$1" ] && name="$@"
|
|
case "$DOCTYPE" in
|
|
man)
|
|
echo "$name <$target>"
|
|
;;
|
|
html)
|
|
echo "link:$target[$name]"
|
|
;;
|
|
esac
|
|
}
|
|
|
|
man()
|
|
{
|
|
target="$1"
|
|
section="$2"
|
|
|
|
case "$DOCTYPE" in
|
|
man)
|
|
echo "\`$target($section)\`"
|
|
;;
|
|
html)
|
|
echo "link:$target.$section.html[\`$target($section)\`]"
|
|
;;
|
|
esac
|
|
}
|
|
|
|
print_keymap_actions()
|
|
{
|
|
keymap=$1
|
|
|
|
case "$DOCTYPE" in
|
|
html)
|
|
# open-link-in-new-tab-in-background
|
|
echo '`----------------------------------`----------------------------------------------------------------------------'
|
|
echo 'Action Description'
|
|
echo '----------------------------------------------------------------------------------------------------------------'
|
|
;;
|
|
esac
|
|
|
|
grep ACTION_ "$CONFIGDIR/actions-$keymap.inc" \
|
|
| while read entry;
|
|
do
|
|
action=$(echo "$entry" | sed 's/ACTION_([^,]*, "\([^"]*\)".*/\1/')
|
|
caption=$(echo "$entry" | sed 's/.*N__("\(.*\)").*/\1/')
|
|
|
|
[ "$action" = "none" ] && continue
|
|
[ "$action" = " *scripting-function*" ] && continue
|
|
|
|
case "$DOCTYPE" in
|
|
man)
|
|
echo
|
|
echo "$action::"
|
|
echo " $caption."
|
|
;;
|
|
html)
|
|
printf "%-34s %s\n" "$action" "$caption"
|
|
;;
|
|
esac
|
|
done
|
|
|
|
case "$DOCTYPE" in
|
|
html)
|
|
echo '---------------------------------------------------------------------------------------------------------------'
|
|
;;
|
|
esac
|
|
}
|
|
|
|
print_keymap_defaults()
|
|
{
|
|
keymap="$1"
|
|
KEYMAP=$(echo $1 | tr '[a-z]' '[A-Z]')
|
|
|
|
case "$DOCTYPE" in
|
|
html)
|
|
# Ctrl-Insert
|
|
echo '`-----------`-------------------------------------------------------------------------------'
|
|
echo 'Key Description (Action)'
|
|
echo '--------------------------------------------------------------------------------------------'
|
|
;;
|
|
esac
|
|
|
|
grep ACT_$KEYMAP $KBDBIND | grep '^[[:space:]]{' | grep -v '{ "' \
|
|
| while read entry
|
|
do
|
|
entry=$(echo "$entry" | sed 's/.*{ { //' | sed 's/ }//')
|
|
key=$(echo "$entry" | sed "s/\(KBD_[^,]*\|'.*'\),.*/\1/")
|
|
modifier=$(echo "$entry" | sed "s/.*KBD_MOD_\([A-Z_]*\).*/\1/")
|
|
action=$(echo "$entry" | sed "s/.*,.*\(ACT_$KEYMAP\)_\([A-Z_]*\).*/\2/")
|
|
action=$(grep " $action," "$CONFIGDIR/actions-$keymap.inc" \
|
|
| sed "s/.*\"\([^\"]*\)\".*N__(\"\(.*\)\").*/\2 ('\1')/")
|
|
|
|
case "$key" in
|
|
KBD_*)
|
|
key=$(grep $key $KBDBIND \
|
|
| grep '^[[:space:]]{ "' \
|
|
| sed 's/.*"\([^"]*\)".*/\1/')
|
|
;;
|
|
"' '")
|
|
key="Space"
|
|
;;
|
|
*)
|
|
key=$(echo "$key" | sed "s/^'\(.*\)'/\1/" \
|
|
| sed "s/'/\\\\'/")
|
|
;;
|
|
esac
|
|
|
|
case "$modifier" in
|
|
ALT) modifier="Alt-" ;;
|
|
CTRL) modifier="Ctrl-" ;;
|
|
*) modifier="" ;;
|
|
esac
|
|
|
|
case "$DOCTYPE" in
|
|
man)
|
|
echo
|
|
echo "'$modifier$key'::"
|
|
echo " $action"
|
|
;;
|
|
html)
|
|
printf "%-11s %s\n" "$modifier$key" "$action"
|
|
;;
|
|
esac
|
|
done
|
|
|
|
case "$DOCTYPE" in
|
|
html)
|
|
echo '--------------------------------------------------------------------------------------------'
|
|
;;
|
|
esac
|
|
}
|
|
|
|
cat << __END__
|
|
elinkskeys(5)
|
|
=============
|
|
|
|
NAME
|
|
----
|
|
elinkskeys - keybindings for ELinks
|
|
|
|
SYNOPSIS
|
|
--------
|
|
Information on how to configure keybinding and overview of the default
|
|
keybindings.
|
|
|
|
DESCRIPTION
|
|
-----------
|
|
|
|
Key binding for elinks should be placed in a file called
|
|
~/.elinks/elinks.conf. Note that any information regarding their
|
|
format/structure may not be up-to-date. If you will discover that, please
|
|
feed us with a patch.
|
|
|
|
Key binding statements are of the form:
|
|
|
|
bind <keymap> <keystroke> = <action>
|
|
|
|
where:
|
|
|
|
<keymap>::
|
|
is 'main', 'edit', or 'menu'.
|
|
|
|
<keystroke>::
|
|
is a case sensitive key, which you can prefix with 'Ctrl-' or 'Alt-'.
|
|
'Ctrl-' must be followed by an uppercase key. See below for a list of
|
|
valid keys.
|
|
|
|
<action>::
|
|
|
|
is what the key should do. The actions available are dependent on the
|
|
keymap, and are listed separately below.
|
|
|
|
All words/strings may all be quoted "like so". Backslashes are escape
|
|
characters, even if not between quotes. Lines beginning with a hash
|
|
character (\`#\`) are comments.
|
|
|
|
Keys can be unbound just by binding them to the special 'none' action. It
|
|
may be of use if you accidentally type a key often.
|
|
|
|
EXAMPLE BINDINGS
|
|
----------------
|
|
|
|
Some sample keybindings:
|
|
|
|
bind "main" "v" = "view-image"
|
|
bind "main" "l" = "jump-to-link"
|
|
bind "main" "L" = "link-menu"
|
|
bind "main" "F10" = "file-menu"
|
|
bind "main" "F9" = "menu"
|
|
bind "main" "Escape" = "menu"
|
|
bind "edit" "Ctrl-R" = "auto-complete-unambiguous"
|
|
bind "edit" "Ctrl-W" = "auto-complete"
|
|
bind "edit" "Ctrl-K" = "kill-to-eol"
|
|
bind "menu" "Ctrl-B" = "page-up"
|
|
bind "menu" "PageUp" = "page-up"
|
|
bind "menu" "Ctrl-F" = "page-down"
|
|
bind "menu" "PageDown" = "page-down"
|
|
# ELinks with Lua support
|
|
bind "main" "," = "lua-console"
|
|
|
|
KEYS
|
|
----
|
|
|
|
Valid keys are: alphanumeric characters, punctuation, 'Enter', 'Backspace',
|
|
'Tab', 'Escape', 'Left', 'Right', 'Up', 'Down', 'Insert', 'Delete', 'Home',
|
|
'End', 'PageUp', 'PageDown', 'F1' to 'F12'.
|
|
|
|
Some keys will need to be quoted or escaped. For example, space can be
|
|
written as \`" "\` (quote space quote), and the quote itself as \\"
|
|
(backslash quote). Backslash can be written as \\\\ (double backslash).
|
|
|
|
MAIN KEYMAP ACTIONS
|
|
~~~~~~~~~~~~~~~~~~~
|
|
|
|
The main keymap is used for general browsing.
|
|
|
|
$(print_keymap_actions main)
|
|
|
|
EDIT KEYMAP ACTIONS
|
|
~~~~~~~~~~~~~~~~~~~
|
|
|
|
The edit keymap is used for editing text fields.
|
|
|
|
$(print_keymap_actions edit)
|
|
|
|
MENU KEYMAP ACTIONS
|
|
~~~~~~~~~~~~~~~~~~~
|
|
|
|
The menu keymap is used for navigating menus.
|
|
|
|
$(print_keymap_actions menu)
|
|
|
|
DEFAULT BINDINGS
|
|
----------------
|
|
|
|
The default bindings are shown below. Any bindings in
|
|
\`~/.elinks/elinks.conf\` will override these.
|
|
|
|
MAIN KEYS
|
|
~~~~~~~~~
|
|
|
|
$(print_keymap_defaults main)
|
|
|
|
EDIT KEYS
|
|
~~~~~~~~~
|
|
|
|
$(print_keymap_defaults edit)
|
|
|
|
MENU KEYS
|
|
~~~~~~~~~
|
|
|
|
$(print_keymap_defaults menu)
|
|
|
|
AUTHOR
|
|
------
|
|
|
|
This manual page was finally written by Peter Wang (one and a half years
|
|
after writing the binding code), using excerpts by David Mediavilla. You can
|
|
thank Petr Baudis for the subtle requests for documentation. Updated by Zas.
|
|
Moved to asciidoc format and cleaned up by Jonas Fonseca.
|
|
|
|
SEE ALSO
|
|
--------
|
|
|
|
$(man elinks 1), \`elinks.conf(5)\`
|
|
|
|
__END__
|