Another copy of my dotfiles. Because I don't completely trust GitHub.
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.

134 lines
6.0 KiB

  1. From 74a98d9600c50d50b9323cf8e459c88eb15da557 Mon Sep 17 00:00:00 2001
  2. From: efe <efe@efe.kim>
  3. Date: Sat, 9 Feb 2019 13:16:51 -0500
  4. Subject: [PATCH] Modal behaviour, 'i' to insert 'Esc' to get to the normal
  5. mode
  6. ---
  7. config.def.h | 53 +++++++++++++++++++++++++++-------------------------
  8. surf.c | 14 +++++++++++++-
  9. 2 files changed, 41 insertions(+), 26 deletions(-)
  10. diff --git a/config.def.h b/config.def.h
  11. index 34265f6..8b7d5a2 100644
  12. --- a/config.def.h
  13. +++ b/config.def.h
  14. @@ -130,41 +130,44 @@ static SiteSpecific certs[] = {
  15. */
  16. static Key keys[] = {
  17. /* modifier keyval function arg */
  18. - { MODKEY, GDK_KEY_g, spawn, SETPROP("_SURF_URI", "_SURF_GO", PROMPT_GO) },
  19. - { MODKEY, GDK_KEY_f, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
  20. - { MODKEY, GDK_KEY_slash, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
  21. + { 0, GDK_KEY_g, spawn, SETPROP("_SURF_URI", "_SURF_GO", PROMPT_GO) },
  22. + { 0, GDK_KEY_f, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
  23. + { 0, GDK_KEY_slash, spawn, SETPROP("_SURF_FIND", "_SURF_FIND", PROMPT_FIND) },
  24. - { 0, GDK_KEY_Escape, stop, { 0 } },
  25. - { MODKEY, GDK_KEY_c, stop, { 0 } },
  26. + { 0, GDK_KEY_i, insert, { .i = 1 } },
  27. + { 0, GDK_KEY_Escape, insert, { .i = 0 } },
  28. - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_r, reload, { .i = 1 } },
  29. - { MODKEY, GDK_KEY_r, reload, { .i = 0 } },
  30. + { 0, GDK_KEY_c, stop, { 0 } },
  31. - { MODKEY, GDK_KEY_l, navigate, { .i = +1 } },
  32. - { MODKEY, GDK_KEY_h, navigate, { .i = -1 } },
  33. + { MODKEY, GDK_KEY_r, reload, { .i = 1 } },
  34. + { 0, GDK_KEY_r, reload, { .i = 0 } },
  35. +
  36. + { 0, GDK_KEY_l, navigate, { .i = +1 } },
  37. + { 0, GDK_KEY_h, navigate, { .i = -1 } },
  38. /* vertical and horizontal scrolling, in viewport percentage */
  39. - { MODKEY, GDK_KEY_j, scrollv, { .i = +10 } },
  40. - { MODKEY, GDK_KEY_k, scrollv, { .i = -10 } },
  41. - { MODKEY, GDK_KEY_space, scrollv, { .i = +50 } },
  42. - { MODKEY, GDK_KEY_b, scrollv, { .i = -50 } },
  43. - { MODKEY, GDK_KEY_i, scrollh, { .i = +10 } },
  44. - { MODKEY, GDK_KEY_u, scrollh, { .i = -10 } },
  45. + { 0, GDK_KEY_j, scrollv, { .i = +10 } },
  46. + { 0, GDK_KEY_k, scrollv, { .i = -10 } },
  47. + { 0, GDK_KEY_space, scrollv, { .i = +50 } },
  48. + { 0, GDK_KEY_b, scrollv, { .i = -50 } },
  49. + { 0, GDK_KEY_i, scrollh, { .i = +10 } },
  50. + { 0, GDK_KEY_u, scrollh, { .i = -10 } },
  51. - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_j, zoom, { .i = -1 } },
  52. - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_k, zoom, { .i = +1 } },
  53. - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_q, zoom, { .i = 0 } },
  54. - { MODKEY, GDK_KEY_minus, zoom, { .i = -1 } },
  55. - { MODKEY, GDK_KEY_plus, zoom, { .i = +1 } },
  56. + { 0|GDK_SHIFT_MASK, GDK_KEY_j, zoom, { .i = -1 } },
  57. + { 0|GDK_SHIFT_MASK, GDK_KEY_k, zoom, { .i = +1 } },
  58. + { 0|GDK_SHIFT_MASK, GDK_KEY_q, zoom, { .i = 0 } },
  59. + { 0, GDK_KEY_minus, zoom, { .i = -1 } },
  60. + { 0|GDK_SHIFT_MASK, GDK_KEY_plus, zoom, { .i = +1 } },
  61. + { 0, GDK_KEY_equal, zoom, { .i = 0 } },
  62. - { MODKEY, GDK_KEY_p, clipboard, { .i = 1 } },
  63. - { MODKEY, GDK_KEY_y, clipboard, { .i = 0 } },
  64. + { 0, GDK_KEY_p, clipboard, { .i = 1 } },
  65. + { 0, GDK_KEY_y, clipboard, { .i = 0 } },
  66. - { MODKEY, GDK_KEY_n, find, { .i = +1 } },
  67. - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_n, find, { .i = -1 } },
  68. + { 0, GDK_KEY_n, find, { .i = +1 } },
  69. + { 0|GDK_SHIFT_MASK, GDK_KEY_n, find, { .i = -1 } },
  70. - { MODKEY|GDK_SHIFT_MASK, GDK_KEY_p, print, { 0 } },
  71. + { MODKEY, GDK_KEY_p, print, { 0 } },
  72. { MODKEY, GDK_KEY_t, showcert, { 0 } },
  73. { MODKEY|GDK_SHIFT_MASK, GDK_KEY_a, togglecookiepolicy, { 0 } },
  74. diff --git a/surf.c b/surf.c
  75. index 2b54e3c..f4cbe68 100644
  76. --- a/surf.c
  77. +++ b/surf.c
  78. @@ -175,6 +175,7 @@ static void spawn(Client *c, const Arg *a);
  79. static void msgext(Client *c, char type, const Arg *a);
  80. static void destroyclient(Client *c);
  81. static void cleanup(void);
  82. +static int insertmode = 0;
  83. /* GTK/WebKit */
  84. static WebKitWebView *newview(Client *c, WebKitWebView *rv);
  85. @@ -231,6 +232,7 @@ static void togglefullscreen(Client *c, const Arg *a);
  86. static void togglecookiepolicy(Client *c, const Arg *a);
  87. static void toggleinspector(Client *c, const Arg *a);
  88. static void find(Client *c, const Arg *a);
  89. +static void insert(Client *c, const Arg *a);
  90. /* Buttons */
  91. static void clicknavigate(Client *c, const Arg *a, WebKitHitTestResult *h);
  92. @@ -1333,7 +1335,11 @@ winevent(GtkWidget *w, GdkEvent *e, Client *c)
  93. updatetitle(c);
  94. break;
  95. case GDK_KEY_PRESS:
  96. - if (!curconfig[KioskMode].val.i) {
  97. + if (!curconfig[KioskMode].val.i &&
  98. + !insertmode ||
  99. + CLEANMASK(e->key.state) == (MODKEY|GDK_SHIFT_MASK) ||
  100. + CLEANMASK(e->key.state) == (MODKEY) ||
  101. + gdk_keyval_to_lower(e->key.keyval) == (GDK_KEY_Escape)) {
  102. for (i = 0; i < LENGTH(keys); ++i) {
  103. if (gdk_keyval_to_lower(e->key.keyval) ==
  104. keys[i].keyval &&
  105. @@ -1947,6 +1953,12 @@ find(Client *c, const Arg *a)
  106. }
  107. }
  108. +void
  109. +insert(Client *c, const Arg *a)
  110. +{
  111. + insertmode = (a->i);
  112. +}
  113. +
  114. void
  115. clicknavigate(Client *c, const Arg *a, WebKitHitTestResult *h)
  116. {
  117. --
  118. 2.20.1