> home > Custom Layer Boundary API

buffer_replace_range

January 19th 2020
Replace a range of text with a specific string

Signature

C++
b32
buffer_replace_range(Application_Links* app,
                     Buffer_ID buffer_id,
                     Range_i64 range,
                     String_Const_u8 string);

Parameters

app

the standard custom layer context pointer

buffer_id

the id of the buffer to modify

range

the range of bytes to replace - the range is left inclusive right exclusive, for example the range [10,20) replaces ten bytes and the byte at index 20 remains in the buffer, possibly shifted if the string is not ten bytes

string

the new text to be placed in the given range

Return

non-zero on success, when the buffer eixsts and the range is contained within the buffer, zero otherwise

Details

This operation is used to implement inserts by setting the range to be empty, [x,x) inserts the string at x, and it implements deletion by setting the string to be empty.
All modifications made by this call are simultaneously saved onto the buffer's history if is enabled.