make editing shortcuts more discoverable
Put them on the menu as well as the palette. And of course, allow them to be selected like first-class commands. Surprisingly this seems to make sense for every shortcut.
This commit is contained in:
parent
d9a6625a8b
commit
24fe137492
83
commands.lua
83
commands.lua
|
@ -40,11 +40,20 @@ Commands = {
|
|||
'reload note at cursor from disk',
|
||||
'reload all from disk',
|
||||
'delete note at cursor from disk (if possible)',
|
||||
'copy selection to clipboard (ctrl+c)',
|
||||
'search (all notes)',
|
||||
'/ (find on screen)',
|
||||
},
|
||||
editable={
|
||||
'exit editing (ctrl+e)',
|
||||
'find in note (ctrl+f)',
|
||||
'copy selection to clipboard (ctrl+c)',
|
||||
'cut selection to clipboard (ctrl+x)',
|
||||
'paste from clipboard (ctrl+v)',
|
||||
'undo (ctrl+z)',
|
||||
'redo (ctrl+y)',
|
||||
'cursor to next word (alt+right arrow)',
|
||||
'cursor to previous word (alt+left arrow)',
|
||||
'capture',
|
||||
'maximize note',
|
||||
'close column surrounding cursor',
|
||||
|
@ -69,11 +78,20 @@ Commands = {
|
|||
'back to surface',
|
||||
'edit note (ctrl+e)',
|
||||
'reload note from disk',
|
||||
'copy selection to clipboard (ctrl+c)',
|
||||
'/ (find on screen)',
|
||||
},
|
||||
maximized_editable={
|
||||
'exit editing (ctrl+e)',
|
||||
'back to surface',
|
||||
'find in note (ctrl+f)',
|
||||
'copy selection to clipboard (ctrl+c)',
|
||||
'cut selection to clipboard (ctrl+x)',
|
||||
'paste from clipboard (ctrl+v)',
|
||||
'undo (ctrl+z)',
|
||||
'redo (ctrl+y)',
|
||||
'cursor to next word (alt+right arrow)',
|
||||
'cursor to previous word (alt+left arrow)',
|
||||
'reload note from disk',
|
||||
'search (all notes)',
|
||||
'/ (find on screen)',
|
||||
|
@ -100,24 +118,29 @@ function draw_menu_bar()
|
|||
add_hotkey_to_menu('ctrl+enter: search commands...')
|
||||
App.color(Menu_border_color)
|
||||
love.graphics.line(Menu_cursor-10,2, Menu_cursor-10,Menu_status_bar_height-2)
|
||||
if Display_settings.mode == 'normal'
|
||||
and Cursor_pane.col >= 1 -- not an empty pane
|
||||
then
|
||||
if Cursor_pane.col >= 1 then
|
||||
local pane = Surface[Cursor_pane.col][Cursor_pane.row]
|
||||
if pane then
|
||||
if not pane.editable then
|
||||
local left_sx = left_edge_sx(Cursor_pane.col)
|
||||
local up_sy = up_edge_sy(Cursor_pane.col, Cursor_pane.row)
|
||||
if should_show_column(left_sx) and should_show_pane(pane, up_sy) then
|
||||
add_hotkey_to_menu('ctrl+e: edit')
|
||||
add_panning_hotkeys_to_menu()
|
||||
end
|
||||
add_hotkey_to_menu('x/X: narrower/wider columns')
|
||||
else
|
||||
if pane.cursor_x >= 0 and pane.cursor_x < App.screen.width and pane.cursor_y >= Header_height and pane.cursor_y < App.screen.height then
|
||||
add_hotkey_to_menu('ctrl+e: stop editing')
|
||||
if Display_settings.mode == 'normal'
|
||||
then
|
||||
if not pane.editable then
|
||||
local left_sx = left_edge_sx(Cursor_pane.col)
|
||||
local up_sy = up_edge_sy(Cursor_pane.col, Cursor_pane.row)
|
||||
if should_show_column(left_sx) and should_show_pane(pane, up_sy) then
|
||||
add_hotkey_to_menu('ctrl+e: edit')
|
||||
add_panning_hotkeys_to_menu()
|
||||
end
|
||||
add_hotkey_to_menu('x/X: narrower/wider columns')
|
||||
else
|
||||
add_panning_hotkeys_to_menu()
|
||||
if pane.cursor_x >= 0 and pane.cursor_x < App.screen.width and pane.cursor_y >= Header_height and pane.cursor_y < App.screen.height then
|
||||
add_hotkey_to_menu('ctrl+e: stop editing')
|
||||
add_hotkey_to_menu('ctrl+f: find')
|
||||
add_hotkey_to_menu('alt+left alt+right: prev/next word')
|
||||
add_hotkey_to_menu('ctrl+z ctrl+y: undo/redo')
|
||||
add_hotkey_to_menu('ctrl+x ctrl+c ctrl+v: cut/copy/paste')
|
||||
else
|
||||
add_panning_hotkeys_to_menu()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -391,6 +414,23 @@ function run_command(cmd, args)
|
|||
command.reload_note()
|
||||
elseif cmd == 'delete note at cursor from disk' then
|
||||
command.delete_note()
|
||||
-- editing
|
||||
elseif cmd == 'find in note' then
|
||||
command.send_key_to_current_pane('C-f', 'f')
|
||||
elseif cmd == 'copy selection to clipboard' then
|
||||
command.send_key_to_current_pane('C-c', 'c')
|
||||
elseif cmd == 'cut selection to clipboard' then
|
||||
command.send_key_to_current_pane('C-x', 'x')
|
||||
elseif cmd == 'paste from clipboard' then
|
||||
command.send_key_to_current_pane('C-v', 'v')
|
||||
elseif cmd == 'undo' then
|
||||
command.send_key_to_current_pane('C-z', 'z')
|
||||
elseif cmd == 'redo' then
|
||||
command.send_key_to_current_pane('C-y', 'y')
|
||||
elseif cmd == 'cursor to next word' then
|
||||
command.send_key_to_current_pane('M-right', 'right')
|
||||
elseif cmd == 'cursor to previous word' then
|
||||
command.send_key_to_current_pane('M-left', 'left')
|
||||
else
|
||||
print(('not implemented yet: %s'):format(function_name))
|
||||
end
|
||||
|
@ -924,6 +964,19 @@ function command.delete_note()
|
|||
command.reload_all()
|
||||
end
|
||||
|
||||
function command.send_key_to_current_pane(chord, key)
|
||||
if Cursor_pane.col < 1 then
|
||||
print('no current note')
|
||||
return
|
||||
end
|
||||
local pane = Surface[Cursor_pane.col][Cursor_pane.row]
|
||||
if pane == nil then
|
||||
print('no current note')
|
||||
return
|
||||
end
|
||||
edit.keychord_pressed(pane, chord, key)
|
||||
end
|
||||
|
||||
-- return a new pane with a unique filename
|
||||
function new_pane()
|
||||
local id = os.date('%Y/%m/%d/%H-%M-%S')
|
||||
|
|
Loading…
Reference in New Issue
Block a user