/
uim-internal.h
188 lines (157 loc) · 5.65 KB
/
uim-internal.h
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
/*
Copyright (c) 2003-2012 uim Project http://code.google.com/p/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.
*/
#ifndef UIM_INTERNAL_H
#define UIM_INTERNAL_H
#include <config.h>
#if UIM_USE_ERROR_GUARD
#include <setjmp.h>
#endif
#if HAVE_ISSETUGID
#include <unistd.h>
#endif
#include "uim.h"
#include "uim-scm.h"
#ifdef __cplusplus
extern "C" {
#endif
#if UIM_USE_ERROR_GUARD
#if HAVE_SIGSETJMP
#define JMP_BUF sigjmp_buf
#define SETJMP(env) sigsetjmp((env), 1)
#define LONGJMP(env, val) siglongjmp((env), (val))
#else
#define JMP_BUF jmp_buf
#define SETJMP(env) setjmp(env)
#define LONGJMP(env, val) longjmp((env), (val))
#endif
#endif /* UIM_USE_ERROR_GUARD */
struct uim_candidate_ {
char *str; /* candidate */
char *heading_label;
char *annotation;
/* uim_pos part_of_speech; */
/* int freq; */
/* int freshness; */
/* int formality; */
/* char *src_dict; */
};
struct uim_context_ {
uim_lisp sc; /* Scheme-side context */
void *ptr; /* 1st callback argument */
/* encoding handlings */
char *client_encoding;
struct uim_code_converter *conv_if;
void *outbound_conv;
void *inbound_conv;
/* whether key input to IM is enabled */
uim_bool is_enabled;
/* legacy 'mode' API*/
int mode;
int nr_modes;
char **modes;
/* legacy 'property' API */
char *propstr;
/* commit */
void (*commit_cb)(void *ptr, const char *str);
/* preedit */
void (*preedit_clear_cb)(void *ptr);
void (*preedit_pushback_cb)(void *ptr, int attr, const char *str);
void (*preedit_update_cb)(void *ptr);
/* candidate selector */
void (*candidate_selector_activate_cb)(void *ptr, int nr, int index);
void (*candidate_selector_select_cb)(void *ptr, int index);
void (*candidate_selector_shift_page_cb)(void *ptr, int direction);
void (*candidate_selector_deactivate_cb)(void *ptr);
void (*candidate_selector_delay_activate_cb)(void *ptr, int delay);
/* text acquisition */
int (*acquire_text_cb)(void *ptr,
enum UTextArea text_id, enum UTextOrigin origin,
int former_len, int latter_len,
char **former, char **latter);
int (*delete_text_cb)(void *ptr,
enum UTextArea text_id, enum UTextOrigin origin,
int former_len, int latter_len);
/* mode */
void (*mode_list_update_cb)(void *ptr);
void (*mode_update_cb)(void *ptr, int);
/* property */
void (*prop_list_update_cb)(void *ptr, const char *str);
/* configuration changed */
void (*configuration_changed_cb)(void *ptr);
/* IM switching */
void (*switch_app_global_im_cb)(void *ptr, const char *name);
void (*switch_system_global_im_cb)(void *ptr, const char *name);
};
void uim_init_error(void);
#if UIM_USE_ERROR_GUARD
/* internal functions: don't call directly */
uim_bool uim_caught_fatal_error(void);
uim_bool uim_catch_error_begin_pre(void);
uim_bool uim_catch_error_begin_post(void);
void uim_catch_error_end(void);
/* can be nested */
#define UIM_CATCH_ERROR_BEGIN() \
(uim_caught_fatal_error() \
|| (uim_catch_error_begin_pre() \
&& SETJMP(uim_catch_block_env) \
&& uim_catch_error_begin_post()))
#define UIM_CATCH_ERROR_END() uim_catch_error_end()
#else /* not UIM_USE_ERROR_GUARD */
/* if !UIM_USE_ERROR_GUARD, uim immediately exit(3)s on any error. */
#define UIM_CATCH_ERROR_BEGIN() UIM_FALSE
#define UIM_CATCH_ERROR_END() ((void)0)
#endif /* not UIM_USE_ERROR_GUARD */
/* throw recoverable error */
void uim_throw_error(const char *msg);
void uim_init_dynlib(void);
void uim_quit_dynlib(void);
void uim_init_im_subrs(void);
void uim_init_key_subrs(void);
void uim_init_util_subrs(void);
void uim_init_notify_subrs(void);
void uim_init_rk_subrs(void);
void uim_init_intl_subrs(void);
#if UIM_USE_NOTIFY_PLUGINS
uim_bool uim_notify_fatal_raw(const char *msg);
#else
uim_bool uim_notify_info(const char *msg_fmt, ...);
uim_bool uim_notify_fatal(const char *msg_fmt, ...);
#endif
void uim_set_encoding(uim_context uc, const char *enc);
#if HAVE_ISSETUGID
#define uim_issetugid() issetugid()
#else
uim_bool uim_issetugid(void);
#endif
#if UIM_USE_ERROR_GUARD
/* don't touch directly */
extern JMP_BUF uim_catch_block_env;
#endif
#ifdef __cplusplus
}
#endif
#endif