[uim-commit] r255 - in trunk: scm uim
yamaken@freedesktop.org
yamaken@freedesktop.org
Tue Jan 11 09:11:18 PST 2005
Author: yamaken
Date: 2005-01-11 09:11:15 -0800 (Tue, 11 Jan 2005)
New Revision: 255
Modified:
trunk/scm/key.scm
trunk/uim/slib.c
trunk/uim/uim-key.c
Log:
* uim/uim-key.c
- (struct key_entry):
* Named from the anonymous struct for key_tab
* Add const qualifier to member 'str'
- (key_tab): Rewrite definition using struct key_entry
- (define_valid_key_symbols): New static function
- (get_sym, keycode_to_sym, handle_key): Add const qualifier to
appropriate 'char *' pointers
- (uim_init_key_subrs):
* Add define_valid_key_symbols() invocation
* Remove unnecessary cast
* scm/key.scm
- (valid-key-symbols): Remove here. The variable is defined in
uim-key.c
- (key-symbol?): New procedure
- (set-key-binding, regist-key-binding): Remove these obsolete
placeholders existing in comment
* uim/slib.c
- (init_subrs): Cosmetic change
Modified: trunk/scm/key.scm
===================================================================
--- trunk/scm/key.scm 2005-01-11 16:20:34 UTC (rev 254)
+++ trunk/scm/key.scm 2005-01-11 17:11:15 UTC (rev 255)
@@ -33,98 +33,12 @@
;; config
(define enable-emacs-like-key-prefix? #t)
-;;
-(define valid-key-symbols
- '(backspace
- delete
- escape
- return
- tab
- left
- up
- right
- down
- prior
- next
- home
- end
- zenkaku-hankaku
- Multi_key
- Mode_switch
- Henkan_Mode
- Muhenkan
- F1
- F2
- F3
- F4
- F5
- F6
- F7
- F8
- F9
- F10
- F11
- F12
- F13
- F14
- F15
- F16
- F17
- F18
- F19
- F20
- F21
- F22
- F23
- F24
- F25
- F26
- F27
- F28
- F29
- F30
- F31
- F32
- F33
- F34
- F35
- Private1
- Private2
- Private3
- Private4
- Private5
- Private6
- Private7
- Private8
- Private9
- Private10
- Private11
- Private12
- Private13
- Private14
- Private15
- Private16
- Private17
- Private18
- Private19
- Private20
- Private21
- Private22
- Private23
- Private24
- Private25
- Private26
- Private27
- Private28
- Private29
- Private30
- Shift_key
- Alt_key
- Control_key
- Meta_key
- Super_key
- Hyper_key))
+;; valid-key-symbols is defined in uim-key.c
+(define key-symbol?
+ (lambda (sym)
+ (member sym valid-key-symbols)))
+
(define intern-key-symbol
(lambda (key-str)
(let ((sym (string->symbol key-str)))
@@ -425,16 +339,6 @@
(set! enable-emacs-like-key-prefix? saved-enable-eprefix?)
res)))
-;(define set-key-binding
-; (lambda (im state flavor)
-; #f
-; ))
-
-;(define regist-key-binding
-; (lambda (bind-name bind-table)
-; #f
-;))
-
;;
(define-key left-key? "left")
(define-key right-key? "right")
Modified: trunk/uim/slib.c
===================================================================
--- trunk/uim/slib.c 2005-01-11 16:20:34 UTC (rev 254)
+++ trunk/uim/slib.c 2005-01-11 17:11:15 UTC (rev 255)
@@ -4544,8 +4544,8 @@
init_subr_1 ("string-length", string_length);
init_subr_1 ("string-dimension", string_dim);
init_lsubr ("string-append", string_append);
- init_subr_1 ("string->integer",string2integer);
- init_subr_2 ("string=?",string_equal);
+ init_subr_1 ("string->integer", string2integer);
+ init_subr_2 ("string=?", string_equal);
init_subr_2 ("eval", leval);
init_subr_2 ("apply", lapply);
init_fsubr ("define", leval_define);
Modified: trunk/uim/uim-key.c
===================================================================
--- trunk/uim/uim-key.c 2005-01-11 16:20:34 UTC (rev 254)
+++ trunk/uim/uim-key.c 2005-01-11 17:11:15 UTC (rev 255)
@@ -40,13 +40,12 @@
#include "uim-compat-scm.h"
#include "context.h"
-/* valid-key-symbols in key.scm has also to be updated if you add new
- * key definition to key_tab
- */
-static struct {
+struct key_entry {
int key;
- char *str;
-} key_tab[] = {
+ const char *str;
+};
+
+static struct key_entry key_tab[] = {
{UKey_Backspace, "backspace"},
{UKey_Delete, "delete"},
{UKey_Escape, "escape"},
@@ -158,11 +157,24 @@
}
#endif
-static char *
+static void
+define_valid_key_symbols(void)
+{
+ int i;
+
+ UIM_EVAL_STRING(NULL, "(define valid-key-symbols ())");
+ for (i = 0; key_tab[i].key; i++) {
+ UIM_EVAL_FSTRING1(NULL,
+ "(set! valid-key-symbols (cons '%s valid-key-symbols))",
+ key_tab[i].str);
+ }
+}
+
+static const char *
get_sym(int key)
{
int i;
- char *res = NULL;
+ const char *res = NULL;
for (i = 0; key_tab[i].key; i++) {
if (key_tab[i].key == key) {
res = key_tab[i].str;
@@ -174,7 +186,7 @@
static int
keycode_to_sym(int key, char *buf)
{
- char *s = get_sym(key);
+ char *s = (char *)get_sym(key);
if (!s) {
if (key > 128) {
return -1;
@@ -187,7 +199,7 @@
}
static void
-handle_key(uim_context uc, char *p, int key, int state)
+handle_key(uim_context uc, const char *p, int key, int state)
{
char keybuf[20];
int rv;
@@ -259,5 +271,6 @@
void
uim_init_key_subrs(void)
{
- uim_scm_init_fsubr("define-key", (uim_lisp (*)(uim_lisp, uim_lisp))define_key);
+ define_valid_key_symbols();
+ uim_scm_init_fsubr("define-key", define_key);
}
More information about the Uim-commit
mailing list