4 * Copyright (c) Tuomo Valkonen 1999-2007.
6 * See the included file LICENSE for details.
9 #include <libextl/readconfig.h>
10 #include <libextl/extl.h>
11 #include <libtu/minmax.h>
12 #include <ioncore/binding.h>
13 #include <ioncore/conf-bindings.h>
14 #include <ioncore/frame.h>
15 #include <ioncore/saveload.h>
16 #include <ioncore/bindmaps.h>
17 #include <ioncore/ioncore.h>
29 /*{{{ Module information */
32 #include "../version.h"
34 char mod_query_ion_api_version[]=ION_API_VERSION;
43 WBindmap *mod_query_input_bindmap=NULL;
44 WBindmap *mod_query_wedln_bindmap=NULL;
53 ModQueryConfig mod_query_config={
61 * Set module configuration. The following are supported:
63 * \begin{tabularx}{\linewidth}{lX}
64 * \tabhead{Field & Description}
65 * \var{autoshowcompl} & (boolean) Is auto-show-completions enabled?
67 * \var{autoshowcompl_delay} & (integer) auto-show-completions delay
68 * in milliseconds (default: 250). \\
69 * \var{caseicompl} & (boolean) Turn some completions case-insensitive
70 * (default: false). \\
74 void mod_query_set(ExtlTab tab)
76 ModQueryConfig *c=&mod_query_config;
78 extl_table_gets_b(tab, "autoshowcompl", &c->autoshowcompl);
79 extl_table_gets_b(tab, "caseicompl", &c->caseicompl);
81 if(extl_table_gets_i(tab, "autoshowcompl_delay",
82 &c->autoshowcompl_delay)){
83 c->autoshowcompl_delay=maxof(c->autoshowcompl_delay, 0);
88 * Get module configuration. For more information see
89 * \fnref{mod_query.set}.
93 ExtlTab mod_query_get()
95 ModQueryConfig *c=&mod_query_config;
96 ExtlTab tab=extl_create_table();
98 extl_table_sets_b(tab, "autoshowcompl", c->autoshowcompl);
99 extl_table_sets_b(tab, "caseicompl", c->caseicompl);
100 extl_table_sets_i(tab, "autoshowcompl_delay", c->autoshowcompl_delay);
109 /*{{{ Init & deinit */
112 static void load_history()
117 if(!extl_read_savefile("saved_queryhist", &tab))
120 n=extl_table_get_n(tab);
124 if(extl_table_geti_s(tab, i, &s)){
125 mod_query_history_push(s);
130 extl_unref_table(tab);
134 static void save_history()
136 ExtlTab tab=mod_query_history_table();
138 extl_write_savefile("saved_queryhist", tab);
140 extl_unref_table(tab);
144 static bool loaded_ok=FALSE;
146 void mod_query_deinit()
148 mod_query_unregister_exports();
150 if(mod_query_input_bindmap!=NULL){
151 ioncore_free_bindmap("WInput", mod_query_input_bindmap);
152 mod_query_input_bindmap=NULL;
155 if(mod_query_wedln_bindmap!=NULL){
156 ioncore_free_bindmap("WEdln", mod_query_wedln_bindmap);
157 mod_query_wedln_bindmap=NULL;
160 hook_remove(ioncore_snapshot_hook, save_history);
164 bool mod_query_init()
166 if(!mod_query_register_exports())
169 mod_query_input_bindmap=ioncore_alloc_bindmap("WInput", NULL);
170 mod_query_wedln_bindmap=ioncore_alloc_bindmap("WEdln", NULL);
172 if(mod_query_wedln_bindmap==NULL ||
173 mod_query_input_bindmap==NULL){
177 /*ioncore_read_config("cfg_query", NULL, TRUE);*/
183 hook_add(ioncore_snapshot_hook, save_history);