@@ -293,44 +293,10 @@ Java_com_osfans_trime_core_Rime_getRimeStatus(JNIEnv *env, jclass /* thiz */) {
293
293
return obj;
294
294
}
295
295
296
- static bool is_save_option (const char *p) {
297
- auto rime = rime_get_api ();
298
- bool is_save = false ;
299
- std::string option_name (p);
300
- if (option_name.empty ()) return is_save;
301
- RimeConfig config = {nullptr };
302
- bool b = rime->config_open (" default" , &config);
303
- if (!b) return is_save;
304
- const char *key = " switcher/save_options" ;
305
- RimeConfigIterator iter = {nullptr };
306
- rime->config_begin_list (&iter, &config, key);
307
- while (rime->config_next (&iter)) {
308
- std::string item (rime->config_get_cstring (&config, iter.path ));
309
- if (option_name == item) {
310
- is_save = true ;
311
- break ;
312
- }
313
- }
314
- rime->config_end (&iter);
315
- rime->config_close (&config);
316
- return is_save;
317
- }
318
-
319
296
// runtime options
320
297
extern " C" JNIEXPORT void JNICALL Java_com_osfans_trime_core_Rime_setRimeOption (
321
298
JNIEnv *env, jclass /* thiz */ , jstring option, jboolean value) {
322
- auto rime = rime_get_api ();
323
- RimeConfig user = {nullptr };
324
- auto opt = CString (env, option);
325
- bool b;
326
- if (is_save_option (opt)) {
327
- if (rime->user_config_open (" user" , &user)) {
328
- std::string key = " var/option/" + std::string (opt);
329
- rime->config_set_bool (&user, key.c_str (), value);
330
- rime->config_close (&user);
331
- }
332
- }
333
- Rime::Instance ().setOption (opt, value);
299
+ Rime::Instance ().setOption (CString (env, option), value);
334
300
}
335
301
336
302
extern " C" JNIEXPORT jboolean JNICALL
@@ -354,16 +320,7 @@ Java_com_osfans_trime_core_Rime_getCurrentRimeSchema(JNIEnv *env,
354
320
extern " C" JNIEXPORT jboolean JNICALL
355
321
Java_com_osfans_trime_core_Rime_selectRimeSchema (JNIEnv *env, jclass /* thiz */ ,
356
322
jstring schema_id) {
357
- auto rime = rime_get_api ();
358
- RimeConfig user = {nullptr };
359
- auto schema = CString (env, schema_id);
360
- if (rime->user_config_open (" user" , &user)) {
361
- rime->config_set_string (&user, " var/previously_selected_schema" , schema);
362
- std::string key = " var/schema_access_time/" + std::string (schema);
363
- rime->config_set_int (&user, key.c_str (), time (nullptr ));
364
- rime->config_close (&user);
365
- }
366
- return Rime::Instance ().selectSchema (schema);
323
+ return Rime::Instance ().selectSchema (CString (env, schema_id));
367
324
}
368
325
369
326
// testing
0 commit comments