Blender V4.3
string_cursor_utf8.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include "BLI_string_utf8.h"
#include "BLI_utildefines.h"
#include "BLI_string_cursor_utf8.h"
#include "BLI_strict_flags.h"

Go to the source code of this file.

Typedefs

typedef enum eStrCursorDelimType eStrCursorDelimType
 

Enumerations

enum  eStrCursorDelimType {
  STRCUR_DELIM_NONE , STRCUR_DELIM_ALPHANUMERIC , STRCUR_DELIM_PUNCT , STRCUR_DELIM_BRACE ,
  STRCUR_DELIM_OPERATOR , STRCUR_DELIM_QUOTE , STRCUR_DELIM_OTHER , STRCUR_DELIM_WHITESPACE
}
 

Functions

static eStrCursorDelimType cursor_delim_type_unicode (const uint uch)
 
static eStrCursorDelimType cursor_delim_type_utf8 (const char *ch_utf8, const int ch_utf8_len, const int pos)
 
bool BLI_str_cursor_step_next_utf8 (const char *str, const int str_maxlen, int *pos)
 
bool BLI_str_cursor_step_prev_utf8 (const char *str, const int str_maxlen, int *pos)
 
void BLI_str_cursor_step_utf8 (const char *str, const int str_maxlen, int *pos, eStrCursorJumpDirection direction, eStrCursorJumpType jump, bool use_init_step)
 
bool BLI_str_cursor_step_next_utf32 (const char32_t *str, const int str_maxlen, int *pos)
 
bool BLI_str_cursor_step_prev_utf32 (const char32_t *str, const int str_maxlen, int *pos)
 
void BLI_str_cursor_step_utf32 (const char32_t *str, const int str_maxlen, int *pos, eStrCursorJumpDirection direction, eStrCursorJumpType jump, bool use_init_step)
 
void BLI_str_cursor_step_bounds_utf8 (const char *str, const int str_maxlen, const int pos, int *r_start, int *r_end)
 
void BLI_str_cursor_step_bounds_utf32 (const char32_t *str, const int str_maxlen, const int pos, int *r_start, int *r_end)
 

Typedef Documentation

◆ eStrCursorDelimType

The category of character as returned by cursor_delim_type_unicode.

Note
Don't compare with any values besides STRCUR_DELIM_NONE as cursor motion should only delimit on changes, not treat some groups differently.

For range calculation the order prioritizes expansion direction, when the cursor is between two different categories, "hug" the smaller values. Where white-space gets lowest priority. See BLI_str_cursor_step_bounds_utf8. This is done so expanding the range at a word boundary always chooses the word instead of the white-space before or after it.

Enumeration Type Documentation

◆ eStrCursorDelimType

The category of character as returned by cursor_delim_type_unicode.

Note
Don't compare with any values besides STRCUR_DELIM_NONE as cursor motion should only delimit on changes, not treat some groups differently.

For range calculation the order prioritizes expansion direction, when the cursor is between two different categories, "hug" the smaller values. Where white-space gets lowest priority. See BLI_str_cursor_step_bounds_utf8. This is done so expanding the range at a word boundary always chooses the word instead of the white-space before or after it.

Enumerator
STRCUR_DELIM_NONE 
STRCUR_DELIM_ALPHANUMERIC 
STRCUR_DELIM_PUNCT 
STRCUR_DELIM_BRACE 
STRCUR_DELIM_OPERATOR 
STRCUR_DELIM_QUOTE 
STRCUR_DELIM_OTHER 
STRCUR_DELIM_WHITESPACE 

Definition at line 31 of file string_cursor_utf8.c.

Function Documentation

◆ BLI_str_cursor_step_bounds_utf32()

void BLI_str_cursor_step_bounds_utf32 ( const char32_t * str,
int str_maxlen,
int pos,
int * r_start,
int * r_end )

◆ BLI_str_cursor_step_bounds_utf8()

void BLI_str_cursor_step_bounds_utf8 ( const char * str,
int str_maxlen,
int pos,
int * r_start,
int * r_end )

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).
Parameters
strThe string with a cursor position
str_maxlenThe maximum characters to consider
posThe starting cursor position.
r_startreturned start of word/sequence boundary (0-based)
r_endreturned end of word/sequence boundary (0-based)

Definition at line 372 of file string_cursor_utf8.c.

References BLI_assert, BLI_str_cursor_step_utf8(), cursor_delim_type_utf8(), next, pos, str, STRCUR_DELIM_NONE, STRCUR_DIR_NEXT, STRCUR_DIR_PREV, and STRCUR_JUMP_DELIM.

Referenced by console_selectword_invoke(), text_select_word_exec(), and ui_do_but_textedit().

◆ BLI_str_cursor_step_next_utf32()

bool BLI_str_cursor_step_next_utf32 ( const char32_t * str,
const int str_maxlen,
int * pos )

◆ BLI_str_cursor_step_next_utf8()

bool BLI_str_cursor_step_next_utf8 ( const char * str,
const int str_maxlen,
int * pos )

◆ BLI_str_cursor_step_prev_utf32()

bool BLI_str_cursor_step_prev_utf32 ( const char32_t * str,
const int str_maxlen,
int * pos )

◆ BLI_str_cursor_step_prev_utf8()

bool BLI_str_cursor_step_prev_utf8 ( const char * str,
const int str_maxlen,
int * pos )

◆ BLI_str_cursor_step_utf32()

◆ BLI_str_cursor_step_utf8()

◆ cursor_delim_type_unicode()

◆ cursor_delim_type_utf8()

static eStrCursorDelimType cursor_delim_type_utf8 ( const char * ch_utf8,
const int ch_utf8_len,
const int pos )
static