118 static bool log_win_on_top; |
122 static bool log_win_on_top; |
119 static bool roster_win_on_right; |
123 static bool roster_win_on_right; |
120 static time_t LastActivity; |
124 static time_t LastActivity; |
121 |
125 |
122 static char inputLine[INPUTLINE_LENGTH+1]; |
126 static char inputLine[INPUTLINE_LENGTH+1]; |
123 #ifdef HAVE_ASPELL_H |
127 #if defined(WITH_ENCHANT) || defined(WITH_ASPELL) |
124 static char maskLine[INPUTLINE_LENGTH+1]; |
128 static char maskLine[INPUTLINE_LENGTH+1]; |
125 #endif |
129 #endif |
126 static char *ptr_inputline; |
130 static char *ptr_inputline; |
127 static short int inputline_offset; |
131 static short int inputline_offset; |
128 static int completion_started; |
132 static int completion_started; |
159 time_t timestamp, guint prefix_flags, |
163 time_t timestamp, guint prefix_flags, |
160 unsigned mucnicklen); |
164 unsigned mucnicklen); |
161 inline void scr_UpdateBuddyWindow(void); |
165 inline void scr_UpdateBuddyWindow(void); |
162 inline void scr_set_chatmode(int enable); |
166 inline void scr_set_chatmode(int enable); |
163 |
167 |
164 #ifdef HAVE_ASPELL_H |
168 #define SPELLBADCHAR 5 |
165 #define ASPELLBADCHAR 5 |
169 |
|
170 #ifdef WITH_ENCHANT |
|
171 EnchantBroker *spell_broker; |
|
172 EnchantDict *spell_checker; |
|
173 #endif |
|
174 |
|
175 #ifdef WITH_ASPELL |
166 AspellConfig *spell_config; |
176 AspellConfig *spell_config; |
167 AspellSpeller *spell_checker; |
177 AspellSpeller *spell_checker; |
168 #endif |
178 #endif |
169 |
179 |
170 typedef struct { |
180 typedef struct { |
3975 time(&chatstate_timestamp); |
3985 time(&chatstate_timestamp); |
3976 } |
3986 } |
3977 return; |
3987 return; |
3978 } |
3988 } |
3979 |
3989 |
3980 #ifdef HAVE_ASPELL_H |
3990 #if defined(WITH_ENCHANT) || defined(WITH_ASPELL) |
3981 // Aspell initialization |
3991 // initialization |
3982 void spellcheck_init(void) |
3992 void spellcheck_init(void) |
3983 { |
3993 { |
3984 int aspell_enable = settings_opt_get_int("aspell_enable"); |
3994 int spell_enable = settings_opt_get_int("spell_enable"); |
3985 const char *aspell_lang = settings_opt_get("aspell_lang"); |
3995 const char *spell_lang = settings_opt_get("spell_lang"); |
3986 const char *aspell_encoding = settings_opt_get("aspell_encoding"); |
3996 #ifdef WITH_ASPELL |
|
3997 const char *spell_encoding = settings_opt_get("spell_encoding"); |
3987 AspellCanHaveError *possible_err; |
3998 AspellCanHaveError *possible_err; |
3988 |
3999 #endif |
3989 if (!aspell_enable) |
4000 |
|
4001 if (!spell_enable) |
3990 return; |
4002 return; |
3991 |
4003 |
|
4004 #ifdef WITH_ENCHANT |
|
4005 if (spell_checker) { |
|
4006 enchant_broker_free_dict(spell_broker, spell_checker); |
|
4007 enchant_broker_free(spell_broker); |
|
4008 spell_checker = NULL; |
|
4009 spell_broker = NULL; |
|
4010 } |
|
4011 |
|
4012 spell_broker = enchant_broker_init(); |
|
4013 spell_checker = enchant_broker_request_dict(spell_broker, spell_lang); |
|
4014 #endif |
|
4015 #ifdef WITH_ASPELL |
3992 if (spell_checker) { |
4016 if (spell_checker) { |
3993 delete_aspell_speller(spell_checker); |
4017 delete_aspell_speller(spell_checker); |
3994 delete_aspell_config(spell_config); |
4018 delete_aspell_config(spell_config); |
3995 spell_checker = NULL; |
4019 spell_checker = NULL; |
3996 spell_config = NULL; |
4020 spell_config = NULL; |
3997 } |
4021 } |
3998 |
4022 |
3999 spell_config = new_aspell_config(); |
4023 spell_config = new_aspell_config(); |
4000 aspell_config_replace(spell_config, "encoding", aspell_encoding); |
4024 aspell_config_replace(spell_config, "encoding", spell_encoding); |
4001 aspell_config_replace(spell_config, "lang", aspell_lang); |
4025 aspell_config_replace(spell_config, "lang", spell_lang); |
4002 possible_err = new_aspell_speller(spell_config); |
4026 possible_err = new_aspell_speller(spell_config); |
4003 |
4027 |
4004 if (aspell_error_number(possible_err) != 0) { |
4028 if (aspell_error_number(possible_err) != 0) { |
4005 spell_checker = NULL; |
4029 spell_checker = NULL; |
4006 delete_aspell_config(spell_config); |
4030 delete_aspell_config(spell_config); |
4007 spell_config = NULL; |
4031 spell_config = NULL; |
4008 } else { |
4032 } else { |
4009 spell_checker = to_aspell_speller(possible_err); |
4033 spell_checker = to_aspell_speller(possible_err); |
4010 } |
4034 } |
4011 } |
4035 #endif |
4012 |
4036 } |
4013 // Deinitialization of Aspell spellchecker |
4037 |
|
4038 // Deinitialization of spellchecker |
4014 void spellcheck_deinit(void) |
4039 void spellcheck_deinit(void) |
4015 { |
4040 { |
4016 if (spell_checker) { |
4041 if (spell_checker) { |
|
4042 #ifdef WITH_ENCHANT |
|
4043 enchant_broker_free_dict(spell_broker, spell_checker); |
|
4044 #endif |
|
4045 #ifdef WITH_ASPELL |
4017 delete_aspell_speller(spell_checker); |
4046 delete_aspell_speller(spell_checker); |
|
4047 #endif |
4018 spell_checker = NULL; |
4048 spell_checker = NULL; |
4019 } |
4049 } |
4020 |
4050 |
|
4051 #ifdef WITH_ENCHANT |
|
4052 if (spell_broker) { |
|
4053 enchant_broker_free(spell_broker); |
|
4054 spell_broker = NULL; |
|
4055 } |
|
4056 #endif |
|
4057 #ifdef WITH_ASPELL |
4021 if (spell_config) { |
4058 if (spell_config) { |
4022 delete_aspell_config(spell_config); |
4059 delete_aspell_config(spell_config); |
4023 spell_config = NULL; |
4060 spell_config = NULL; |
4024 } |
4061 } |
4025 } |
4062 #endif |
4026 |
4063 } |
4027 #define aspell_isalpha(c) (utf8_mode ? iswalpha(get_char(c)) : isalpha(*c)) |
4064 |
|
4065 #define spell_isalpha(c) (utf8_mode ? iswalpha(get_char(c)) : isalpha(*c)) |
4028 |
4066 |
4029 // Spell checking function |
4067 // Spell checking function |
4030 static void spellcheck(char *line, char *checked) |
4068 static void spellcheck(char *line, char *checked) |
4031 { |
4069 { |
4032 const char *start, *line_start; |
4070 const char *start, *line_start; |
4061 continue; |
4099 continue; |
4062 } |
4100 } |
4063 |
4101 |
4064 start = line; |
4102 start = line; |
4065 |
4103 |
4066 while (aspell_isalpha(line)) |
4104 while (spell_isalpha(line)) |
4067 line = next_char(line); |
4105 line = next_char(line); |
4068 |
4106 |
4069 if (spell_checker && |
4107 if (spell_checker && |
4070 aspell_speller_check(spell_checker, start, line - start) == 0) |
4108 #ifdef WITH_ENCHANT |
4071 memset(&checked[start - line_start], ASPELLBADCHAR, line - start); |
4109 enchant_dict_check(spell_checker, start, line - start) != 0 |
4072 } |
|
4073 } |
|
4074 #endif |
4110 #endif |
|
4111 #ifdef WITH_ASPELL |
|
4112 aspell_speller_check(spell_checker, start, line - start) == 0 |
|
4113 #endif |
|
4114 ) |
|
4115 memset(&checked[start - line_start], SPELLBADCHAR, line - start); |
|
4116 } |
|
4117 } |
|
4118 #endif |
4075 |
4119 |
4076 /* vim: set expandtab cindent cinoptions=>2\:2(0: For Vim users... */ |
4120 /* vim: set expandtab cindent cinoptions=>2\:2(0: For Vim users... */ |