mirror of
https://github.com/mpv-player/mpv
synced 2024-12-23 23:32:26 +00:00
console.lua: define remaining emacs keybindings
This commit is contained in:
parent
c82ffb6670
commit
87c9eefb29
@ -14,50 +14,82 @@ Keybindings
|
|||||||
ESC
|
ESC
|
||||||
Hide the console.
|
Hide the console.
|
||||||
|
|
||||||
ENTER
|
ENTER, Ctrl+J and Ctrl+M
|
||||||
Run the typed command.
|
Run the typed command.
|
||||||
|
|
||||||
Shift+ENTER
|
Shift+ENTER
|
||||||
Type a literal newline character.
|
Type a literal newline character.
|
||||||
|
|
||||||
Ctrl+LEFT and Ctrl+RIGHT
|
LEFT and Ctrl+B
|
||||||
Move cursor to previous/next word.
|
Move the cursor to the previous character.
|
||||||
|
|
||||||
UP and DOWN
|
RIGHT and Ctrl+F
|
||||||
Navigate command history.
|
Move the cursor to the next character.
|
||||||
|
|
||||||
|
Ctrl+LEFT and Alt+B
|
||||||
|
Move the cursor to the beginning of the current word, or if between words,
|
||||||
|
to the beginning of the previous word.
|
||||||
|
|
||||||
|
Ctrl+RIGHT and Alt+F
|
||||||
|
Move the cursor to the end of the current word, or if between words, to the
|
||||||
|
end of the next word.
|
||||||
|
|
||||||
|
HOME and Ctrl+A
|
||||||
|
Move the cursor to the start of the current line.
|
||||||
|
|
||||||
|
END and Ctrl+E
|
||||||
|
Move the cursor to the end of the current line.
|
||||||
|
|
||||||
|
BACKSPACE and Ctrl+H
|
||||||
|
Delete the previous character.
|
||||||
|
|
||||||
|
Ctrl+D
|
||||||
|
Hide the console if the current line is empty, otherwise delete the next
|
||||||
|
character.
|
||||||
|
|
||||||
|
Ctrl+BACKSPACE and Ctrl+W
|
||||||
|
Delete text from the cursor to the beginning of the current word, or if
|
||||||
|
between words, to the beginning of the previous word.
|
||||||
|
|
||||||
|
Ctrl+DEL and Alt+D
|
||||||
|
Delete text from the cursor to the end of the current word, or if between
|
||||||
|
words, to the end of the next word.
|
||||||
|
|
||||||
|
Ctrl+U
|
||||||
|
Delete text from the cursor to the beginning of the current line.
|
||||||
|
|
||||||
|
Ctrl+K
|
||||||
|
Delete text from the cursor to the end of the current line.
|
||||||
|
|
||||||
|
Ctrl+C
|
||||||
|
Clear the current line.
|
||||||
|
|
||||||
|
UP and Ctrl+P
|
||||||
|
Move back in the command history.
|
||||||
|
|
||||||
|
DOWN and Ctrl+N
|
||||||
|
Move forward in the command history.
|
||||||
|
|
||||||
PGUP
|
PGUP
|
||||||
Go to the first command in the history.
|
Go to the first command in the history.
|
||||||
|
|
||||||
PGDN
|
PGDN
|
||||||
Stop navigating command history.
|
Stop navigating the command history.
|
||||||
|
|
||||||
INSERT
|
INSERT
|
||||||
Toggle insert mode.
|
Toggle insert mode.
|
||||||
|
|
||||||
Shift+INSERT
|
|
||||||
Paste text (uses the primary selection on X11 and Wayland).
|
|
||||||
|
|
||||||
TAB
|
|
||||||
Complete the command or property name at the cursor.
|
|
||||||
|
|
||||||
Ctrl+C
|
|
||||||
Clear current line.
|
|
||||||
|
|
||||||
Ctrl+K
|
|
||||||
Delete text from the cursor to the end of the line.
|
|
||||||
|
|
||||||
Ctrl+L
|
|
||||||
Clear all log messages from the console.
|
|
||||||
|
|
||||||
Ctrl+U
|
|
||||||
Delete text from the cursor to the beginning of the line.
|
|
||||||
|
|
||||||
Ctrl+V
|
Ctrl+V
|
||||||
Paste text (uses the clipboard on X11 and Wayland).
|
Paste text (uses the clipboard on X11 and Wayland).
|
||||||
|
|
||||||
Ctrl+W
|
Shift+INSERT
|
||||||
Delete text from the cursor to the beginning of the current word.
|
Paste text (uses the primary selection on X11 and Wayland).
|
||||||
|
|
||||||
|
TAB and Ctrl+I
|
||||||
|
Complete the command or property name at the cursor.
|
||||||
|
|
||||||
|
Ctrl+L
|
||||||
|
Clear all log messages from the console.
|
||||||
|
|
||||||
Commands
|
Commands
|
||||||
--------
|
--------
|
||||||
|
@ -260,7 +260,7 @@ function prev_utf8(str, pos)
|
|||||||
return pos
|
return pos
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Insert a character at the current cursor position (any_unicode, Shift+Enter)
|
-- Insert a character at the current cursor position (any_unicode)
|
||||||
function handle_char_input(c)
|
function handle_char_input(c)
|
||||||
if insert_mode then
|
if insert_mode then
|
||||||
line = line:sub(1, cursor - 1) .. c .. line:sub(next_utf8(line, cursor))
|
line = line:sub(1, cursor - 1) .. c .. line:sub(next_utf8(line, cursor))
|
||||||
@ -313,10 +313,13 @@ function clear()
|
|||||||
update()
|
update()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Close the REPL if the current line is empty, otherwise do nothing (Ctrl+D)
|
-- Close the REPL if the current line is empty, otherwise delete the next
|
||||||
|
-- character (Ctrl+D)
|
||||||
function maybe_exit()
|
function maybe_exit()
|
||||||
if line == '' then
|
if line == '' then
|
||||||
set_active(false)
|
set_active(false)
|
||||||
|
else
|
||||||
|
handle_del()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -571,7 +574,7 @@ function go_end()
|
|||||||
update()
|
update()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Delete from the cursor to the end of the word (Ctrl+W)
|
-- Delete from the cursor to the beginning of the word (Ctrl+Backspace)
|
||||||
function del_word()
|
function del_word()
|
||||||
local before_cur = line:sub(1, cursor - 1)
|
local before_cur = line:sub(1, cursor - 1)
|
||||||
local after_cur = line:sub(cursor)
|
local after_cur = line:sub(cursor)
|
||||||
@ -582,6 +585,18 @@ function del_word()
|
|||||||
update()
|
update()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Delete from the cursor to the end of the word (Ctrl+Del)
|
||||||
|
function del_next_word()
|
||||||
|
if cursor > line:len() then return end
|
||||||
|
|
||||||
|
local before_cur = line:sub(1, cursor - 1)
|
||||||
|
local after_cur = line:sub(cursor)
|
||||||
|
|
||||||
|
after_cur = after_cur:gsub('^%s*[^%s]+', '', 1)
|
||||||
|
line = before_cur .. after_cur
|
||||||
|
update()
|
||||||
|
end
|
||||||
|
|
||||||
-- Delete from the cursor to the end of the line (Ctrl+K)
|
-- Delete from the cursor to the end of the line (Ctrl+K)
|
||||||
function del_to_eol()
|
function del_to_eol()
|
||||||
line = line:sub(1, cursor - 1)
|
line = line:sub(1, cursor - 1)
|
||||||
@ -675,25 +690,37 @@ function get_bindings()
|
|||||||
{ 'enter', handle_enter },
|
{ 'enter', handle_enter },
|
||||||
{ 'kp_enter', handle_enter },
|
{ 'kp_enter', handle_enter },
|
||||||
{ 'shift+enter', function() handle_char_input('\n') end },
|
{ 'shift+enter', function() handle_char_input('\n') end },
|
||||||
|
{ 'ctrl+j', handle_enter },
|
||||||
|
{ 'ctrl+m', handle_enter },
|
||||||
{ 'bs', handle_backspace },
|
{ 'bs', handle_backspace },
|
||||||
{ 'shift+bs', handle_backspace },
|
{ 'shift+bs', handle_backspace },
|
||||||
|
{ 'ctrl+h', handle_backspace },
|
||||||
{ 'del', handle_del },
|
{ 'del', handle_del },
|
||||||
{ 'shift+del', handle_del },
|
{ 'shift+del', handle_del },
|
||||||
{ 'ins', handle_ins },
|
{ 'ins', handle_ins },
|
||||||
{ 'shift+ins', function() paste(false) end },
|
{ 'shift+ins', function() paste(false) end },
|
||||||
{ 'mbtn_mid', function() paste(false) end },
|
{ 'mbtn_mid', function() paste(false) end },
|
||||||
{ 'left', function() prev_char() end },
|
{ 'left', function() prev_char() end },
|
||||||
|
{ 'ctrl+b', function() prev_char() end },
|
||||||
{ 'right', function() next_char() end },
|
{ 'right', function() next_char() end },
|
||||||
|
{ 'ctrl+f', function() next_char() end },
|
||||||
{ 'up', function() move_history(-1) end },
|
{ 'up', function() move_history(-1) end },
|
||||||
|
{ 'ctrl+p', function() move_history(-1) end },
|
||||||
{ 'wheel_up', function() move_history(-1) end },
|
{ 'wheel_up', function() move_history(-1) end },
|
||||||
{ 'down', function() move_history(1) end },
|
{ 'down', function() move_history(1) end },
|
||||||
|
{ 'ctrl+n', function() move_history(1) end },
|
||||||
{ 'wheel_down', function() move_history(1) end },
|
{ 'wheel_down', function() move_history(1) end },
|
||||||
{ 'wheel_left', function() end },
|
{ 'wheel_left', function() end },
|
||||||
{ 'wheel_right', function() end },
|
{ 'wheel_right', function() end },
|
||||||
{ 'ctrl+left', prev_word },
|
{ 'ctrl+left', prev_word },
|
||||||
|
{ 'alt+b', prev_word },
|
||||||
{ 'ctrl+right', next_word },
|
{ 'ctrl+right', next_word },
|
||||||
|
{ 'alt+f', next_word },
|
||||||
{ 'tab', complete },
|
{ 'tab', complete },
|
||||||
|
{ 'ctrl+i', complete },
|
||||||
|
{ 'ctrl+a', go_home },
|
||||||
{ 'home', go_home },
|
{ 'home', go_home },
|
||||||
|
{ 'ctrl+e', go_end },
|
||||||
{ 'end', go_end },
|
{ 'end', go_end },
|
||||||
{ 'pgup', handle_pgup },
|
{ 'pgup', handle_pgup },
|
||||||
{ 'pgdwn', handle_pgdown },
|
{ 'pgdwn', handle_pgdown },
|
||||||
@ -704,7 +731,10 @@ function get_bindings()
|
|||||||
{ 'ctrl+u', del_to_start },
|
{ 'ctrl+u', del_to_start },
|
||||||
{ 'ctrl+v', function() paste(true) end },
|
{ 'ctrl+v', function() paste(true) end },
|
||||||
{ 'meta+v', function() paste(true) end },
|
{ 'meta+v', function() paste(true) end },
|
||||||
|
{ 'ctrl+bs', del_word },
|
||||||
{ 'ctrl+w', del_word },
|
{ 'ctrl+w', del_word },
|
||||||
|
{ 'ctrl+del', del_next_word },
|
||||||
|
{ 'alt+d', del_next_word },
|
||||||
{ 'kp_dec', function() handle_char_input('.') end },
|
{ 'kp_dec', function() handle_char_input('.') end },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user