mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 04:46:55 +03:00
add function edit_get_utf_char
This commit is contained in:
parent
b617640aab
commit
36bf010af6
14
edit/edit.c
14
edit/edit.c
@ -118,6 +118,20 @@ int edit_get_byte (WEdit * edit, long byte_index)
|
||||
}
|
||||
}
|
||||
|
||||
char *edit_get_utf_char (WEdit * edit, long byte_index)
|
||||
{
|
||||
unsigned long p;
|
||||
if (byte_index >= (edit->curs1 + edit->curs2) || byte_index < 0)
|
||||
return NULL;
|
||||
|
||||
if (byte_index >= edit->curs1) {
|
||||
p = edit->curs1 + edit->curs2 - byte_index - 1;
|
||||
return str_get_next_char_safe (edit->buffers2[p >> S_EDIT_BUF_SIZE]+(EDIT_BUF_SIZE - (p & M_EDIT_BUF_SIZE) - 1));
|
||||
} else {
|
||||
return str_get_next_char_safe (edit->buffers1[byte_index >> S_EDIT_BUF_SIZE]+(byte_index & M_EDIT_BUF_SIZE));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize the buffers for an empty files.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user