ARIF_SET_ENGINE(3)
πΈ ARIF_SET_ENGINE(3) πΈ
okay bestie, welcome to the arif_set_engine page from the ARIF User Manual π this is the function that swaps out an input contextβs input method engine β like a full outfit change, but for your IME. letβs get into it.
β¨ NAME β¨
arif_set_engine β set input method engine. periodt.
π SYNOPSIS π
#include <arif.h>
void
arif_set_engine (
struct arif_ctx *ctx,
struct arif_engine const *engine,
void *engine_data
);
π DESCRIPTION π
The arif_set_engine() function changes the input context ctxβs current input method engine and its associated data pointer to engine and engine_data. It also resets the internal state of ctx. so yes, itβs giving full refresh energy for ctx β¨
Passing NULL to engine is allowed. See the "Input context without engine" subsection in NOTES for details.
π§ Input method engines
The struct arif_engine type defines a few functions for ARIF to communicate with an input method engine.
struct arif_engine {
arif_engine_init_func *init;
arif_engine_finalize_func *finalize;
arif_engine_info_func *info;
arif_engine_query_func *query;
};
Only the query function is used by the ARIF library. Itβs up to the library user to call the other functions when needed. no cap π«Ά
π± Engine initialization
If an input method engine needs to be initialized before use, the init function must be implemented. Otherwise, it should be NULL.
typedef int (arif_engine_init_func) (
void const *args,
void **engine_data_ptr
);
Extra info can be passed into the initializer function through args.
If initialization is successful, the function must return 0. Optionally, it can store a pointer to engine_data_ptr, which will be passed as an argument on subsequent engine function calls.
If initialization fails, the function must return a non-zero value. bestie, thatβs the vibe check: 0 means slay, non-zero means nope π
π¦ Engine finalization
If not NULL, the finalize function is used for cleaning up resources for an engine, when the engine is no longer in use.
typedef void (arif_engine_finalize_func) (
void *engine_data
);
The engine_data argument is the pointer stored to engine_data_ptr during initialization.
β Engine info
If not NULL, the info function is used for retrieving information of an engine.
typedef void (arif_engine_info_func) (
void *engine_data,
char const **name_ptr,
char const **description_ptr
);
The engine_data argument is the pointer stored to engine_data_ptr during initialization.
The function can store a NUL-terminated string that identifies an engine to name_ptr. Itβs preferably a short and memorable word (like "pinyin" and "rime").
The function can store another NUL-terminated string to description_ptr, to provide additional information of the engine, such as version, copyright notice, homepage URL, etc.
π₯ Query engine for candidates
The query function is used for asking the engine for candidates of an input text. It must not be NULL.
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
);
The engine_data argument is the pointer stored to engine_data_ptr during initialization.
The line, offset and len arguments correspond to the arguments of function arif_query(3) with the same name. If line is NULL, it means that the caller is asking for more candidates for the previous input text.
The num_candidates argument is the minimum number of candidates required from the engine. The engine should store the pointer of an array containing at least that many candidates to candidates_ptr, and return the number of candidates. If returning less than num_candidates, it indicates that the entire list of candidates is exhausted. The engine should ensure that the memory location referenced by those candidates are valid until the next query call with non-NULL line.
The engine is not responsible for specifying the display text for a candidate, however, it may reuse the display and display_len members to store descriptive information regarding the candidate. This information will be passed to the display function of the input context through the comment and comment_len arguments (see arif_ctx_create(3)).
Both line and candidates_ptr can be NULL, in which case the caller is indicating that a candidate at offset is selected with inlined candidate selection (see arif_query(3)), and the return value is ignored. The engine may make use of this information for purposes like analytics.
π NOTES π
π«Ά Input context without engine
For an input context, when arif_set_engine() is not yet called, or last called with a NULL engine argument, the input context does not have an associated input method engine.
In such input contexts, functions other thanarif_set_engine()orarif_ctx_destroy(3)must not be called. fr fr, donβt do it π
π COPYRIGHT π
Copyright (C) 2023 CismonX <admin@cismon.net>
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
You should have received a copy of the license along with this document. If not, see https://www.gnu.org/licenses/fdl-1.3.html.
π SEE ALSO π
arif_ctx_create(3), arif_ctx_destroy(3), arif_fetch(3), arif_query(3)
This page is from the ARIF User Manual, version 0.1.0, dated Jan 02, 2023 β bye bestie π
π¦ where this page comes from
- alpine 3.24: arif-doc 0.3.0-r1 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms