2023-08-16 00:20:26 +10:00
|
|
|
/* SPDX-FileCopyrightText: 2011 Blender Authors
|
2023-05-31 16:19:06 +02:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
2012-03-07 15:55:12 +00:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
|
* \ingroup bli
|
2012-03-07 15:55:12 +00:00
|
|
|
*/
|
|
|
|
|
|
2020-03-02 15:04:53 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2017-10-17 13:43:10 +11:00
|
|
|
typedef enum eStrCursorJumpType {
|
2012-03-07 15:55:12 +00:00
|
|
|
STRCUR_JUMP_NONE,
|
|
|
|
|
STRCUR_JUMP_DELIM,
|
2019-04-16 16:40:47 +02:00
|
|
|
STRCUR_JUMP_ALL,
|
2017-10-17 13:43:10 +11:00
|
|
|
} eStrCursorJumpType;
|
2012-03-07 15:55:12 +00:00
|
|
|
|
2017-10-17 13:43:10 +11:00
|
|
|
typedef enum eStrCursorJumpDirection {
|
2012-03-07 15:55:12 +00:00
|
|
|
STRCUR_DIR_PREV,
|
2019-04-16 16:40:47 +02:00
|
|
|
STRCUR_DIR_NEXT,
|
2017-10-17 13:43:10 +11:00
|
|
|
} eStrCursorJumpDirection;
|
2012-03-07 15:55:12 +00:00
|
|
|
|
2023-09-20 12:11:30 +10:00
|
|
|
bool BLI_str_cursor_step_next_utf8(const char *str, int str_maxlen, int *pos);
|
|
|
|
|
bool BLI_str_cursor_step_prev_utf8(const char *str, int str_maxlen, int *pos);
|
2012-03-07 15:55:12 +00:00
|
|
|
|
2023-09-20 12:11:30 +10:00
|
|
|
bool BLI_str_cursor_step_next_utf32(const char32_t *str, int str_maxlen, int *pos);
|
|
|
|
|
bool BLI_str_cursor_step_prev_utf32(const char32_t *str, int str_maxlen, int *pos);
|
2022-09-27 08:39:24 -07:00
|
|
|
|
2017-10-17 13:43:10 +11:00
|
|
|
void BLI_str_cursor_step_utf8(const char *str,
|
2023-09-20 12:11:30 +10:00
|
|
|
int str_maxlen,
|
2017-10-17 13:43:10 +11:00
|
|
|
int *pos,
|
|
|
|
|
eStrCursorJumpDirection direction,
|
|
|
|
|
eStrCursorJumpType jump,
|
|
|
|
|
bool use_init_step);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-11-22 12:26:54 -03:00
|
|
|
void BLI_str_cursor_step_utf32(const char32_t *str,
|
2023-09-20 12:11:30 +10:00
|
|
|
int str_maxlen,
|
2017-10-17 13:43:10 +11:00
|
|
|
int *pos,
|
|
|
|
|
eStrCursorJumpDirection direction,
|
|
|
|
|
eStrCursorJumpType jump,
|
|
|
|
|
bool use_init_step);
|
2013-12-29 16:54:43 +11:00
|
|
|
|
2023-05-14 21:50:53 +02:00
|
|
|
/**
|
2023-05-15 10:52:27 +10:00
|
|
|
* Given a position within a string,
|
|
|
|
|
* return the start and end of the closest sequence of delimited characters.
|
|
|
|
|
* Typically a word, but can be a sequence of characters (including spaces).
|
|
|
|
|
*
|
|
|
|
|
* \note When used for word-selection the caller should set the cursor to `r_end` (by convention).
|
2023-05-14 21:50:53 +02:00
|
|
|
*
|
|
|
|
|
* \param str: The string with a cursor position
|
|
|
|
|
* \param str_maxlen: The maximum characters to consider
|
2023-05-15 10:52:27 +10:00
|
|
|
* \param pos: The starting cursor position.
|
2023-05-14 21:50:53 +02:00
|
|
|
* \param r_start: returned start of word/sequence boundary (0-based)
|
|
|
|
|
* \param r_end: returned end of word/sequence boundary (0-based)
|
|
|
|
|
*/
|
|
|
|
|
void BLI_str_cursor_step_bounds_utf8(
|
2023-09-20 12:11:30 +10:00
|
|
|
const char *str, int str_maxlen, int pos, int *r_start, int *r_end);
|
2023-05-14 21:50:53 +02:00
|
|
|
|
2023-05-15 10:29:38 +10:00
|
|
|
/** A UTF32 version of #BLI_str_cursor_step_bounds_utf8 */
|
2023-05-14 21:50:53 +02:00
|
|
|
void BLI_str_cursor_step_bounds_utf32(
|
2023-09-20 12:11:30 +10:00
|
|
|
const char32_t *str, int str_maxlen, int pos, int *r_start, int *r_end);
|
2023-05-14 21:50:53 +02:00
|
|
|
|
2020-03-02 15:04:53 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|