From: Matt Birkholz Date: Sun, 5 Jun 2011 15:11:39 +0000 (-0700) Subject: Genericize gdk keysyms; match Edwin's expectations. X-Git-Tag: 20110609-Gtk~4 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=849100b2f413e9a8d73e67227b3bf3db17d6f538;p=mit-scheme.git Genericize gdk keysyms; match Edwin's expectations. --- diff --git a/src/gtk/keys.scm b/src/gtk/keys.scm index 9ffc73b1e..4beeddc57 100644 --- a/src/gtk/keys.scm +++ b/src/gtk/keys.scm @@ -39,16 +39,33 @@ USA. (let ((entry (vector-binary-search gtk-key-translation-table (lambda (u v) (< u v)) - (lambda (pair) (cdr pair)) + (lambda (pair) (car pair)) keyval))) - (and entry (car entry)))) + (and entry (cdr entry)))) (define-syntax translation-vector (sc-macro-transformer (lambda (form usage-env) - (list->vector - (c-enum-constant-values '(ENUM |GdkKeysyms|) form - (find-c-includes usage-env)))))) + (let* ((overrides + `((,(C-enum "GDK_Cancel") . stop) ;originally called Cancel + )) + (keyval.name + (lambda (gdk-name.keyval) + (let* ((keyval (cdr gdk-name.keyval)) + (gdk-name (car gdk-name.keyval)) + (string (symbol->string gdk-name)) + (name (cond ((assv keyval overrides) => cdr) + ((string-prefix? "GDK_" string) + (intern (string-replace + (string-tail string 4) #\_ #\-))) + (else + (warn "Unexpected GdkKeysym name:" gdk-name) + gdk-name)))) + (cons keyval name))))) + (list->vector + (map keyval.name + (c-enum-constant-values '(ENUM |GdkKeysyms|) form + (find-c-includes usage-env)))))))) (define gtk-key-translation-table - (sort! (translation-vector) (lambda (a b) (< (cdr a) (cdr b))))) \ No newline at end of file + (sort! (translation-vector) (lambda (a b) (< (car a) (car b))))) \ No newline at end of file