You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

153 lines
7.5 KiB

  1. /* Keyboard mappings for Kitty terminal
  2. https://sw.kovidgoyal.net/kitty/index.html#
  3. A library to output the right key shortcut in any common app.
  4. Given a global variable babble_mode to show the environment and a
  5. key that calls the paste macro, do the right type of paste.
  6. Setting the context is done by another macro, or TBD interaction with the host.
  7. Huge thanks to https://en.wikipedia.org/wiki/Table_of_keyboard_shortcuts
  8. and
  9. https://github.com/qmk/qmk_firmware/blob/master/keyboards/planck/keymaps/jeebak/keymap.c
  10. */
  11. #include QMK_KEYBOARD_H
  12. // #define TAB_MEANS TAB
  13. /* #define TAB_MEANS_TAB to keep the meaning of "tab" and "window" used in kitty documentation. .
  14. * Leaving tab undefined will mean that each babble window command applies to a tab,
  15. * and each babble tab command applies to a window inside the kitty OS window.
  16. */
  17. //#define TAB_MEANS_TAB
  18. #ifdef USE_BABBLEPASTE
  19. # include "babblePaste.h"
  20. # ifdef BABL_KITTY
  21. bool babblePaste_kitty(uint16_t keycode) {
  22. # ifdef BABL_MOVE
  23. BABLM(BABL_GO_LEFT_1C, SS_TAP(X_LEFT));
  24. BABLM(BABL_GO_RIGHT_1C, SS_TAP(X_RIGHT));
  25. BABLM(BABL_GO_LEFT_WORD, IMCTL(X_LEFT));
  26. BABLM(BABL_GO_RIGHT_WORD, IMCTL(X_RIGHT));
  27. BABLM(BABL_GO_START_LINE, SS_TAP(X_HOME));
  28. BABLM(BABL_GO_END_LINE, SS_TAP(X_END));
  29. BABLM(BABL_GO_START_DOC, OMSFT(IMCTL(X_HOME)));
  30. BABLM(BABL_GO_END_DOC, OMSFT(IMCTL(X_END)));
  31. // leaving these for command line editing.
  32. BABLM(BABL_GO_NEXT_LINE, SS_TAP(X_DOWN));
  33. BABLM(BABL_GO_PREV_LINE, SS_TAP(X_UP));
  34. // These are for kitty scrolling by one line
  35. // BABLM(BABL_GO_NEXT_LINE, OMSFT(IMCTL(X_DOWN)));
  36. // BABLM(BABL_GO_PREV_LINE, OMSFT(IMCTL(X_UP)));
  37. // passthrough
  38. BABLM(BABL_PGDN, OMSFT(IMCTL(X_PGDOWN))); // kitty pagedown
  39. BABLM(BABL_PGUP, OMSFT(IMCTL(X_PGUP))); // kitty pageup
  40. // passthrough to commanrd line/shell.
  41. BABLM(BABL_DEL_RIGHT_1C, SS_LCTL("d"));
  42. BABLM(BABL_DEL_LEFT_WORD, SS_LCTL("w")); // meta-DEL instead?
  43. BABLM(BABL_DEL_RIGHT_WORD, SS_LALT("d"));
  44. BABLM(BABL_DEL_TO_LINE_END, SS_LCTL("k"));
  45. BABLM(BABL_DEL_TO_LINE_START, SS_LCTL("u"));
  46. BABLM(BABL_GO_PARA_START, IMCTL(X_UP));
  47. BABLM(BABL_GO_PARA_END, IMCTL(X_DOWN));
  48. BABLM(BABL_MODE, "Kitty! ");
  49. # endif
  50. # ifdef BABL_OSKEYS
  51. // cut isn't real, undo/redo are passthrough.
  52. BABLM(BABL_UNDO, SS_LCTL("z"));
  53. BABLM(BABL_REDO, SS_LCTL("y"));
  54. BABLM(BABL_CUT, OMSFT(IMCTL(X_X)));
  55. BABLM(BABL_COPY, OMSFT(IMCTL(X_C)));
  56. BABLM(BABL_PASTE, OMSFT(IMCTL(X_V)));
  57. BABLM(BABL_SELECT_ALL, SS_LCTL("a"));
  58. BABLM(BABL_FIND, SS_LCTL("f")); // passthrough.
  59. // BABLM(BABL_CLOSE_APP, IMALT(X_F4)); // gnome.
  60. // BABLM(BABL_HELP, SS_TAP(X_F1)); // script to pop open kitty web page?
  61. // 2 passthrough.
  62. BABLM(BABL_FIND_NEXT, SS_LCTL("g")); // Gnome*/
  63. BABLM(BABL_FIND_PREV, OMSFT(IMCTL(X_G))); // Gnome*/
  64. // BABLM(BABL_FIND_NEXT (SS_LALT(X_F3)) ); //KDE */
  65. /* BABLM( BABL_FIND_REPLACE , (SS_LCTL("r")) ); // KDE */
  66. // BABLM(BABL_FIND_REPLACE, SS_LCTL("h")); // Gnome*/
  67. BABLM(BABL_RUNAPP, OMSFT(IMCTL(X_O))); // pass current selection to program.
  68. BABLM(BABL_SWITCH_APP_NEXT, IMGUI(X_TAB));
  69. // BABLM(BABL_SWITCH_APP_LAST, OMSFT(IMALT(X_TAB)));
  70. BABLM(BABL_WINDOW_NEXT, IMGUI(X_GRAVE)); // next OS window of kitty.
  71. BABLM(BABL_WINDOW_PREV, OMSFT(IMGUI(X_GRAVE))); // NA?
  72. # ifdef TAB_MEANS_TAB
  73. BABLM(BABL_WINDOW_NEW, OMSFT(IMCTL(X_ENTER))); // a window is a window
  74. # else
  75. BABLM(BABL_WINDOW_NEW, OMSFT(IMCTL(X_T))); // a window is a tab
  76. # endif
  77. // KITTY - missing close window.
  78. // BABLM( BABL_HELP, (SS_TAP(X_F1)) ); // NA?
  79. // BABLM(BABL_LOCK, OMCTL(IMALT(X_L))); // NA passthrough
  80. // BABLM(BABL_SCREENCAPTURE, IMSFT(X_PSCREEN)); // NA passthrough
  81. # endif
  82. # ifdef BABL_BROWSER
  83. # ifdef TAB_MEANS_TAB
  84. // option A - do tab when I say tab.
  85. BABLM(BABL_BROWSER_NEW_TAB, OMSFT(IMCTL(X_T)));
  86. BABLM(BABL_BROWSER_CLOSE_TAB, OMSFT(IMCTL(X_Q)));
  87. BABLM(BABL_BROWSER_NEXT_TAB, OMSFT(IMCTL(X_RIGHT)));
  88. BABLM(BABL_BROWSER_PREV_TAB, OMSFT(IMCTL(X_LEFT)));
  89. // ok, this is a bit of a stretch, overloading meaning of forwards/backwards
  90. BABLM(BABL_BROWSER_FORWARD, OMSFT(IMCTL(X_DOT))); // move current kitty tab forwards
  91. BABLM(BABL_BROWSER_BACK, OMSFT(IMCTL(X_COMMA))); // move current kitty tab back
  92. // requires kitty config of "map ctrl+shift+f7 detach_window"
  93. BABLM(BABL_BROWSER_REOPEN_LAST_TAB, IMCTL(X_F7)); // pop current frame into a window
  94. # else // tab means window/frame.
  95. // option B - do Kitty window (frame) when I say tab
  96. BABLM(BABL_BROWSER_NEW_TAB, OMSFT(IMCTL(X_ENTER)));
  97. BABLM(BABL_BROWSER_NEXT_TAB, OMSFT(IMCTL(X_LBRC)));
  98. BABLM(BABL_BROWSER_PREV_TAB, OMSFT(IMCTL(X_RBRC)));
  99. // ok, this is a bit of a stretch, overloading meaning of forwards/backwards
  100. BABLM(BABL_BROWSER_FORWARD, OMSFT(IMCTL(X_F)));
  101. BABLM(BABL_BROWSER_BACK, OMSFT(IMCTL(X_B)));
  102. // kitty - questionable mental model - reopen current frame as a window
  103. // requires kitty config of "map ctrl+shift+f6 detach_frame"
  104. BABLM(BABL_BROWSER_REOPEN_LAST_TAB, IMCTL(X_F6)); // pop current frame into a window
  105. # endif // tab means tab
  106. // BABLM(BABL_BROWSER_FIND, SS_LCTL("f"));
  107. BABLM(BABL_BROWSER_BOOKMARK, SS_LCTL(SS_LSFT(SS_LALT("t")))); // bookmark == set tab title.
  108. BABLM(BABL_BROWSER_DEV_TOOLS, OMSFT(IMCTL(X_F2))); // edit kitty config.
  109. BABLM(BABL_BROWSER_RELOAD, OMSFT(IMCTL(X_DEL))); // reset terminal
  110. BABLM(BABL_BROWSER_FULLSCREEN, OMSFT(IMCTL(X_F11)));
  111. BABLM(BABL_BROWSER_ZOOM_IN, OMSFT(IMCTL(X_EQUAL)));
  112. BABLM(BABL_BROWSER_ZOOM_OUT, OMSFT(IMCTL(X_MINUS)));
  113. // Again, breaking model to overload "view source"
  114. BABLM(BABL_BROWSER_VIEWSRC, OMSFT(IMCTL(X_O))); // open URL in browser
  115. # endif
  116. # ifdef BABL_APP
  117. BABLM(BABL_APP_SAVE, SS_LCTL("s")); // passthrough.
  118. # ifdef TAB_MEANS_TAB // frames are called windows.
  119. BABLM(BABL_SPLIT_FRAME_VERT, OMSFT(IMCTL(X_ENTER))); // add new frame in kitty window
  120. BABLM(BABL_UNSPLIT_FRAME_VERT, OMSFT(IMCTL(X_W))); // close window
  121. // BUG, this breaks the mental model. move the current frame forward/back in rotation
  122. BABLM(BABL_SPLIT_FRAME_HORIZONTAL, OMSFT(IMCTL(X_F)));
  123. BABLM(BABL_UNSPLIT_FRAME_HORIZONTAL, OMSFT(IMCTL(X_B)));
  124. // KITTY - missing ctrl shift ` = move frame to top.
  125. BABLM(BABL_NEXT_FRAME, OMSFT(IMCTL(X_RBRC)));
  126. BABLM(BABL_PREV_FRAME, OMSFT(IMCTL(X_LBRC)));
  127. # else // splits are tabs
  128. BABLM(BABL_SPLIT_FRAME_VERT, OMSFT(IMCTL(X_T)));
  129. BABLM(BABL_UNSPLIT_FRAME_VERT, OMSFT(IMCTL(X_Q))); // close Tab
  130. BABLM(BABL_NEXT_FRAME, OMSFT(IMCTL(X_RIGHT)));
  131. BABLM(BABL_PREV_FRAME, OMSFT(IMCTL(X_LEFT)));
  132. // ok, this is a bit of a stretch, overloading meaning of forwards/backwards
  133. BABLM(BABL_SPLIT_FRAME_HORIZONTAL, OMSFT(IMCTL(X_DOT))); // move current kitty tab forwards
  134. BABLM(BABL_UNSPLIT_FRAME_HORIZONTAL, OMSFT(IMCTL(X_COMMA))); // move current kitty tab back
  135. # endif // tab means tab
  136. # endif
  137. // Todo, ring bell, flash light, show user this isn't supported
  138. return false;
  139. }
  140. # endif /* kitty mode */
  141. #endif