8 put_string(s
: STRING) is
11 cursor
:= string.count
+ 1
17 text_insert(c
: CHARACTER) is
19 string.insert_character(c
, cursor
)
20 raise_signal(signal_change
)
26 if string.count
> 0 and then cursor
> 1 then
29 raise_signal(signal_change
)
36 if string.count
> 0 and then cursor
<= string.upper
then
38 raise_signal(signal_change
)
45 Result := string.is_empty
63 process_event(e
: EVENT
) is
65 if e
.type
= sdl_keydown
then
70 process_key(e
: EVENT
) is
75 if k
< 256 and then is_normal_key(k
) then
76 if is_kmod(e
.kmod
, kmod_shift
) then
77 text_insert(shifted_key(k
))
79 text_insert(k
.to_character
)
82 elseif k
= sdlk_right
then
84 if cursor
> string.count
+ 1 then
85 cursor
:= string.count
+ 1
87 elseif k
= sdlk_left
then
92 elseif k
= sdlk_backspace
then
94 elseif k
= sdlk_delete
then
96 elseif k
= sdlk_return
then
97 raise_signal(signal_activate
)
101 shifted_key_table
: ARRAY
[CHARACTER] is
105 !!Result.make(0, 127)
109 Result.put((i
- 32).to_character
, i
)
112 Result.put('~', sdlk_backquote
)
113 Result.put('!', sdlk_1
)
114 Result.put('@', sdlk_2
)
115 Result.put('#', sdlk_3
)
116 Result.put('$', sdlk_4
)
117 Result.put('%%', sdlk_5
)
118 Result.put('^', sdlk_6
)
119 Result.put('&', sdlk_7
)
120 Result.put('*', sdlk_8
)
121 Result.put('(', sdlk_9
)
122 Result.put(')', sdlk_0
)
123 Result.put('_', sdlk_minus
)
124 Result.put('+', sdlk_equals
)
125 Result.put('|', sdlk_backslash
)
127 Result.put('{', sdlk_leftbracket
)
128 Result.put('}', sdlk_rightbracket
)
130 Result.put(':', sdlk_semicolon
)
131 Result.put('"', sdlk_quote
)
133 Result.put('<', sdlk_comma
)
134 Result.put('>', sdlk_period
)
135 Result.put('?', sdlk_slash
)
137 Result.put(' ', sdlk_space
)
140 shifted_key(k
: INTEGER) : CHARACTER is
142 if shifted_key_table
.item(k
) /= '%U' then
143 Result := shifted_key_table
.item(k
)
145 Result := k
.to_character
149 is_normal_key(k
: INTEGER) : BOOLEAN is
151 if shifted_key_table
.item(k
) /= '%U' then
161 fill_rect(0, 0, width
, height
, white
)
163 fill_rect(0, 0, width
, height
, grey
)
165 fill_rect(1, 1, width
- 2, height
- 2, black
)
166 if string.count
> 0 then
172 measure_text_size(string.substring(1, cursor
- 1))
176 fill_rect(x
, 2, 1, height
- 4, white
)
184 if textimg
.is_connected
then
187 if string.count
> 0 then
188 textimg
.render_string(string, font
, white
)