arif/include/arif.h

127 lines
2.8 KiB
C
Raw Normal View History

2023-02-12 12:26:45 +00:00
/**
* arif/include/arif.h - ARIF base library
* ----
2023-07-28 00:30:25 +00:00
*
2023-02-12 12:26:45 +00:00
* Copyright (C) 2023 CismonX <admin@cismon.net>
2023-07-28 00:30:25 +00:00
*
2023-02-12 12:26:45 +00:00
* This file is part of ARIF, Another Readline Input Framework.
2023-07-28 00:30:25 +00:00
*
2023-02-12 12:26:45 +00:00
* ARIF is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
2023-07-28 00:30:25 +00:00
*
2023-02-12 12:26:45 +00:00
* ARIF is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
2023-07-28 00:30:25 +00:00
*
2023-02-12 12:26:45 +00:00
* You should have received a copy of the GNU General Public License
* along with ARIF. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef ARIF_H_
#define ARIF_H_
#define ARIF_VER_MAJOR 0
#define ARIF_VER_MINOR 1
#define ARIF_VER_PATCH 0
struct arif_cand;
struct arif_ctx;
typedef char *(arif_cand_disp_func) (
char const *text,
2023-12-01 12:10:15 +00:00
int text_len,
2023-11-30 20:00:15 +00:00
char const *comment,
int comment_len,
2023-02-12 12:26:45 +00:00
int idx,
int *display_len_ptr
);
typedef void (arif_engine_finalize_func) (
void *engine_data
);
typedef void (arif_engine_info_func) (
void *engine_data,
char const **name_ptr,
char const **description_ptr
);
typedef int (arif_engine_init_func) (
void *args,
void **engine_data_ptr
);
typedef int (arif_engine_query_func) (
void *engine_data,
char const *line,
int offset,
int len,
int num_candidates,
struct arif_cand const **candidates_ptr
);
struct arif_cand {
char const *text;
2023-12-01 12:10:15 +00:00
int text_len;
int replace_start;
2023-02-12 12:26:45 +00:00
int replace_len;
char const *transform;
int transform_len;
char const *display;
int display_len;
};
struct arif_engine {
arif_engine_init_func *init;
arif_engine_finalize_func *finalize;
arif_engine_info_func *info;
arif_engine_query_func *query;
};
struct arif_opts {
arif_cand_disp_func *disp_cand;
int page_size;
};
struct arif_ctx *
arif_ctx_create (
struct arif_opts const *options
);
void
arif_ctx_destroy (
struct arif_ctx *ctx
);
int
arif_fetch (
struct arif_ctx *ctx,
struct arif_cand const **candidates_ptr
);
int
arif_query (
struct arif_ctx *ctx,
char const *line,
int offset,
int len
);
int
arif_select_page (
struct arif_ctx *ctx,
int idx
);
void
arif_set_engine (
struct arif_ctx *ctx,
struct arif_engine const *engine,
void *engine_data
);
#endif // !defined(ARIF_H_)