/usr/share/uim/m17nlib.scm is in uim-m17nlib 1:1.8.6+gh20161003.0.d63dadd-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 | ;;;
;;; Copyright (c) 2003-2013 uim Project https://github.com/uim/uim
;;;
;;; 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-custom "generic-key-custom.scm")
(require-custom "m17nlib-custom.scm")
;;; user configs
(define m17nlib-candidate-max 10)
;; key defs
(define-key m17nlib-on-key? 'generic-on-key?)
(define-key m17nlib-off-key? 'generic-off-key?)
;;; implementations
(register-action 'action_m17nlib_off
(lambda (mc)
(list
'off
"-"
(N_ "off")
(N_ "Direct Input Mode")))
(lambda (mc)
(not (m17nlib-context-on mc)))
(lambda (mc)
(m17nlib-context-set-on! mc #f)))
(register-action 'action_m17nlib_on
(lambda (mc)
(let* ((im (m17nlib-context-im mc))
(name (symbol->string (im-name im))))
(list
'on
"O"
(N_ "on")
(string-append name (N_ " Mode")))))
(lambda (mc)
(m17nlib-context-on mc))
(lambda (mc)
(m17nlib-context-set-on! mc #t)))
;; Update widget definitions based on action configurations. The
;; procedure is needed for on-the-fly reconfiguration involving the
;; custom API
(define m17nlib-configure-widgets
(lambda ()
(register-widget 'widget_m17nlib_input_mode
(activity-indicator-new m17nlib-input-mode-actions)
(actions-new m17nlib-input-mode-actions))))
(define m17nlib-context-rec-spec
(append
context-rec-spec
;; renamed from 'id' to avoid conflict with context-id
'((mc-id #f)
(on #f)
(showing-candidate #f))))
(define-record 'm17nlib-context m17nlib-context-rec-spec)
(define m17nlib-context-new-internal m17nlib-context-new)
(define m17nlib-context-new
(lambda (id im name)
(let ((mc (m17nlib-context-new-internal id im))
(mc-id (m17nlib-lib-alloc-context name)))
(m17nlib-context-set-widgets! mc m17nlib-widgets)
(m17nlib-context-set-mc-id! mc mc-id)
mc)))
(define m17nlib-update-preedit
(lambda (mc)
(let* ((mid (m17nlib-context-mc-id mc)))
(if (m17nlib-lib-preedit-changed? mid)
(if (m17nlib-lib-compose-mode? mid)
(begin
(im-clear-preedit mc)
(im-pushback-preedit mc
preedit-underline
(m17nlib-lib-get-left-of-candidate mid))
(im-pushback-preedit mc
(+ preedit-reverse preedit-cursor)
(m17nlib-lib-get-selected-candidate mid))
(im-pushback-preedit mc
preedit-underline
(m17nlib-lib-get-right-of-candidate mid))
(im-update-preedit mc))
(begin
(im-clear-preedit mc)
(im-pushback-preedit mc
preedit-underline
(m17nlib-lib-get-left-of-cursor mid))
(im-pushback-preedit mc
preedit-cursor "")
(im-pushback-preedit mc
preedit-underline
(m17nlib-lib-get-right-of-cursor mid))
(im-update-preedit mc))
)))))
(define m17nlib-update-candidate
(lambda (mc)
(m17nlib-lib-fill-new-candidates! (m17nlib-context-mc-id mc))
(let* ((mid (m17nlib-context-mc-id mc))
(nrcands (m17nlib-lib-get-nr-candidates mid))
(showing-candidate? (m17nlib-context-showing-candidate mc))
(candidates-changed? (m17nlib-lib-candidates-changed? mid)))
;; FIXME: Rewrite this seriese of if with cond.
(if (or
(and showing-candidate? candidates-changed?)
(and showing-candidate? (not (m17nlib-lib-candidate-show? mid)))
(= nrcands 0))
(begin
(im-deactivate-candidate-selector mc)
(m17nlib-context-set-showing-candidate! mc #f)))
(if (and
m17nlib-use-candidate-window?
(or
candidates-changed?
(and
(not showing-candidate?)
(m17nlib-lib-candidate-show? mid)))
(not (= nrcands 0)))
(begin
(im-activate-candidate-selector
mc nrcands m17nlib-candidate-max)
(im-select-candidate
mc (m17nlib-lib-get-candidate-index mid))
(m17nlib-context-set-showing-candidate! mc #t)))
(if (and (m17nlib-context-showing-candidate mc)
(m17nlib-lib-candidate-show? mid))
(im-select-candidate mc (m17nlib-lib-get-candidate-index mid))))))
(define m17nlib-construct-modifier
(lambda (key key-state)
(let ((key-str ""))
(if (and
(shift-key-mask key-state)
(not (ichar-graphic? key)))
(set! key-str (string-append "S-" key-str)))
(if (and
(control-key-mask key-state)
(ichar-printable? key))
(set! key-str (string-append "C-" key-str)))
(if (alt-key-mask key-state)
(set! key-str (string-append "A-" key-str)))
(if (meta-key-mask key-state)
(set! key-str (string-append "M-" key-str)))
(if (super-key-mask key-state)
(set! key-str (string-append "s-" key-str)))
(if (hyper-key-mask key-state)
(set! key-str (string-append "H-" key-str)))
key-str)))
(define m17nlib-construct-key
(lambda (key key-state)
(if (symbol? key)
(let ((mkey (assq key m17nlib-key-translation-alist)))
(if mkey
(cdr mkey)
""))
(if (control-key-mask key-state)
(charcode->string (ichar-upcase key))
(charcode->string key)))))
(define m17nlib-proc-direct-state
(lambda (mc key key-state)
(if (m17nlib-on-key? key key-state)
(m17nlib-context-set-on! mc #t)
(m17nlib-commit-raw mc))))
(define m17nlib-commit-raw
(lambda (mc)
(im-commit-raw mc)))
(define m17nlib-key-translation-alist
'((backspace . "BackSpace")
(delete . "Delete")
(escape . "Escape")
(return . "Return")
(tab . "Tab")
(left . "Left")
(up . "Up")
(right . "Right")
(down . "Down")
(prior . "Page_Down")
(next . "Page_Up")
(home . "Home")
(end . "End")
(zenkaku-hankaku . "")
(Multi_key . "")
(Mode_switch . "")
(Henkan_Mode . "")
(Muhenkan . "")
(Kanji . "")
(hiragana-katakana . "")
(F1 . "F1")
(F2 . "F2")
(F3 . "F3")
(F4 . "F4")
(F5 . "F5")
(F6 . "F6")
(F7 . "F7")
(F8 . "F8")
(F9 . "F9")
(F10 . "F10")
(F11 . "F11")
(F12 . "F12")
(F13 . "F13")
(F14 . "F14")
(F15 . "F15")
(F16 . "F16")
(F17 . "F17")
(F18 . "F18")
(F19 . "F19")
(F20 . "F20")))
; Unfortunatelly, we don't have simple way to translate...
(define m17nlib-translate-ukey-to-mkey
(lambda (key key-state)
(string-append
(m17nlib-construct-modifier key key-state)
(m17nlib-construct-key key key-state))))
(define m17nlib-init-handler
(lambda (id im arg)
(m17nlib-context-new id im arg)))
(define m17nlib-release-handler
(lambda (mc)
#f))
(define m17nlib-push-key
(lambda (mc key key-state)
(let ((mid (m17nlib-context-mc-id mc))
(mkey (m17nlib-translate-ukey-to-mkey key key-state)))
(m17nlib-lib-push-symbol-key mid mkey))))
(define m17nlib-press-key-handler
(lambda (mc key key-state)
(let* ((mid (m17nlib-context-mc-id mc)))
(if (m17nlib-context-on mc)
(if (m17nlib-push-key mc key key-state)
#f ; Key event is consumed in m17n-push-key
(let* ((result (m17nlib-lib-get-result mid))
(consumed? (car result))
(commit-str (cdr result)))
(if (m17nlib-off-key? key key-state)
(begin
(m17nlib-context-set-on! mc #f)
(if (not (string=? commit-str ""))
(im-commit mc commit-str)))
(if (string=? commit-str "")
(im-commit-raw mc)
(begin
(im-commit mc commit-str)
(m17nlib-lib-commit mid)
(if (not consumed?)
(im-commit-raw mc)))))))
(m17nlib-proc-direct-state mc key key-state))
(m17nlib-update-preedit mc)
(m17nlib-update-candidate mc))))
(define m17nlib-release-key-handler
(lambda (mc key key-state)
(if (or (ichar-control? key)
(not (m17nlib-context-on mc)))
;; don't discard key release event for apps
(m17nlib-commit-raw mc))))
(define m17nlib-reset-handler
(lambda (mc)
(let ((mid (m17nlib-context-mc-id mc)))
(m17nlib-lib-push-symbol-key mid "input-reset"))))
(define m17nlib-focus-in-handler
(lambda (mc)
(let ((mid (m17nlib-context-mc-id mc)))
(m17nlib-lib-push-symbol-key mid "input-focus-in")
(m17nlib-update-preedit mc))))
(define m17nlib-focus-out-handler
(lambda (mc)
(let ((mid (m17nlib-context-mc-id mc)))
(m17nlib-lib-push-symbol-key mid "input-focus-out")
(m17nlib-update-preedit mc))))
(define m17nlib-displace-handler
(lambda (mc)
(let ((mid (m17nlib-context-mc-id mc)))
(m17nlib-lib-push-symbol-key mid "input-focus-move")
(m17nlib-update-preedit mc))))
(define m17nlib-get-candidate-handler
(lambda (mc idx accel-enum-hint)
(let* ((mid (m17nlib-context-mc-id mc))
(cand (m17nlib-lib-get-nth-candidate
mid idx)))
(list cand (digit->string (+ idx 1)) ""))))
(define m17nlib-set-candidate-index-handler
(lambda (mc idx)
#f))
;; Developer specified IM rejection should be completely withdrawn
;; after we got flexible install-time IM preference list. These
;; redundant IMs should be "disabled by default, but can be enabled"
;; under the feature. But we should invest our time for more valuable
;; issues. -- YamaKen 2005-01-25
(define duplicated-im-list
'("m17n-ja-anthy"
"m17n-ja-tcode"
"m17n-zh-pinyin"
"m17n-zh-py"))
;; At now, simply enable all IMs. Although they are redundant and
;; unconfortable, they can be disabled by uim-pref.
;; -- YamaKen 2005-01-25
(define duplicated-im?
(if #t
(lambda (name)
#f)
(lambda (name)
(member name duplicated-im-list))))
(define m17nlib-register
(lambda (i nr-im)
(if (> nr-im i)
(begin
(if (not (duplicated-im? (m17nlib-lib-nth-input-method-name i)))
(register-im
(string->symbol (m17nlib-lib-nth-input-method-name i))
(m17nlib-lib-nth-input-method-lang i)
"UTF-8"
(m17nlib-lib-nth-input-method-name i)
(m17nlib-lib-nth-input-method-short-desc i)
(m17nlib-lib-nth-input-method-name i)
m17nlib-init-handler
m17nlib-release-handler
context-mode-handler
m17nlib-press-key-handler
m17nlib-release-key-handler
m17nlib-reset-handler
m17nlib-get-candidate-handler
m17nlib-set-candidate-index-handler
context-prop-activate-handler
#f
m17nlib-focus-in-handler
m17nlib-focus-out-handler
#f
m17nlib-displace-handler
))
(m17nlib-register (+ i 1) nr-im))
())))
(m17nlib-lib-init)
(m17nlib-register 0 (m17nlib-lib-nr-input-methods))
(m17nlib-configure-widgets)
|