From 431d80a8b8a72e46731897299e735e3ad25e2603 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Thu, 8 Sep 2016 18:03:43 -0400 Subject: [PATCH] switched buffer_boundary_seek over to custom code --- 4coder_API.html | 194 ++++++------ 4coder_custom_api.h | 4 - 4coder_default_include.cpp | 370 ++++++++++++++++++++++- 4coder_string.h | 18 ++ 4ed_api_implementation.cpp | 103 ------- buffer/4coder_buffer_abstract.cpp | 474 ------------------------------ internal_4coder_string.cpp | 12 + internal_4coder_tests.cpp | 90 +++++- win32_4ed.cpp | 4 +- 9 files changed, 585 insertions(+), 684 deletions(-) diff --git a/4coder_API.html b/4coder_API.html index ac3d40e1..c1ada157 100644 --- a/4coder_API.html +++ b/4coder_API.html @@ -2,7 +2,7 @@

4cpp Lexing Library

Table of Contents

§1 Introduction

This is the documentation for alpha 4.0.11 The documentation is still under construction so some of the links are linking to sections that have not been written yet. What is here should be correct and I suspect useful even without some of the other sections.

If you have questions or discover errors please contact editor@4coder.net or to get help from community members you can post on the 4coder forums hosted on handmade.network at 4coder.handmade.network

§2 4coder Systems

Coming Soon
-

§3 Types and Functions

§3.1 Function List

§3.2 Type List

§3.3 Function Descriptions

§3.3.1: exec_command

bool32 app->exec_command(
Application_Links *app,
Command_ID command_id
)
Parameters
command_id
The command_id parameter specifies which internal command to execute.
Return
This call returns non-zero if command_id named a valid internal command.
Description
A call to exec_command executes an internal command. +

§3 Types and Functions

§3.1 Function List

§3.2 Type List

§3.3 Function Descriptions

§3.3.1: exec_command

bool32 app->exec_command(
Application_Links *app,
Command_ID command_id
)
Parameters
command_id
The command_id parameter specifies which internal command to execute.
Return
This call returns non-zero if command_id named a valid internal command.
Description
A call to exec_command executes an internal command. If command_id is invalid a warning is posted to *messages*.

See Also

§3.3.2: exec_system_command

bool32 app->exec_system_command(
Application_Links *app,
View_Summary *view,
Buffer_Identifier buffer,
char *path,
int32_t path_len,
char *command,
int32_t command_len,
Command_Line_Input_Flag flags
)
Parameters
view
If the view parameter is non-null it specifies a view to display the command's output buffer.
buffer
The buffer the command will output to is specified by the buffer parameter. See Buffer_Identifier for information on how this type specifies a buffer.
path
The path parameter specifies the path in which the command shall be executed. The string need not be null terminated.
path_len
The parameter path_len specifies the length of the path string.
command
The command parameter specifies the command that shall be executed. The string need not be null terminated.
command_len
The parameter command_len specifies the length of the command string.
flags
Flags for the behavior of the call are specified in the flags parameter.
Return
This call returns non-zero on success.
Description
A call to exec_system_command executes a command as if called from the command line, and sends the output to a buffer. The buffer identifier can either name a new buffer that does not exist, name a buffer that does @@ -18,83 +18,81 @@ If the buffer returned does not exist, the loop is finished. Buffers should not be killed durring a buffer loop.

See Also

§3.3.8: get_buffer_next

void app->get_buffer_next(
Application_Links *app,
Buffer_Summary *buffer,
Access_Flag access
)
Parameters
buffer
The Buffer_Summary pointed to by buffer is iterated to the next buffer or to a null summary if this is the last buffer.
access
The access parameter determines what levels of protection this call can access. The buffer outputted will be the next buffer that is accessible.
Description
This call steps a Buffer_Summary to the next buffer in the global buffer order. The global buffer order is kept roughly in the order of most recently used to least recently used.

If the buffer outputted does not exist, the loop is finished. -Buffers should not be killed or created durring a buffer loop.

See Also

§3.3.9: get_buffer

Buffer_Summary app->get_buffer(
Application_Links *app,
Buffer_ID buffer_id,
Access_Flag access
)
Parameters
buffer_id
The parameter buffer_id specifies which buffer to try to get.
access
The access parameter determines what levels of protection this call can access.
Return
This call returns a summary that describes the indicated buffer if it exists and is accessible.
See Also

§3.3.10: get_buffer_by_name

Buffer_Summary app->get_buffer_by_name(
Application_Links *app,
char *name,
int32_t len,
Access_Flag access
)
Parameters
name
The name parameter specifies the buffer name to try to get. The string need not be null terminated.
len
The len parameter specifies the length of the name string.
access
The access parameter determines what levels of protection this call can access.
Return
This call returns a summary that describes the indicated buffer if it exists and is accessible.
See Also

§3.3.11: buffer_boundary_seek

int32_t app->buffer_boundary_seek(
Application_Links *app,
Buffer_Summary *buffer,
int32_t start_pos,
bool32 seek_forward,
Seek_Boundary_Flag flags
)
Parameters
buffer
The buffer parameter specifies the buffer through which to seek.
start_pos
The beginning position of the seek is specified by start_pos measured in absolute position.
seek_forward
If this parameter is non-zero it indicates that the seek should move foward through the buffer.
flags
This field specifies the types of boundaries at which the seek should stop.
Return
This call returns the absolute position where the seek stopped. -If the seek goes below 0 the returned value is -1. -If the seek goes past the end the returned value is the size of the buffer.
See Also

§3.3.12: buffer_read_range

bool32 app->buffer_read_range(
Application_Links *app,
Buffer_Summary *buffer,
int32_t start,
int32_t end,
char *out
)
Parameters
buffer
This parameter specifies the buffer to read.
start
This parameter specifies absolute position of the first character in the read range.
end
This parameter specifies the absolute position of the the character one past the end of the read range.
out
This paramter provides the output character buffer to fill with the result of the read.
Return
This call returns non-zero if the read succeeds.
Description
The output buffer must have a capacity of at least (end - start). +Buffers should not be killed or created durring a buffer loop.

See Also

§3.3.9: get_buffer

Buffer_Summary app->get_buffer(
Application_Links *app,
Buffer_ID buffer_id,
Access_Flag access
)
Parameters
buffer_id
The parameter buffer_id specifies which buffer to try to get.
access
The access parameter determines what levels of protection this call can access.
Return
This call returns a summary that describes the indicated buffer if it exists and is accessible.
See Also

§3.3.10: get_buffer_by_name

Buffer_Summary app->get_buffer_by_name(
Application_Links *app,
char *name,
int32_t len,
Access_Flag access
)
Parameters
name
The name parameter specifies the buffer name to try to get. The string need not be null terminated.
len
The len parameter specifies the length of the name string.
access
The access parameter determines what levels of protection this call can access.
Return
This call returns a summary that describes the indicated buffer if it exists and is accessible.
See Also

§3.3.11: buffer_read_range

bool32 app->buffer_read_range(
Application_Links *app,
Buffer_Summary *buffer,
int32_t start,
int32_t end,
char *out
)
Parameters
buffer
This parameter specifies the buffer to read.
start
This parameter specifies absolute position of the first character in the read range.
end
This parameter specifies the absolute position of the the character one past the end of the read range.
out
This paramter provides the output character buffer to fill with the result of the read.
Return
This call returns non-zero if the read succeeds.
Description
The output buffer must have a capacity of at least (end - start). The output is not null terminated.

This call fails if the buffer does not exist, -or if the read range is not within the bounds of the buffer.

See Also

§3.3.13: buffer_replace_range

bool32 app->buffer_replace_range(
Application_Links *app,
Buffer_Summary *buffer,
int32_t start,
int32_t end,
char *str,
int32_t len
)
Parameters
buffer
This parameter specifies the buffer to edit.
start
This parameter specifies absolute position of the first character in the replace range.
end
This parameter specifies the absolute position of the the character one past the end of the replace range.
str
This parameter specifies the the string to write into the range; it need not be null terminated.
len
This parameter specifies the length of the str string.
Return
This call returns non-zero if the replacement succeeds.
Description
If this call succeeds it deletes the range from start to end +or if the read range is not within the bounds of the buffer.

See Also

§3.3.12: buffer_replace_range

bool32 app->buffer_replace_range(
Application_Links *app,
Buffer_Summary *buffer,
int32_t start,
int32_t end,
char *str,
int32_t len
)
Parameters
buffer
This parameter specifies the buffer to edit.
start
This parameter specifies absolute position of the first character in the replace range.
end
This parameter specifies the absolute position of the the character one past the end of the replace range.
str
This parameter specifies the the string to write into the range; it need not be null terminated.
len
This parameter specifies the length of the str string.
Return
This call returns non-zero if the replacement succeeds.
Description
If this call succeeds it deletes the range from start to end and writes str in the same position. If end == start then this call is equivalent to inserting the string at start. If len == 0 this call is equivalent to deleteing the range from start to end.

This call fails if the buffer does not exist, or if the replace -range is not within the bounds of the buffer.

See Also

§3.3.14: buffer_compute_cursor

bool32 app->buffer_compute_cursor(
Application_Links *app,
Buffer_Summary *buffer,
Buffer_Seek seek,
Partial_Cursor *cursor_out
)
Parameters
buffer
The buffer parameter specifies the buffer on which to run the cursor computation.
seek
The seek parameter specifies the target position for the seek.
cursor_out
On success this struct is filled with the result of the seek.
Return
This call returns non-zero on success. This call can fail if the buffer summary provided +range is not within the bounds of the buffer.

See Also

§3.3.13: buffer_compute_cursor

bool32 app->buffer_compute_cursor(
Application_Links *app,
Buffer_Summary *buffer,
Buffer_Seek seek,
Partial_Cursor *cursor_out
)
Parameters
buffer
The buffer parameter specifies the buffer on which to run the cursor computation.
seek
The seek parameter specifies the target position for the seek.
cursor_out
On success this struct is filled with the result of the seek.
Return
This call returns non-zero on success. This call can fail if the buffer summary provided does not summarize an actual buffer in 4coder, or if the provided seek format is invalid. The valid seek types are seek_pos and seek_line_char.
Description
Computes a Partial_Cursor for the given seek position with no side effects. The seek position must be one of the types supported by Partial_Cursor. Those -types are absolute position and line,column position.

See Also

§3.3.15: buffer_batch_edit

bool32 app->buffer_batch_edit(
Application_Links *app,
Buffer_Summary *buffer,
char *str,
int32_t str_len,
Buffer_Edit *edits,
int32_t edit_count,
Buffer_Batch_Edit_Type type
)
Parameters
str
This parameter provides all of the source string for the edits in the batch.
str_len
This parameter specifies the length of the str string.
edits
This parameter provides about the source string and destination range of each edit as an array.
edit_count
This parameter specifies the number of Buffer_Edit structs in edits.
type
This prameter specifies what type of batch edit to execute.
Return
This call returns non-zero if the batch edit succeeds. This call can fail if the provided -buffer summary does not refer to an actual buffer in 4coder.
Description
TODO

See Also

§3.3.16: buffer_set_setting

bool32 app->buffer_set_setting(
Application_Links *app,
Buffer_Summary *buffer,
Buffer_Setting_ID setting,
int32_t value
)
Parameters
buffer
The buffer parameter specifies the buffer on which to set a setting.
setting
The setting parameter identifies the setting that shall be changed.
value
The value parameter specifies the value to which the setting shall be changed.
See Also

§3.3.17: buffer_token_count

int32_t app->buffer_token_count(
Application_Links *app,
Buffer_Summary *buffer
)
No documentation generated for this function.

§3.3.18: buffer_read_tokens

bool32 app->buffer_read_tokens(
Application_Links *app,
Buffer_Summary *buffer,
int32_t first_token,
int32_t last_token,
Cpp_Token *tokens_out
)
No documentation generated for this function.

§3.3.19: create_buffer

Buffer_Summary app->create_buffer(
Application_Links *app,
char *filename,
int32_t filename_len,
Buffer_Create_Flag flags
)
Parameters
filename
The filename parameter specifies the name of the file to be opened or created; it need not be null terminated.
filename_len
The filename_len parameter spcifies the length of the filename string.
flags
The flags parameter specifies behaviors for buffer creation.
Return
This call returns the summary of the created buffer.
Description
Tries to create a new buffer and associate it to the given filename. If such a buffer already +types are absolute position and line,column position.

See Also

§3.3.14: buffer_batch_edit

bool32 app->buffer_batch_edit(
Application_Links *app,
Buffer_Summary *buffer,
char *str,
int32_t str_len,
Buffer_Edit *edits,
int32_t edit_count,
Buffer_Batch_Edit_Type type
)
Parameters
str
This parameter provides all of the source string for the edits in the batch.
str_len
This parameter specifies the length of the str string.
edits
This parameter provides about the source string and destination range of each edit as an array.
edit_count
This parameter specifies the number of Buffer_Edit structs in edits.
type
This prameter specifies what type of batch edit to execute.
Return
This call returns non-zero if the batch edit succeeds. This call can fail if the provided +buffer summary does not refer to an actual buffer in 4coder.
Description
TODO

See Also

§3.3.15: buffer_set_setting

bool32 app->buffer_set_setting(
Application_Links *app,
Buffer_Summary *buffer,
Buffer_Setting_ID setting,
int32_t value
)
Parameters
buffer
The buffer parameter specifies the buffer on which to set a setting.
setting
The setting parameter identifies the setting that shall be changed.
value
The value parameter specifies the value to which the setting shall be changed.
See Also

§3.3.16: buffer_token_count

int32_t app->buffer_token_count(
Application_Links *app,
Buffer_Summary *buffer
)
No documentation generated for this function.

§3.3.17: buffer_read_tokens

bool32 app->buffer_read_tokens(
Application_Links *app,
Buffer_Summary *buffer,
int32_t first_token,
int32_t last_token,
Cpp_Token *tokens_out
)
No documentation generated for this function.

§3.3.18: create_buffer

Buffer_Summary app->create_buffer(
Application_Links *app,
char *filename,
int32_t filename_len,
Buffer_Create_Flag flags
)
Parameters
filename
The filename parameter specifies the name of the file to be opened or created; it need not be null terminated.
filename_len
The filename_len parameter spcifies the length of the filename string.
flags
The flags parameter specifies behaviors for buffer creation.
Return
This call returns the summary of the created buffer.
Description
Tries to create a new buffer and associate it to the given filename. If such a buffer already exists the existing buffer is returned in the Buffer_Summary and no new buffer is created. If the buffer does not exist a new buffer is created and named after the given filename. If the filename corresponds to a file on the disk that file is loaded and put into buffer, if -the filename does not correspond to a file on disk the buffer is created empty.

See Also

§3.3.20: save_buffer

bool32 app->save_buffer(
Application_Links *app,
Buffer_Summary *buffer,
char *filename,
int32_t filename_len,
uint32_t flags
)
Parameters
buffer
The buffer parameter specifies the buffer to save to a file.
filename
The filename parameter specifies the name of the file to associated to the buffer; it need not be null terminated.
filename_len
The filename_len parameter specifies the length of the filename string.
flags
This parameter is not currently used and should be set to 0 for now.
Return
This call returns non-zero on success.

§3.3.21: kill_buffer

bool32 app->kill_buffer(
Application_Links *app,
Buffer_Identifier buffer,
View_ID view_id,
Buffer_Kill_Flag flags
)
Parameters
buffer
The buffer parameter specifies the buffer to try to kill.
view_id
The view_id parameter specifies the view that will contain the "are you sure" dialogue if the buffer is dirty.
flags
The flags parameter specifies behaviors for the buffer kill.
Return
This call returns non-zero if the buffer is killed.
Description
Tries to kill the idenfied buffer. If the buffer is dirty and the "are you sure" +the filename does not correspond to a file on disk the buffer is created empty.

See Also

§3.3.19: save_buffer

bool32 app->save_buffer(
Application_Links *app,
Buffer_Summary *buffer,
char *filename,
int32_t filename_len,
uint32_t flags
)
Parameters
buffer
The buffer parameter specifies the buffer to save to a file.
filename
The filename parameter specifies the name of the file to associated to the buffer; it need not be null terminated.
filename_len
The filename_len parameter specifies the length of the filename string.
flags
This parameter is not currently used and should be set to 0 for now.
Return
This call returns non-zero on success.

§3.3.20: kill_buffer

bool32 app->kill_buffer(
Application_Links *app,
Buffer_Identifier buffer,
View_ID view_id,
Buffer_Kill_Flag flags
)
Parameters
buffer
The buffer parameter specifies the buffer to try to kill.
view_id
The view_id parameter specifies the view that will contain the "are you sure" dialogue if the buffer is dirty.
flags
The flags parameter specifies behaviors for the buffer kill.
Return
This call returns non-zero if the buffer is killed.
Description
Tries to kill the idenfied buffer. If the buffer is dirty and the "are you sure" dialogue needs to be displayed the provided view is used to show the dialogue. -If the view is not open the kill fails.

See Also

§3.3.22: get_view_first

View_Summary app->get_view_first(
Application_Links *app,
Access_Flag access
)
Parameters
access
The access parameter determines what levels of protection this call can access.
Return
This call returns the summary of the first view in a view loop.
Description
This call begins a loop across all the open views.

+If the view is not open the kill fails.

See Also

§3.3.21: get_view_first

View_Summary app->get_view_first(
Application_Links *app,
Access_Flag access
)
Parameters
access
The access parameter determines what levels of protection this call can access.
Return
This call returns the summary of the first view in a view loop.
Description
This call begins a loop across all the open views.

If the View_Summary returned is a null summary, the loop is finished. -Views should not be closed or opened durring a view loop.

See Also

§3.3.23: get_view_next

void app->get_view_next(
Application_Links *app,
View_Summary *view,
Access_Flag access
)
Parameters
view
The View_Summary pointed to by view is iterated to the next view or to a null summary if this is the last view.
access
The access parameter determines what levels of protection this call can access. The view outputted will be the next view that is accessible.
Description
This call steps a View_Summary to the next view in the global view order.

+Views should not be closed or opened durring a view loop.

See Also

§3.3.22: get_view_next

void app->get_view_next(
Application_Links *app,
View_Summary *view,
Access_Flag access
)
Parameters
view
The View_Summary pointed to by view is iterated to the next view or to a null summary if this is the last view.
access
The access parameter determines what levels of protection this call can access. The view outputted will be the next view that is accessible.
Description
This call steps a View_Summary to the next view in the global view order.

If the view outputted does not exist, the loop is finished. -Views should not be closed or opened durring a view loop.

See Also

§3.3.24: get_view

View_Summary app->get_view(
Application_Links *app,
View_ID view_id,
Access_Flag access
)
Parameters
view_id
The view_id specifies the view to try to get.
access
The access parameter determines what levels of protection this call can access.
Return
This call returns a summary that describes the indicated view if it is open and accessible.
See Also

§3.3.25: get_active_view

View_Summary app->get_active_view(
Application_Links *app,
Access_Flag access
)
Parameters
access
The access parameter determines what levels of protection this call can access.
Return
This call returns a summary that describes the active view.
See Also

§3.3.26: open_view

View_Summary app->open_view(
Application_Links *app,
View_Summary *view_location,
View_Split_Position position
)
Parameters
view_location
The view_location parameter specifies the view to split to open the new view.
position
The position parameter specifies how to split the view and where to place the new view.
Return
If this call succeeds it returns a View_Summary describing the newly created view, if it fails it +Views should not be closed or opened durring a view loop.

See Also

§3.3.23: get_view

View_Summary app->get_view(
Application_Links *app,
View_ID view_id,
Access_Flag access
)
Parameters
view_id
The view_id specifies the view to try to get.
access
The access parameter determines what levels of protection this call can access.
Return
This call returns a summary that describes the indicated view if it is open and accessible.
See Also

§3.3.24: get_active_view

View_Summary app->get_active_view(
Application_Links *app,
Access_Flag access
)
Parameters
access
The access parameter determines what levels of protection this call can access.
Return
This call returns a summary that describes the active view.
See Also

§3.3.25: open_view

View_Summary app->open_view(
Application_Links *app,
View_Summary *view_location,
View_Split_Position position
)
Parameters
view_location
The view_location parameter specifies the view to split to open the new view.
position
The position parameter specifies how to split the view and where to place the new view.
Return
If this call succeeds it returns a View_Summary describing the newly created view, if it fails it returns a null summary.
Description
4coder is built with a limit of 16 views. If 16 views are already open when this is called the -call will fail.

See Also

§3.3.27: close_view

bool32 app->close_view(
Application_Links *app,
View_Summary *view
)
Parameters
view
The view parameter specifies which view to close.
Return
This call returns non-zero on success.
Description
If the given view is open and is not the last view, it will be closed. +call will fail.

See Also

§3.3.26: close_view

bool32 app->close_view(
Application_Links *app,
View_Summary *view
)
Parameters
view
The view parameter specifies which view to close.
Return
This call returns non-zero on success.
Description
If the given view is open and is not the last view, it will be closed. If the given view is the active view, the next active view in the global order of view will be made active. -If the given view is the last open view in the system, the call will fail.


§3.3.28: set_active_view

bool32 app->set_active_view(
Application_Links *app,
View_Summary *view
)
Parameters
view
The view parameter specifies which view to make active.
Return
This call returns non-zero on success.
Description
If the given view is open, it is set as the +If the given view is the last open view in the system, the call will fail.


§3.3.27: set_active_view

bool32 app->set_active_view(
Application_Links *app,
View_Summary *view
)
Parameters
view
The view parameter specifies which view to make active.
Return
This call returns non-zero on success.
Description
If the given view is open, it is set as the active view, and takes subsequent commands and is returned -from get_active_view.

See Also

§3.3.29: view_set_setting

bool32 app->view_set_setting(
Application_Links *app,
View_Summary *view,
View_Setting_ID setting,
int32_t value
)
Parameters
view
The view parameter specifies the view on which to set a setting.
setting
The setting parameter identifies the setting that shall be changed.
value
The value parameter specifies the value to which the setting shall be changed.
Return
This call returns non-zero on success.
See Also

§3.3.30: view_set_split_proportion

bool32 app->view_set_split_proportion(
Application_Links *app,
View_Summary *view,
float t
)
Parameters
view
The view parameter specifies which view shall have it's size adjusted.
t
The t parameter specifies the proportion of the containing box that the view should occupy. t should be in [0,1].
Return
This call returns non-zero on success.

§3.3.31: view_compute_cursor

bool32 app->view_compute_cursor(
Application_Links *app,
View_Summary *view,
Buffer_Seek seek,
Full_Cursor *cursor_out
)
Parameters
view
The view parameter specifies the view on which to run the cursor computation.
seek
The seek parameter specifies the target position for the seek.
cursor_out
On success this struct is filled with the result of the seek.
Return
This call returns non-zero on success.
Description
Computes a Full_Cursor for the given seek position with no side effects.

See Also

§3.3.32: view_set_cursor

bool32 app->view_set_cursor(
Application_Links *app,
View_Summary *view,
Buffer_Seek seek,
bool32 set_preferred_x
)
Parameters
view
The view parameter specifies the view in which to set the cursor.
seek
The seek parameter specifies the target position for the seek.
set_preferred_x
If this parameter is true the preferred x is updated to match the new cursor x.
Return
This call returns non-zero on success.
Description
This call sets the the view's cursor position. set_preferred_x should usually be true +from get_active_view.

See Also

§3.3.28: view_set_setting

bool32 app->view_set_setting(
Application_Links *app,
View_Summary *view,
View_Setting_ID setting,
int32_t value
)
Parameters
view
The view parameter specifies the view on which to set a setting.
setting
The setting parameter identifies the setting that shall be changed.
value
The value parameter specifies the value to which the setting shall be changed.
Return
This call returns non-zero on success.
See Also

§3.3.29: view_set_split_proportion

bool32 app->view_set_split_proportion(
Application_Links *app,
View_Summary *view,
float t
)
Parameters
view
The view parameter specifies which view shall have it's size adjusted.
t
The t parameter specifies the proportion of the containing box that the view should occupy. t should be in [0,1].
Return
This call returns non-zero on success.

§3.3.30: view_compute_cursor

bool32 app->view_compute_cursor(
Application_Links *app,
View_Summary *view,
Buffer_Seek seek,
Full_Cursor *cursor_out
)
Parameters
view
The view parameter specifies the view on which to run the cursor computation.
seek
The seek parameter specifies the target position for the seek.
cursor_out
On success this struct is filled with the result of the seek.
Return
This call returns non-zero on success.
Description
Computes a Full_Cursor for the given seek position with no side effects.

See Also

§3.3.31: view_set_cursor

bool32 app->view_set_cursor(
Application_Links *app,
View_Summary *view,
Buffer_Seek seek,
bool32 set_preferred_x
)
Parameters
view
The view parameter specifies the view in which to set the cursor.
seek
The seek parameter specifies the target position for the seek.
set_preferred_x
If this parameter is true the preferred x is updated to match the new cursor x.
Return
This call returns non-zero on success.
Description
This call sets the the view's cursor position. set_preferred_x should usually be true unless the change in cursor position is is a vertical motion that tries to keep the -cursor in the same column or x position.

See Also

§3.3.33: view_set_scroll

bool32 app->view_set_scroll(
Application_Links *app,
View_Summary *view,
GUI_Scroll_Vars scroll
)
Description
TODO

See Also

§3.3.34: view_set_mark

bool32 app->view_set_mark(
Application_Links *app,
View_Summary *view,
Buffer_Seek seek
)
Parameters
view
The view parameter specifies the view in which to set the mark.
seek
The seek parameter specifies the target position for the seek.
Return
This call returns non-zero on success.
Description
This call sets the the view's mark position.

See Also

§3.3.35: view_set_highlight

bool32 app->view_set_highlight(
Application_Links *app,
View_Summary *view,
int32_t start,
int32_t end,
bool32 turn_on
)
Parameters
view
The view parameter specifies the view in which to set the highlight.
start
This parameter specifies the absolute position of the first character of the highlight range.
end
This parameter specifies the absolute position of the character one past the end of the highlight range.
turn_on
This parameter indicates whether the highlight is being turned on or off.
Return
This call returns non-zero on success.
Description
The highlight is mutually exclusive to the cursor. When the turn_on parameter +cursor in the same column or x position.

See Also

§3.3.32: view_set_scroll

bool32 app->view_set_scroll(
Application_Links *app,
View_Summary *view,
GUI_Scroll_Vars scroll
)
Description
TODO

See Also

§3.3.33: view_set_mark

bool32 app->view_set_mark(
Application_Links *app,
View_Summary *view,
Buffer_Seek seek
)
Parameters
view
The view parameter specifies the view in which to set the mark.
seek
The seek parameter specifies the target position for the seek.
Return
This call returns non-zero on success.
Description
This call sets the the view's mark position.

See Also

§3.3.34: view_set_highlight

bool32 app->view_set_highlight(
Application_Links *app,
View_Summary *view,
int32_t start,
int32_t end,
bool32 turn_on
)
Parameters
view
The view parameter specifies the view in which to set the highlight.
start
This parameter specifies the absolute position of the first character of the highlight range.
end
This parameter specifies the absolute position of the character one past the end of the highlight range.
turn_on
This parameter indicates whether the highlight is being turned on or off.
Return
This call returns non-zero on success.
Description
The highlight is mutually exclusive to the cursor. When the turn_on parameter is set to true the highlight will be shown and the cursor will be hidden. After that either setting the cursor with view_set_cursor or calling view_set_highlight -and the turn_on set to false, will switch back to showing the cursor.


§3.3.36: view_set_buffer

bool32 app->view_set_buffer(
Application_Links *app,
View_Summary *view,
Buffer_ID buffer_id,
Set_Buffer_Flag flags
)
Parameters
view
The view parameter specifies the view in which to display the buffer.
buffer_id
The buffer_id parameter specifies which buffer to show in the view.
flags
The flags parameter specifies behaviors for setting the buffer.
Return
This call returns non-zero on success.
Description
On success view_set_buffer sets the specified view's current buffer and -cancels and dialogue shown in the view and displays the file.

See Also

§3.3.37: view_post_fade

bool32 app->view_post_fade(
Application_Links *app,
View_Summary *view,
float seconds,
int32_t start,
int32_t end,
int_color color
)
Parameters
view
The view parameter specifies the view onto which the fade effect shall be posted.
seconds
This parameter specifies the number of seconds the fade effect should last.
start
This parameter specifies the absolute position of the first character of the fade range.
end
This parameter specifies the absolute position of the character one past the end of the fdae range.
color
The color parameter specifies the initial color of the text before it fades to it's natural color.
Return
This call returns non-zero on success.
See Also

§3.3.38: get_user_input

User_Input app->get_user_input(
Application_Links *app,
Input_Type_Flag get_type,
Input_Type_Flag abort_type
)
Parameters
get_type
The get_type parameter specifies the set of input types that should be returned.
abort_type
The get_type parameter specifies the set of input types that should trigger an abort signal.
Return
This call returns a User_Input that describes a user input event.
Description
This call preempts the command. The command is resumed if either a get or abort condition +and the turn_on set to false, will switch back to showing the cursor.


§3.3.35: view_set_buffer

bool32 app->view_set_buffer(
Application_Links *app,
View_Summary *view,
Buffer_ID buffer_id,
Set_Buffer_Flag flags
)
Parameters
view
The view parameter specifies the view in which to display the buffer.
buffer_id
The buffer_id parameter specifies which buffer to show in the view.
flags
The flags parameter specifies behaviors for setting the buffer.
Return
This call returns non-zero on success.
Description
On success view_set_buffer sets the specified view's current buffer and +cancels and dialogue shown in the view and displays the file.

See Also

§3.3.36: view_post_fade

bool32 app->view_post_fade(
Application_Links *app,
View_Summary *view,
float seconds,
int32_t start,
int32_t end,
int_color color
)
Parameters
view
The view parameter specifies the view onto which the fade effect shall be posted.
seconds
This parameter specifies the number of seconds the fade effect should last.
start
This parameter specifies the absolute position of the first character of the fade range.
end
This parameter specifies the absolute position of the character one past the end of the fdae range.
color
The color parameter specifies the initial color of the text before it fades to it's natural color.
Return
This call returns non-zero on success.
See Also

§3.3.37: get_user_input

User_Input app->get_user_input(
Application_Links *app,
Input_Type_Flag get_type,
Input_Type_Flag abort_type
)
Parameters
get_type
The get_type parameter specifies the set of input types that should be returned.
abort_type
The get_type parameter specifies the set of input types that should trigger an abort signal.
Return
This call returns a User_Input that describes a user input event.
Description
This call preempts the command. The command is resumed if either a get or abort condition is met, or if another command is executed. If either the abort condition is met or another command is executed an abort signal is returned. If an abort signal is ever returned the command should finish execution without any more calls that preempt the command. -If a get condition is met the user input is returned.

See Also

§3.3.39: get_command_input

User_Input app->get_command_input(
Application_Links *app
)
Return
This call returns the input that triggered the currently executing command.
See Also

§3.3.40: get_mouse_state

Mouse_State app->get_mouse_state(
Application_Links *app
)
Return
This call returns the current mouse state as of the beginning of the frame.
See Also

§3.3.41: start_query_bar

bool32 app->start_query_bar(
Application_Links *app,
Query_Bar *bar,
uint32_t flags
)
Parameters
bar
This parameter provides a Query_Bar that should remain in valid memory +If a get condition is met the user input is returned.

See Also

§3.3.38: get_command_input

User_Input app->get_command_input(
Application_Links *app
)
Return
This call returns the input that triggered the currently executing command.
See Also

§3.3.39: get_mouse_state

Mouse_State app->get_mouse_state(
Application_Links *app
)
Return
This call returns the current mouse state as of the beginning of the frame.
See Also

§3.3.40: start_query_bar

bool32 app->start_query_bar(
Application_Links *app,
Query_Bar *bar,
uint32_t flags
)
Parameters
bar
This parameter provides a Query_Bar that should remain in valid memory until end_query_bar or the end of the command. It is commonly a good idea to make this a pointer to a Query_Bar stored on the stack.
flags
This parameter is not currently used and should be 0 for now.
Return
This call returns non-zero on success.
Description
This call tells the active view to begin displaying a "Query_Bar" which is a small GUI element that can overlap a buffer or other 4coder GUI. The contents of the bar can be changed after the call to start_query_bar and the query bar shown by 4coder will reflect the change. Since the bar stops showing when the command exits the -only use for this call is in an interactive command that makes calls to get_user_input.


§3.3.42: end_query_bar

void app->end_query_bar(
Application_Links *app,
Query_Bar *bar,
uint32_t flags
)
Parameters
bar
This parameter should be a bar pointer of a currently active query bar.
flags
This parameter is not currently used and should be 0 for now.
Description
Stops showing the particular query bar specified by the bar parameter.



§3.3.44: change_theme

void app->change_theme(
Application_Links *app,
char *name,
int32_t len
)
Parameters
name
The name parameter specifies the name of the theme to begin using; it need not be null terminated.
len
The len parameter specifies the length of the name string.
Description
This call changes 4coder's color pallet to one of the built in themes.


§3.3.45: change_font

void app->change_font(
Application_Links *app,
char *name,
int32_t len,
bool32 apply_to_all_files
)
Parameters
name
The name parameter specifies the name of the font to begin using; it need not be null terminated.
len
The len parameter specifies the length of the name string.
apply_to_all_files
If this is set all open files change to this font. Usually this should be true -durring the start hook because several files already exist at that time.
Description
This call changes 4coder's default font to one of the built in fonts.


§3.3.46: buffer_set_font

void app->buffer_set_font(
Application_Links *app,
Buffer_Summary *buffer,
char *name,
int32_t len
)
Parameters
buffer
This parameter the buffer that shall have it's font changed
name
The name parameter specifies the name of the font to begin using; it need not be null terminated.
len
The len parameter specifies the length of the name string.
Description
This call sets the display font of a particular buffer.


§3.3.47: set_theme_colors

void app->set_theme_colors(
Application_Links *app,
Theme_Color *colors,
int32_t count
)
Parameters
colors
The colors pointer provides an array of color structs pairing differet style tags to color codes.
count
The count parameter specifies the number of Theme_Color structs in the colors array.
Description
For each struct in the array, the slot in the main color pallet specified by the +only use for this call is in an interactive command that makes calls to get_user_input.


§3.3.41: end_query_bar

void app->end_query_bar(
Application_Links *app,
Query_Bar *bar,
uint32_t flags
)
Parameters
bar
This parameter should be a bar pointer of a currently active query bar.
flags
This parameter is not currently used and should be 0 for now.
Description
Stops showing the particular query bar specified by the bar parameter.



§3.3.43: change_theme

void app->change_theme(
Application_Links *app,
char *name,
int32_t len
)
Parameters
name
The name parameter specifies the name of the theme to begin using; it need not be null terminated.
len
The len parameter specifies the length of the name string.
Description
This call changes 4coder's color pallet to one of the built in themes.


§3.3.44: change_font

void app->change_font(
Application_Links *app,
char *name,
int32_t len,
bool32 apply_to_all_files
)
Parameters
name
The name parameter specifies the name of the font to begin using; it need not be null terminated.
len
The len parameter specifies the length of the name string.
apply_to_all_files
If this is set all open files change to this font. Usually this should be true +durring the start hook because several files already exist at that time.
Description
This call changes 4coder's default font to one of the built in fonts.


§3.3.45: buffer_set_font

void app->buffer_set_font(
Application_Links *app,
Buffer_Summary *buffer,
char *name,
int32_t len
)
Parameters
buffer
This parameter the buffer that shall have it's font changed
name
The name parameter specifies the name of the font to begin using; it need not be null terminated.
len
The len parameter specifies the length of the name string.
Description
This call sets the display font of a particular buffer.


§3.3.46: set_theme_colors

void app->set_theme_colors(
Application_Links *app,
Theme_Color *colors,
int32_t count
)
Parameters
colors
The colors pointer provides an array of color structs pairing differet style tags to color codes.
count
The count parameter specifies the number of Theme_Color structs in the colors array.
Description
For each struct in the array, the slot in the main color pallet specified by the struct's tag is set to the color code in the struct. If the tag value is invalid -no change is made to the color pallet.


§3.3.48: get_theme_colors

void app->get_theme_colors(
Application_Links *app,
Theme_Color *colors,
int32_t count
)
Parameters
colors
an array of color structs listing style tags to get color values for
count
the number of color structs in the colors array
Description
For each struct in the array, the color field of the struct is filled with the +no change is made to the color pallet.


§3.3.47: get_theme_colors

void app->get_theme_colors(
Application_Links *app,
Theme_Color *colors,
int32_t count
)
Parameters
colors
an array of color structs listing style tags to get color values for
count
the number of color structs in the colors array
Description
For each struct in the array, the color field of the struct is filled with the color from the slot in the main color pallet specified by the tag. If the tag -value is invalid the color is filled with black.


§3.3.49: directory_get_hot

int32_t app->directory_get_hot(
Application_Links *app,
char *out,
int32_t capacity
)
Parameters
out
This parameter provides a character buffer that receives the 4coder 'hot directory'.
capacity
This parameter specifies the maximum size to be output to the out buffer.
Return
This call returns the size of the string written into the buffer.
Description
4coder has a concept of a 'hot directory' which is the directory most recently +value is invalid the color is filled with black.


§3.3.48: directory_get_hot

int32_t app->directory_get_hot(
Application_Links *app,
char *out,
int32_t capacity
)
Parameters
out
This parameter provides a character buffer that receives the 4coder 'hot directory'.
capacity
This parameter specifies the maximum size to be output to the out buffer.
Return
This call returns the size of the string written into the buffer.
Description
4coder has a concept of a 'hot directory' which is the directory most recently accessed in the GUI. Whenever the GUI is opened it shows the hot directory.

In the future this will be deprecated and eliminated in favor of more flexible -directories controlled on the custom side.


§3.3.50: get_file_list

File_List app->get_file_list(
Application_Links *app,
char *dir,
int32_t len
)
Parameters
dir
This parameter specifies the directory whose files will be enumerated in the returned list; it need not be null terminated.
len
This parameter the length of the dir string.
Return
This call returns a File_List struct containing pointers to the names of the files in +directories controlled on the custom side.


§3.3.49: get_file_list

File_List app->get_file_list(
Application_Links *app,
char *dir,
int32_t len
)
Parameters
dir
This parameter specifies the directory whose files will be enumerated in the returned list; it need not be null terminated.
len
This parameter the length of the dir string.
Return
This call returns a File_List struct containing pointers to the names of the files in the specified directory. The File_List returned should be passed to free_file_list -when it is no longer in use.

§3.3.51: free_file_list

void app->free_file_list(
Application_Links *app,
File_List list
)
Parameters
list
This parameter provides the file list to be freed.
Description
After this call the file list passed in should not be read or written to.


§3.3.52: memory_allocate

void* app->memory_allocate(
Application_Links *app,
int32_t size
)
Parameters
size
The size in bytes of the block that should be returned.
Description
This calls to a low level OS allocator which means it is best used +when it is no longer in use.

§3.3.50: free_file_list

void app->free_file_list(
Application_Links *app,
File_List list
)
Parameters
list
This parameter provides the file list to be freed.
Description
After this call the file list passed in should not be read or written to.


§3.3.51: memory_allocate

void* app->memory_allocate(
Application_Links *app,
int32_t size
)
Parameters
size
The size in bytes of the block that should be returned.
Description
This calls to a low level OS allocator which means it is best used for infrequent, large allocations. The size of the block must be remembered -if it will be freed or if it's mem protection status will be changed.

See Also

§3.3.53: memory_set_protection

bool32 app->memory_set_protection(
Application_Links *app,
void *ptr,
int32_t size,
Memory_Protect_Flags flags
)
Parameters
ptr
The base of the block on which to set memory protection flags.
size
The size that was originally used to allocate this block.
flags
The new memory protection flags.
Description
This call sets the memory protection flags of a block of memory that was previously -allocate by memory_allocate.

See Also

§3.3.54: memory_free

void app->memory_free(
Application_Links *app,
void *ptr,
int32_t size
)
Parameters
mem
The base of a block to free.
size
The size that was originally used to allocate this block.
Description
This call frees a block of memory that was previously allocated by -memory_allocate.

See Also

§3.3.55: file_exists

bool32 app->file_exists(
Application_Links *app,
char *filename,
int32_t len
)
Parameters
filename
This parameter specifies the full path to a file; it need not be null terminated.
len
This parameter specifies the length of the filename string.
Return
This call returns non-zero if and only if the file exists.

§3.3.56: directory_cd

bool32 app->directory_cd(
Application_Links *app,
char *dir,
int32_t *len,
int32_t capacity,
char *rel_path,
int32_t rel_len
)
Parameters
dir
This parameter provides a character buffer that stores a directory; it need not be null terminated.
len
This parameter specifies the length of the dir string.
capacity
This parameter specifies the maximum size of the dir string.
rel_path
This parameter specifies the path to change to, may include '.' or '..'; it need not be null terminated.
rel_len
This parameter specifies the length of the rel_path string.
Return
This call returns non-zero if the call succeeds.
Description
This call succeeds if the new directory exists and the it fits inside the +if it will be freed or if it's mem protection status will be changed.

See Also

§3.3.52: memory_set_protection

bool32 app->memory_set_protection(
Application_Links *app,
void *ptr,
int32_t size,
Memory_Protect_Flags flags
)
Parameters
ptr
The base of the block on which to set memory protection flags.
size
The size that was originally used to allocate this block.
flags
The new memory protection flags.
Description
This call sets the memory protection flags of a block of memory that was previously +allocate by memory_allocate.

See Also

§3.3.53: memory_free

void app->memory_free(
Application_Links *app,
void *ptr,
int32_t size
)
Parameters
mem
The base of a block to free.
size
The size that was originally used to allocate this block.
Description
This call frees a block of memory that was previously allocated by +memory_allocate.

See Also

§3.3.54: file_exists

bool32 app->file_exists(
Application_Links *app,
char *filename,
int32_t len
)
Parameters
filename
This parameter specifies the full path to a file; it need not be null terminated.
len
This parameter specifies the length of the filename string.
Return
This call returns non-zero if and only if the file exists.

§3.3.55: directory_cd

bool32 app->directory_cd(
Application_Links *app,
char *dir,
int32_t *len,
int32_t capacity,
char *rel_path,
int32_t rel_len
)
Parameters
dir
This parameter provides a character buffer that stores a directory; it need not be null terminated.
len
This parameter specifies the length of the dir string.
capacity
This parameter specifies the maximum size of the dir string.
rel_path
This parameter specifies the path to change to, may include '.' or '..'; it need not be null terminated.
rel_len
This parameter specifies the length of the rel_path string.
Return
This call returns non-zero if the call succeeds.
Description
This call succeeds if the new directory exists and the it fits inside the dir buffer. If the call succeeds the dir buffer is filled with the new directory and len is overwritten with the length of the new string in the buffer.

For instance if dir contains "C:/Users/MySelf" and rel is "Documents" the buffer will contain "C:/Users/MySelf/Documents" and len will contain the length of that string. This call can also be used with rel set to ".." to traverse to parent -folders.


§3.3.57: get_4ed_path

bool32 app->get_4ed_path(
Application_Links *app,
char *out,
int32_t capacity
)
Parameters
out
This parameter provides a character buffer that receives the path to the 4ed executable file.
capacity
This parameter specifies the maximum capacity of the out buffer.
Return
This call returns non-zero on success.

§3.3.58: show_mouse_cursor

void app->show_mouse_cursor(
Application_Links *app,
Mouse_Cursor_Show_Type show
)
Parameters
show
This parameter specifies the new state of the mouse cursor.
See Also

§3.3.59: toggle_fullscreen

void app->toggle_fullscreen(
Application_Links *app
)
Description
This call tells 4coder to switch into or out of full screen mode. +folders.


§3.3.56: get_4ed_path

bool32 app->get_4ed_path(
Application_Links *app,
char *out,
int32_t capacity
)
Parameters
out
This parameter provides a character buffer that receives the path to the 4ed executable file.
capacity
This parameter specifies the maximum capacity of the out buffer.
Return
This call returns non-zero on success.

§3.3.57: show_mouse_cursor

void app->show_mouse_cursor(
Application_Links *app,
Mouse_Cursor_Show_Type show
)
Parameters
show
This parameter specifies the new state of the mouse cursor.
See Also

§3.3.58: toggle_fullscreen

void app->toggle_fullscreen(
Application_Links *app
)
Description
This call tells 4coder to switch into or out of full screen mode. The changes of full screen mode do not take effect until the end of the current frame. On Windows this call will not work unless 4coder was started in "stream mode". -Stream mode can be enabled with -S or -F flags on the command line to 4ed.


§3.3.60: is_fullscreen

bool32 app->is_fullscreen(
Application_Links *app
)
Description
This call returns true if the 4coder is in full screen mode. This call +Stream mode can be enabled with -S or -F flags on the command line to 4ed.


§3.3.59: is_fullscreen

bool32 app->is_fullscreen(
Application_Links *app
)
Description
This call returns true if the 4coder is in full screen mode. This call takes toggles that have already occured this frame into account. So it may return true even though the frame has not ended and actually put 4coder into full screen. If it returns true though, 4coder will definitely be full screen by the beginning of the next -frame if the state is not changed.


§3.3.61: send_exit_signal

void app->send_exit_signal(
Application_Links *app
)
Description
This call sends a signal to 4coder to attempt to exit. If there are unsaved +frame if the state is not changed.


§3.3.60: send_exit_signal

void app->send_exit_signal(
Application_Links *app
)
Description
This call sends a signal to 4coder to attempt to exit. If there are unsaved files this triggers a dialogue ensuring you're okay with closing.


§3.4 Type Descriptions

§3.4.1: bool32

typedef int32_t bool32;
Description
bool32 is an alias name to signal that an integer parameter or field is for true/false vales.


§3.4.2: int_color

typedef uint32_t int_color;
Description
int_color is an alias name to signal that an integer parameter or field is for a color value, colors are specified as 24 bit integers in 3 channels: 0xRRGGBB.


§3.4.3: Key_Code

typedef unsigned char Key_Code;
Description
Key_Code is the alias for key codes including raw codes and codes translated @@ -179,107 +177,107 @@ will be replaced into the buffer.

view_id
If this is not a null summary, this field is the id of the associated view. If this is a null summary then view_id is 0.

buffer_id
If this is not a null summary, then this is the id of the buffer this view currently sees.

lock_flags
If this is not a null summary, this field contains flags describing the protection status of the view.

cursor
If this is not a null summary, this describes the position of the cursor.

mark
If this is not a null summary, this describes the position of the mark.

preferred_x
If this is not a null summary, this is the x position that is maintained in vertical navigation.

line_height
If this is not a null summary, this specifies the height of a line rendered in the view.

unwrapped_lines
If this is not a null summary, this indicates that the view is set to render with unwrapped lines.

show_whitespace
If this is not a null summary, this indicates that the view is set to highlight white space.

file_region
If this is not a null summary, this describes the screen position in which this view's buffer is displayed.

scroll_vars
If this is not a null summary, this describes the scrolling position inside the view.

See Also

§3.4.40: User_Input

struct User_Input {
User_Input_Type_ID type;
bool32 abort;
union {
Key_Event_Data key;
Mouse_State mouse;
};
Generic_Command command;
};
Description
User_Input describes a user input event which can be either a key press or mouse event.

Fields
type
This field specifies whether the event was a key press or mouse event.

abort
This field indicates that an abort event has occurred and the command needs to shut down.

key
This field describes a key press event.

mouse
This field describes a mouse input event.

command
If this event would trigger a command, this field specifies what the command would be.

See Also

§3.4.41: Query_Bar

struct Query_Bar {
String prompt;
String string;
};
Description
Query_Bar is a struct used to store information in the user's control that will be displayed as a drop down bar durring an interactive command.

Fields
prompt
This specifies the prompt portion of the drop down bar.

string
This specifies the main string portion of the drop down bar.


§3.4.42: Event_Message

struct Event_Message {
int32_t type;
};
Description
This feature is not implemented.

Fields
type
This feature is not implemented.


§3.4.43: Theme_Color

struct Theme_Color {
Style_Tag tag;
int_color color;
};
Description
Theme_Color stores a style tag/color pair, for the purpose of setting and getting colors in the theme .

Fields
tag
color
See Also

-

§4 String Library

§4.1 String Intro

Coming Soon

§4.2 String Function List

§4.3 String Function Descriptions

§4.3.1: char_is_slash

fstr_bool char_is_slash(
char c
)
Description
This call returns non-zero if c is \ or /.


§4.3.2: char_to_upper

char char_to_upper(
char c
)
Description
If c is a lowercase letter this call returns the uppercase equivalent, otherwise it returns c.


§4.3.3: char_to_lower

char char_to_lower(
char c
)
Description
If c is an uppercase letter this call returns the lowercase equivalent, otherwise it returns c.


§4.3.4: char_is_whitespace

fstr_bool char_is_whitespace(
char c
)
Description
This call returns non-zero if c is whitespace.


§4.3.5: char_is_alpha_numeric

fstr_bool char_is_alpha_numeric(
char c
)
Description
This call returns non-zero if c is any alphanumeric character including underscore.


§4.3.6: char_is_alpha_numeric_true

fstr_bool char_is_alpha_numeric_true(
char c
)
Description
This call returns non-zero if c is any alphanumeric character no including underscore.


§4.3.7: char_is_alpha

fstr_bool char_is_alpha(
char c
)
Description
This call returns non-zero if c is any alphabetic character including underscore.


§4.3.8: char_is_alpha_true

fstr_bool char_is_alpha_true(
char c
)
Description
This call returns non-zero if c is any alphabetic character.


§4.3.9: char_is_hex

fstr_bool char_is_hex(
char c
)
Description
This call returns non-zero if c is any valid hexadecimal digit.


§4.3.10: char_is_numeric

fstr_bool char_is_numeric(
char c
)
Description
This call returns non-zero if c is any valid decimal digit.


§4.3.11: make_string_cap

String make_string_cap(
void *str,
int32_t size,
int32_t mem_size
)
Parameters
str
The str parameter provides the of memory with which the string shall operate.
size
The size parameter expresses the initial size of the string. -If the memory does not already contain a useful string this should be zero.
mem_size
The mem_size parameter expresses the full size of the memory provided by str.
Description
This call returns the String created from the parameters.


§4.3.12: make_string

String make_string(
void *str,
int32_t size
)
Parameters
str
The str parameter provides the of memory with which the string shall operate.
size
The size parameter expresses the initial size of the string. +

§4 String Library

§4.1 String Intro

Coming Soon

§4.2 String Function List

§4.3 String Function Descriptions

§4.3.1: char_is_slash

fstr_bool char_is_slash(
char c
)
Description
This call returns non-zero if c is \ or /.


§4.3.2: char_is_upper

fstr_bool char_is_upper(
char c
)
Description
If c is an uppercase letter this call returns true.


§4.3.3: char_is_lower

fstr_bool char_is_lower(
char c
)
Description
If c is a lower letter this call returns true.


§4.3.4: char_to_upper

char char_to_upper(
char c
)
Description
If c is a lowercase letter this call returns the uppercase equivalent, otherwise it returns c.


§4.3.5: char_to_lower

char char_to_lower(
char c
)
Description
If c is an uppercase letter this call returns the lowercase equivalent, otherwise it returns c.


§4.3.6: char_is_whitespace

fstr_bool char_is_whitespace(
char c
)
Description
This call returns non-zero if c is whitespace.


§4.3.7: char_is_alpha_numeric

fstr_bool char_is_alpha_numeric(
char c
)
Description
This call returns non-zero if c is any alphanumeric character including underscore.


§4.3.8: char_is_alpha_numeric_true

fstr_bool char_is_alpha_numeric_true(
char c
)
Description
This call returns non-zero if c is any alphanumeric character no including underscore.


§4.3.9: char_is_alpha

fstr_bool char_is_alpha(
char c
)
Description
This call returns non-zero if c is any alphabetic character including underscore.


§4.3.10: char_is_alpha_true

fstr_bool char_is_alpha_true(
char c
)
Description
This call returns non-zero if c is any alphabetic character.


§4.3.11: char_is_hex

fstr_bool char_is_hex(
char c
)
Description
This call returns non-zero if c is any valid hexadecimal digit.


§4.3.12: char_is_numeric

fstr_bool char_is_numeric(
char c
)
Description
This call returns non-zero if c is any valid decimal digit.


§4.3.13: make_string_cap

String make_string_cap(
void *str,
int32_t size,
int32_t mem_size
)
Parameters
str
The str parameter provides the of memory with which the string shall operate.
size
The size parameter expresses the initial size of the string. +If the memory does not already contain a useful string this should be zero.
mem_size
The mem_size parameter expresses the full size of the memory provided by str.
Description
This call returns the String created from the parameters.


§4.3.14: make_string

String make_string(
void *str,
int32_t size
)
Parameters
str
The str parameter provides the of memory with which the string shall operate.
size
The size parameter expresses the initial size of the string. If the memory does not already contain a useful string this should be zero. Since this version does not specify the size of the memory it is also assumed that this size is the maximum size -of the memory.
Description
This call returns the String created from the parameters.


§4.3.13: make_lit_string

#define make_lit_string(s)
Description
This macro takes a literal string in quotes and uses it to create a String -with the correct size and memory size. Strings created this way should usually not be mutated.


§4.3.14: make_fixed_width_string

#define make_fixed_width_string(s)
Description
This macro takes a local char array with a fixed width and uses it to create -an empty String with the correct size and memory size to operate on the array.


§4.3.15: expand_str

#define expand_str(s)
Description
This macro is a helper for any calls that take a char*,integer pair to specify a -string. This macro expands to both of those parameters from one String struct.


§4.3.16: str_size

int32_t str_size(
char *str
)
Description
This call returns the number of bytes before a null terminator starting at str.


§4.3.17: make_string_slowly

String make_string_slowly(
void *str
)
Description
This call makes a string by counting the number of bytes before a null terminator and -treating that as the size and memory size of the string.


§4.3.18: substr_tail

String substr_tail(
String str,
int32_t start
)
Description
This call creates a substring of str that starts with an offset from str's base. +of the memory.
Description
This call returns the String created from the parameters.


§4.3.15: make_lit_string

#define make_lit_string(s)
Description
This macro takes a literal string in quotes and uses it to create a String +with the correct size and memory size. Strings created this way should usually not be mutated.


§4.3.16: make_fixed_width_string

#define make_fixed_width_string(s)
Description
This macro takes a local char array with a fixed width and uses it to create +an empty String with the correct size and memory size to operate on the array.


§4.3.17: expand_str

#define expand_str(s)
Description
This macro is a helper for any calls that take a char*,integer pair to specify a +string. This macro expands to both of those parameters from one String struct.


§4.3.18: str_size

int32_t str_size(
char *str
)
Description
This call returns the number of bytes before a null terminator starting at str.


§4.3.19: make_string_slowly

String make_string_slowly(
void *str
)
Description
This call makes a string by counting the number of bytes before a null terminator and +treating that as the size and memory size of the string.


§4.3.20: substr_tail

String substr_tail(
String str,
int32_t start
)
Description
This call creates a substring of str that starts with an offset from str's base. The new string uses the same underlying memory so both strings will see changes. -Usually strings created this way should only go through immutable calls.


§4.3.19: substr

String substr(
String str,
int32_t start,
int32_t size
)
Description
This call creates a substring of str that starts with an offset from str's base, +Usually strings created this way should only go through immutable calls.


§4.3.21: substr

String substr(
String str,
int32_t start,
int32_t size
)
Description
This call creates a substring of str that starts with an offset from str's base, and has a fixed size. The new string uses the same underlying memory so both strings -will see changes. Usually strings created this way should only go through immutable calls.


§4.3.20: skip_whitespace

String skip_whitespace(
String str
)
Description
This call creates a substring that starts with the first non-whitespace character of str. +will see changes. Usually strings created this way should only go through immutable calls.


§4.3.22: skip_whitespace

String skip_whitespace(
String str
)
Description
This call creates a substring that starts with the first non-whitespace character of str. Like other substr calls, the new string uses the underlying memory and so should usually be -considered immutable.

See Also

§4.3.21: chop_whitespace

String chop_whitespace(
String str
)
Description
This call creates a substring that ends with the last non-whitespace character of str. +considered immutable.

See Also

§4.3.23: chop_whitespace

String chop_whitespace(
String str
)
Description
This call creates a substring that ends with the last non-whitespace character of str. Like other substr calls, the new string uses the underlying memory and so should usually be -considered immutable.

See Also

§4.3.22: skip_chop_whitespace

String skip_chop_whitespace(
String str
)
Description
This call is equivalent to calling skip_whitespace and chop_whitespace together.

See Also

§4.3.23: tailstr

String tailstr(
String str
)
Description
This call returns an empty String with underlying memory taken from -the portion of str's memory that is not used.


§4.3.24: match_cc

fstr_bool match_cc(
char *a,
char *b
)
Description
This call returns non-zero if a and b are equivalent.


§4.3.25: match_sc

fstr_bool match_sc(
String a,
char *b
)
Description
This call returns non-zero if a and b are equivalent.


§4.3.26: match_cs

fstr_bool match_cs(
char *a,
String b
)
Description
This call returns non-zero if a and b are equivalent.


§4.3.27: match_ss

fstr_bool match_ss(
String a,
String b
)
Description
This call returns non-zero if a and b are equivalent.


§4.3.28: match_part_ccl

fstr_bool match_part_ccl(
char *a,
char *b,
int32_t *len
)
Parameters
len
If this call returns non-zero this parameter is used to output the length of b.
Description
This call is similar to a match call, except that it is permitted for a to be longer than b. -In other words this call returns non-zero if b is a prefix of a.


§4.3.29: match_part_scl

fstr_bool match_part_scl(
String a,
char *b,
int32_t *len
)
Parameters
len
If this call returns non-zero this parameter is used to output the length of b.
Description
This call is similar to a match call, except that it is permitted for a to be longer than b. -In other words this call returns non-zero if b is a prefix of a.


§4.3.30: match_part_cc

fstr_bool match_part_cc(
char *a,
char *b
)
Parameters
len
If this call returns non-zero this parameter is used to output the length of b.
Description
This call is similar to a match call, except that it is permitted for a to be longer than b. -In other words this call returns non-zero if b is a prefix of a.


§4.3.31: match_part_sc

fstr_bool match_part_sc(
String a,
char *b
)
Description
This call is similar to a match call, except that it is permitted for a to be longer than b. -In other words this call returns non-zero if b is a prefix of a.


§4.3.32: match_part_cs

fstr_bool match_part_cs(
char *a,
String b
)
Description
This call is similar to a match call, except that it is permitted for a to be longer than b. -In other words this call returns non-zero if b is a prefix of a.


§4.3.33: match_part_ss

fstr_bool match_part_ss(
String a,
String b
)
Description
This call is similar to a match call, except that it is permitted for a to be longer than b. -In other words this call returns non-zero if b is a prefix of a.


§4.3.34: match_insensitive_cc

fstr_bool match_insensitive_cc(
char *a,
char *b
)
Description
This call returns non-zero if a and b are equivalent under case insensitive comparison.


§4.3.35: match_insensitive_sc

fstr_bool match_insensitive_sc(
String a,
char *b
)
Description
This call returns non-zero if a and b are equivalent under case insensitive comparison.


§4.3.36: match_insensitive_cs

fstr_bool match_insensitive_cs(
char *a,
String b
)
Description
This call returns non-zero if a and b are equivalent under case insensitive comparison.


§4.3.37: match_insensitive_ss

fstr_bool match_insensitive_ss(
String a,
String b
)
Description
This call returns non-zero if a and b are equivalent under case insensitive comparison.


§4.3.38: match_part_insensitive_ccl

fstr_bool match_part_insensitive_ccl(
char *a,
char *b,
int32_t *len
)
Parameters
len
If this call returns non-zero this parameter is used to output the length of b.
Description
This call performs the same partial matching rule as match_part under case insensitive comparison.

See Also

§4.3.39: match_part_insensitive_scl

fstr_bool match_part_insensitive_scl(
String a,
char *b,
int32_t *len
)
Parameters
len
If this call returns non-zero this parameter is used to output the length of b.
Description
This call performs the same partial matching rule as match_part under case insensitive comparison.

See Also

§4.3.40: match_part_insensitive_cc

fstr_bool match_part_insensitive_cc(
char *a,
char *b
)
Description
This call performs the same partial matching rule as match_part under case insensitive comparison.

See Also

§4.3.41: match_part_insensitive_sc

fstr_bool match_part_insensitive_sc(
String a,
char *b
)
Description
This call performs the same partial matching rule as match_part under case insensitive comparison.

See Also

§4.3.42: match_part_insensitive_cs

fstr_bool match_part_insensitive_cs(
char *a,
String b
)
Description
This call performs the same partial matching rule as match_part under case insensitive comparison.

See Also

§4.3.43: match_part_insensitive_ss

fstr_bool match_part_insensitive_ss(
String a,
String b
)
Description
This call performs the same partial matching rule as match_part under case insensitive comparison.

See Also

§4.3.44: compare_cc

int32_t compare_cc(
char *a,
char *b
)
Description
This call returns zero if a and b are equivalent, +considered immutable.

See Also

§4.3.24: skip_chop_whitespace

String skip_chop_whitespace(
String str
)
Description
This call is equivalent to calling skip_whitespace and chop_whitespace together.

See Also

§4.3.25: tailstr

String tailstr(
String str
)
Description
This call returns an empty String with underlying memory taken from +the portion of str's memory that is not used.


§4.3.26: match_cc

fstr_bool match_cc(
char *a,
char *b
)
Description
This call returns non-zero if a and b are equivalent.


§4.3.27: match_sc

fstr_bool match_sc(
String a,
char *b
)
Description
This call returns non-zero if a and b are equivalent.


§4.3.28: match_cs

fstr_bool match_cs(
char *a,
String b
)
Description
This call returns non-zero if a and b are equivalent.


§4.3.29: match_ss

fstr_bool match_ss(
String a,
String b
)
Description
This call returns non-zero if a and b are equivalent.


§4.3.30: match_part_ccl

fstr_bool match_part_ccl(
char *a,
char *b,
int32_t *len
)
Parameters
len
If this call returns non-zero this parameter is used to output the length of b.
Description
This call is similar to a match call, except that it is permitted for a to be longer than b. +In other words this call returns non-zero if b is a prefix of a.


§4.3.31: match_part_scl

fstr_bool match_part_scl(
String a,
char *b,
int32_t *len
)
Parameters
len
If this call returns non-zero this parameter is used to output the length of b.
Description
This call is similar to a match call, except that it is permitted for a to be longer than b. +In other words this call returns non-zero if b is a prefix of a.


§4.3.32: match_part_cc

fstr_bool match_part_cc(
char *a,
char *b
)
Parameters
len
If this call returns non-zero this parameter is used to output the length of b.
Description
This call is similar to a match call, except that it is permitted for a to be longer than b. +In other words this call returns non-zero if b is a prefix of a.


§4.3.33: match_part_sc

fstr_bool match_part_sc(
String a,
char *b
)
Description
This call is similar to a match call, except that it is permitted for a to be longer than b. +In other words this call returns non-zero if b is a prefix of a.


§4.3.34: match_part_cs

fstr_bool match_part_cs(
char *a,
String b
)
Description
This call is similar to a match call, except that it is permitted for a to be longer than b. +In other words this call returns non-zero if b is a prefix of a.


§4.3.35: match_part_ss

fstr_bool match_part_ss(
String a,
String b
)
Description
This call is similar to a match call, except that it is permitted for a to be longer than b. +In other words this call returns non-zero if b is a prefix of a.


§4.3.36: match_insensitive_cc

fstr_bool match_insensitive_cc(
char *a,
char *b
)
Description
This call returns non-zero if a and b are equivalent under case insensitive comparison.


§4.3.37: match_insensitive_sc

fstr_bool match_insensitive_sc(
String a,
char *b
)
Description
This call returns non-zero if a and b are equivalent under case insensitive comparison.


§4.3.38: match_insensitive_cs

fstr_bool match_insensitive_cs(
char *a,
String b
)
Description
This call returns non-zero if a and b are equivalent under case insensitive comparison.


§4.3.39: match_insensitive_ss

fstr_bool match_insensitive_ss(
String a,
String b
)
Description
This call returns non-zero if a and b are equivalent under case insensitive comparison.


§4.3.40: match_part_insensitive_ccl

fstr_bool match_part_insensitive_ccl(
char *a,
char *b,
int32_t *len
)
Parameters
len
If this call returns non-zero this parameter is used to output the length of b.
Description
This call performs the same partial matching rule as match_part under case insensitive comparison.

See Also

§4.3.41: match_part_insensitive_scl

fstr_bool match_part_insensitive_scl(
String a,
char *b,
int32_t *len
)
Parameters
len
If this call returns non-zero this parameter is used to output the length of b.
Description
This call performs the same partial matching rule as match_part under case insensitive comparison.

See Also

§4.3.42: match_part_insensitive_cc

fstr_bool match_part_insensitive_cc(
char *a,
char *b
)
Description
This call performs the same partial matching rule as match_part under case insensitive comparison.

See Also

§4.3.43: match_part_insensitive_sc

fstr_bool match_part_insensitive_sc(
String a,
char *b
)
Description
This call performs the same partial matching rule as match_part under case insensitive comparison.

See Also

§4.3.44: match_part_insensitive_cs

fstr_bool match_part_insensitive_cs(
char *a,
String b
)
Description
This call performs the same partial matching rule as match_part under case insensitive comparison.

See Also

§4.3.45: match_part_insensitive_ss

fstr_bool match_part_insensitive_ss(
String a,
String b
)
Description
This call performs the same partial matching rule as match_part under case insensitive comparison.

See Also

§4.3.46: compare_cc

int32_t compare_cc(
char *a,
char *b
)
Description
This call returns zero if a and b are equivalent, it returns negative if a sorts before b alphabetically, -and positive if a sorts after b alphabetically.


§4.3.45: compare_sc

int32_t compare_sc(
String a,
char *b
)
Description
This call returns zero if a and b are equivalent, +and positive if a sorts after b alphabetically.


§4.3.47: compare_sc

int32_t compare_sc(
String a,
char *b
)
Description
This call returns zero if a and b are equivalent, it returns negative if a sorts before b alphabetically, -and positive if a sorts after b alphabetically.


§4.3.46: compare_cs

int32_t compare_cs(
char *a,
String b
)
Description
This call returns zero if a and b are equivalent, +and positive if a sorts after b alphabetically.


§4.3.48: compare_cs

int32_t compare_cs(
char *a,
String b
)
Description
This call returns zero if a and b are equivalent, it returns negative if a sorts before b alphabetically, -and positive if a sorts after b alphabetically.


§4.3.47: compare_ss

int32_t compare_ss(
String a,
String b
)
Description
This call returns zero if a and b are equivalent, +and positive if a sorts after b alphabetically.


§4.3.49: compare_ss

int32_t compare_ss(
String a,
String b
)
Description
This call returns zero if a and b are equivalent, it returns negative if a sorts before b alphabetically, -and positive if a sorts after b alphabetically.


§4.3.48: find_c_char

int32_t find_c_char(
char *str,
int32_t start,
char character
)
Parameters
str
The str parameter provides a null terminated string to search.
start
The start parameter provides the index of the first character in str to search.
character
The character parameter provides the character for which to search.
Description
This call returns the index of the first occurance of character, or the size of the string -if the character is not found.


§4.3.49: find_s_char

int32_t find_s_char(
String str,
int32_t start,
char character
)
Parameters
str
The str parameter provides a string to search.
start
The start parameter provides the index of the first character in str to search.
character
The character parameter provides the character for which to search.
Description
This call returns the index of the first occurance of character, or the size of the string -if the character is not found.


§4.3.50: rfind_s_char

int32_t rfind_s_char(
String str,
int32_t start,
char character
)
Parameters
str
The str parameter provides a string to search.
start
The start parameter provides the index of the first character in str to search.
character
The character parameter provides the character for which to search.
Description
This call looks for the largest index less than or equal to the start position where -the given character occurs. If the index is found it is returned otherwise -1 is returned.


§4.3.51: find_c_chars

int32_t find_c_chars(
char *str,
int32_t start,
char *characters
)
Parameters
str
The str parameter provides a null terminated string to search.
start
The start parameter provides the index of the first character in str to search.
character
The characters parameter provides a null terminated array of characters for which to search.
Description
This call returns the index of the first occurance of a character in the characters array, -or the size of the string if no such character is not found.


§4.3.52: find_s_chars

int32_t find_s_chars(
String str,
int32_t start,
char *characters
)
Parameters
str
The str parameter provides a string to search.
start
The start parameter provides the index of the first character in str to search.
character
The characters parameter provides a null terminated array of characters for which to search.
Description
This call returns the index of the first occurance of a character in the characters array, -or the size of the string if no such character is not found.


§4.3.53: find_substr_c

int32_t find_substr_c(
char *str,
int32_t start,
String seek
)
Parameters
str
The str parameter provides a null terminated string to search.
start
The start parameter provides the index of the first character in str to search.
seek
The seek parameter provides a string to find in str.
Description
This call returns the index of the first occurance of the seek substring in str or the -size of str if no such substring in str is found.


§4.3.54: find_substr_s

int32_t find_substr_s(
String str,
int32_t start,
String seek
)
Parameters
str
The str parameter provides a string to search.
start
The start parameter provides the index of the first character in str to search.
seek
The seek parameter provides a string to find in str.
Description
This call returns the index of the first occurance of the seek substring in str or the -size of str if no such substring in str is found.


§4.3.55: rfind_substr_s

int32_t rfind_substr_s(
String str,
int32_t start,
String seek
)
Parameters
str
The str parameter provides a string to search.
start
The start parameter provides the index of the first character in str to search.
seek
The seek parameter provides a string to find in str.
Description
This call returns the index of the last occurance of the seek substring in str -or -1 if no such substring in str is found.


§4.3.56: find_substr_insensitive_c

int32_t find_substr_insensitive_c(
char *str,
int32_t start,
String seek
)
Parameters
str
The str parameter provides a null terminated string to search.
start
The start parameter provides the index of the first character in str to search.
seek
The seek parameter provides a string to find in str.
Description
This call acts as find_substr under case insensitive comparison.

See Also

§4.3.57: find_substr_insensitive_s

int32_t find_substr_insensitive_s(
String str,
int32_t start,
String seek
)
Parameters
str
The str parameter provides a string to search.
start
The start parameter provides the index of the first character in str to search.
seek
The seek parameter provides a string to find in str.
Description
This call acts as find_substr under case insensitive comparison.

See Also

§4.3.58: has_substr_c

fstr_bool has_substr_c(
char *s,
String seek
)
Description
This call returns non-zero if the string s contains a substring equivalent to seek.


§4.3.59: has_substr_s

fstr_bool has_substr_s(
String s,
String seek
)
Description
This call returns non-zero if the string s contains a substring equivalent to seek.


§4.3.60: has_substr_insensitive_c

fstr_bool has_substr_insensitive_c(
char *s,
String seek
)
Description
This call returns non-zero if the string s contains a substring equivalent to seek -under case insensitive comparison.


§4.3.61: has_substr_insensitive_s

fstr_bool has_substr_insensitive_s(
String s,
String seek
)
Description
This call returns non-zero if the string s contains a substring equivalent to seek -under case insensitive comparison.


§4.3.62: copy_fast_unsafe_cc

int32_t copy_fast_unsafe_cc(
char *dest,
char *src
)
Description
This call performs a copy from the src buffer to the dest buffer. +and positive if a sorts after b alphabetically.


§4.3.50: find_c_char

int32_t find_c_char(
char *str,
int32_t start,
char character
)
Parameters
str
The str parameter provides a null terminated string to search.
start
The start parameter provides the index of the first character in str to search.
character
The character parameter provides the character for which to search.
Description
This call returns the index of the first occurance of character, or the size of the string +if the character is not found.


§4.3.51: find_s_char

int32_t find_s_char(
String str,
int32_t start,
char character
)
Parameters
str
The str parameter provides a string to search.
start
The start parameter provides the index of the first character in str to search.
character
The character parameter provides the character for which to search.
Description
This call returns the index of the first occurance of character, or the size of the string +if the character is not found.


§4.3.52: rfind_s_char

int32_t rfind_s_char(
String str,
int32_t start,
char character
)
Parameters
str
The str parameter provides a string to search.
start
The start parameter provides the index of the first character in str to search.
character
The character parameter provides the character for which to search.
Description
This call looks for the largest index less than or equal to the start position where +the given character occurs. If the index is found it is returned otherwise -1 is returned.


§4.3.53: find_c_chars

int32_t find_c_chars(
char *str,
int32_t start,
char *characters
)
Parameters
str
The str parameter provides a null terminated string to search.
start
The start parameter provides the index of the first character in str to search.
character
The characters parameter provides a null terminated array of characters for which to search.
Description
This call returns the index of the first occurance of a character in the characters array, +or the size of the string if no such character is not found.


§4.3.54: find_s_chars

int32_t find_s_chars(
String str,
int32_t start,
char *characters
)
Parameters
str
The str parameter provides a string to search.
start
The start parameter provides the index of the first character in str to search.
character
The characters parameter provides a null terminated array of characters for which to search.
Description
This call returns the index of the first occurance of a character in the characters array, +or the size of the string if no such character is not found.


§4.3.55: find_substr_c

int32_t find_substr_c(
char *str,
int32_t start,
String seek
)
Parameters
str
The str parameter provides a null terminated string to search.
start
The start parameter provides the index of the first character in str to search.
seek
The seek parameter provides a string to find in str.
Description
This call returns the index of the first occurance of the seek substring in str or the +size of str if no such substring in str is found.


§4.3.56: find_substr_s

int32_t find_substr_s(
String str,
int32_t start,
String seek
)
Parameters
str
The str parameter provides a string to search.
start
The start parameter provides the index of the first character in str to search.
seek
The seek parameter provides a string to find in str.
Description
This call returns the index of the first occurance of the seek substring in str or the +size of str if no such substring in str is found.


§4.3.57: rfind_substr_s

int32_t rfind_substr_s(
String str,
int32_t start,
String seek
)
Parameters
str
The str parameter provides a string to search.
start
The start parameter provides the index of the first character in str to search.
seek
The seek parameter provides a string to find in str.
Description
This call returns the index of the last occurance of the seek substring in str +or -1 if no such substring in str is found.


§4.3.58: find_substr_insensitive_c

int32_t find_substr_insensitive_c(
char *str,
int32_t start,
String seek
)
Parameters
str
The str parameter provides a null terminated string to search.
start
The start parameter provides the index of the first character in str to search.
seek
The seek parameter provides a string to find in str.
Description
This call acts as find_substr under case insensitive comparison.

See Also

§4.3.59: find_substr_insensitive_s

int32_t find_substr_insensitive_s(
String str,
int32_t start,
String seek
)
Parameters
str
The str parameter provides a string to search.
start
The start parameter provides the index of the first character in str to search.
seek
The seek parameter provides a string to find in str.
Description
This call acts as find_substr under case insensitive comparison.

See Also

§4.3.60: has_substr_c

fstr_bool has_substr_c(
char *s,
String seek
)
Description
This call returns non-zero if the string s contains a substring equivalent to seek.


§4.3.61: has_substr_s

fstr_bool has_substr_s(
String s,
String seek
)
Description
This call returns non-zero if the string s contains a substring equivalent to seek.


§4.3.62: has_substr_insensitive_c

fstr_bool has_substr_insensitive_c(
char *s,
String seek
)
Description
This call returns non-zero if the string s contains a substring equivalent to seek +under case insensitive comparison.


§4.3.63: has_substr_insensitive_s

fstr_bool has_substr_insensitive_s(
String s,
String seek
)
Description
This call returns non-zero if the string s contains a substring equivalent to seek +under case insensitive comparison.


§4.3.64: copy_fast_unsafe_cc

int32_t copy_fast_unsafe_cc(
char *dest,
char *src
)
Description
This call performs a copy from the src buffer to the dest buffer. The copy does not stop until a null terminator is found in src. There is no safety against overrun so dest must be large enough to contain src. The null terminator is not written to dest. This call returns the number -of bytes coppied to dest.


§4.3.63: copy_fast_unsafe_cs

int32_t copy_fast_unsafe_cs(
char *dest,
String src
)
Description
This call performs a copy from the src string to the dest buffer. +of bytes coppied to dest.


§4.3.65: copy_fast_unsafe_cs

int32_t copy_fast_unsafe_cs(
char *dest,
String src
)
Description
This call performs a copy from the src string to the dest buffer. The copy does not stop until src.size characters are coppied. There is no safety against overrun so dest must be large enough to contain src. The null terminator is not written to dest. This call returns the number -of bytes coppied to dest.


§4.3.64: copy_checked_ss

fstr_bool copy_checked_ss(
String *dest,
String src
)
Description
This call performs a copy from the src string to the dest string. +of bytes coppied to dest.


§4.3.66: copy_checked_ss

fstr_bool copy_checked_ss(
String *dest,
String src
)
Description
This call performs a copy from the src string to the dest string. The memory_size of dest is checked before any coppying is done. -This call returns non-zero on a successful copy.


§4.3.65: copy_partial_sc

fstr_bool copy_partial_sc(
String *dest,
char *src
)
Description
This call performs a copy from the src buffer to the dest string. +This call returns non-zero on a successful copy.


§4.3.67: copy_partial_sc

fstr_bool copy_partial_sc(
String *dest,
char *src
)
Description
This call performs a copy from the src buffer to the dest string. The memory_size of dest is checked if the entire copy cannot be performed, as many bytes as possible are coppied to dest. This call returns non-zero -if the entire string is coppied to dest.


§4.3.66: copy_partial_ss

fstr_bool copy_partial_ss(
String *dest,
String src
)
Description
This call performs a copy from the src string to the dest string. +if the entire string is coppied to dest.


§4.3.68: copy_partial_ss

fstr_bool copy_partial_ss(
String *dest,
String src
)
Description
This call performs a copy from the src string to the dest string. The memory_size of dest is checked if the entire copy cannot be performed, as many bytes as possible are coppied to dest. This call returns non-zero -if the entire string is coppied to dest.


§4.3.67: copy_cc

int32_t copy_cc(
char *dest,
char *src
)
Description
This call performs a copy from src to dest equivalent to copy_fast_unsafe.

See Also

§4.3.68: copy_ss

void copy_ss(
String *dest,
String src
)
Description
This call performs a copy from src to dest equivalent to copy_checked.

See Also

§4.3.69: copy_sc

void copy_sc(
String *dest,
char *src
)
Description
This call performs a copy from src to dest equivalent to copy_partial.

See Also

§4.3.70: append_checked_ss

fstr_bool append_checked_ss(
String *dest,
String src
)
Description
This call checks if there is enough space in dest's underlying memory -to append src onto dest. If there is src is appended and the call returns non-zero.


§4.3.71: append_partial_sc

fstr_bool append_partial_sc(
String *dest,
char *src
)
Description
This call attemps to append as much of src into the space in dest's underlying memory -as possible. If the entire string is appended the call returns non-zero.


§4.3.72: append_partial_ss

fstr_bool append_partial_ss(
String *dest,
String src
)
Description
This call attemps to append as much of src into the space in dest's underlying memory -as possible. If the entire string is appended the call returns non-zero.


§4.3.73: append_s_char

fstr_bool append_s_char(
String *dest,
char c
)
Description
This call attemps to append c onto dest. If there is space left in dest's underlying -memory the character is appended and the call returns non-zero.


§4.3.74: append_ss

fstr_bool append_ss(
String *dest,
String src
)
Description
This call is equivalent to append_partial.

See Also

§4.3.75: append_sc

fstr_bool append_sc(
String *dest,
char *src
)
Description
This call is equivalent to append_partial.

See Also

§4.3.76: terminate_with_null

fstr_bool terminate_with_null(
String *str
)
Description
This call attemps to append a null terminator onto str without effecting the +if the entire string is coppied to dest.


§4.3.69: copy_cc

int32_t copy_cc(
char *dest,
char *src
)
Description
This call performs a copy from src to dest equivalent to copy_fast_unsafe.

See Also

§4.3.70: copy_ss

void copy_ss(
String *dest,
String src
)
Description
This call performs a copy from src to dest equivalent to copy_checked.

See Also

§4.3.71: copy_sc

void copy_sc(
String *dest,
char *src
)
Description
This call performs a copy from src to dest equivalent to copy_partial.

See Also

§4.3.72: append_checked_ss

fstr_bool append_checked_ss(
String *dest,
String src
)
Description
This call checks if there is enough space in dest's underlying memory +to append src onto dest. If there is src is appended and the call returns non-zero.


§4.3.73: append_partial_sc

fstr_bool append_partial_sc(
String *dest,
char *src
)
Description
This call attemps to append as much of src into the space in dest's underlying memory +as possible. If the entire string is appended the call returns non-zero.


§4.3.74: append_partial_ss

fstr_bool append_partial_ss(
String *dest,
String src
)
Description
This call attemps to append as much of src into the space in dest's underlying memory +as possible. If the entire string is appended the call returns non-zero.


§4.3.75: append_s_char

fstr_bool append_s_char(
String *dest,
char c
)
Description
This call attemps to append c onto dest. If there is space left in dest's underlying +memory the character is appended and the call returns non-zero.


§4.3.76: append_ss

fstr_bool append_ss(
String *dest,
String src
)
Description
This call is equivalent to append_partial.

See Also

§4.3.77: append_sc

fstr_bool append_sc(
String *dest,
char *src
)
Description
This call is equivalent to append_partial.

See Also

§4.3.78: terminate_with_null

fstr_bool terminate_with_null(
String *str
)
Description
This call attemps to append a null terminator onto str without effecting the size of str. This is usually called when the time comes to pass the the string to an API that requires a null terminator. This call returns non-zero if there was a spare -byte in the strings underlying memory.


§4.3.77: append_padding

fstr_bool append_padding(
String *dest,
char c,
int32_t target_size
)
Description
This call pads out dest so that it has a size of target_size by appending +byte in the strings underlying memory.


§4.3.79: append_padding

fstr_bool append_padding(
String *dest,
char c,
int32_t target_size
)
Description
This call pads out dest so that it has a size of target_size by appending the padding character c until the target size is achieved. This call returns -non-zero if dest does not run out of space in the underlying memory.


§4.3.78: replace_char

void replace_char(
String *str,
char replace,
char with
)
Parameters
str
The str parameter provides the string in which replacement shall be performed.
replace
The replace character specifies which character should be replaced.
with
The with character specifies what to write into the positions where replacement occurs.
Description
This call replaces all occurances of character in str with another character.


§4.3.79: to_lower_cc

void to_lower_cc(
char *src,
char *dst
)
Parameters
src
The source string to conver to lowercase. This string must be null terminated.
dst
The destination buffer to receive the converted string. This must be large +non-zero if dest does not run out of space in the underlying memory.


§4.3.80: replace_char

void replace_char(
String *str,
char replace,
char with
)
Parameters
str
The str parameter provides the string in which replacement shall be performed.
replace
The replace character specifies which character should be replaced.
with
The with character specifies what to write into the positions where replacement occurs.
Description
This call replaces all occurances of character in str with another character.


§4.3.81: to_lower_cc

void to_lower_cc(
char *src,
char *dst
)
Parameters
src
The source string to conver to lowercase. This string must be null terminated.
dst
The destination buffer to receive the converted string. This must be large enough to contain all of src and a null terminator.
Description
Rewrites the string in src into dst with all letters lowercased. src and dst should not overlap with the exception that src and dst may be exactly equal in order to convert the -string in place.


§4.3.80: to_lower_ss

void to_lower_ss(
String *dst,
String src
)
Parameters
dst
The destination buffer to receive the converted string. +string in place.


§4.3.82: to_lower_ss

void to_lower_ss(
String *dst,
String src
)
Parameters
dst
The destination buffer to receive the converted string. This must have a capacity of at least the size of src.
src
The source string to conver to lowercase.
Description
Rewrites the string in src into dst. src and dst should not overlap with the exception -that src and dst may be exactly equal in order to convert the string in place.


§4.3.81: to_lower_s

void to_lower_s(
String *str
)
Parameters
str
The string to be converted to all lowercase.
Description
This version of to_lower converts str to lowercase in place.


§4.3.82: to_upper_cc

void to_upper_cc(
char *src,
char *dst
)
Parameters
src
The source string to convert to uppercase. This string must be null terminated.
dst
The destination buffer to receive the converted string. +that src and dst may be exactly equal in order to convert the string in place.


§4.3.83: to_lower_s

void to_lower_s(
String *str
)
Parameters
str
The string to be converted to all lowercase.
Description
This version of to_lower converts str to lowercase in place.


§4.3.84: to_upper_cc

void to_upper_cc(
char *src,
char *dst
)
Parameters
src
The source string to convert to uppercase. This string must be null terminated.
dst
The destination buffer to receive the converted string. This must be large enough to contain all of src and a null terminator.
Description
Rewrites the string in src into dst. src and dst should not overlap with the exception -that src and dst may be exactly equal in order to convert the string in place.


§4.3.83: to_upper_ss

void to_upper_ss(
String *dst,
String src
)
Parameters
dst
The destination buffer to receive the converted string. +that src and dst may be exactly equal in order to convert the string in place.


§4.3.85: to_upper_ss

void to_upper_ss(
String *dst,
String src
)
Parameters
dst
The destination buffer to receive the converted string. This must have a capacity of at least the size of src.
src
The source string to convert to uppercase.
Description
Rewrites the string in src into dst. src and dst should not overlap with the exception -that src and dst may be exactly equal in order to convert the string in place.


§4.3.84: to_upper_s

void to_upper_s(
String *str
)
Parameters
str
The string to be converted to all uppercase.
Description
This version of to_upper converts str to uppercase in place.


§4.3.85: to_camel_cc

void to_camel_cc(
char *src,
char *dst
)
Parameters
src
The source string to convert to camel case.
dst
The destination buffer to receive the converted string. +that src and dst may be exactly equal in order to convert the string in place.


§4.3.86: to_upper_s

void to_upper_s(
String *str
)
Parameters
str
The string to be converted to all uppercase.
Description
This version of to_upper converts str to uppercase in place.


§4.3.87: to_camel_cc

void to_camel_cc(
char *src,
char *dst
)
Parameters
src
The source string to convert to camel case.
dst
The destination buffer to receive the converted string. This must be large enough to contain all of src and a null terminator.
Description
Rewrites the string in src into dst. src and dst should not overlap with the exception that src and dst may be exactly equal in order to -convert the string in place.


§4.3.86: int_to_str_size

int32_t int_to_str_size(
int32_t x
)
Description
This call returns the number of bytes required to represent x as a string.


§4.3.87: int_to_str

fstr_bool int_to_str(
String *dest,
int32_t x
)
Description
This call writes a string representation of x into dest. If there is enough -space in dest this call returns non-zero.


§4.3.88: append_int_to_str

fstr_bool append_int_to_str(
String *dest,
int32_t x
)
Description
This call appends a string representation of x onto dest. If there is enough -space in dest this call returns non-zero.


§4.3.89: u64_to_str_size

int32_t u64_to_str_size(
uint64_t x
)
Description
This call returns the number of bytes required to represent x as a string.


§4.3.90: u64_to_str

fstr_bool u64_to_str(
String *dest,
uint64_t x
)
Description
This call writes a string representation of x into dest. If there is enough -space in dest this call returns non-zero.


§4.3.91: append_u64_to_str

fstr_bool append_u64_to_str(
String *dest,
uint64_t x
)
Description
This call appends a string representation of x onto dest. If there is enough -space in dest this call returns non-zero.


§4.3.92: float_to_str_size

int32_t float_to_str_size(
float x
)
Description
This call returns the number of bytes required to represent x as a string.


§4.3.93: append_float_to_str

fstr_bool append_float_to_str(
String *dest,
float x
)
Description
This call writes a string representation of x into dest. If there is enough -space in dest this call returns non-zero.


§4.3.94: float_to_str

fstr_bool float_to_str(
String *dest,
float x
)
Description
This call appends a string representation of x onto dest. If there is enough -space in dest this call returns non-zero.


§4.3.95: str_is_int_c

int32_t str_is_int_c(
char *str
)
Description
If str is a valid string representation of an integer, this call returns non-zero


§4.3.96: str_is_int_s

fstr_bool str_is_int_s(
String str
)
Description
If str is a valid string representation of an integer, this call returns non-zero.


§4.3.97: str_to_int_c

int32_t str_to_int_c(
char *str
)
Description
If str is a valid string representation of an integer, this call will return -the integer represented by the string. Otherwise this call returns zero.


§4.3.98: str_to_int_s

int32_t str_to_int_s(
String str
)
Description
If str represents a valid string representation of an integer, this call will return -the integer represented by the string. Otherwise this call returns zero.


§4.3.99: hexchar_to_int

int32_t hexchar_to_int(
char c
)
Description
If c is a valid hexadecimal digit [0-9a-fA-F] this call returns the value of -the integer value of the digit. Otherwise the return is some nonsense value.


§4.3.100: int_to_hexchar

char int_to_hexchar(
int32_t x
)
Description
If x is in the range [0,15] this call returns the equivalent lowercase hexadecimal digit. -Otherwise the return is some nonsense value.


§4.3.101: hexstr_to_int

uint32_t hexstr_to_int(
String str
)
Description
This call interprets str has a hexadecimal representation of an integer and returns -the represented integer value.


§4.3.102: color_to_hexstr

fstr_bool color_to_hexstr(
String *s,
uint32_t color
)
Description
This call fills s with the hexadecimal representation of the color. -If there is enough memory in s to represent the color this call returns non-zero.


§4.3.103: hexstr_to_color

fstr_bool hexstr_to_color(
String s,
uint32_t *out
)
Description
This call interprets s as a color and writes the 32-bit integer representation into out.


§4.3.104: reverse_seek_slash_pos

int32_t reverse_seek_slash_pos(
String str,
int32_t pos
)
Description
This call searches for a slash in str by starting pos bytes from the end and going backwards.


§4.3.105: reverse_seek_slash

int32_t reverse_seek_slash(
String str
)
Description
This call searches for a slash in str by starting at the end and going backwards.


§4.3.106: front_of_directory

String front_of_directory(
String dir
)
Description
This call returns a substring of dir containing only the file name or -folder name furthest to the right in the directory.

See Also

§4.3.107: path_of_directory

String path_of_directory(
String dir
)
Description
This call returns a substring of dir containing the whole path except -for the final file or folder name.

See Also

§4.3.108: set_last_folder_sc

fstr_bool set_last_folder_sc(
String *dir,
char *folder_name,
char slash
)
Parameters
dir
The dir parameter is the directory string in which to set the last folder in the directory.
folder_name
The folder_name parameter is a null terminated string specifying the name to set +convert the string in place.


§4.3.88: int_to_str_size

int32_t int_to_str_size(
int32_t x
)
Description
This call returns the number of bytes required to represent x as a string.


§4.3.89: int_to_str

fstr_bool int_to_str(
String *dest,
int32_t x
)
Description
This call writes a string representation of x into dest. If there is enough +space in dest this call returns non-zero.


§4.3.90: append_int_to_str

fstr_bool append_int_to_str(
String *dest,
int32_t x
)
Description
This call appends a string representation of x onto dest. If there is enough +space in dest this call returns non-zero.


§4.3.91: u64_to_str_size

int32_t u64_to_str_size(
uint64_t x
)
Description
This call returns the number of bytes required to represent x as a string.


§4.3.92: u64_to_str

fstr_bool u64_to_str(
String *dest,
uint64_t x
)
Description
This call writes a string representation of x into dest. If there is enough +space in dest this call returns non-zero.


§4.3.93: append_u64_to_str

fstr_bool append_u64_to_str(
String *dest,
uint64_t x
)
Description
This call appends a string representation of x onto dest. If there is enough +space in dest this call returns non-zero.


§4.3.94: float_to_str_size

int32_t float_to_str_size(
float x
)
Description
This call returns the number of bytes required to represent x as a string.


§4.3.95: append_float_to_str

fstr_bool append_float_to_str(
String *dest,
float x
)
Description
This call writes a string representation of x into dest. If there is enough +space in dest this call returns non-zero.


§4.3.96: float_to_str

fstr_bool float_to_str(
String *dest,
float x
)
Description
This call appends a string representation of x onto dest. If there is enough +space in dest this call returns non-zero.


§4.3.97: str_is_int_c

int32_t str_is_int_c(
char *str
)
Description
If str is a valid string representation of an integer, this call returns non-zero


§4.3.98: str_is_int_s

fstr_bool str_is_int_s(
String str
)
Description
If str is a valid string representation of an integer, this call returns non-zero.


§4.3.99: str_to_int_c

int32_t str_to_int_c(
char *str
)
Description
If str is a valid string representation of an integer, this call will return +the integer represented by the string. Otherwise this call returns zero.


§4.3.100: str_to_int_s

int32_t str_to_int_s(
String str
)
Description
If str represents a valid string representation of an integer, this call will return +the integer represented by the string. Otherwise this call returns zero.


§4.3.101: hexchar_to_int

int32_t hexchar_to_int(
char c
)
Description
If c is a valid hexadecimal digit [0-9a-fA-F] this call returns the value of +the integer value of the digit. Otherwise the return is some nonsense value.


§4.3.102: int_to_hexchar

char int_to_hexchar(
int32_t x
)
Description
If x is in the range [0,15] this call returns the equivalent lowercase hexadecimal digit. +Otherwise the return is some nonsense value.


§4.3.103: hexstr_to_int

uint32_t hexstr_to_int(
String str
)
Description
This call interprets str has a hexadecimal representation of an integer and returns +the represented integer value.


§4.3.104: color_to_hexstr

fstr_bool color_to_hexstr(
String *s,
uint32_t color
)
Description
This call fills s with the hexadecimal representation of the color. +If there is enough memory in s to represent the color this call returns non-zero.


§4.3.105: hexstr_to_color

fstr_bool hexstr_to_color(
String s,
uint32_t *out
)
Description
This call interprets s as a color and writes the 32-bit integer representation into out.


§4.3.106: reverse_seek_slash_pos

int32_t reverse_seek_slash_pos(
String str,
int32_t pos
)
Description
This call searches for a slash in str by starting pos bytes from the end and going backwards.


§4.3.107: reverse_seek_slash

int32_t reverse_seek_slash(
String str
)
Description
This call searches for a slash in str by starting at the end and going backwards.


§4.3.108: front_of_directory

String front_of_directory(
String dir
)
Description
This call returns a substring of dir containing only the file name or +folder name furthest to the right in the directory.

See Also

§4.3.109: path_of_directory

String path_of_directory(
String dir
)
Description
This call returns a substring of dir containing the whole path except +for the final file or folder name.

See Also

§4.3.110: set_last_folder_sc

fstr_bool set_last_folder_sc(
String *dir,
char *folder_name,
char slash
)
Parameters
dir
The dir parameter is the directory string in which to set the last folder in the directory.
folder_name
The folder_name parameter is a null terminated string specifying the name to set at the end of the directory.
slash
The slash parameter specifies what slash to use between names in the directory.
Description
This call deletes the last file name or folder name in the dir string and appends the new provided one. -If there is enough memory in dir this call returns non-zero.


§4.3.109: set_last_folder_ss

fstr_bool set_last_folder_ss(
String *dir,
String folder_name,
char slash
)
Parameters
dir
The dir parameter is the directory string in which to set the last folder in the directory.
folder_name
The folder_name parameter is a string specifying the name to set at the end of the directory.
slash
The slash parameter specifies what slash to use between names in the directory.
Description
This call deletes the last file name or folder name in the dir string and appends the new provided one. -If there is enough memory in dir this call returns non-zero.


§4.3.110: file_extension

String file_extension(
String str
)
Description
This call returns a substring containing only the file extension of the provided filename.

See Also

§4.3.111: remove_extension

fstr_bool remove_extension(
String *str
)
Description
This call attemps to delete a file extension off the end of a filename. -This call returns non-zero on success.


§4.3.112: remove_last_folder

fstr_bool remove_last_folder(
String *str
)
Description
This call attemps to delete a folder or filename off the end of a path string. -This call returns non-zero on success.


§4.3.113: string_set_match_table

fstr_bool string_set_match_table(
void *str_set,
int32_t item_size,
int32_t count,
String str,
int32_t *match_index
)
Parameters
str_set
The str_set parameter may be an array of any type. +If there is enough memory in dir this call returns non-zero.


§4.3.111: set_last_folder_ss

fstr_bool set_last_folder_ss(
String *dir,
String folder_name,
char slash
)
Parameters
dir
The dir parameter is the directory string in which to set the last folder in the directory.
folder_name
The folder_name parameter is a string specifying the name to set at the end of the directory.
slash
The slash parameter specifies what slash to use between names in the directory.
Description
This call deletes the last file name or folder name in the dir string and appends the new provided one. +If there is enough memory in dir this call returns non-zero.


§4.3.112: file_extension

String file_extension(
String str
)
Description
This call returns a substring containing only the file extension of the provided filename.

See Also

§4.3.113: remove_extension

fstr_bool remove_extension(
String *str
)
Description
This call attemps to delete a file extension off the end of a filename. +This call returns non-zero on success.


§4.3.114: remove_last_folder

fstr_bool remove_last_folder(
String *str
)
Description
This call attemps to delete a folder or filename off the end of a path string. +This call returns non-zero on success.


§4.3.115: string_set_match_table

fstr_bool string_set_match_table(
void *str_set,
int32_t item_size,
int32_t count,
String str,
int32_t *match_index
)
Parameters
str_set
The str_set parameter may be an array of any type. It should point at the String in the first element of the array.
count
The item_size parameter should describe the "stride" from one String to the next, in other words it should be the size of one element of the array.
count
The count parameter specifies the number of elements in the str_set array.
str
The str parameter specifies the string to match against the str_set.
match_index
If this call succeeds match_index is filled with the index into str_set where the match occurred.
Description
This call tries to see if str matches any of the strings in str_set. If there is a match the call -succeeds and returns non-zero. The matching rule is equivalent to the matching rule for match.

See Also

§4.3.114: string_set_match

fstr_bool string_set_match(
String *str_set,
int32_t count,
String str,
int32_t *match_index
)
Parameters
str_set
The str_set parameter is an array of String structs specifying matchable strings.
count
The count parameter specifies the number of String structs in the str_set array.
str
The str parameter specifies the string to match against the str_set.
match_index
If this call succeeds match_index is filled with the index into str_set where the match occurred.
Description
This call tries to see if str matches any of the strings in str_set. If there is a match the call +succeeds and returns non-zero. The matching rule is equivalent to the matching rule for match.

See Also

§4.3.116: string_set_match

fstr_bool string_set_match(
String *str_set,
int32_t count,
String str,
int32_t *match_index
)
Parameters
str_set
The str_set parameter is an array of String structs specifying matchable strings.
count
The count parameter specifies the number of String structs in the str_set array.
str
The str parameter specifies the string to match against the str_set.
match_index
If this call succeeds match_index is filled with the index into str_set where the match occurred.
Description
This call tries to see if str matches any of the strings in str_set. If there is a match the call succeeds and returns non-zero. The matching rule is equivalent to the matching rule for match.

See Also

§5 Lexer Library

§5.1 Lexer Intro

The 4cpp lexer system provides a polished, fast, flexible system that takes in C/C++ and outputs a tokenization of the text data. There are two API levels. One level is setup to let you easily get a tokenization of the file. This level manages memory for you with malloc to make it as fast as possible to start getting your tokens. The second level enables deep integration by allowing control over allocation, data chunking, and output rate control.

To use the quick setup API you simply include 4cpp_lexer.h and read the documentation at cpp_lex_file.

To use the the fancier API include 4cpp_lexer.h and read the documentation at cpp_lex_step. If you want to be absolutely sure you are not including malloc into your program you can define FCPP_FORBID_MALLOC before the include and the "step" API will continue to work.

There are a few more features in 4cpp that are not documented yet. You are free to try to use these, but I am not totally sure they are ready yet, and when they are they will be documented.

§5.2 Lexer Function List

§5.3 Lexer Types List

§5.4 Lexer Function Descriptions

§5.4.1: cpp_get_token

Cpp_Get_Token_Result cpp_get_token(
Cpp_Token_Array *token_array_in,
int32_t pos
)
Parameters
token_array
The array of tokens from which to get a token.
pos
The position, measured in bytes, to get the token for.
Return
A Cpp_Get_Token_Result struct is returned containing the index of a token and a flag indicating whether the pos is contained in the token diff --git a/4coder_custom_api.h b/4coder_custom_api.h index 5dfc3251..96b386ce 100644 --- a/4coder_custom_api.h +++ b/4coder_custom_api.h @@ -8,7 +8,6 @@ #define GET_BUFFER_NEXT_SIG(n) void n(Application_Links *app, Buffer_Summary *buffer, Access_Flag access) #define GET_BUFFER_SIG(n) Buffer_Summary n(Application_Links *app, Buffer_ID buffer_id, Access_Flag access) #define GET_BUFFER_BY_NAME_SIG(n) Buffer_Summary n(Application_Links *app, char *name, int32_t len, Access_Flag access) -#define BUFFER_BOUNDARY_SEEK_SIG(n) int32_t n(Application_Links *app, Buffer_Summary *buffer, int32_t start_pos, bool32 seek_forward, Seek_Boundary_Flag flags) #define BUFFER_READ_RANGE_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, char *out) #define BUFFER_REPLACE_RANGE_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, char *str, int32_t len) #define BUFFER_COMPUTE_CURSOR_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, Buffer_Seek seek, Partial_Cursor *cursor_out) @@ -69,7 +68,6 @@ typedef GET_BUFFER_FIRST_SIG(Get_Buffer_First_Function); typedef GET_BUFFER_NEXT_SIG(Get_Buffer_Next_Function); typedef GET_BUFFER_SIG(Get_Buffer_Function); typedef GET_BUFFER_BY_NAME_SIG(Get_Buffer_By_Name_Function); -typedef BUFFER_BOUNDARY_SEEK_SIG(Buffer_Boundary_Seek_Function); typedef BUFFER_READ_RANGE_SIG(Buffer_Read_Range_Function); typedef BUFFER_REPLACE_RANGE_SIG(Buffer_Replace_Range_Function); typedef BUFFER_COMPUTE_CURSOR_SIG(Buffer_Compute_Cursor_Function); @@ -131,7 +129,6 @@ Get_Buffer_First_Function *get_buffer_first; Get_Buffer_Next_Function *get_buffer_next; Get_Buffer_Function *get_buffer; Get_Buffer_By_Name_Function *get_buffer_by_name; -Buffer_Boundary_Seek_Function *buffer_boundary_seek; Buffer_Read_Range_Function *buffer_read_range; Buffer_Replace_Range_Function *buffer_replace_range; Buffer_Compute_Cursor_Function *buffer_compute_cursor; @@ -200,7 +197,6 @@ app_links->get_buffer_first = Get_Buffer_First;\ app_links->get_buffer_next = Get_Buffer_Next;\ app_links->get_buffer = Get_Buffer;\ app_links->get_buffer_by_name = Get_Buffer_By_Name;\ -app_links->buffer_boundary_seek = Buffer_Boundary_Seek;\ app_links->buffer_read_range = Buffer_Read_Range;\ app_links->buffer_replace_range = Buffer_Replace_Range;\ app_links->buffer_compute_cursor = Buffer_Compute_Cursor;\ diff --git a/4coder_default_include.cpp b/4coder_default_include.cpp index f1d507d2..82414d4e 100644 --- a/4coder_default_include.cpp +++ b/4coder_default_include.cpp @@ -1375,12 +1375,376 @@ CUSTOM_COMMAND_SIG(seek_beginning_of_line){ app->view_set_cursor(app, &view, seek_pos(new_pos), true); } +// TODO(allen): REDUCE DUPLICATION! +static int32_t +buffer_seek_whitespace_right(Application_Links *app, Buffer_Summary *buffer, int32_t pos){ + char data_chunk[1024]; + Stream_Chunk stream = {0}; + + if (init_stream_chunk(&stream, app, buffer, + pos, data_chunk, sizeof(data_chunk))){ + + bool32 still_looping = 1; + do{ + for (; pos < stream.end; ++pos){ + if (!char_is_whitespace(stream.data[pos])){ + goto double_break1; + } + } + still_looping = forward_stream_chunk(&stream); + }while(still_looping); + double_break1:; + + still_looping = 1; + do{ + for (; pos < stream.end; ++pos){ + if (char_is_whitespace(stream.data[pos])){ + goto double_break2; + } + } + still_looping = forward_stream_chunk(&stream); + }while(still_looping); + double_break2:; + } + + return(pos); +} + +static int32_t +buffer_seek_whitespace_left(Application_Links *app, Buffer_Summary *buffer, int32_t pos){ + char data_chunk[1024]; + Stream_Chunk stream = {0}; + + --pos; + if (pos > 0){ + if (init_stream_chunk(&stream, app, buffer, + pos, data_chunk, sizeof(data_chunk))){ + + bool32 still_looping = 1; + do{ + for (; pos >= stream.start; --pos){ + if (!char_is_whitespace(stream.data[pos])){ + goto double_break1; + } + } + still_looping = backward_stream_chunk(&stream); + }while(still_looping); + double_break1:; + + still_looping = 1; + do{ + for (; pos >= stream.start; --pos){ + if (char_is_whitespace(stream.data[pos])){ + ++pos; + goto double_break2; + } + } + still_looping = backward_stream_chunk(&stream); + }while(still_looping); + double_break2:; + } + } + else{ + pos = 0; + } + + return(pos); +} + +static int32_t +buffer_seek_alphanumeric_right(Application_Links *app, Buffer_Summary *buffer, int32_t pos){ + char data_chunk[1024]; + Stream_Chunk stream = {0}; + + if (init_stream_chunk(&stream, app, buffer, + pos, data_chunk, sizeof(data_chunk))){ + + bool32 still_looping = 1; + do{ + for (; pos < stream.end; ++pos){ + if (char_is_alpha_numeric_true(stream.data[pos])){ + goto double_break1; + } + } + still_looping = forward_stream_chunk(&stream); + }while(still_looping); + double_break1:; + + still_looping = 1; + do{ + for (; pos < stream.end; ++pos){ + if (!char_is_alpha_numeric_true(stream.data[pos])){ + goto double_break2; + } + } + still_looping = forward_stream_chunk(&stream); + }while(still_looping); + double_break2:; + } + + return(pos); +} + +static int32_t +buffer_seek_alphanumeric_left(Application_Links *app, Buffer_Summary *buffer, int32_t pos){ + char data_chunk[1024]; + Stream_Chunk stream = {0}; + + --pos; + if (pos > 0){ + if (init_stream_chunk(&stream, app, buffer, + pos, data_chunk, sizeof(data_chunk))){ + + bool32 still_looping = 1; + do{ + for (; pos >= stream.start; --pos){ + if (char_is_alpha_numeric_true(stream.data[pos])){ + goto double_break1; + } + } + still_looping = backward_stream_chunk(&stream); + }while(still_looping); + double_break1:; + + still_looping = 1; + do{ + for (; pos >= stream.start; --pos){ + if (!char_is_alpha_numeric_true(stream.data[pos])){ + ++pos; + goto double_break2; + } + } + still_looping = backward_stream_chunk(&stream); + }while(still_looping); + double_break2:; + } + } + else{ + pos = 0; + } + + return(pos); +} + +static int32_t +buffer_seek_range_camel_right(Application_Links *app, Buffer_Summary *buffer, int32_t pos, int32_t an_pos){ + char data_chunk[1024]; + Stream_Chunk stream = {0}; + + ++pos; + if (pos < an_pos){ + stream.max_end = an_pos; + if (init_stream_chunk(&stream, app, buffer, + pos, data_chunk, sizeof(data_chunk))){ + + char c = 0, pc = stream.data[pos]; + ++pos; + + bool32 still_looping = 1; + do{ + for (; pos < stream.end; ++pos){ + c = stream.data[pos]; + if (char_is_upper(c) && char_is_lower(pc)){ + goto double_break1; + } + pc = c; + } + still_looping = forward_stream_chunk(&stream); + }while(still_looping); + double_break1:; + } + } + else{ + pos = an_pos; + } + + return(pos); +} + +static int32_t +buffer_seek_range_camel_left(Application_Links *app, Buffer_Summary *buffer, int32_t pos, int32_t an_pos){ + char data_chunk[1024]; + Stream_Chunk stream = {0}; + + --pos; + if (pos > 0){ + stream.min_start = an_pos+1; + if (init_stream_chunk(&stream, app, buffer, + pos, data_chunk, sizeof(data_chunk))){ + + char c = 0, pc = stream.data[pos]; + + bool32 still_looping = 1; + do{ + for (; pos >= stream.start; --pos){ + c = stream.data[pos]; + if (char_is_upper(c) && char_is_lower(pc)){ + goto double_break1; + } + pc = c; + } + still_looping = backward_stream_chunk(&stream); + }while(still_looping); + double_break1:; + } + } + else{ + pos = 0; + } + + return(pos); +} + +static int32_t +buffer_seek_alphanumeric_or_camel_right(Application_Links *app, Buffer_Summary *buffer, int32_t pos){ + int32_t an_pos = buffer_seek_alphanumeric_right(app, buffer, pos); + int32_t result = buffer_seek_range_camel_right(app, buffer, pos, an_pos); + return(result); +} + +static int32_t +buffer_seek_alphanumeric_or_camel_left(Application_Links *app, Buffer_Summary *buffer, int32_t pos){ + int32_t an_pos = buffer_seek_alphanumeric_left(app, buffer, pos); + int32_t result = buffer_seek_range_camel_left(app, buffer, pos, an_pos); + return(result); +} + +static int32_t +seek_token_left(Cpp_Token_Array *tokens, int32_t pos){ + Cpp_Get_Token_Result get = cpp_get_token(tokens, pos); + if (get.token_index == -1){ + get.token_index = 0; + } + + Cpp_Token *token = tokens->tokens + get.token_index; + if (token->start == pos && get.token_index > 0){ + --token; + } + + return token->start; +} + +static int32_t +seek_token_right(Cpp_Token_Array *tokens, int32_t pos){ + Cpp_Get_Token_Result get = cpp_get_token(tokens, pos); + if (get.in_whitespace){ + ++get.token_index; + } + if (get.token_index >= tokens->count){ + get.token_index = tokens->count-1; + } + + Cpp_Token *token = tokens->tokens + get.token_index; + return token->start + token->size; +} + +static int32_t +buffer_boundary_seek(Application_Links *app, Buffer_Summary *buffer, int32_t start_pos, + bool32 seek_forward, Seek_Boundary_Flag flags)/* +DOC_PARAM(buffer, The buffer parameter specifies the buffer through which to seek.) +DOC_PARAM(start_pos, The beginning position of the seek is specified by start_pos measured in absolute position.) +DOC_PARAM(seek_forward, If this parameter is non-zero it indicates that the seek should move foward through the buffer.) +DOC_PARAM(flags, This field specifies the types of boundaries at which the seek should stop.) +DOC_RETURN(This call returns the absolute position where the seek stopped. +If the seek goes below 0 the returned value is -1. +If the seek goes past the end the returned value is the size of the buffer.) +DOC_SEE(Seek_Boundary_Flag) +DOC_SEE(4coder_Buffer_Positioning_System) +*/{ + int32_t result = 0; + if (buffer->exists){ + // TODO(allen): reduce duplication? + int32_t size = buffer->size; + int32_t pos[4] = {0}; + int32_t new_pos = 0; + + if (start_pos < 0){ + start_pos = 0; + } + else if (start_pos > size){ + start_pos = size; + } + + if (seek_forward){ + for (int32_t i = 0; i < ArrayCount(pos); ++i) pos[i] = size; + + if (flags & (1)){ + pos[0] = buffer_seek_whitespace_right(app, buffer, start_pos); + } + + if (flags & (1 << 1)){ + if (buffer->tokens_are_ready){ + Cpp_Token_Array array; + // TODO(allen): Fill this array. + pos[1] = seek_token_right(&array, start_pos); + } + else{ + pos[1] = buffer_seek_whitespace_right(app, buffer, start_pos); + } + } + + if (flags & (1 << 2)){ + pos[2] = buffer_seek_alphanumeric_right(app, buffer, start_pos); + if (flags & (1 << 3)){ + pos[3] = buffer_seek_range_camel_right(app, buffer, start_pos, pos[2]); + } + } + else{ + if (flags & (1 << 3)){ + pos[3] = buffer_seek_alphanumeric_or_camel_right(app, buffer, start_pos); + } + } + + new_pos = size; + for (int32_t i = 0; i < ArrayCount(pos); ++i){ + if (pos[i] < new_pos) new_pos = pos[i]; + } + } + else{ + if (flags & (1)){ + pos[0] = buffer_seek_whitespace_left(app, buffer, start_pos); + } + + if (flags & (1 << 1)){ + if (buffer->tokens_are_ready){ + Cpp_Token_Array array; + // TODO(allen): Fill this array. + pos[1] = seek_token_left(&array, start_pos); + } + else{ + pos[1] = buffer_seek_whitespace_left(app, buffer, start_pos); + } + } + + if (flags & (1 << 2)){ + pos[2] = buffer_seek_alphanumeric_left(app, buffer, start_pos); + if (flags & (1 << 3)){ + pos[3] = buffer_seek_range_camel_left(app, buffer, start_pos, pos[2]); + } + } + else{ + if (flags & (1 << 3)){ + pos[3] = buffer_seek_alphanumeric_or_camel_left(app, buffer, start_pos); + } + } + + new_pos = 0; + for (int32_t i = 0; i < ArrayCount(pos); ++i){ + if (pos[i] > new_pos) new_pos = pos[i]; + } + } + result = new_pos; + } + + return(result); +} + static void basic_seek(Application_Links *app, int32_t seek_type, uint32_t flags){ uint32_t access = AccessProtected; View_Summary view = app->get_active_view(app, access); Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access); - int32_t pos = app->buffer_boundary_seek(app, &buffer, view.cursor.pos, seek_type, flags); + int32_t pos = buffer_boundary_seek(app, &buffer, view.cursor.pos, seek_type, flags); app->view_set_cursor(app, &view, seek_pos(pos), true); } @@ -1567,8 +1931,8 @@ CUSTOM_COMMAND_SIG(snipe_token_or_word){ view = app->get_active_view(app, access); buffer = app->get_buffer(app, view.buffer_id, access); - pos1 = app->buffer_boundary_seek(app, &buffer, view.cursor.pos, false, BoundaryToken | BoundaryWhitespace); - pos2 = app->buffer_boundary_seek(app, &buffer, pos1, true, BoundaryToken | BoundaryWhitespace); + pos1 = buffer_boundary_seek(app, &buffer, view.cursor.pos, false, BoundaryToken | BoundaryWhitespace); + pos2 = buffer_boundary_seek(app, &buffer, pos1, true, BoundaryToken | BoundaryWhitespace); Range range = make_range(pos1, pos2); app->buffer_replace_range(app, &buffer, range.start, range.end, 0, 0); diff --git a/4coder_string.h b/4coder_string.h index d521319c..eeafb33b 100644 --- a/4coder_string.h +++ b/4coder_string.h @@ -48,6 +48,8 @@ typedef struct Offset_String{ #define FCODER_STRING_H FSTRING_INLINE fstr_bool char_is_slash(char c); +FSTRING_INLINE fstr_bool char_is_upper(char c); +FSTRING_INLINE fstr_bool char_is_lower(char c); FSTRING_INLINE char char_to_upper(char c); FSTRING_INLINE char char_to_lower(char c); FSTRING_INLINE fstr_bool char_is_whitespace(char c); @@ -261,6 +263,22 @@ char_is_slash(char c) } #endif +#if !defined(FSTRING_GUARD) +FSTRING_INLINE fstr_bool +char_is_upper(char c) +{ + return (c >= 'A' && c <= 'Z'); +} +#endif + +#if !defined(FSTRING_GUARD) +FSTRING_INLINE fstr_bool +char_is_lower(char c) +{ + return (c >= 'a' && c <= 'z'); +} +#endif + #if !defined(FSTRING_GUARD) FSTRING_INLINE char char_to_upper(char c) diff --git a/4ed_api_implementation.cpp b/4ed_api_implementation.cpp index 9926bb6d..5b5a14f8 100644 --- a/4ed_api_implementation.cpp +++ b/4ed_api_implementation.cpp @@ -579,109 +579,6 @@ seek_token_right(Cpp_Token_Array *tokens, i32 pos){ return token->start + token->size; } -API_EXPORT int32_t -Buffer_Boundary_Seek(Application_Links *app, Buffer_Summary *buffer, int32_t start_pos, bool32 seek_forward, Seek_Boundary_Flag flags)/* -DOC_PARAM(buffer, The buffer parameter specifies the buffer through which to seek.) -DOC_PARAM(start_pos, The beginning position of the seek is specified by start_pos measured in absolute position.) -DOC_PARAM(seek_forward, If this parameter is non-zero it indicates that the seek should move foward through the buffer.) -DOC_PARAM(flags, This field specifies the types of boundaries at which the seek should stop.) -DOC_RETURN(This call returns the absolute position where the seek stopped. -If the seek goes below 0 the returned value is -1. -If the seek goes past the end the returned value is the size of the buffer.) -DOC_SEE(Seek_Boundary_Flag) -DOC_SEE(4coder_Buffer_Positioning_System) -*/{ - Command_Data *cmd = (Command_Data*)app->cmd_context; - Editing_File *file; - int32_t result = 0; - - file = imp_get_file(cmd, buffer); - - if (file){ - // TODO(allen): reduce duplication? - i32 size = buffer_size(&file->state.buffer); - i32 pos[4] = {0}; - i32 new_pos = 0; - - if (start_pos < 0){ - start_pos = 0; - } - else if (start_pos > size){ - start_pos = size; - } - - if (seek_forward){ - for (i32 i = 0; i < ArrayCount(pos); ++i) pos[i] = size; - - if (flags & (1)){ - pos[0] = buffer_seek_whitespace_right(&file->state.buffer, start_pos); - } - - if (flags & (1 << 1)){ - if (file->state.tokens_complete){ - pos[1] = seek_token_right(&file->state.token_array, start_pos); - } - else{ - pos[1] = buffer_seek_whitespace_right(&file->state.buffer, start_pos); - } - } - - if (flags & (1 << 2)){ - pos[2] = buffer_seek_alphanumeric_right(&file->state.buffer, start_pos); - if (flags & (1 << 3)){ - pos[3] = buffer_seek_range_camel_right(&file->state.buffer, start_pos, pos[2]); - } - } - else{ - if (flags & (1 << 3)){ - pos[3] = buffer_seek_alphanumeric_or_camel_right(&file->state.buffer, start_pos); - } - } - - new_pos = size; - for (i32 i = 0; i < ArrayCount(pos); ++i){ - if (pos[i] < new_pos) new_pos = pos[i]; - } - } - else{ - if (flags & (1)){ - pos[0] = buffer_seek_whitespace_left(&file->state.buffer, start_pos); - } - - if (flags & (1 << 1)){ - if (file->state.tokens_complete){ - pos[1] = seek_token_left(&file->state.token_array, start_pos); - } - else{ - pos[1] = buffer_seek_whitespace_left(&file->state.buffer, start_pos); - } - } - - if (flags & (1 << 2)){ - pos[2] = buffer_seek_alphanumeric_left(&file->state.buffer, start_pos); - if (flags & (1 << 3)){ - pos[3] = buffer_seek_range_camel_left(&file->state.buffer, start_pos, pos[2]); - } - } - else{ - if (flags & (1 << 3)){ - pos[3] = buffer_seek_alphanumeric_or_camel_left(&file->state.buffer, start_pos); - } - } - - new_pos = 0; - for (i32 i = 0; i < ArrayCount(pos); ++i){ - if (pos[i] > new_pos) new_pos = pos[i]; - } - } - result = new_pos; - - fill_buffer_summary(buffer, file, cmd); - } - - return(result); -} - API_EXPORT bool32 Buffer_Read_Range(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, char *out)/* DOC_PARAM(buffer, This parameter specifies the buffer to read.) diff --git a/buffer/4coder_buffer_abstract.cpp b/buffer/4coder_buffer_abstract.cpp index dd927a89..96e80cc9 100644 --- a/buffer/4coder_buffer_abstract.cpp +++ b/buffer/4coder_buffer_abstract.cpp @@ -24,25 +24,6 @@ buffer_stringify(Buffer_Type *buffer, int start, int end, char *out){ } } -inline_4tech void -buffer_backify(Buffer_Type *buffer, int start, int end, char *out){ - for (Buffer_Backify_Type loop = buffer_backify_loop(buffer, end, start); - buffer_backify_good(&loop); - buffer_backify_next(&loop)){ - memcpy_4tech(out, loop.data, loop.size); - out += loop.size; - } -} - -internal_4tech char -buffer_get_char(Buffer_Type *buffer, int i){ - char out = 0; - if (i >= 0 && i < buffer_size(buffer)){ - buffer_stringify(buffer, i, i+1, &out); - } - return(out); -} - internal_4tech int buffer_convert_out(Buffer_Type *buffer, char *dest, int max){ Buffer_Stringify_Type loop; @@ -86,461 +67,6 @@ buffer_count_newlines(Buffer_Type *buffer, int start, int end){ return(count); } -internal_4tech int -buffer_seek_delimiter(Buffer_Type *buffer, int pos, char delim){ - Buffer_Stringify_Type loop; - char *data; - int end, size; - - size = buffer_size(buffer); - for(loop = buffer_stringify_loop(buffer, pos, size); - buffer_stringify_good(&loop); - buffer_stringify_next(&loop)){ - end = loop.size + loop.absolute_pos; - data = loop.data - loop.absolute_pos; - for (; pos < end; ++pos){ - if (data[pos] == delim) goto double_break; - } - } - double_break: - return(pos); -} - -internal_4tech int -buffer_reverse_seek_delimiter(Buffer_Type *buffer, int pos, char delim){ - Buffer_Backify_Type loop; - char *data; - int end; - - for(loop = buffer_backify_loop(buffer, pos, 0); - buffer_backify_good(&loop); - buffer_backify_next(&loop)){ - end = loop.size + loop.absolute_pos; - data = loop.data - loop.absolute_pos; - for (; pos >= 0; --pos){ - if (data[pos] == delim) goto double_break; - } - } - double_break: - return(pos); -} - -internal_4tech int -buffer_seek_whitespace_right(Buffer_Type *buffer, int pos){ - Buffer_Stringify_Type loop; - char *data; - int end; - int size; - - size = buffer_size(buffer); - loop = buffer_stringify_loop(buffer, pos, size); - - for (;buffer_stringify_good(&loop); - buffer_stringify_next(&loop)){ - end = loop.size + loop.absolute_pos; - data = loop.data - loop.absolute_pos; - for (; pos < end && is_whitespace(data[pos]); ++pos); - if (!is_whitespace(data[pos])) break; - } - - for (;buffer_stringify_good(&loop); - buffer_stringify_next(&loop)){ - end = loop.size + loop.absolute_pos; - data = loop.data - loop.absolute_pos; - for (; pos < end && !is_whitespace(data[pos]); ++pos); - if (is_whitespace(data[pos])) break; - } - - return(pos); -} - -internal_4tech int -buffer_seek_whitespace_left(Buffer_Type *buffer, int pos){ - Buffer_Backify_Type loop; - char *data; - int end; - int size; - - --pos; - if (pos > 0){ - size = buffer_size(buffer); - loop = buffer_backify_loop(buffer, pos, 1); - - for (;buffer_backify_good(&loop); - buffer_backify_next(&loop)){ - end = loop.absolute_pos; - data = loop.data - loop.absolute_pos; - for (; pos >= end && is_whitespace(data[pos]); --pos); - if (!is_whitespace(data[pos])) break; - } - - for (;buffer_backify_good(&loop); - buffer_backify_next(&loop)){ - end = loop.absolute_pos; - data = loop.data - loop.absolute_pos; - for (; pos >= end && !is_whitespace(data[pos]); --pos); - if (is_whitespace(data[pos])) break; - } - - if (pos != 0) ++pos; - } - else{ - pos = 0; - } - - return(pos); -} - -internal_4tech int -buffer_seek_word_right_assume_on_word(Buffer_Type *buffer, int pos){ - Buffer_Stringify_Type loop; - char *data; - int end; - int size; - - size = buffer_size(buffer); - loop = buffer_stringify_loop(buffer, pos, size); - - for (;buffer_stringify_good(&loop); - buffer_stringify_next(&loop)){ - end = loop.size + loop.absolute_pos; - data = loop.data - loop.absolute_pos; - for (; pos < end; ++pos){ - if (!is_alphanumeric(data[pos])) goto double_break; - } - } - double_break: - - return(pos); -} - -internal_4tech int -buffer_seek_alphanumeric_right(Buffer_Type *buffer, int pos){ - Buffer_Stringify_Type loop; - char *data; - int end; - int size; - - size = buffer_size(buffer); - loop = buffer_stringify_loop(buffer, pos, size); - - for (;buffer_stringify_good(&loop); - buffer_stringify_next(&loop)){ - end = loop.size + loop.absolute_pos; - data = loop.data - loop.absolute_pos; - for (; pos < end; ++pos){ - if (is_alphanumeric_true(data[pos])) goto buffer_seek_alphanumeric_right_mid; - } - } - - buffer_seek_alphanumeric_right_mid: - for (;buffer_stringify_good(&loop); - buffer_stringify_next(&loop)){ - end = loop.size + loop.absolute_pos; - data = loop.data - loop.absolute_pos; - for (; pos < end; ++pos){ - if (!is_alphanumeric_true(data[pos])) goto buffer_seek_alphanumeric_right_end; - } - } - - buffer_seek_alphanumeric_right_end: - return(pos); -} - -internal_4tech int -buffer_seek_alphanumeric_left(Buffer_Type *buffer, int pos){ - Buffer_Backify_Type loop; - char *data; - int end; - int size; - - --pos; - if (pos >= 0){ - size = buffer_size(buffer); - loop = buffer_backify_loop(buffer, pos, 1); - - for (;buffer_backify_good(&loop); - buffer_backify_next(&loop)){ - end = loop.absolute_pos; - data = loop.data - end; - for (; pos >= end; --pos){ - if (is_alphanumeric_true(data[pos])) goto buffer_seek_alphanumeric_left_mid; - } - } - - buffer_seek_alphanumeric_left_mid: - for (;buffer_backify_good(&loop); - buffer_backify_next(&loop)){ - end = loop.absolute_pos; - data = loop.data - end; - for (; pos >= end; --pos){ - if (!is_alphanumeric_true(data[pos])){ - ++pos; - goto buffer_seek_alphanumeric_left_end; - } - } - } - } - else{ - pos = 0; - } - - buffer_seek_alphanumeric_left_end: - return(pos); -} - -internal_4tech int -buffer_seek_range_camel_right(Buffer_Type *buffer, int pos, int an_pos){ - Buffer_Stringify_Type loop; - char *data; - int end, size; - char ch, prev_ch; - - size = buffer_size(buffer); - assert_4tech(pos <= an_pos); - assert_4tech(an_pos <= size); - - ++pos; - if (pos < an_pos){ - loop = buffer_stringify_loop(buffer, pos, an_pos); - if (buffer_stringify_good(&loop)){ - prev_ch = loop.data[0]; - ++pos; - - for (;buffer_stringify_good(&loop); - buffer_stringify_next(&loop)){ - end = loop.size + loop.absolute_pos; - data = loop.data - loop.absolute_pos; - for (; pos < end; ++pos){ - ch = data[pos]; - if (is_upper(ch) && is_lower(prev_ch)) goto buffer_seek_alphanumeric_or_camel_right_end; - prev_ch = ch; - } - } - } - } - else{ - pos = an_pos; - } - - buffer_seek_alphanumeric_or_camel_right_end: - return(pos); -} - -internal_4tech int -buffer_seek_range_camel_left(Buffer_Type *buffer, int pos, int an_pos){ - Buffer_Backify_Type loop; - char *data; - int end, size; - char ch, prev_ch; - - size = buffer_size(buffer); - assert_4tech(an_pos <= pos); - assert_4tech(0 <= an_pos); - - --pos; - loop = buffer_backify_loop(buffer, pos, an_pos+1); - if (buffer_backify_good(&loop)){ - prev_ch = loop.data[0]; - - for (;buffer_backify_good(&loop); - buffer_backify_next(&loop)){ - end = loop.absolute_pos; - data = loop.data - loop.absolute_pos; - for (; pos >= end; --pos){ - ch = data[pos]; - if (is_upper(ch) && is_lower(prev_ch)) goto buffer_seek_alphanumeric_or_camel_left_end; - prev_ch = ch; - } - } - } - - buffer_seek_alphanumeric_or_camel_left_end: - return(pos); -} - -internal_4tech int -buffer_seek_alphanumeric_or_camel_right(Buffer_Type *buffer, int pos){ - int an_pos, result; - an_pos = buffer_seek_alphanumeric_right(buffer, pos); - result = buffer_seek_range_camel_right(buffer, pos, an_pos); - return(result); -} - -internal_4tech int -buffer_seek_alphanumeric_or_camel_left(Buffer_Type *buffer, int pos){ - int an_pos, result; - an_pos = buffer_seek_alphanumeric_left(buffer, pos); - result = buffer_seek_range_camel_left(buffer, pos, an_pos); - return(result); -} - -struct Hard_Start_Result{ - int char_pos; - int indent_pos; - int all_whitespace; - int all_space; -}; - -internal_4tech Hard_Start_Result -buffer_find_hard_start(Buffer_Type *buffer, int line_start, int tab_width){ - Hard_Start_Result result = {0}; - Buffer_Stringify_Type loop; - char *data; - int size, end; - char c; - - result.all_space = 1; - result.indent_pos = 0; - - size = buffer_size(buffer); - - tab_width -= 1; - - result.char_pos = line_start; - for (loop = buffer_stringify_loop(buffer, line_start, size); - buffer_stringify_good(&loop); - buffer_stringify_next(&loop)){ - end = loop.size + loop.absolute_pos; - data = loop.data - loop.absolute_pos; - for (; result.char_pos < end; ++result.char_pos){ - c = data[result.char_pos]; - - if (c == '\n' || c == 0){ - result.all_whitespace = 1; - goto buffer_find_hard_start_end; - } - if (c >= '!' && c <= '~') goto buffer_find_hard_start_end; - if (c == '\t') result.indent_pos += tab_width; - if (c != ' ') result.all_space = 0; - result.indent_pos += 1; - } - } - - buffer_find_hard_start_end: - return(result); -} - -internal_4tech int -buffer_find_string(Buffer_Type *buffer, int start_pos, int end_pos, char *str, int len, char *spare){ - Buffer_Stringify_Type loop; - char *data; - int end, pos; - - pos = start_pos; - if (len > 0){ - for (loop = buffer_stringify_loop(buffer, start_pos, end_pos - len + 1); - buffer_stringify_good(&loop); - buffer_stringify_next(&loop)){ - end = loop.size + loop.absolute_pos; - data = loop.data - loop.absolute_pos; - for (; pos < end; ++pos){ - if (*str == data[pos]){ - buffer_stringify(buffer, pos, pos + len, spare); - if (is_match(str, spare, len)) - goto buffer_find_string_end; - } - } - } - } - - buffer_find_string_end: - if (pos >= end_pos - len + 1) pos = end_pos; - return(pos); -} - -internal_4tech int -buffer_rfind_string(Buffer_Type *buffer, int start_pos, char *str, int len, char *spare){ - Buffer_Backify_Type loop; - char *data; - int end, size; - int pos; - - size = buffer_size(buffer); - - pos = start_pos; - if (pos > size - len) pos = size - len; - - if (len > 0){ - for (loop = buffer_backify_loop(buffer, start_pos, 0); - buffer_backify_good(&loop); - buffer_backify_next(&loop)){ - end = loop.absolute_pos; - data = loop.data - loop.absolute_pos; - for (; pos >= end; --pos){ - if (*str == data[pos]){ - buffer_stringify(buffer, pos, pos + len, spare); - if (is_match(str, spare, len)) - goto buffer_rfind_string_end; - } - } - } - } - - buffer_rfind_string_end: - return(pos); -} - -internal_4tech int -buffer_find_string_insensitive(Buffer_Type *buffer, int start_pos, int end_pos, char *str, int len, char *spare){ - Buffer_Stringify_Type loop; - char *data; - int end, pos; - - pos = start_pos; - if (len > 0){ - for (loop = buffer_stringify_loop(buffer, start_pos, end_pos - len + 1); - buffer_stringify_good(&loop); - buffer_stringify_next(&loop)){ - end = loop.size + loop.absolute_pos; - data = loop.data - loop.absolute_pos; - for (; pos < end; ++pos){ - if (to_upper(*str) == to_upper(data[pos])){ - buffer_stringify(buffer, pos, pos + len, spare); - if (is_match_insensitive(str, spare, len)) - goto buffer_find_string_end; - } - } - } - } - - buffer_find_string_end: - if (pos >= end_pos - len + 1) pos = end_pos; - return(pos); -} - -internal_4tech int -buffer_rfind_string_insensitive(Buffer_Type *buffer, int start_pos, char *str, int len, char *spare){ - Buffer_Backify_Type loop; - char *data; - int end, size; - int pos; - - size = buffer_size(buffer); - - pos = start_pos; - if (pos > size - len) pos = size - len; - - if (len > 0){ - for (loop = buffer_backify_loop(buffer, start_pos, 0); - buffer_backify_good(&loop); - buffer_backify_next(&loop)){ - end = loop.absolute_pos; - data = loop.data - loop.absolute_pos; - for (; pos >= end; --pos){ - if (to_upper(*str) == to_upper(data[pos])){ - buffer_stringify(buffer, pos, pos + len, spare); - if (is_match_insensitive(str, spare, len)) - goto buffer_rfind_string_end; - } - } - } - } - - buffer_rfind_string_end: - return(pos); -} - #ifndef NON_ABSTRACT_4TECH typedef struct Buffer_Measure_Starts{ int i; diff --git a/internal_4coder_string.cpp b/internal_4coder_string.cpp index fd24b4b3..d0791c98 100644 --- a/internal_4coder_string.cpp +++ b/internal_4coder_string.cpp @@ -67,6 +67,18 @@ char_is_slash(char c) return (c == '\\' || c == '/'); } +FSTRING_INLINE fstr_bool +char_is_upper(char c) +/* DOC(If c is an uppercase letter this call returns true.) */{ + return (c >= 'A' && c <= 'Z'); +} + +FSTRING_INLINE fstr_bool +char_is_lower(char c) +/* DOC(If c is a lower letter this call returns true.) */{ + return (c >= 'a' && c <= 'z'); +} + FSTRING_INLINE char char_to_upper(char c) /* DOC(If c is a lowercase letter this call returns the uppercase equivalent, otherwise it returns c.) */{ diff --git a/internal_4coder_tests.cpp b/internal_4coder_tests.cpp index eec071a9..8ca0fa52 100644 --- a/internal_4coder_tests.cpp +++ b/internal_4coder_tests.cpp @@ -16,6 +16,8 @@ Allen Webster #include "4coder_default_include.cpp" +#include + #include #pragma intrinsic(__rdtsc) @@ -80,11 +82,97 @@ CUSTOM_COMMAND_SIG(run_all_tests){ exec_command(app, reopen_test); } +#if 0 +CUSTOM_COMMAND_SIG(generate_stop_spots_test_data){ + Buffer_Summary buffer = app->create_buffer(app, literal(LOTS_OF_FILES "/4ed.cpp"), 0); + View_Summary view = app->get_active_view(app, AccessAll); + app->view_set_buffer(app, &view, buffer.buffer_id, 0); + + FILE *file = fopen(TEST_FILES "/stop_spots_data", "wb"); + + if (file){ + Partial_Cursor curs; + int32_t pos; + + app->buffer_compute_cursor(app, &buffer, seek_line_char(316, 29), &curs); + fwrite(&curs.pos, 4, 1, file); + + static Seek_Boundary_Flag flag_set[] = { + BoundaryWhitespace, + BoundaryToken, + BoundaryAlphanumeric, + BoundaryCamelCase, + BoundaryWhitespace | BoundaryToken, + BoundaryWhitespace | BoundaryAlphanumeric, + BoundaryToken | BoundaryCamelCase, + }; + + for (int32_t flag_i = 0; flag_i < ArrayCount(flag_set); ++flag_i){ + for (int32_t seek_forward = 0; seek_forward <= 1; ++seek_forward){ + pos = curs.pos; + for (int32_t i = 0; i < 100; ++i){ + pos = app->buffer_boundary_seek(app, &buffer, pos, seek_forward, flag_set[flag_i]); + fwrite(&pos, 4, 1, file); + } + } + } + + fclose(file); + } +} +#endif + +static void +fcheck(int32_t x, FILE *file){ + int32_t x0 = 0; + fread(&x0, 4, 1, file); + Assert(x == x0); +} + +CUSTOM_COMMAND_SIG(stop_spots_test){ + Buffer_Summary buffer = app->create_buffer(app, literal(LOTS_OF_FILES "/4ed.cpp"), 0); + View_Summary view = app->get_active_view(app, AccessAll); + app->view_set_buffer(app, &view, buffer.buffer_id, 0); + + FILE *file = fopen(TEST_FILES "/stop_spots_data", "rb"); + + if (file){ + Partial_Cursor curs; + int32_t pos; + + app->buffer_compute_cursor(app, &buffer, seek_line_char(316, 29), &curs); + fcheck(curs.pos, file); + + static Seek_Boundary_Flag flag_set[] = { + BoundaryWhitespace, + BoundaryToken, + BoundaryAlphanumeric, + BoundaryCamelCase, + BoundaryWhitespace | BoundaryToken, + BoundaryWhitespace | BoundaryAlphanumeric, + BoundaryToken | BoundaryCamelCase, + }; + + for (int32_t flag_i = 0; flag_i < ArrayCount(flag_set); ++flag_i){ + for (int32_t seek_forward = 0; seek_forward <= 1; ++seek_forward){ + pos = curs.pos; + for (int32_t i = 0; i < 100; ++i){ + pos = buffer_boundary_seek(app, &buffer, pos, seek_forward, flag_set[flag_i]); + fcheck(pos, file); + } + } + } + + fclose(file); + } +} + static void test_get_bindings(Bind_Helper *context){ begin_map(context, mapid_global); - bind(context, key_f3, MDFR_NONE, run_all_tests); + //bind(context, key_f3, MDFR_NONE, run_all_tests); + bind(context, key_f3, MDFR_NONE, stop_spots_test); end_map(context); } diff --git a/win32_4ed.cpp b/win32_4ed.cpp index f89ebf40..312bbf2e 100644 --- a/win32_4ed.cpp +++ b/win32_4ed.cpp @@ -1833,7 +1833,9 @@ Win32Callback(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam){ win32vars.input_chunk.pers.mouse_l = 0; win32vars.input_chunk.pers.mouse_r = 0; - win32vars.input_chunk.pers.control_keys[MDFR_SHIFT_INDEX] = 0; + for (int32_t i = 0; i < MDFR_INDEX_COUNT; ++i){ + win32vars.input_chunk.pers.control_keys[i] = 0; + } win32vars.input_chunk.pers.controls = null_control_keys; }break;