Doc: Fix callback arguments style

In addition, add callback signatures.
This commit is contained in:
Daijiro Fukuda 2022-05-23 18:50:19 +09:00
parent 4d8c6c9f11
commit fa0d693fcd
2 changed files with 43 additions and 18 deletions

View File

@ -235,36 +235,42 @@ glfwSetPreeditCallback(window, preedit_callback);
The callback function receives chunk of text and focused block information. The callback function receives chunk of text and focused block information.
@code @code
static void preedit_callback(GLFWwindow* window, int strLength, unsigned int* string, int blockLength, int* blocks, int focusedBlock) { void preedit_callback(GLFWwindow* window,
int preedit_length,
unsigned int* preedit_string,
int block_count,
int* block_sizes,
int focused_block)
{
} }
@endcode @endcode
strLength and string parameter represent whole preedit text. Each character of the preedit string is a codepoint like @ref input_char. "preedit_length" and "preedit_string" parameter represent whole preedit text. Each character of the preedit string is a codepoint like @ref input_char.
If you want to type the text "寿司(sushi)", Usually the callback is called several times like the following sequence: If you want to type the text "寿司(sushi)", Usually the callback is called several times like the following sequence:
-# key event: s -# key event: s
-# preedit: [string: "", block: [1], focusedBlock: 0] -# preedit: [preedit_string: "", block_sizes: [1], focused_block: 0]
-# key event: u -# key event: u
-# preedit: [string: "す", block: [1], focusedBlock: 0] -# preedit: [preedit_string: "す", block_sizes: [1], focused_block: 0]
-# key event: s -# key event: s
-# preedit: [string: "すs", block: [2], focusedBlock: 0] -# preedit: [preedit_string: "すs", block_sizes: [2], focused_block: 0]
-# key event: h -# key event: h
-# preedit: [string: "すsh", block: [2], focusedBlock: 0] -# preedit: [preedit_string: "すsh", block_sizes: [2], focused_block: 0]
-# key event: i -# key event: i
-# preedit: [string: "すし", block: [2], focusedBlock: 0] -# preedit: [preedit_string: "すし", block_sizes: [2], focused_block: 0]
-# key event: ' ' -# key event: ' '
-# preedit: [string: "寿司", block: [2], focusedBlock: 0] -# preedit: [preedit_string: "寿司", block_sizes: [2], focused_block: 0]
-# char: '寿' -# char: '寿'
-# char: '司' -# char: '司'
-# preedit: [string: "", block: [], focusedBlock: 0] -# preedit: [preedit_string: "", block_sizes: [], focused_block: 0]
If preedit text includes several semantic blocks, preedit callbacks returns several blocks after a space key pressed: If preedit text includes several semantic blocks, preedit callbacks returns several blocks after a space key pressed:
-# preedit: [string: "わたしはすしをたべます", block: [11], focusedBlock: 0] -# preedit: [preedit_string: "わたしはすしをたべます", block_sizes: [11], focused_block: 0]
-# preedit: [string: "私は寿司を食べます", block: [2, 7], focusedBlock: 1] -# preedit: [preedit_string: "私は寿司を食べます", block_sizes: [2, 7], focused_block: 1]
"blocks" is a list of block length. The above case, it contains the following blocks and second block is focused. "block_sizes" is a list of block length. The above case, it contains the following blocks and second block is focused.
- 私は - 私は
- [寿司を食べます] - [寿司を食べます]

View File

@ -1883,11 +1883,11 @@ typedef void (* GLFWcharmodsfun)(GLFWwindow* window, unsigned int codepoint, int
* This is the function pointer type for preedit callback functions. * This is the function pointer type for preedit callback functions.
* *
* @param[in] window The window that received the event. * @param[in] window The window that received the event.
* @param[in] length Preedit string length. * @param[in] preedit_length Preedit string length.
* @param[in] string Preedit string. * @param[in] preedit_string Preedit string.
* @param[in] count Attributed block count. * @param[in] block_count Attributed block count.
* @param[in] blocksizes List of attributed block size. * @param[in] block_sizes List of attributed block size.
* @param[in] focusedblock Focused block index. * @param[in] focused_block Focused block index.
* *
* @sa @ref preedit * @sa @ref preedit
* @sa glfwSetPreeditCallback * @sa glfwSetPreeditCallback
@ -1898,7 +1898,7 @@ typedef void (* GLFWpreeditfun)(GLFWwindow* window,
int preedit_length, int preedit_length,
unsigned int* preedit_string, unsigned int* preedit_string,
int block_count, int block_count,
int* block_sizes_list, int* block_sizes,
int focused_block); int focused_block);
/*! @brief The function pointer type for IME status change callbacks. /*! @brief The function pointer type for IME status change callbacks.
@ -5261,6 +5261,18 @@ GLFWAPI GLFWcharmodsfun glfwSetCharModsCallback(GLFWwindow* window, GLFWcharmods
* callback. * callback.
* @return The previously set callback, or `NULL` if no callback was set or an * @return The previously set callback, or `NULL` if no callback was set or an
* error occurred. * error occurred.
*
* @callback_signature
* @code
* void function_name(GLFWwindow* window,
int preedit_length,
unsigned int* preedit_string,
int block_count,
int* block_sizes,
int focused_block)
* @endcode
* For more information about the callback parameters, see the
* [function pointer type](@ref GLFWpreeditfun).
* *
* @par Thread Safety * @par Thread Safety
* This function may only be called from the main thread. * This function may only be called from the main thread.
@ -5283,6 +5295,13 @@ GLFWAPI GLFWpreeditfun glfwSetPreeditCallback(GLFWwindow* window, GLFWpreeditfun
* callback. * callback.
* @return The previously set callback, or `NULL` if no callback was set or an * @return The previously set callback, or `NULL` if no callback was set or an
* error occurred. * error occurred.
*
* @callback_signature
* @code
* void function_name(GLFWwindow* window)
* @endcode
* For more information about the callback parameters, see the
* [function pointer type](@ref GLFWimestatusfun).
* *
* @par Thread Safety * @par Thread Safety
* This function may only be called from the main thread. * This function may only be called from the main thread.