[uim-commit] r499 - in trunk: helper scm uim
yamaken at freedesktop.org
yamaken at freedesktop.org
Wed Feb 2 21:24:14 PST 2005
Author: yamaken
Date: 2005-02-02 21:24:11 -0800 (Wed, 02 Feb 2005)
New Revision: 499
Modified:
trunk/helper/pref-gtk.c
trunk/scm/custom.scm
trunk/scm/skk-key-custom.scm
trunk/scm/util.scm
trunk/uim/uim-custom.c
Log:
* This commit performs again adaptation of key-str representation for
uim-pref. See [Anthy-dev 1718] for further information.
* helper/pref-gtk.c
- (key_pref_set_value):
* Ignore Shift modifier for printable char keys for
easy-to-recognize key configuration. uim-custom performs
implicit shift key encoding/decoding appropriately.
* Remove g_ascii_tolower() in accordance with the specification
change of key representation on uim-pref
* scm/custom.scm
- (key-list-encode-shift): Add support for non-letter printable char
- (key-list-ignore-regular-shift): Fix for non-letter chars
- (key-list-ignore-letter-shift,
key-list-ignore-punct-numeric-shift, key-list-strip-shift,
key-list-strip-regular-shift): New procedure
- (key-list-export-as-basic, key-list-import-as-basic): Replace the
filter in accordance with the specification change
* scm/util.scm
- (string->printable-char): New procedure
- (string->letter): Simplify with string->printable-char
* scm/skk-key-custom.scm
- (custom skk-special-midashi-key): Replace <Shift> with
<IgnoreShift> to fit to the specification change
* uim/uim-custom.c
- (literalize_string): New procedure
- (extract_key_literal, uim_custom_save_group, uim_custom_set): Fix
broken string escaping
Modified: trunk/helper/pref-gtk.c
===================================================================
--- trunk/helper/pref-gtk.c 2005-02-03 01:41:08 UTC (rev 498)
+++ trunk/helper/pref-gtk.c 2005-02-03 05:24:11 UTC (rev 499)
@@ -1299,8 +1299,14 @@
gchar keystr[256] = {0};
gint len = sizeof(keystr) / sizeof(gchar);
+ /*
+ * Ignore Shift modifier for printable char keys for
+ * easy-to-recognize key configuration. uim-custom performs
+ * implicit shift key encoding/decoding appropriately.
+ */
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(key_pref_win.shift_toggle),
- mod & GDK_SHIFT_MASK);
+ ((keyval >= 256) || !g_ascii_isgraph(keyval)) &&
+ (mod & GDK_SHIFT_MASK));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(key_pref_win.control_toggle),
mod & GDK_CONTROL_MASK);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(key_pref_win.alt_toggle),
@@ -1399,12 +1405,7 @@
} else if (keyval >= GDK_F1 && keyval <= GDK_F35) {
g_snprintf(keystr, len, "%d", keyval - GDK_KP_0 + UKey_0);
} else if (keyval < 256) {
- /*
- * Downcase alphabet keys for easy-to-recognize key
- * configuration. uim-custom performs implicit shift key
- * encoding/decoding appropriately.
- */
- keystr[0] = g_ascii_tolower(keyval);
+ keystr[0] = keyval;
keystr[1] = '\0';
} else {
/* UKey_Other */
Modified: trunk/scm/custom.scm
===================================================================
--- trunk/scm/custom.scm 2005-02-03 01:41:08 UTC (rev 498)
+++ trunk/scm/custom.scm 2005-02-03 05:24:11 UTC (rev 499)
@@ -223,17 +223,23 @@
;; TODO: write test
(define key-list-encode-shift
(lambda (key-list)
- (let ((has-shift? (memq 'Shift_key key-list))
- (letter (string->letter (find string? key-list))))
+ (let* ((has-shift? (memq 'Shift_key key-list))
+ (str (find string? key-list))
+ (printable (string->printable-char str))
+ (letter (string->letter str)))
(filter-map (lambda (elem)
(cond
((and (eq? elem 'Shift_key)
- letter)
+ (char-graphic? printable))
#f)
((and (string? elem)
has-shift?
letter)
(charcode->string (char-upcase letter)))
+ ((and (string? elem)
+ has-shift?
+ (char-graphic? printable))
+ str)
(else
elem)))
key-list))))
@@ -254,17 +260,53 @@
;; TODO: write test
(define key-list-ignore-regular-shift
(lambda (key-list)
+ (let ((printable (string->printable-char (find string? key-list))))
+ (if (char-graphic? printable)
+ (cons 'IgnoreRegularShift key-list)
+ key-list))))
+
+;; TODO: write test
+(define key-list-ignore-letter-shift
+ (lambda (key-list)
(let ((letter (string->letter (find string? key-list))))
(if letter
(cons 'IgnoreShift key-list)
key-list))))
;; TODO: write test
+(define key-list-ignore-punct-numeric-shift
+ (lambda (key-list)
+ (let* ((str (find string? key-list))
+ (c (string->printable-char str)))
+ (if (and (char-graphic? c)
+ (not (char-alphabetic? c)))
+ (cons 'IgnoreShift key-list)
+ key-list))))
+
+;; TODO: write test
(define key-list-ignore-case
(lambda (key-list)
(let ((letter (string->letter (find string? key-list))))
(if letter
(cons 'IgnoreCase key-list)
+ key-list))))
+
+;; TODO: write test
+(define key-list-strip-shift
+ (lambda (key-list)
+ (remove (lambda (key)
+ (eq? key 'Shift_key))
+ key-list)))
+
+;; TODO: write test
+(define key-list-strip-regular-shift
+ (lambda (key-list)
+ (let* ((str (find string? key-list))
+ (printable (string->printable-char str)))
+ (if (char-graphic? printable)
+ (remove (lambda (key)
+ (eq? key 'Shift_key))
+ key-list)
key-list))))
;; TODO: write test
@@ -274,13 +316,15 @@
;; TODO: write test
(define key-list-export-as-basic (compose key-list-visualize-space
- key-list-decode-shift
+ key-list-encode-shift
key-list-strip-translators))
;; TODO: write test
(define key-list-import-as-basic (compose key-list-characterize-space
+ key-list-ignore-punct-numeric-shift
key-list-ignore-case
- key-list-decode-shift))
+ key-list-decode-shift
+ key-list-strip-regular-shift))
;; TODO: write test
(define key-list-export-as-traditional (compose key-list-visualize-space
Modified: trunk/scm/skk-key-custom.scm
===================================================================
--- trunk/scm/skk-key-custom.scm 2005-02-03 01:41:08 UTC (rev 498)
+++ trunk/scm/skk-key-custom.scm 2005-02-03 05:24:11 UTC (rev 499)
@@ -173,7 +173,7 @@
(_ "[SKK] previous completion candidate")
(_ "long description will be here"))
-(define-custom 'skk-special-midashi-key '("<Shift>>" "<Shift><" "<Shift>?")
+(define-custom 'skk-special-midashi-key '("<IgnoreShift>>" "<IgnoreShift><" "<IgnoreShift>?")
'(skk-keys-advanced1)
'(key)
(_ "[SKK] skk-special-midashi-key?")
Modified: trunk/scm/util.scm
===================================================================
--- trunk/scm/util.scm 2005-02-03 01:41:08 UTC (rev 498)
+++ trunk/scm/util.scm 2005-02-03 05:24:11 UTC (rev 499)
@@ -102,11 +102,18 @@
(let ((buf (string-append "\"\"" s s)))
(print-to-string s buf))))
-(define string->letter
+;; TODO: write test
+(define string->printable-char
(lambda (str)
(let ((c (and (= (string-length str)
1)
(string->charcode str))))
+ (and (char-printable? c)
+ c))))
+
+(define string->letter
+ (lambda (str)
+ (let ((c (string->printable-char str)))
(and (char-alphabetic? c)
c))))
Modified: trunk/uim/uim-custom.c
===================================================================
--- trunk/uim/uim-custom.c 2005-02-03 01:41:08 UTC (rev 498)
+++ trunk/uim/uim-custom.c 2005-02-03 05:24:11 UTC (rev 499)
@@ -63,6 +63,8 @@
uim_bool uim_custom_init(void);
uim_bool uim_custom_quit(void);
+static char *literalize_string(const char *str);
+
static char *c_list_to_str(const void *const *list, char *(*mapper)(const void *elem), const char *sep);
static int uim_custom_type_eq(const char *custom_sym, const char *custom_type);
@@ -119,6 +121,22 @@
static char *
+literalize_string(const char *str)
+{
+ uim_lisp stack_start;
+ uim_lisp form;
+ char *escaped;
+
+ uim_scm_gc_protect_stack(&stack_start);
+ form = uim_scm_list2(uim_scm_make_symbol("string-escape"),
+ uim_scm_make_str(str));
+ escaped = uim_scm_c_str(uim_scm_eval(form));
+ uim_scm_gc_unprotect_stack(&stack_start);
+
+ return escaped;
+}
+
+static char *
c_list_to_str(const void *const *list, char *(*mapper)(const void *elem), const char *sep)
{
size_t buf_size;
@@ -447,8 +465,7 @@
switch (custom_key->type) {
case UCustomKey_Regular:
- UIM_EVAL_FSTRING1(NULL, "\"\\\"%s\\\"\"", custom_key->literal);
- literal = uim_scm_c_str(uim_scm_return_value());
+ literal = literalize_string(custom_key->literal);
break;
case UCustomKey_Reference:
literal = strdup(custom_key->literal);
@@ -842,7 +859,7 @@
for (sym = custom_syms; *sym; sym++) {
def_literal = uim_custom_definition_as_literal(*sym);
if (def_literal) {
- fprintf(file, def_literal);
+ fputs(def_literal, file);
fprintf(file, "\n");
free(def_literal);
}
@@ -978,6 +995,8 @@
uim_bool
uim_custom_set(const struct uim_custom *custom)
{
+ char *literal;
+
if (!custom)
return UIM_FALSE;
@@ -991,12 +1010,16 @@
custom->symbol, custom->value->as_int);
break;
case UCustom_Str:
- UIM_EVAL_FSTRING2(NULL, "(custom-set-value! '%s \"%s\")",
- custom->symbol, custom->value->as_str);
+ literal = literalize_string(custom->value->as_str);
+ UIM_EVAL_FSTRING2(NULL, "(custom-set-value! '%s %s)",
+ custom->symbol, literal);
+ free(literal);
break;
case UCustom_Pathname:
- UIM_EVAL_FSTRING2(NULL, "(custom-set-value! '%s \"%s\")",
- custom->symbol, custom->value->as_pathname);
+ literal = literalize_string(custom->value->as_pathname);
+ UIM_EVAL_FSTRING2(NULL, "(custom-set-value! '%s %s)",
+ custom->symbol, literal);
+ free(literal);
break;
case UCustom_Choice:
UIM_EVAL_FSTRING2(NULL, "(custom-set-value! '%s '%s)",
More information about the Uim-commit
mailing list