[uim-commit] r949 - branches/composer/scm

yamaken at freedesktop.org yamaken at freedesktop.org
Fri Jul 8 15:20:31 EST 2005


Author: yamaken
Date: 2005-07-07 22:20:25 -0700 (Thu, 07 Jul 2005)
New Revision: 949

Added:
   branches/composer/scm/ng-action.scm
Modified:
   branches/composer/scm/Makefile.am
Log:
* This commit adds simplified and polymorphic-action-capable action
  handling framework intended to be used with the composer framework.

  All variable and procedures are coexistible with legacy
  action.scm. But some procedures have 'ng-' prefix to avoid
  confliction. The prefixes will be removed when legacy action.scm has
  been obsoleted.

* scm/ng-action.scm
  - New file
  - (record indication, record action-skeleton, record action): New
    record. record indication is exactly same as in load-action.scm
  - (indication-rec-spec, action-skeleton-rec-spec, action-rec-spec,
    std-indication-null, std-indication-fallback,
    std-indication-separator, std-action-separator): New variable
  -(legacy-action-new, ng-action-new, action-new,
    action-skeleton-bless, action-activate!, action-ready?,
    ng-action-indicate, action-status, action-status-encoder-selected,
    action-status-encoder-checked, actionset-fetcher,
    actionset-opaque, actionset-new, actionset-fetch-action-skeleton,
    actionset-fetch-action, actionset-handle-event): New procedure
* scm/Makefile.am
  - (SCM_FILES): Add ng-action.scm, ng-anthy.scm, ng-canna.scm


Modified: branches/composer/scm/Makefile.am
===================================================================
--- branches/composer/scm/Makefile.am	2005-07-07 09:11:51 UTC (rev 948)
+++ branches/composer/scm/Makefile.am	2005-07-08 05:20:25 UTC (rev 949)
@@ -6,7 +6,7 @@
 GENERATED_SCM_FILES = installed-modules.scm loader.scm
 SCM_FILES = plugin.scm im.scm im-custom.scm lazy-load.scm init.scm \
  default.scm \
- util.scm key.scm ustr.scm action.scm load-action.scm i18n.scm \
+ util.scm key.scm ustr.scm ng-action.scm action.scm load-action.scm i18n.scm \
  ng-key.scm physical-key.scm event.scm evmap.scm evmap-csv.scm \
  event-translator.scm \
  key-custom.scm \
@@ -21,8 +21,8 @@
  generic.scm generic-custom.scm generic-key-custom.scm \
  pyload.scm PY.scm pyunihan.scm pinyin-big5.scm \
  japanese.scm japanese-azik.scm japanese-kana.scm \
- anthy.scm anthy-custom.scm anthy-key-custom.scm \
- canna.scm canna-custom.scm canna-key-custom.scm \
+ anthy.scm ng-anthy.scm anthy-custom.scm anthy-key-custom.scm \
+ canna.scm ng-canna.scm canna-custom.scm canna-key-custom.scm \
  prime.scm prime-custom.scm prime-key-custom.scm \
  skk.scm skk-editor.scm skk-custom.scm skk-key-custom.scm \
  tcode.scm \

Added: branches/composer/scm/ng-action.scm
===================================================================
--- branches/composer/scm/ng-action.scm	2005-07-07 09:11:51 UTC (rev 948)
+++ branches/composer/scm/ng-action.scm	2005-07-08 05:20:25 UTC (rev 949)
@@ -0,0 +1,205 @@
+;;; ng-action.scm: Action handling framework for uim (next generation)
+;;;
+;;; Copyright (c) 2005 uim Project http://uim.freedesktop.org/
+;;;
+;;; All rights reserved.
+;;;
+;;; Redistribution and use in source and binary forms, with or without
+;;; modification, are permitted provided that the following conditions
+;;; are met:
+;;; 1. Redistributions of source code must retain the above copyright
+;;;    notice, this list of conditions and the following disclaimer.
+;;; 2. Redistributions in binary form must reproduce the above copyright
+;;;    notice, this list of conditions and the following disclaimer in the
+;;;    documentation and/or other materials provided with the distribution.
+;;; 3. Neither the name of authors nor the names of its contributors
+;;;    may be used to endorse or promote products derived from this software
+;;;    without specific prior written permission.
+;;;
+;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND
+;;; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+;;; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+;;; ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
+;;; FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+;;; OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+;;; HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+;;; LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+;;; OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+;;; SUCH DAMAGE.
+;;;;
+
+(require "util.scm")
+(require "i18n.scm")
+(require "event.scm")
+
+
+;; CAUTION: Use ng-action-new, ng-action-indicate and action-actid
+;; instead of action-new, action-indicate and action-id until legacy
+;; action.scm has been obsoleted.  -- YamaKen 2005-07-08
+
+;;
+;; indication
+;;
+
+;; keep same as load-action.scm until legacy action.scm has been obsoleted
+(define indication-rec-spec
+  '((id           #f)  ;; must be first field
+    (iconic-label "")
+    (label        "")
+    (short-desc   "")))
+(define-record 'indication indication-rec-spec)
+
+
+;;
+;; action
+;;
+
+;; TODO: rename 'actid' to 'id'
+(define action-skeleton-rec-spec
+  '((actid         #f)  ;; must be first field
+    (indicate-proc #f)
+    (activate-proc #f)
+    (precond-pred  #f)
+    (status-proc   #f)))
+(define-record 'action-skeleton action-skeleton-rec-spec)
+
+;; TODO: rename ng-action-new to action-new
+(define action-rec-spec
+  '(append
+    (owner #f)  ;; must be first field
+    action-skeleton-rec-spec))
+(define legacy-action-new (and (symbol-bound? 'action-new)
+			       action-new))
+(define-record 'action action-rec-spec)
+(define ng-action-new action-new)
+(define action-new legacy-action-new)
+
+;; .returns Concrete action object
+(define action-skeleton-bless
+  (lambda (skeleton owner)
+    (cons owner skeleton)))
+
+;; .returns A bool value indicates succeeded or not
+(define action-activate!
+  (lambda (act)
+    (and (action-ready? act)
+	 (let ((proc (action-activate-proc act)))
+	   (if proc
+	       (proc act))
+	   #t))))
+
+(define action-ready?
+  (lambda (act)
+    (let ((pred (action-precond-pred act)))
+      (or (not pred)
+	  (pred act)))))
+
+;; TODO: rename to action-indicate
+(define ng-action-indicate
+  (lambda (act)
+    (let ((proc (action-indicate-proc act)))
+      (if proc
+	  (proc act)
+	  std-indication-fallback))))
+
+;; Provide useful status information about an action for human
+;; intended to be used via chooser UI and so on.
+;;
+;; .returns A symbol indicates status of the action 'selected 'checked
+;; or #f. 'selected indicates that the action is exclusively selected
+;; from a related group of actions. 'checked indicates that the action
+;; has some activity regardless of status of other actions. #f
+;; indicates no status. The two symbols are expected to be visualized
+;; as appropriate different figure.
+(define action-status
+  (lambda (act)
+    (let ((proc (action-status-proc act)))
+      (and proc
+	   (proc act)))))
+
+;; usage: (action-status-encoder-selected anthy-direct-mode?)
+(define action-status-encoder-selected
+  (lambda (stat?)
+    (lambda (act)
+      (and stat?
+	   (stat? act)
+	   'selected))))
+
+(define action-status-encoder-checked
+  (lambda (stat?)
+    (lambda (act)
+      (and stat?
+	   (stat? act)
+	   'checked))))
+
+
+;;
+;; actionset
+;;
+
+;; actionset is an abstract action-skeleton repository formed as
+;; (fetcher . opaque).
+;;
+;; usage: (actionset-new assq (list skeleton0 skeleton1 skeleton2))
+
+(define actionset-fetcher car)
+(define actionset-opaque cdr)
+
+(define actionset-new
+  (lambda (fetcher opaque)
+    (if (procedure? fetcher)
+	(cons fetcher opaque)
+	(error "actionset-new: invalid fetcher"))))
+
+(define actionset-fetch-action-skeleton
+  (lambda (actset act-id)
+    ((actionset-fetcher actset) act-id (actionset-opaque actset))))
+
+(define actionset-fetch-action
+  (lambda (actset owner act-id)
+    (let ((skeleton (actionset-fetch-action-skeleton actset)))
+      (and skeleton
+	   (action-skeleton-bless skeleton owner)))))
+
+(define actionset-handle-event
+  (lambda (actset owner ev)
+    (case (event-type ev)
+      ((action)
+       (let* ((act-id (action-event-action-id ev))
+	      (act (actionset-fetch-action actset owner act-id)))
+	 (and act
+	      (action-activate! act))))
+
+      (else
+       #f))))
+
+
+;;
+;; standard definitions
+;;
+
+(define std-indication-null
+  (indication-new 'null
+		  ""
+		  ""
+		  ""))
+
+(define std-indication-fallback
+  (indication-new 'unknown
+		  (N_ "?")
+		  (N_ "unknown")
+		  (N_ "unknown")))
+
+;; any UI should replace an indication that has 'separator as
+;; indication-id with real separator rather than label and icon
+(define std-indication-separator
+  (indication-new 'separator
+		  (N_ "--")
+		  (N_ "--------")
+		  ""))
+
+(define std-action-separator
+  (action-skeleton-new 'act_separator
+		       (lambda (act)
+			 std-indication-separator)))



More information about the uim-commit mailing list