File: sdlskk.rsd

package info (click to toggle)
ruby-sdl 2.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, sid, stretch
  • size: 1,544 kB
  • ctags: 1,359
  • sloc: cpp: 7,598; ansic: 4,498; ruby: 2,246; makefile: 106; sh: 102
file content (477 lines) | stat: -rw-r--r-- 8,142 bytes parent folder | download | duplicates (4)
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
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
= SDLSKK
* ((<Japanese input system by SDLSKK>))
* ((<SDL::SKK::Context>))
* ((<SDL::SKK::Dictionary>))
* ((<SDL::SKK::Keybind>))
* ((<SDL::SKK::RomKanaRuleTable>))
* SDLSKK methods
TOC

== Japanese input system by SDLSKK
Ruby/SDL has 
((<SKK|URL:http://openlab.jp/skk/index-j.html>))-like
Japanese input system by 
((<SDLSKK|URL:http://www.kmc.gr.jp/~ohai/sdlskk.html>)).

This system enables you not only to input Japanse
but also to handle line input including 
cut and paste.

Please see sample/sdlskk.rb.

== SDL::SKK
This module has some SDLSKK-related module functions
and classes.

METHODS(SKK)

== SDL::SKK::Context
This class represents input state.

METHODS(SKK::Context)

== SDL::SKK::Dictionary
This class represents a Kana-Kanji dictionary.
Load SKK dictionary from files.

METHODS(SKK::Dictionary)

== SDL::SKK::Keybind
This class represents keybind.

METHODS(SKK::Keybind)

== SDL::SKK::RomKanaRuleTable
This class represents the translation table
from Romaji(Alphabet) to Kana.
Load text data from a file and create new table object.

METHODS(SKK::RomKanaRuleTable)

== SDLSKK methods
%%%
NAME encoding=
MOD SKK
TYPE .
DEP SDLSKK
PURPOSE Set SDLSKK internal encoding

PROTO
encoding=(encoding)

DESC
Sets SDLSKKK internal encoding to $[encoding].
Following constants are allowed:
* SDL::SKK::EUCJP
* SDL::SKK::UTF8
* SDL::SKK::SJIS
Default is SDL::SKK::EUCJP.

This encoding determines 
the encoding of @[dictionary files|SKK::Dictionary#load],
@[a romaji-kana translation table file|SKK::RomKanaRuleTable.new]
and @[private dictionary|SKK::Dictionary#save].

NOTES
This function should call once before calling other
SDLSKK methods.

SEEALSO
SKK.encoding
SKK::Dictionary#load
SKK::Dictionary#save
SKK::RomKanaRuleTable.new

%%
NAME encoding
MOD SKK
TYPE .
DEP SDLSKK
PURPOSE Get SDLSKK internal encoding
RVAL UINT

PROTO
encoding

DESC
Returns the SDLSKK internal encoding. Please see
@[SKK.encoding=] for more detail.

SEEALSO
SKK.encoding=

%%
NAME new
MOD SKK::RomKanaRuleTable
TYPE .
DEP SDLSKK
PURPOSE Load a Romaji-Kana trasnlation table
RVAL SDL::SKK::RomKanaRuleTable

PROTO
new(filename)

DESC
Load a Romaji-Kana trasnlation table from $[filename].
File format is:
* a line beginnig with ;; is comment
* empty line is ignored
* one entry per one line: <input alphabets><TAB><Katakana><TAB><Hiragana>
  
NOTES
Encoding of this file is set by @[SKK.encoding=]
before loading it.

SEEALSO
SKK::Context.new

%%
NAME new
MOD SKK::Dictionary
TYPE .
DEP SDLSKK
PURPOSE Create empty dictionary
RVAL SDL::SKK::Dictionary

PROTO
new

DESC
Creates empty dictionary object and returns it.

SEEALSO
SKK::Dictionary#load

%%
NAME load
MOD SKK::Dictionary
TYPE #
DEP SDLSKK
PURPOSE Read a dictionary file

PROTO
load(filename, user)

DESC
Read a dictionary data from $[filename]. 
Format of dictionary is same as of SKK
(Ruby/SDL cannot read data with annotations).
If $[user] is true, loaded data is treated as
user dictionary data. If $[user] is false,
loaded data is treated as system dictionary data.

NOTES
Encoding of this file is set by @[SKK.encoding=]
before loading it.

EXCEPTION *

SEEALSO
SKK::Dictionary.new
SKK::Dictionary#save
SKK::Context.new

%%
NAME save
MOD SKK::Dictionary
TYPE #
DEP SDLSKK
PURPOSE Save user dictionary data

PROTO
save(filename)

DESC
Save user dictionary data into $[filename].

SEEALSO
SKK::Dictionary.new
SKK::Dictionary#load

%%
NAME new
MOD SKK::Keybind
TYPE .
DEP SDLSKK
PURPOSE Create empty keybind
RVAL SDL::SKK::Keybind

PROTO
new

DESC
Creates empty keybind object and returns it.
Add keybind to this object using
@[SKK::Keybind#set_key] and @[SKK::Keybind#set_default_key].

SEEALSO
SKK::Keybind#set_key
SKK::Keybind#set_default_key
SKK::Context.new

%%
NAME set_key
MOD SKK::Keybind
TYPE #
DEP SDLSKK
PURPOSE Set keybind

PROTO
set_key(key_str, cmd_str)

DESC
Sets keybind. $[key_str] is a key-symbol string.
$[cmd_str] is command string.

Following strings are allowed as $[key_str]:
* Alphabet and ascii characters like "%"
* "SPC" "TAB" "DEL" "RET" "UP" "DOWN" "RIGHT" "LEFT" "INSERT" "HOME" "END"
  "PAGEUP" "PAGEDOWN" "F1" "F2" "F3" "F4" "F5" "F6" "F7" "F8" "F9" "F10"
  "F11" "F12" "F13" "F14" "F15" "HELP"
* key with modifiers like "C-a" and "M-C-a"

Following strings is allowed as $[cmd_str]:
* "backward-char",
* "forward-char",
* "backward-delete-char",
* "delete-char",
* "kakutei",
* "kettei",
* "space",
* "keyboard-quit",
* "set-mark-command",
* "kill-region",
* "yank",
* "copy",
* "graph-char",
* "upper-char",
* "lower-char",
* "abbrev-input",
* "latin-mode",
* "previous-candidate",
* "jisx0208-mode",
* "toggle-kana",
* "beginning-of-line"
* "end-of-line"
* "do-nothing"

You shouldn't change the keybind of only one ascii character key
like "a" and "/".

@[SKK::Keybind#set_default_key] is useful.

SEEALSO
SKK::Keybind#set_default_key
SKK::Keybind#unset_key

%%
NAME set_default_key
MOD SKK::Keybind
TYPE #
DEP SDLSKK
PURPOSE Load default Emacs-like keybinds

PROTO
set_default_key

DESC
Load default Emacs-like keybinds.

SEEALSO
SKK::Keybind#set_key

%%
NAME unset_key
MOD SKK::Keybind
TYPE #
DEP SDLSKK
PURPOSE Unset keybind

PROTO
unset_key(key_str)

DESC
Unset keybind of $[key_str].

SEEALSO
SKK::Keybind#set_key

%%
NAME new
MOD SKK::Context
TYPE .
DEP SDLSKK
PURPOSE Create new input context
RVAL SKK::Context

PROTO
new(dict, romkama_table, bind, use_minibuffer)

DESC
Creates input context and returns new @[SKK::Context] object.
$[dict] is a @[dictionary|SKK::Dictionary],
$[romkama_table] is a
@[Ronaji-Kana translation table|SKK::RomKanaRuleTable]
and $[bind] is @[keybind|SKK::Keybind].
If $[use_minibuffer] is true, 
SKK-like minibuffer is enabled.

EXAMPLE
# Create dictionary object and read data from 'jisyo'
dict = SDL::SKK::Dictionary.new
dict.load( 'jisyo', false )
# Read Romaji-Kana translation table from 'rule_table'
table = SDL::SKK::RomKanaRuleTable.new( 'rule_table' )
# Set keybind
bind = SDL::SKK::Keybind.new
bind.set_default_key

# Create context
context = SDL::SKK::Context.new( dict, table, bind, use_minibuffer )

SEEALSO
SKK::Context#input
SKK::Context#str

%%
NAME input
MOD SKK::Context
TYPE #
DEP SDLSKK
PURPOSE Handle keyboard event

PROTO
input(event)

DESC
Handles keyboard event. $[event] should be 
@[Event] object.
This method handles only @[keydown events|Event::KeyDown]
and ignore other events.

EXAMPLE
while event = SDL::Event.poll do
  case event
  when SDL::Event::Quit
    exit
  when SDL::Event::KeyDown
    if event.sym == SDL::Key::ESCAPE then
      exit
    end
    if event.sym == SDL::Key::F1
      dict.save("test_user_dict")
    end
    context.input( event )      
  end
end

%%
NAME str
MOD SKK::Context
TYPE #
DEP SDLSKK
PURPOSE Get input string
RVAL String

PROTO
str

DESC
Returns input string.

NOTES
If Ruby/SDL m17n support is enabled,
the string with proper encoding will be returned.

SEEALSO
SKK::Context#render_str
SKK::Context#clear
SKK::Context#clear_text
SKK.encoding

%%
NAME render_str
MOD SKK::Context
TYPE #
DEP SDLSKK
PURPOSE Render input string
RVAL SDL::Surface

PROTO
render_str(font, r, g, b)

DESC
Renders input string and returns @[Surface] object.

SEEALSO
SKK::Context#render_minibuffer_str

%%
NAME render_minibuffer_str
MOD SKK::Context
TYPE #
DEP SDLSKK
PURPOSE Render minibuffer string

PROTO
render_minibuffer_str(font, r, g, b)

DESC
Renders minibuffer string and returns @[Surface] object.

%%
NAME clear
MOD SKK::Context
TYPE #
DEP SDLSKK
PURPOSE Clear context

PROTO
clear

DESC
Clears input context.

SEEALSO
SKK::Context#clear_text

%%
NAME clear_text
MOD SKK::Context
TYPE #
DEP SDLSKK
PURPOSE Creat input text

PROTO
clear_text

DESC
Clears input text, but input mode is held.

If you want multi-line input, this method is better
than @[SKK::Context#clear]

SEEALSO
SKK::Context#get_basic_mode

%%
NAME get_basic_mode
MOD SKK::Context
TYPE #
DEP SDLSKK
PURPOSE Get whether input mode is basic mode
RVAL true/false

PROTO
get_basic_mode

DESC
Returns true if $[self]'s input mode is kakutei-mode,
latin-mode or jisx0208-latim-mode, otherwise returns
false.

NOTES
Please see ((<SKK|URL:http://openlab.jp/skk/index.html>)).

SEEALSO
SKK::Context#clear_text