Advertisement
arismoko

Untitled

Aug 1st, 2024
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 KB | None | 0 0
  1. -- keybinds.lua
  2.  
  3. local function setupKeybinds(avim, Model, View, modes)
  4. -- Normal mode keybindings
  5. avim.keys.map("normal", "y", function()
  6. Model:yankLine() -- Regular yank line with lowercase 'y'
  7. end)
  8.  
  9. avim.keys.map("normal", "Y", function()
  10. Model:yankLine() -- Yank line, but using the 'Y' uppercase for emphasis (or different action)
  11. Model.statusMessage = "Yanked entire line"
  12. View:drawStatusBar(Model, View:getScreenWidth(), View:getScreenHeight())
  13. end)
  14.  
  15. avim.keys.map("normal", "p", function()
  16. Model:paste()
  17. View:drawLine(Model, Model.cursorY - Model.scrollOffset)
  18. Model.statusMessage = "Pasted text"
  19. View:drawStatusBar(Model, View:getScreenWidth(), View:getScreenHeight())
  20. end)
  21.  
  22. avim.keys.map("normal", "d", function()
  23. Model:cutLine() -- Regular delete/cut line with lowercase 'd'
  24. View:drawScreen(Model, View:getScreenWidth(), View:getScreenHeight())
  25. end)
  26.  
  27. avim.keys.map("normal", "D", function()
  28. Model:cutLine() -- Uppercase 'D' could be used for a different kind of deletion
  29. Model.statusMessage = "Deleted entire line"
  30. View:drawStatusBar(Model, View:getScreenWidth(), View:getScreenHeight())
  31. end)
  32.  
  33. avim.keys.map("normal", "c^ + x", function()
  34. Model:cutLine()
  35. Model.statusMessage = "Ctrl + X: Cut line"
  36. View:drawStatusBar(Model, View:getScreenWidth(), View:getScreenHeight())
  37. end)
  38.  
  39. avim.keys.map("normal", "a^ + s", function()
  40. Model:saveFile()
  41. Model.statusMessage = "Alt + S: File saved"
  42. View:drawStatusBar(Model, View:getScreenWidth(), View:getScreenHeight())
  43. end)
  44.  
  45. avim.keys.map("normal", "s", function()
  46. Model:saveFile()
  47. Model.statusMessage = "File saved"
  48. View:drawStatusBar(Model, View:getScreenWidth(), View:getScreenHeight())
  49. end)
  50.  
  51. avim.keys.map("normal", "i", function()
  52. modes.handleInsertMode(Model, View)
  53. end)
  54.  
  55. avim.keys.map("normal", "q", function()
  56. Model.shouldExit = true -- Set the exit flag
  57. end)
  58.  
  59. avim.keys.map("normal", "v", function()
  60. Model:startVisualMode()
  61. modes.handleVisualMode(Model, View)
  62. end)
  63.  
  64. -- Visual mode keybindings
  65. avim.keys.map("visual", "y", function()
  66. Model:yankSelection()
  67. Model:endVisualMode()
  68. modes.handleNormalMode(Model, View)
  69. end)
  70.  
  71. avim.keys.map("visual", "d", function()
  72. Model:cutSelection()
  73. View:drawScreen(Model, View:getScreenWidth(), View:getScreenHeight())
  74. modes.handleNormalMode(Model, View)
  75. end)
  76.  
  77. avim.keys.map("visual", "escape", function()
  78. Model:endVisualMode()
  79. modes.handleNormalMode(Model, View)
  80. end)
  81. end
  82.  
  83. return setupKeybinds
  84.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement