diff --git a/rc/appearance.lua b/rc/appearance.lua index 6e1540b..6274cb1 100644 --- a/rc/appearance.lua +++ b/rc/appearance.lua @@ -20,11 +20,18 @@ gtk-xft-antialias=1 gtk-xft-hinting=1 gtk-xft-hintstyle="hintfull" gtk-xft-rgba="rgb" -gtk-key-theme-name="Emacs" ]] local gtk2 = io.open(os.getenv("HOME") .. "/.gtkrc-2.0", "w") gtk2:write(gtk) +gtk2:write([[ +gtk-key-theme-name="Emacs" +binding "does-not-intercept-ctrl-w" { + unbind "w" +} +class "GtkEntry" binding "does-not-intercept-ctrl-w" +class "GtkTextView" binding "does-not-intercept-ctrl-w" +]]) gtk2:close() -- GTK3 is the same, but no double quotes for strings @@ -34,6 +41,49 @@ gtk, _ = gtk:gsub('"', '') gtk3:write("[Settings]\n") gtk3:write(gtk) gtk3:close() +local gtk3 = io.open(os.getenv("HOME") .. "/.config/gtk-3.0/gtk.css", "w") +gtk3:write([[ +/* Useless: we cannot override properly by unbinding some keys */ +/* @import url("/usr/share/themes/Emacs/gtk-3.0/gtk-keys.css"); */ + +@binding-set custom-text-entry +{ + bind "b" { "move-cursor" (logical-positions, -1, 0) }; + bind "b" { "move-cursor" (logical-positions, -1, 1) }; + bind "f" { "move-cursor" (logical-positions, 1, 0) }; + bind "f" { "move-cursor" (logical-positions, 1, 1) }; + + bind "b" { "move-cursor" (words, -1, 0) }; + bind "b" { "move-cursor" (words, -1, 1) }; + bind "f" { "move-cursor" (words, 1, 0) }; + bind "f" { "move-cursor" (words, 1, 1) }; + + bind "a" { "move-cursor" (paragraph-ends, -1, 0) }; + bind "a" { "move-cursor" (paragraph-ends, -1, 1) }; + bind "e" { "move-cursor" (paragraph-ends, 1, 0) }; + bind "e" { "move-cursor" (paragraph-ends, 1, 1) }; + + /* bind "w" { "cut-clipboard" () }; */ + bind "y" { "paste-clipboard" () }; + + bind "d" { "delete-from-cursor" (chars, 1) }; + bind "d" { "delete-from-cursor" (word-ends, 1) }; + bind "k" { "delete-from-cursor" (paragraph-ends, 1) }; + bind "backslash" { "delete-from-cursor" (whitespace, 1) }; + bind "BackSpace" { "delete-from-cursor" (word-ends, -1) }; + + bind "space" { "delete-from-cursor" (whitespace, 1) + "insert-at-cursor" (" ") }; + bind "KP_Space" { "delete-from-cursor" (whitespace, 1) + "insert-at-cursor" (" ") }; +} + +GtkEntry, GtkTextView +{ + gtk-key-bindings: custom-text-entry; +} +]]) +gtk3:close() -- For QT, the configuration file is ~/.config/Trolltech.conf. It -- seems a bit complex to override it each time. The solution is to