1 /* vifm
2  * Copyright (C) 2015 xaizek.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18 
19 #ifndef VIFM__ENGINE__ABBREVS_H__
20 #define VIFM__ENGINE__ABBREVS_H__
21 
22 #include <stddef.h> /* wchar_t */
23 
24 /* Registers abbreviation from LHS to RHS.  Overwrites any previously existing
25  * abbreviations for LHS.  Returns zero on success or non-zero on memory
26  * allocation error. */
27 int vle_abbr_add(const wchar_t lhs[], const wchar_t rhs[]);
28 
29 /* Same as vle_abbr_add(), but registers noremap kind of abbreviation. */
30 int vle_abbr_add_no_remap(const wchar_t lhs[], const wchar_t rhs[]);
31 
32 /* Removes abbreviation by first matching matching str with LHS and, if no
33  * matches found, with RHS.  Returns zero on successful removal, otherwise
34  * (no abbreviation found) non-zero is returned. */
35 int vle_abbr_remove(const wchar_t str[]);
36 
37 /* Expands str if it's a full match for LHS of any of previously registered
38  * abbreviations.  Returns NULL is str doesn't match any LHS, otherwise pointer
39  * to string managed by the unit is returned. */
40 const wchar_t * vle_abbr_expand(const wchar_t str[], int *no_remap);
41 
42 /* Removes all registered abbreviations. */
43 void vle_abbr_reset(void);
44 
45 /* Completes names of abbreviations. */
46 void vle_abbr_complete(const char prefix[]);
47 
48 /* Enumerates registered abbreviations.  For the first call *state must be set
49  * to NULL.  Returns zero when end of the list is reached (and sets pointers to
50  * NULLs), otherwise zero is returned.  Do not modify abbreviations between
51  * calls. */
52 int vle_abbr_iter(const wchar_t **lhs, const wchar_t **rhs, int *no_remap,
53 		void **param);
54 
55 #endif /* VIFM__ENGINE__ABBREVS_H__ */
56 
57 /* vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 : */
58 /* vim: set cinoptions+=t0 filetype=c : */
59