m17nInputMethod(3m17n)
๐ m17nInputMethod ๐
okay so this is the m17nInputMethod(3m17n) page from The m17n Library, and it's literally the blueprint for input methods. bestie, we're gonna go through it together, no skipped details, fr fr. ๐
โจ NAME โจ
The NAME line says: m17nInputMethod_-_Input_Method_(ba - - API for Input method. โ yeah, that's the whole vibe.
๐ธ SYNOPSIS ๐ธ
๐ Data Structures ๐
struct MInputDriverโ Structure of input method driver.struct MInputMethodโ Structure of input method.struct MInputContextโ Structure of input context.
๐ฆ Typedefs ๐ฆ
typedef void(* MInputCallbackFunc) (MInputContext *ic, MSymbol command)โ Type of input method callback functions.
โญ Enumerations โญ
enum MInputCandidatesChanged { MINPUT_CANDIDATES_LIST_CHANGED = 1, MINPUT_CANDIDATES_INDEX_CHANGED = 2, MINPUT_CANDIDATES_SHOW_CHANGED = 4, MINPUT_CANDIDATES_CHANGED_MAX }โ Bit-masks to specify how candidates of input method is changed."(yes, there's a lil stray quote at the end, iconic.)
๐ Variables ๐
MSymbol Minput_methodโ Symbol whose name is 'input-method'.MInputDriver minput_default_driverโ The default driver for internal input methods.MInputDriver * minput_driverโ The driver for internal input methods.MSymbol Minput_driverโ (no description in the original, it's just there being mysterious)
๐ Variables: Predefined symbols for callback commands ๐
These are the predefined symbols that are used as the COMMAND argument of callback functions of an input method driver (see MInputDriver::callback_list).
Most of them do not require extra argument nor return any value; exceptions are these:
Minput_get_surrounding_text: When a callback function assigned for this command is called, the first element of MInputContext::plist has key Minteger and the value specifies which portion of the surrounding text should be retrieved. If the value is positive, it specifies the number of characters following the current cursor position. If the value is negative, the absolute value specifies the number of characters preceding the current cursor position. If the value is zero, it means that the caller just wants to know if the surrounding text is currently supported or not.
If the surrounding text is currently supported, the callback function must set the key of this element to Mtext and the value to the retrieved M-text. The length of the M-text may be shorter than the requested number of characters, if the available text is not that long. The length can be zero in the worst case. Or, the length may be longer if an application thinks it is more efficient to return that length.
If the surrounding text is not currently supported, the callback function should return without changing the first element of MInputContext::plist.
Minput_delete_surrounding_text: When a callback function assigned for this command is called, the first element of MInputContext::plist has key Minteger and the value specifies which portion of the surrounding text should be deleted in the same way as the case of Minput_get_surrounding_text. The callback function must delete the specified text. It should not alter MInputContext::plist.
MSymbol Minput_preedit_startMSymbol Minput_preedit_doneMSymbol Minput_preedit_drawMSymbol Minput_status_startMSymbol Minput_status_doneMSymbol Minput_status_drawMSymbol Minput_candidates_startMSymbol Minput_candidates_doneMSymbol Minput_candidates_drawMSymbol Minput_set_spotMSymbol Minput_toggleMSymbol Minput_resetMSymbol Minput_get_surrounding_textMSymbol Minput_delete_surrounding_text
๐ Variables: Predefined symbols for special input events ๐
These are the predefined symbols that are used as the KEY argument of minput_filter().
MSymbol Minput_focus_outMSymbol Minput_focus_inMSymbol Minput_focus_move
๐ง Variables: Predefined symbols used in input method information ๐ง
MSymbol MinheritedMSymbol McustomizedMSymbol Mconfigured
๐ฅ Functions ๐ฅ
MInputMethod * minput_open_im (MSymbol language, MSymbol name, void *arg)โ Open an input method.void minput_close_im (MInputMethod *im)โ Close an input method.MInputContext * minput_create_ic (MInputMethod *im, void *arg)โ Create an input context.void minput_destroy_ic (MInputContext *ic)โ Destroy an input context.int minput_filter (MInputContext *ic, MSymbol key, void *arg)โ Filter an input key.int minput_lookup (MInputContext *ic, MSymbol key, void *arg, MText *mt)โ Look up a text produced in the input context.void minput_set_spot (MInputContext *ic, int x, int y, int ascent, int descent, int fontsize, MText *mt, int pos)โ Set the spot of the input context.void minput_toggle (MInputContext *ic)โ Toggle input method.void minput_reset_ic (MInputContext *ic)โ Reset an input context.MPlist * minput_get_title_icon (MSymbol language, MSymbol name)โ Get title and icon filename of an input method.MText * minput_get_description (MSymbol language, MSymbol name)โ Get description text of an input method.MPlist * minput_get_command (MSymbol language, MSymbol name, MSymbol command)โ (no description in the original)int minput_config_command (MSymbol language, MSymbol name, MSymbol command, MPlist *keyseqlist)โ (no description in the original)MPlist * minput_get_variable (MSymbol language, MSymbol name, MSymbol variable)โ (no description in the original)int minput_config_variable (MSymbol language, MSymbol name, MSymbol variable, MPlist *value)โ Configure the value of an input method variable.char * minput_config_file ()โ Get the name of per-user customization file.int minput_save_config (void)โ Save configurations in per-user customization file.MPlist * minput_list (MSymbol language)โ (no description in the original)
๐ Obsolete functions ๐
MPlist * minput_get_variables (MSymbol language, MSymbol name)โ (no description in the original)int minput_set_variable (MSymbol language, MSymbol name, MSymbol variable, void *value)โ Set the initial value of an input method variable.MPlist * minput_get_commands (MSymbol language, MSymbol name)โ Get information about input method commands.int minput_assign_command_keys (MSymbol language, MSymbol name, MSymbol command, MPlist *keyseq)โ Assign a key sequence to an input method command (obsolete).MPlist * minput_parse_im_names (MText *mt)โ Parse input method names.int minput_callback (MInputContext *ic, MSymbol command)โ Call a callback function.
๐ Detailed Description ๐
API for Input method.
An input method is an object to enable inputting various characters. An input method is identified by a pair of symbols, LANGUAGE and NAME. This pair decides an input method driver of the input method. An input method driver is a set of functions for handling the input method. There are two kinds of input methods; internal one and foreign one.
- Internal Input Method โ An internal input method has non
MnilLANGUAGE, and its body is defined in the m17n database by the tag<Minput_method, LANGUAGE, NAME>. For this kind of input methods, the m17n library uses two predefined input method drivers, one for CUI use and the other for GUI use. Those drivers utilize the input processing engine provided by the m17n library itself. The m17n database may provide input methods that are not limited to a specific language. The database usesMtas LANGUAGE of those input methods. An internal input method accepts an input key which is a symbol associated with an input event. As there is no way for the m17n library to know how input events are represented in an application program, an application programmer has to convert an input event to an input key by himself. See the documentation of the functionminput_event_to_key()for the detail. - Foreign Input Method โ A foreign input method has
MnilLANGUAGE, and its body is defined in an external resource (e.g. XIM of X Window System). For this kind of input methods, the symbol NAME must have a property of keyMinput_driver, and the value must be a pointer to an input method driver. Therefore, by preparing a proper driver, any kind of input method can be treated in the framework of the m17n library. For convenience, the m17n-X library provides an input method driver that enables the input style of OverTheSpot for XIM, and storesMinput_driverproperty of the symbolMximwith a pointer to the driver. See the documentation of m17n GUI API for the detail.
๐ PROCESSING FLOW ๐
The typical processing flow of handling an input method is:
- open an input method
- create an input context for the input method
- filter an input key
- look up a produced text in the input context
๐ธ Data Structure Documentation ๐ธ
๐ MInputDriver
Structure of input method driver. It's giving "the blueprint of how an IM actually drives", bestie.
โจ FIELD DOCUMENTATION โจ
int(* MInputDriver::open_im) (MInputMethod *im)โ Opens an input method. This one opens the input methodim. It gets called fromminput_open_im(), and it runs after every member ofimexcept<info>has been set. If openingimworks, it returns0. If it doesn't, it returns-1. The function is allowed to set upim->infoto stash all kinds of info that the other driver functions will come back and read. ๐void(* MInputDriver::close_im) (MInputMethod *im)โ Closes an input method. This closesim. It gets called fromminput_close_im(). It frees all the memory allocated forim->info(if any) after it finishes every task involved in closing the input method. But heads up โ the other members ofimmust not be touched. ๐ โ๏ธint(* MInputDriver::create_ic) (MInputContext *ic)โ Creates an input context. This makes the input contextic. It's called fromminput_create_ic()after every member oficexcept<info>has been set. If creatingicsucceeds, it returns0. If not,-1. The function can set upic->infoto keep various info that the other driver functions refer to. โจvoid(* MInputDriver::destroy_ic) (MInputContext *ic)โ Destroys an input context. This one gets called fromminput_destroy_ic()and destroys the input contextic. It frees all the memory allocated foric->info(if any) after it finishes every task of destroying the input method. But again โ the other members oficshould not be touched. ๐int(* MInputDriver::filter) (MInputContext *ic, MSymbol key, void *arg)โ Filters an input key. Called fromminput_filter(), and it filters an input key.keyandargare literally the same ones given tominput_filter(). The job here is to handlekeyand update the internal state ofic. Ifkeygets absorbed by the input method and no text is produced, it returns1. Otherwise, it returns0. It may updateic->status,ic->preedit,ic->cursor_pos,ic->ncandidates,ic->candidates, andic->producedif that's what's needed for the member<callback>. ๐ซถ The meaning ofargdepends on the input method driver. Peep the documentation ofminput_default_driverandminput_gui_driverfor the tea, for instance. ๐int(* MInputDriver::lookup) (MInputContext *ic, MSymbol key, void *arg, MText *mt)โ Looks up a produced text in an input context. Called fromminput_lookup(), it looks up a produced text in the input contextic. This function concatenates a text produced by the input keykey(if any) onto M-textmt. Ifkeywas correctly handled by the input method ofic, it returns0. Otherwise, it returns1. The meaning ofargdepends on the input method driver โ see the docs forminput_default_driverandminput_gui_driver, for instance. ๐MPlist* MInputDriver::callback_listโ List of callback functions. List of callback functions. (Yes bestie, it really says it twice.) Keys are one ofMinput_preedit_start,Minput_preedit_draw,Minput_preedit_done,Minput_status_start,Minput_status_draw,Minput_status_done,Minput_candidates_start,Minput_candidates_draw,Minput_candidates_done,Minput_set_spot,Minput_toggle,Minput_reset,Minput_get_surrounding_text,Minput_delete_surrounding_text. Values are functions of typeMInputCallbackFunc. ๐
๐ MInputMethod
Structure of input method.
โจ FIELD DOCUMENTATION โจ
MSymbol MInputMethod::languageโ Which language this input method is for. The value isMnilif the input method is foreign. ๐ฆMSymbol MInputMethod::nameโ Name of the input method. If the input method is foreign, it must have a property of keyMinput_driver, and the value must be a pointer to a proper input method driver. periodt. ๐MInputDriver MInputMethod::driverโ Input method driver of the input method.void* MInputMethod::argโ The argument given tominput_open_im().void* MInputMethod::infoโ Pointer to extra information that<driver>.open_im()sets up.
๐ MInputContext
Structure of input context. This is the main character of the whole operation, ngl.
โจ FIELD DOCUMENTATION โจ
MInputMethod* MInputContext::imโ Backward pointer to the input method. It gets set up by the functionminput_create_ic().MText* MInputContext::producedโ M-text produced by the input method. Set up by the functionminput_filter().void* MInputContext::argโ Argument given to the functionminput_create_ic().int MInputContext::activeโ Flag telling whether the input context is currently active or inactive. It's set to1(active) when the input context is created. It gets toggled by the functionminput_toggle(). โจint MInputContext::xโ X and Y coordinate of the spot.int MInputContext::yโ (the other half of that X and Y coordinate of the spot ๐ซถ)int MInputContext::ascentโ Ascent and descent pixels of the line of the spot.int MInputContext::descentโ (the descent half of those pixels ๐)int MInputContext::fontsizeโ Font size for preedit text, measured in 1/10 point.MText* MInputContext::mtโ M-text at the spot, orNULL.int MInputContext::posโ Character position in<mt>at the spot.struct { ... } MInputContext::spotโ Spot location and size of the input context.void* MInputContext::infoโ The usage of the following members depends on the input method driver. The descriptions below are for the driver of an internal input method. They're set by the function<im>->driver.filter(). Pointer to extra information that<im>->driver.create_ic()sets up. It's used to record the internal state of the input context. ๐งMText* MInputContext::statusโ M-text describing the current status of the input context.int MInputContext::status_changedโ The function<im>->driver.filter()sets the value to1when it changes<status>.MText* MInputContext::preeditโ M-text containing the current preedit text. The function<im>->driver.filter()sets the value.int MInputContext::preedit_changedโ The function<im>->driver.filter()sets the value to1when it changes<preedit>.int MInputContext::cursor_posโ Cursor position of<preedit>.int MInputContext::cursor_pos_changedโ The function<im>->driver.filter()sets the value to1when it changes<cursor_pos>.MPlist* MInputContext::candidate_listโ Plist of the current candidate groups. Each element is an M-text or a plist. If an element is an M-text (i.e. the key isMtext), candidates in that group are characters in the M-text. If it's a plist (i.e. the key isMplist), each element is an M-text, and the candidates in that group are those M-texts. ๐int MInputContext::candidate_indexโ Index number of the currently selected candidate across all the candidates. The index of the first candidate is0. So like, if the number is8, and the first candidate group contains7candidates, then the currently selected candidate is the second element of the second candidate group. math bestie ๐งฎโจint MInputContext::candidate_fromโ Start and the end positions of the preedit text where<candidate_list>corresponds to.int MInputContext::candidate_toโ (the end position half of that range ๐ )int MInputContext::candidate_showโ Flag telling whether the current candidate group must be shown or not. The function<im>->driver.filter()sets the value to1when an input method requires showing candidates, and sets the value to0otherwise. ๐int MInputContext::candidates_changedโ The function<im>->driver.filter()sets the value to the bitwise OR of enumMInputCandidatesChangedwhen it changed any of the above members (<candidate_XXX>), and sets the value to0otherwise.MPlist* MInputContext::plistโ Plist that can be freely used by<im>->driverfunctions. The driver of internal input method uses it to exchange extra arguments and results for callback functions. The function<im>->driver.create_ic()sets this to an empty plist, and the function<im>->driver.destroy_ic()frees it by usingm17n_object_unref(). ๐ธ
๐ฆ Typedef Documentation ๐ฆ
typedef void(* MInputCallbackFunc) (MInputContext *ic, MSymbol command)โ Type of input method callback functions. This is the type of callback functions called from input method drivers.icis a pointer to an input context, andcommandis a name of the callback for which the function is called. โจ
๐ Enumeration Type Documentation ๐
๐ enum MInputCandidatesChanged
Bit-masks to specify how candidates of input method is changed. Slay, a whole enum of vibes.
Enumerator
MINPUT_CANDIDATES_LIST_CHANGEDMINPUT_CANDIDATES_INDEX_CHANGEDMINPUT_CANDIDATES_SHOW_CHANGEDMINPUT_CANDIDATES_CHANGED_MAX
๐ Variable Documentation ๐
โญ MSymbol Minput_method
Symbol whose name is 'input-method'.
โญ MSymbol Minput_preedit_start
โญ MSymbol Minput_preedit_done
โญ MSymbol Minput_preedit_draw
โญ MSymbol Minput_status_start
โญ MSymbol Minput_status_done
โญ MSymbol Minput_status_draw
โญ MSymbol Minput_candidates_start
โญ MSymbol Minput_candidates_done
โญ MSymbol Minput_candidates_draw
โญ MSymbol Minput_set_spot
โญ MSymbol Minput_toggle
โญ MSymbol Minput_reset
โญ MSymbol Minput_get_surrounding_text
โญ MSymbol Minput_delete_surrounding_text
โญ MSymbol Minput_focus_out
โญ MSymbol Minput_focus_in
โญ MSymbol Minput_focus_move
โญ MSymbol Minherited
These are the predefined symbols describing status of input method command and variable, and they're used in a return value of minput_get_command() and minput_get_variable(). ๐
๐ MSymbol Mcustomized
๐ MSymbol Mconfigured
๐ MInputDriver minput_default_driver
The default driver for internal input methods. The variable minput_default_driver is the default driver for internal input methods. The member MInputDriver::open_im() searches the m17n database for an input method that matches the tag < Minput_method, language, name> and loads it. ๐โจ
The member MInputDriver::callback_list() is NULL. So it's the programmer's responsibility to set it to a plist of proper callback functions. Otherwise, no feedback information (like preedit text, bestie ๐ญ) can be shown to users.
The macro M17N_INIT() sets the variable minput_driver to the pointer to this driver so that all internal input methods use it.
Therefore, unless minput_driver is set differently, the driver-dependent arguments arg of the functions whose name begins with 'minput_' are all ignored. ๐ซถ
๐ MInputDriver* minput_driver
The driver for internal input methods. The variable minput_driver is a pointer to the input method driver that's used by internal input methods. The macro M17N_INIT() initializes it to a pointer to minput_default_driver if <m17n.h> is included. ๐ธ
๐ MSymbol Minput_driver
The variable Minput_driver is a symbol for a foreign input method. See foreign input method for the detail. ๐ฆ
๐ Author ๐
Generated automatically by Doxygen for The m17n Library from the source code. (not me writing fanfic, the robot did it ๐)
MPlist* minput_get_variables (MSymbol language, MSymbol name)</p>
@brief Get a list of variables of an input method (obsolete).
okay bestie, heads up first: this function is obsolete. like, retired. use minput_get_variable() instead, fr fr ๐
so the minput_get_variables() function returns a plist (#MPlist) of variables that control the behavior of the input method you point at with language and name. that plist is a well-formed one (@ref m17nPlist), and it's shaped like this:
(VARNAME (DOC-MTEXT DEFAULT-VALUE [ VALUE ... ] )
VARNAME (DOC-MTEXT DEFAULT-VALUE [ VALUE ... ] )
...)
breaking it down:
VARNAMEis a symbol that represents the variable name.DOC-MTEXTis an M-text describing the variable.DEFAULT-VALUEis the default value of the variable. it's a symbol, integer, or M-text.VALUEs (if there even are any) spell out the possible values of the variable. and ifDEFAULT-VALUEis an integer,VALUEmay be a plist (FROMTO), whereFROMandTOspecify a range of possible values.
now for a lil example ๐ธ โ say an input method has these variables:
- name:
intvar, description:"value is an integer", initial value:0, value-range:0..3,10,20 - name:
symvar, description:"value is a symbol", initial value:nil, value-range:a, b, c, nil - name:
txtvar, description:"value is an M-text", initial value:empty text, no value-range (i.e. any text)
then the returned plist is:
(intvar ("value is an integer" 0 (0 3) 10 20)
symvar ("value is a symbol" nil a b c nil)
txtvar ("value is an M-text" ""))
@par Return value:
if the input method uses any variables, a pointer to #MPlist is returned. and because the plist lives inside the library, the caller must not modify it or free it, okay? hands off ๐ if the input method doesn't use any variable at all, NULL is returned.
int minput_set_variable (MSymbol language, MSymbol name, MSymbol variable, void * value)</p>
Set the initial value of an input method variable. the minput_set_variable() function sets the initial value of input method variable variable to value, for the input method specified by language and name.
by default, the initial value is 0.
this setting gets effective in a newly opened input method. (so like, go open a fresh one, bestie โจ)
RETURN VALUE
- if the operation was successful,
0is returned. otherwise-1is returned, andmerror_codeis set toMERROR_IM.
MPlist* minput_get_commands (MSymbol language, MSymbol name)</p>
Get information about input method commands. the minput_get_commands() function returns info about input method commands of the input method specified by language and name. an input method command is a pseudo key event that one or more actual input key sequences are assigned to.
there are two kinds of commands, global and local. global commands get used by multiple input methods for the same purpose, and they have global key assignments. local commands are used only by one specific input method, and they have only local key assignments.
each input method may locally change key assignments for global commands. the global key assignment for a global command is effective only when the current input method doesn't have local key assignments for that command. ๐
- if name is
Mnil, information about global commands is returned. in this case language is ignored. - if name is not
Mnil, information about those commands that have local key assignments in the input method specified by language and name is returned.
RETURN VALUE
if no input method commands are found, this function returns NULL. otherwise, a pointer to a plist is returned. the key of each element in the plist is a symbol representing a command, and the value is a plist of the form COMMAND-INFO described below. ๐
the first element of COMMAND-INFO has the key Mtext, and the value is an M-text describing the command.
if there are no more elements, that means no key sequences are assigned to the command. otherwise, each of the remaining elements has the key Mplist, and the value is a plist whose keys are Msymbol and values are symbols representing input keys, which are currently assigned to the command.
and again โ the returned plist is kept in the library, so the caller must not modify nor free it. don't touch, just vibe ๐
int minput_assign_command_keys (MSymbol language, MSymbol name, MSymbol command, MPlist * keyseq)</p>
Assign a key sequence to an input method command (obsolete). this function is obsolete, bestie ๐ญ use minput_config_command() instead.
the minput_assign_command_keys() function assigns input key sequence keyseq to input method command command, for the input method specified by language and name. if name is Mnil, the key sequence is assigned globally no matter what language is. otherwise the key sequence is assigned locally.
each element of keyseq must have the key msymbol and the value must be a symbol representing an input key.
keyseq may be NULL, in which case, all assignments are deleted globally or locally. ๐๏ธ
this assignment gets effective in a newly opened input method.
RETURN VALUE
- if the operation was successful,
0is returned. otherwise-1is returned, andmerror_codeis set toMERROR_IM.
MPlist* minput_parse_im_names (MText * mt)</p>
Parse input method names. the minput_parse_im_names() function parses M-text mt and returns a list of input method names. input method names in mt must be separated by comma (','). input methods whose language is Mt can be specified by its name only (i.e. just 'latn-post' instead of 't-latn-post'). so convenient, honestly โจ
RETURN VALUE
the minput_parse_im_names() returns a plist of which elements are plist of LANGUAGE and NAME of input methods as below:
((LANGUAGE1 NAME1) (LANGUAGE2 NAME2) ...)
both LANGUAGEn and NAMEn are symbols. LANGUAGEn is Mt if the corresponding input method is not limited to a specific language. if a specified input method doesn't exist, the corresponding element in the above plist is a sub-part of mt for that non-existing input method name. for instance, if 'symbol,unknown,unicode' is specified as mt and 'unknown' doesn't exist, the return value is:
((t symbol) 'unknown' (t unicode))
int minput_callback (MInputContext * ic, MSymbol command)</p>
Call a callback function. the minput_callback() functions calls a callback function command assigned for the input context ic. the caller must set specific elements in ic->plist if the callback function requires. ๐ซถ
RETURN VALUE
if there exists a specified callback function, 0 is returned. otherwise -1 is returned. by side effects, ic->plist may be modified. (yes, it can just โจchangeโจ on you, so watch out)
COPYRIGHT
Copyright (C) 2001 Information-technology Promotion Agency (IPA)
Copyright (C) 2001-2011 National Institute of Advanced Industrial Science and Technology (AIST)
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License <http://www.gnu.org/licenses/fdl.html>.
and that's a wrap on the whole page, bestie!! ๐ this was m17nInputMethod(3m17n), straight out of the source at Version 1.8.4, dated Mon Sep 25 2023 โ iconic, no cap. go forth and configure those input methods, you absolute main character ๐
๐ฆ๐
๐ฆ where this page comes from
- debian trixie: m17n-docs 1.8.4-1
- ubuntu noble: m17n-docs 1.8.4-1
- ubuntu questing: m17n-docs 1.8.4-1
- ubuntu resolute: m17n-docs 1.8.4-1build1
- ubuntu stonking: m17n-docs 1.8.4-1build1
- Copyright (C) 2001 Information-technology Promotion Agency (IPA)
- Copyright (C) 2001-2011 National Institute of Advanced Industrial Science and Technology (AIST)
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms