void aspell_init (void) { AspellCanHaveError *error = NULL; if (global_speller != NULL) return; global_speller = g_try_malloc (sizeof (spell_t)); if (global_speller == NULL) return; if (!spell_available ()) { g_free (global_speller); global_speller = NULL; return; } global_speller->config = mc_new_aspell_config (); global_speller->speller = NULL; error = mc_new_aspell_speller (global_speller->config); if (mc_aspell_error_number (error) == 0) global_speller->speller = mc_to_aspell_speller (error); else { edit_error_dialog (_("Error"), mc_aspell_error_message (error)); mc_delete_aspell_can_have_error (error); aspell_clean (); } }
gboolean edit_load_user_map(WEdit *edit) { static config_t cfg; config_t new_cfg; char *file; struct stat s; if (edit_key_emulation != EDIT_KEY_EMULATION_USER) return TRUE; file = mhl_str_dir_plus_file(home_dir, MC_USERMAP); if (stat(file, &s) < 0) { char *msg = g_strdup_printf(_("%s not found!"), file); edit_error_dialog(_("Error"), msg); g_free(msg); g_free(file); return FALSE; } if (s.st_mtime != cfg.mtime) { memset(&new_cfg, 0, sizeof(new_cfg)); new_cfg.mtime = s.st_mtime; if (!load_user_keymap(&new_cfg, file)) { edit_error_dialog(_("Error"), error_msg); cfg_free_maps(&new_cfg); g_free(file); return FALSE; } else { cfg_free_maps(&cfg); cfg = new_cfg; } } edit->user_map = (edit_key_map_type *) cfg.keymap->data; edit->ext_map = (edit_key_map_type *) cfg.ext_keymap->data; memcpy(edit->labels, cfg.labels, sizeof(edit->labels)); g_free(file); return TRUE; }
void aspell_init (void) { AspellCanHaveError *error = NULL; if (strcmp (spell_language, "NONE") == 0) return; if (global_speller != NULL) return; global_speller = g_try_malloc (sizeof (spell_t)); if (global_speller == NULL) return; if (!spell_available ()) { MC_PTR_FREE (global_speller); return; } global_speller->config = mc_new_aspell_config (); global_speller->speller = NULL; if (spell_language != NULL) mc_aspell_config_replace (global_speller->config, "lang", spell_language); error = mc_new_aspell_speller (global_speller->config); if (mc_aspell_error_number (error) == 0) global_speller->speller = mc_to_aspell_speller (error); else { edit_error_dialog (_("Error"), mc_aspell_error_message (error)); mc_delete_aspell_can_have_error (error); aspell_clean (); } }