editline-tabcomp

Tab completion implementation for BSD editline (libedit)

git clone https://git.8pit.net/editline-tabcomp.git

 1/* Copyright (C) 2019 Sören Tempel
 2 *
 3 * This program is free software: you can redistribute it and/or modify
 4 * it under the terms of the GNU General Public License as published by
 5 * the Free Software Foundation, either version 3 of the License, or
 6 * (at your option) any later version.
 7 *
 8 * This program is distributed in the hope that it will be useful,
 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <https://www.gnu.org/licenses/>.
15 */
16
17#ifndef EDITLINE_TABCOMP
18#define EDITLINE_TABCOMP
19
20#include <histedit.h>
21
22/* Completion functions, receives the input prefix and its length. */
23typedef void (*compfn)(const char *, size_t);
24
25/* Can be called from the completion function, adds a completion to the
26 * list of suggested completions, performs memory allocations */
27void addcomp(char *);
28
29/* Initializes the completion API with the given completion function.
30 * The second argument indicates what kind of completions should be
31 * performed. If zero lines are completed, otherwise individual words. */
32void initcomp(compfn, int);
33
34/* Editline completion function which needs to be added using EL_ADDFN
35 * and bound to the completion key (e.g. tab) using EL_BIND. */
36unsigned char complete(EditLine *, int);
37
38#endif