From 8cf49b566ed927a4b28e58665572893e640a1a13 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Tue, 6 Sep 2016 17:22:35 -0400 Subject: [PATCH] wrote lexer function docs, expanded doc generator --- 4coder_API.html | 411 +++++++++++++++++-------------- 4cpp_lexer.h | 488 ++++++++++++++++++++++--------------- 4cpp_lexer_fsms.h | 97 -------- 4cpp_lexer_types.h | 116 ++++++++- 4ed.cpp | 2 +- 4ed_api_implementation.cpp | 10 +- 4ed_file.cpp | 4 +- 4ed_file_view.cpp | 162 ++++++------ 4ed_metagen.cpp | 312 ++++++++++++++++++++---- build.c | 7 +- fsm_table_generator.cpp | 17 +- win32_api_impl.cpp | 4 +- 12 files changed, 1000 insertions(+), 630 deletions(-) delete mode 100644 4cpp_lexer_fsms.h diff --git a/4coder_API.html b/4coder_API.html index d21b5613..1b0eec6d 100644 --- a/4coder_API.html +++ b/4coder_API.html @@ -3,304 +3,341 @@

§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. -If command_id is invalid a warning is posted to *messages*.
See Also
Command_ID

§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. +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 -exist, or provide the id of a buffer that does exist. - +exist, or provide the id of a buffer that does exist.

If the buffer is not already in an open view and the view parameter is not NULL, -then the provided view will display the output buffer. - -If the view parameter is NULL, no view will switch to the output.
See Also

§3.3.3: clipboard_post

void app->clipboard_post(
Application_Links *app,
int32_t clipboard_id,
char *str,
int32_t len
)
Parameters
clipboard_id
This parameter is set up to prepare for future features, it should always be 0 for now.
str
The str parameter specifies the string to be posted to the clipboard, it need not be null terminated.
len
The len parameter specifies the length of the str string.
Description
Stores the string str in the clipboard initially with index 0. +then the provided view will display the output buffer.

+If the view parameter is NULL, no view will switch to the output.

See Also

§3.3.3: clipboard_post

void app->clipboard_post(
Application_Links *app,
int32_t clipboard_id,
char *str,
int32_t len
)
Parameters
clipboard_id
This parameter is set up to prepare for future features, it should always be 0 for now.
str
The str parameter specifies the string to be posted to the clipboard, it need not be null terminated.
len
The len parameter specifies the length of the str string.
Description
Stores the string str in the clipboard initially with index 0. Also reports the copy to the operating system, so that it may -be pasted into other applications.
See Also

§3.3.4: clipboard_count

int32_t app->clipboard_count(
Application_Links *app,
int32_t clipboard_id
)
Parameters
clipboard_id
This parameter is set up to prepare for future features, it should always be 0 for now.
Description
This call returns the number of items in the clipboard.
See Also

§3.3.5: clipboard_index

int32_t app->clipboard_index(
Application_Links *app,
int32_t clipboard_id,
int32_t item_index,
char *out,
int32_t len
)
Parameters
clipboard_id
This parameter is set up to prepare for future features, it should always be 0 for now.
item_index
This parameter specifies which item to read, 0 is the most recent copy, 1 is the second most recent copy, etc.
out
This parameter provides a buffer where the clipboard contents are written. This parameter may be NULL.
len
This parameter specifies the length of the out buffer.
Return
This call returns the size of the item associated with item_index.
Description
This function always returns the size of the item even if the output buffer is NULL. +be pasted into other applications.

See Also

§3.3.4: clipboard_count

int32_t app->clipboard_count(
Application_Links *app,
int32_t clipboard_id
)
Parameters
clipboard_id
This parameter is set up to prepare for future features, it should always be 0 for now.
Description
This call returns the number of items in the clipboard.

See Also

§3.3.5: clipboard_index

int32_t app->clipboard_index(
Application_Links *app,
int32_t clipboard_id,
int32_t item_index,
char *out,
int32_t len
)
Parameters
clipboard_id
This parameter is set up to prepare for future features, it should always be 0 for now.
item_index
This parameter specifies which item to read, 0 is the most recent copy, 1 is the second most recent copy, etc.
out
This parameter provides a buffer where the clipboard contents are written. This parameter may be NULL.
len
This parameter specifies the length of the out buffer.
Return
This call returns the size of the item associated with item_index.
Description
This function always returns the size of the item even if the output buffer is NULL. If the output buffer is too small to contain the whole string, it is filled with the -first len character of the clipboard contents. The output string is not null terminated.
See Also

§3.3.6: get_buffer_count

int32_t app->get_buffer_count(
Application_Links *app
)
Description
TODO

§3.3.7: get_buffer_first

Buffer_Summary app->get_buffer_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 buffer in a buffer loop.
Description
This call begins a loop across all the buffers. - +first len character of the clipboard contents. The output string is not null terminated.

See Also

§3.3.6: get_buffer_count

int32_t app->get_buffer_count(
Application_Links *app
)
Description
TODO


§3.3.7: get_buffer_first

Buffer_Summary app->get_buffer_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 buffer in a buffer loop.
Description
This call begins a loop across all the buffers.

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. - +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. +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). -The output is not null terminated. - +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.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 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. - +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.
Description
Computes a Partial_Cursor for the given seek position with no side effects. +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.
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.
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_auto_indent

bool32 app->buffer_auto_indent(
Application_Links *app,
Buffer_Summary *buffer,
int32_t start,
int32_t end,
int32_t tab_width,
Auto_Indent_Flag flags
)
Parameters
buffer
The buffer specifies the buffer in which to apply auto indentation.
start
This parameter specifies the absolute position of the start of the indentation range.
end
This parameter specifies the absolute position of the end of the indentation range.
tab_width
The tab_width parameter specifies how many spaces should be used for one indentation in space mode.
flags
This parameter specifies behaviors for the indentation.
Return
This call returns non-zero when the call succeeds.
Description
Applies the built in auto-indentation rule to the code in the range from +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.
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_auto_indent

bool32 app->buffer_auto_indent(
Application_Links *app,
Buffer_Summary *buffer,
int32_t start,
int32_t end,
int32_t tab_width,
Auto_Indent_Flag flags
)
Parameters
buffer
The buffer specifies the buffer in which to apply auto indentation.
start
This parameter specifies the absolute position of the start of the indentation range.
end
This parameter specifies the absolute position of the end of the indentation range.
tab_width
The tab_width parameter specifies how many spaces should be used for one indentation in space mode.
flags
This parameter specifies behaviors for the indentation.
Return
This call returns non-zero when the call succeeds.
Description
Applies the built in auto-indentation rule to the code in the range from start to end by inserting spaces or tabs at the beginning of the lines. If the buffer does not have lexing enabled or the lexing job has not -completed this function will fail.
See Also

§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 +completed this function will fail.

See Also

§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.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" +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.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 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.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. - +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.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 +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.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. +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.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 +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.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 +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.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 +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.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 +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.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 +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.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 +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.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 +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.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. - +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.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 +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.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 +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.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 +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. - +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.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. +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.59: is_fullscreen

bool32 app->is_fullscreen(
Application_Links *app
)
See Also

§3.3.59: is_fullscreen

bool32 app->is_fullscreen(
Application_Links *app
)
Description


§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 -to textual input that takes modifiers into account.

§3.4.4: Buffer_ID

typedef int32_t Buffer_ID;
Description
Buffer_ID is used to name a 4coder buffer. Each buffer has a unique id but -when a buffer is closed it's id may be recycled by future, different buffers.

§3.4.5: View_ID

typedef int32_t View_ID;
Description
View_ID is used to name a 4coder view. Each view has a unique id in -the interval [1,16].

§3.4.6: Key_Modifier

enum Key_Modifier;
Description
A Key_Modifier acts as an index for specifying modifiers in arrays.
Values
MDFR_SHIFT_INDEX
MDFR_CONTROL_INDEX
MDFR_ALT_INDEX
MDFR_CAPS_INDEX
MDFR_HOLD_INDEX
MDFR_INDEX_COUNT
MDFR_INDEX_COUNT is used to specify the number of modifiers supported.

§3.4.7: Key_Modifier_Flag

enum Key_Modifier_Flag;
Description
A Key_Modifier_Flag field is used to specify a specific state of modifiers. -Flags can be combined with bit or to specify a state with multiple modifiers.
Values
MDFR_NONE = 0x0
MDFR_NONE specifies that no modifiers are pressed.
MDFR_CTRL = 0x1
MDFR_ALT = 0x2
MDFR_SHIFT = 0x4

§3.4.8: Command_ID

enum Command_ID;
Description
A Command_ID is used as a name for commands implemented internally in 4coder.
Values
cmdid_null
cmdid_null is set aside to always be zero and is not associated with any command.
cmdid_undo
cmdid_undo performs a standard undo behavior.
cmdid_redo
cmdid_redo reperforms an edit that was undone.
cmdid_history_backward
cmdid_history_backward performs a step backwards through the file history, which includes previously lost redo branches.
cmdid_history_forward
cmdid_history_forward unperforms the previous cmdid_history_backward step if possib.e
cmdid_interactive_new
cmdid_interactive_new begins an interactive dialogue to create a new buffer.
cmdid_interactive_open
cmdid_interactive_open begins an interactive dialogue to open a file into a buffer.
cmdid_save_as
cmdid_save_as does not currently work and is likely to be removed rather that fixed.
cmdid_interactive_switch_buffer
cmdid_interactive_switch_buffer begins an interactive dialogue to choose an open buffer to swap into the active view.
cmdid_interactive_kill_buffer
cmdid_interactive_kill_buffer begins an interactive dialogue to choose an open buffer to kill.
cmdid_reopen
cmdid_reopen reloads the active buffer's associated file and discards the old buffer contents for the reloaded file.
cmdid_save
cmdid_save saves the buffer's contents into the associated file.
cmdid_kill_buffer
cmdid_kill_buffer tries to kill the active buffer.
cmdid_open_color_tweaker
cmdid_open_color_tweaker opens the theme editing GUI.
cmdid_open_config
cmdid_open_config opens the configuration menu.
cmdid_open_menu
cmdid_open_menu opens the top level menu.
cmdid_open_debug
cmdid_open_debug opens the debug information viewer mode.
cmdid_count

§3.4.9: Memory_Protect_Flags

enum Memory_Protect_Flags;
Description
TODO
Values
MemProtect_Read = 0x1
TODO
MemProtect_Write = 0x2
TODO
MemProtect_Execute = 0x4
TODO

§3.4.10: User_Input_Type_ID

enum User_Input_Type_ID;
Description
User_Input_Type_ID specifies a type of user input event.
Values
UserInputNone
UserInputNone indicates that no event has occurred.
UserInputKey
UserInputKey indicates an event which can be described by a Key_Event_Data struct.
UserInputMouse
UserInputMouse indicates an event which can be described by a Mouse_State struct.

§3.4.11: Event_Message_Type_ID

enum Event_Message_Type_ID;
Description
Event_Message_Type_ID is a part of an unfinished feature.
Values
EventMessage_NoMessage
TODO.
EventMessage_OpenView
TODO.
EventMessage_Frame
TODO.
EventMessage_CloseView
TODO.

§3.4.12: Buffer_Batch_Edit_Type

enum Buffer_Batch_Edit_Type;
Description
A Buffer_Batch_Edit_Type is a type of batch operation.
Values
BatchEdit_Normal
The BatchEdit_Normal operation is always correct but does the most work.
BatchEdit_PreserveTokens
The BatchEdit_PreserveTokens operation is one in which none of the edits add, delete, or change any tokens. - This usually applies when whitespace is being replaced with whitespace.

§3.4.13: Buffer_Setting_ID

enum Buffer_Setting_ID;
Description
A Buffer_Setting_ID names a setting in a buffer.
Values
BufferSetting_Null
BufferSetting_Null is not a valid setting, it is reserved to detect errors.
BufferSetting_Lex
The BufferSetting_Lex setting is used to determine whether to store C++ tokens - from with the buffer.
BufferSetting_WrapLine
The BufferSetting_WrapLine setting is used to determine whether a buffer prefers +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 +to textual input that takes modifiers into account.


§3.4.4: Buffer_ID

typedef int32_t Buffer_ID;
Description
Buffer_ID is used to name a 4coder buffer. Each buffer has a unique id but +when a buffer is closed it's id may be recycled by future, different buffers.


§3.4.5: View_ID

typedef int32_t View_ID;
Description
View_ID is used to name a 4coder view. Each view has a unique id in +the interval [1,16].


§3.4.6: Key_Modifier

enum Key_Modifier;
Description
A Key_Modifier acts as an index for specifying modifiers in arrays.

Values
MDFR_SHIFT_INDEX
MDFR_CONTROL_INDEX
MDFR_ALT_INDEX
MDFR_CAPS_INDEX
MDFR_HOLD_INDEX
MDFR_INDEX_COUNT
MDFR_INDEX_COUNT is used to specify the number of modifiers supported.


§3.4.7: Key_Modifier_Flag

enum Key_Modifier_Flag;
Description
A Key_Modifier_Flag field is used to specify a specific state of modifiers. +Flags can be combined with bit or to specify a state with multiple modifiers.

Values
MDFR_NONE = 0x0
MDFR_NONE specifies that no modifiers are pressed.

MDFR_CTRL = 0x1
MDFR_ALT = 0x2
MDFR_SHIFT = 0x4

§3.4.8: Command_ID

enum Command_ID;
Description
A Command_ID is used as a name for commands implemented internally in 4coder.

Values
cmdid_null
cmdid_null is set aside to always be zero and is not associated with any command.

cmdid_undo
cmdid_undo performs a standard undo behavior.

cmdid_redo
cmdid_redo reperforms an edit that was undone.

cmdid_history_backward
cmdid_history_backward performs a step backwards through the file history, which includes previously lost redo branches.

cmdid_history_forward
cmdid_history_forward unperforms the previous cmdid_history_backward step if possib.e

cmdid_interactive_new
cmdid_interactive_new begins an interactive dialogue to create a new buffer.

cmdid_interactive_open
cmdid_interactive_open begins an interactive dialogue to open a file into a buffer.

cmdid_save_as
cmdid_save_as does not currently work and is likely to be removed rather that fixed.

cmdid_interactive_switch_buffer
cmdid_interactive_switch_buffer begins an interactive dialogue to choose an open buffer to swap into the active view.

cmdid_interactive_kill_buffer
cmdid_interactive_kill_buffer begins an interactive dialogue to choose an open buffer to kill.

cmdid_reopen
cmdid_reopen reloads the active buffer's associated file and discards the old buffer contents for the reloaded file.

cmdid_save
cmdid_save saves the buffer's contents into the associated file.

cmdid_kill_buffer
cmdid_kill_buffer tries to kill the active buffer.

cmdid_open_color_tweaker
cmdid_open_color_tweaker opens the theme editing GUI.

cmdid_open_config
cmdid_open_config opens the configuration menu.

cmdid_open_menu
cmdid_open_menu opens the top level menu.

cmdid_open_debug
cmdid_open_debug opens the debug information viewer mode.

cmdid_count

§3.4.9: Memory_Protect_Flags

enum Memory_Protect_Flags;
Description
TODO

Values
MemProtect_Read = 0x1
TODO

MemProtect_Write = 0x2
TODO

MemProtect_Execute = 0x4
TODO


§3.4.10: User_Input_Type_ID

enum User_Input_Type_ID;
Description
User_Input_Type_ID specifies a type of user input event.

Values
UserInputNone
UserInputNone indicates that no event has occurred.

UserInputKey
UserInputKey indicates an event which can be described by a Key_Event_Data struct.

UserInputMouse
UserInputMouse indicates an event which can be described by a Mouse_State struct.


§3.4.11: Event_Message_Type_ID

enum Event_Message_Type_ID;
Description
Event_Message_Type_ID is a part of an unfinished feature.

Values
EventMessage_NoMessage
TODO.

EventMessage_OpenView
TODO.

EventMessage_Frame
TODO.

EventMessage_CloseView
TODO.


§3.4.12: Buffer_Batch_Edit_Type

enum Buffer_Batch_Edit_Type;
Description
A Buffer_Batch_Edit_Type is a type of batch operation.

Values
BatchEdit_Normal
The BatchEdit_Normal operation is always correct but does the most work.

BatchEdit_PreserveTokens
The BatchEdit_PreserveTokens operation is one in which none of the edits add, delete, or change any tokens. + This usually applies when whitespace is being replaced with whitespace.


§3.4.13: Buffer_Setting_ID

enum Buffer_Setting_ID;
Description
A Buffer_Setting_ID names a setting in a buffer.

Values
BufferSetting_Null
BufferSetting_Null is not a valid setting, it is reserved to detect errors.

BufferSetting_Lex
The BufferSetting_Lex setting is used to determine whether to store C++ tokens + from with the buffer.

BufferSetting_WrapLine
The BufferSetting_WrapLine setting is used to determine whether a buffer prefers to be viewed with wrapped lines, individual views can be set to override this value after - being tied to the buffer.
BufferSetting_MapID
The BufferSetting_MapID setting specifies the id of the command map that should be - active when a buffer is active.
BufferSetting_Eol
The BufferSetting_Eol setting specifies how line ends should be saved to the backing file. - A 1 indicates dos endings "\r\n" and a 0 indicates nix endings "\n".
BufferSetting_Unimportant
The BufferSetting_Unimportant setting marks a buffer so that it's dirty state will be completely + being tied to the buffer.

BufferSetting_MapID
The BufferSetting_MapID setting specifies the id of the command map that should be + active when a buffer is active.

BufferSetting_Eol
The BufferSetting_Eol setting specifies how line ends should be saved to the backing file. + A 1 indicates dos endings "\r\n" and a 0 indicates nix endings "\n".

BufferSetting_Unimportant
The BufferSetting_Unimportant setting marks a buffer so that it's dirty state will be completely ignored. This means the "dirty" star is hidden and the buffer can be closed without presenting an - "are you sure" dialogue screen.
BufferSetting_ReadOnly
The BufferSetting_ReadOnly setting marks a buffer so that it can only be returned from buffer - access calls that include an AccessProtected flag.

§3.4.14: View_Setting_ID

enum View_Setting_ID;
Description
A View_Setting_ID names a setting in a view.
Values
ViewSetting_Null
ViewSetting_Null is not a valid setting, it is reserved to detect errors.
ViewSetting_WrapLine
The ViewSetting_WrapLine setting determines whether the view applies line wrapping + "are you sure" dialogue screen.

BufferSetting_ReadOnly
The BufferSetting_ReadOnly setting marks a buffer so that it can only be returned from buffer + access calls that include an AccessProtected flag.


§3.4.14: View_Setting_ID

enum View_Setting_ID;
Description
A View_Setting_ID names a setting in a view.

Values
ViewSetting_Null
ViewSetting_Null is not a valid setting, it is reserved to detect errors.

ViewSetting_WrapLine
The ViewSetting_WrapLine setting determines whether the view applies line wrapping at the border of the panel for long lines. Whenever the view switches to a new buffer it - will reset this setting to match the 'preferred' line wrapping setting of the buffer.
ViewSetting_ShowWhitespace
The ViewSetting_ShowWhitespace setting determines whether the view highlights - whitespace in a file. Whenever the view switches to a new buffer this setting is turned off.
ViewSetting_ShowScrollbar
The ViewSetting_ShowScrollbar setting determines whether a scroll bar is - attached to a view in it's scrollable section.

§3.4.15: Buffer_Create_Flag

enum Buffer_Create_Flag;
Description
A Buffer_Create_Flag field specifies how a buffer should be created.
Values
BufferCreate_Background = 0x1
BufferCreate_Background is not currently implemented.
BufferCreate_AlwaysNew = 0x2
When BufferCreate_AlwaysNew is set it indicates the buffer should be - cleared to empty even if it's associated file already has content.
BufferCreate_NeverNew = 0x4
When BufferCreate_NeverNew is set it indicates that the buffer should - only be created if it is an existing file or an open buffer.

§3.4.16: Buffer_Kill_Flag

enum Buffer_Kill_Flag;
Description
A Buffer_Kill_Flag field specifies how a buffer should be killed.
Values
BufferKill_Background = 0x1
BufferKill_Background is not currently implemented.
BufferKill_AlwaysKill = 0x2
When BufferKill_AlwaysKill is set it indicates the buffer should be killed - without asking, even when the buffer is dirty.

§3.4.17: Access_Flag

enum Access_Flag;
Description
An Access_Flag field specifies what sort of permission you grant to an + will reset this setting to match the 'preferred' line wrapping setting of the buffer.

ViewSetting_ShowWhitespace
The ViewSetting_ShowWhitespace setting determines whether the view highlights + whitespace in a file. Whenever the view switches to a new buffer this setting is turned off.

ViewSetting_ShowScrollbar
The ViewSetting_ShowScrollbar setting determines whether a scroll bar is + attached to a view in it's scrollable section.


§3.4.15: Buffer_Create_Flag

enum Buffer_Create_Flag;
Description
A Buffer_Create_Flag field specifies how a buffer should be created.

Values
BufferCreate_Background = 0x1
BufferCreate_Background is not currently implemented.

BufferCreate_AlwaysNew = 0x2
When BufferCreate_AlwaysNew is set it indicates the buffer should be + cleared to empty even if it's associated file already has content.

BufferCreate_NeverNew = 0x4
When BufferCreate_NeverNew is set it indicates that the buffer should + only be created if it is an existing file or an open buffer.


§3.4.16: Buffer_Kill_Flag

enum Buffer_Kill_Flag;
Description
A Buffer_Kill_Flag field specifies how a buffer should be killed.

Values
BufferKill_Background = 0x1
BufferKill_Background is not currently implemented.

BufferKill_AlwaysKill = 0x2
When BufferKill_AlwaysKill is set it indicates the buffer should be killed + without asking, even when the buffer is dirty.


§3.4.17: Access_Flag

enum Access_Flag;
Description
An Access_Flag field specifies what sort of permission you grant to an access call. An access call is usually one the returns a summary struct. If a 4coder object has a particular protection flag set and the corresponding bit is not set in the access field, that 4coder object is hidden. On the other hand if a protection flag is set in the access parameter and the object does not have -that protection flag, the object is still returned from the access call.
Values
AccessOpen = 0x0
AccessOpen does not include any bits, it indicates that the access should - only return objects that have no protection flags set.
AccessProtected = 0x1
AccessProtected is set on buffers and views that are "read only" such as +that protection flag, the object is still returned from the access call.

Values
AccessOpen = 0x0
AccessOpen does not include any bits, it indicates that the access should + only return objects that have no protection flags set.

AccessProtected = 0x1
AccessProtected is set on buffers and views that are "read only" such as the output from an app->exec_system_command call such as *build*. This is to prevent - the user from accidentally editing output that they might prefer to keep in tact.
AccessHidden = 0x2
AccessHidden is set on any view that is not currently showing it's file, for - instance because it is navigating the file system to open a file.
AccessAll = 0xFF
AccessAll is a catchall access for cases where an access call should always - return an object no matter what it's protection flags are.

§3.4.18: Seek_Boundary_Flag

enum Seek_Boundary_Flag;
Description
A Seek_Boundary_Flag field specifies a set of "boundary" types used in seeks for the -beginning or end of different types of words.
Values
BoundaryWhitespace = 0x1
BoundaryToken = 0x2
BoundaryAlphanumeric = 0x4
BoundaryCamelCase = 0x8

§3.4.19: Command_Line_Input_Flag

enum Command_Line_Input_Flag;
Description
A Command_Line_Input_Flag field specifies the behavior of a call to a command line interface.
Values
CLI_OverlapWithConflict = 0x1
If CLI_OverlapWithConflict is set if output buffer of the new command is already + the user from accidentally editing output that they might prefer to keep in tact.

AccessHidden = 0x2
AccessHidden is set on any view that is not currently showing it's file, for + instance because it is navigating the file system to open a file.

AccessAll = 0xFF
AccessAll is a catchall access for cases where an access call should always + return an object no matter what it's protection flags are.


§3.4.18: Seek_Boundary_Flag

enum Seek_Boundary_Flag;
Description
A Seek_Boundary_Flag field specifies a set of "boundary" types used in seeks for the +beginning or end of different types of words.

Values
BoundaryWhitespace = 0x1
BoundaryToken = 0x2
BoundaryAlphanumeric = 0x4
BoundaryCamelCase = 0x8

§3.4.19: Command_Line_Input_Flag

enum Command_Line_Input_Flag;
Description
A Command_Line_Input_Flag field specifies the behavior of a call to a command line interface.

Values
CLI_OverlapWithConflict = 0x1
If CLI_OverlapWithConflict is set if output buffer of the new command is already in use by another command which is still executing, the older command relinquishes control of the buffer and both operate simultaneously with only the newer command outputting to - the buffer.
CLI_AlwaysBindToView = 0x2
If CLI_AlwaysBindToView is set the output buffer will always be set in the active - view even if it is already set in another open view.
CLI_CursorAtEnd = 0x4
If CLI_CursorAtEnd is set the cursor will be kept at the end of the output buffer, - otherwise the cursor is kept at the beginning.

§3.4.20: Auto_Indent_Flag

enum Auto_Indent_Flag;
Description
An Auto_Indent_Flag field specifies the behavior of an auto indentation operation.
Values
AutoIndent_ClearLine = 0x1
If AutoIndent_ClearLine is set, then any line that is only whitespace will + the buffer.

CLI_AlwaysBindToView = 0x2
If CLI_AlwaysBindToView is set the output buffer will always be set in the active + view even if it is already set in another open view.

CLI_CursorAtEnd = 0x4
If CLI_CursorAtEnd is set the cursor will be kept at the end of the output buffer, + otherwise the cursor is kept at the beginning.


§3.4.20: Auto_Indent_Flag

enum Auto_Indent_Flag;
Description
An Auto_Indent_Flag field specifies the behavior of an auto indentation operation.

Values
AutoIndent_ClearLine = 0x1
If AutoIndent_ClearLine is set, then any line that is only whitespace will be cleared to contain nothing at all. otherwise the line is filled with whitespace - to match the nearby indentation.
AutoIndent_UseTab = 0x2
If AutoIndent_UseTab is set, then when putting in leading whitespace to align + to match the nearby indentation.

AutoIndent_UseTab = 0x2
If AutoIndent_UseTab is set, then when putting in leading whitespace to align code, as many tabs will be used as possible until the fine grained control of spaces - is needed to finish the alignment.

§3.4.21: Set_Buffer_Flag

enum Set_Buffer_Flag;
Description
A Set_Buffer_Flag field specifies the behavior of an operation that sets the buffer of a view.
Values
SetBuffer_KeepOriginalGUI = 0x1
If SetBuffer_KeepOriginalGUI then when the file is set, the view will not switch to it + is needed to finish the alignment.


§3.4.21: Set_Buffer_Flag

enum Set_Buffer_Flag;
Description
A Set_Buffer_Flag field specifies the behavior of an operation that sets the buffer of a view.

Values
SetBuffer_KeepOriginalGUI = 0x1
If SetBuffer_KeepOriginalGUI then when the file is set, the view will not switch to it if some other GUI was currently up, otherwise any GUI that is up is closed and the view - switches to the file.

§3.4.22: Input_Type_Flag

enum Input_Type_Flag;
Description
A Input_Type_Flag field specifies a set of input event types.
Values
EventOnAnyKey = 0x1
If EventOnAnyKey is set, all keyboard events are included in the set.
EventOnEsc = 0x2
If EventOnEsc is set, any press of the escape key is included in the set.
EventOnLeftButton = 0x4
If EventOnLeftButton is set, left clicks are included in the set.
EventOnRightButton = 0x8
If EventOnRightButton is set, right clicks are included in the set.
EventOnWheel = 0x10
If EventOnWheel is set, any wheel movement is included in the set.
EventOnButton = (EventOnLeftButton | EventOnRightButton | EventOnWheel)
If EventOnButton is set, all mouse button events are included in the set.
EventOnMouseMove = 0x20
This is not totally implemented yet.
EventOnMouse = (EventOnButton | EventOnMouseMove)
This is not totally implemented yet.
EventAll = 0xFF
EventAll is a catch all name for including all possible events in the set.

§3.4.23: Mouse_Cursor_Show_Type

enum Mouse_Cursor_Show_Type;
Description
A Mouse_Cursor_Show_Type value specifes a mode for 4coder to handle the mouse cursor.
Values
MouseCursorShow_Never
The MouseCursorShow_Never mode never shows the cursor.
MouseCursorShow_Always
The MouseCursorShow_Never mode always shows the cursor.

§3.4.24: Buffer_Seek_Type

enum Buffer_Seek_Type;
Description
The Buffer_Seek_Type is is used in a Buffer_Seek to identify which -coordinates are suppose to be used for the seek.
Values
buffer_seek_pos
This value indicates absolute positioning where positions are measured as the number of bytes from the start of the file.
buffer_seek_wrapped_xy
This value indicates xy positioning with wrapped lines where the x and y values are in pixels.
buffer_seek_unwrapped_xy
This value indicates xy positioning with unwrapped lines where the x and y values are in pixels.
buffer_seek_line_char
This value indicates line-character, or line-column positioning. These coordinates are 1 based to match standard line numbering.
See Also

§3.4.25: View_Split_Position

enum View_Split_Position;
Description
A View_Split_Position specifies where a new view should be placed as a result of -a view split operation.
Values
ViewSplit_Top
This value indicates that the new view should be above the existing view.
ViewSplit_Bottom
This value indicates that the new view should be below the existing view.
ViewSplit_Left
This value indicates that the new view should be left of the existing view.
ViewSplit_Right
This value indicates that the new view should be right of the existing view.

§3.4.26: Generic_Command

union Generic_Command {
Command_ID cmdid;
Custom_Command_Function * command;
};
Description
Generic_Command acts as a name for a command, and can name an -internal command or a custom command.
Fields
cmdid
If this Generic_Command represents an internal command the cmdid field - will have a value less than cmdid_count, and this field is the command id for the command.
command
If this Generic_Command does not represent an internal command the command - field is the pointer to the custom command..

§3.4.27: Key_Event_Data

struct Key_Event_Data {
Key_Code keycode;
Key_Code character;
Key_Code character_no_caps_lock;
char modifiers[MDFR_INDEX_COUNT];
};
Description
Key_Event_Data describes a key event, including the + switches to the file.


§3.4.22: Input_Type_Flag

enum Input_Type_Flag;
Description
A Input_Type_Flag field specifies a set of input event types.

Values
EventOnAnyKey = 0x1
If EventOnAnyKey is set, all keyboard events are included in the set.

EventOnEsc = 0x2
If EventOnEsc is set, any press of the escape key is included in the set.

EventOnLeftButton = 0x4
If EventOnLeftButton is set, left clicks are included in the set.

EventOnRightButton = 0x8
If EventOnRightButton is set, right clicks are included in the set.

EventOnWheel = 0x10
If EventOnWheel is set, any wheel movement is included in the set.

EventOnButton = (EventOnLeftButton | EventOnRightButton | EventOnWheel)
If EventOnButton is set, all mouse button events are included in the set.

EventOnMouseMove = 0x20
This is not totally implemented yet.

EventOnMouse = (EventOnButton | EventOnMouseMove)
This is not totally implemented yet.

EventAll = 0xFF
EventAll is a catch all name for including all possible events in the set.


§3.4.23: Mouse_Cursor_Show_Type

enum Mouse_Cursor_Show_Type;
Description
A Mouse_Cursor_Show_Type value specifes a mode for 4coder to handle the mouse cursor.

Values
MouseCursorShow_Never
The MouseCursorShow_Never mode never shows the cursor.

MouseCursorShow_Always
The MouseCursorShow_Never mode always shows the cursor.


§3.4.24: Buffer_Seek_Type

enum Buffer_Seek_Type;
Description
The Buffer_Seek_Type is is used in a Buffer_Seek to identify which +coordinates are suppose to be used for the seek.

Values
buffer_seek_pos
This value indicates absolute positioning where positions are measured as the number of bytes from the start of the file.

buffer_seek_wrapped_xy
This value indicates xy positioning with wrapped lines where the x and y values are in pixels.

buffer_seek_unwrapped_xy
This value indicates xy positioning with unwrapped lines where the x and y values are in pixels.

buffer_seek_line_char
This value indicates line-character, or line-column positioning. These coordinates are 1 based to match standard line numbering.

See Also

§3.4.25: View_Split_Position

enum View_Split_Position;
Description
A View_Split_Position specifies where a new view should be placed as a result of +a view split operation.

Values
ViewSplit_Top
This value indicates that the new view should be above the existing view.

ViewSplit_Bottom
This value indicates that the new view should be below the existing view.

ViewSplit_Left
This value indicates that the new view should be left of the existing view.

ViewSplit_Right
This value indicates that the new view should be right of the existing view.


§3.4.26: Generic_Command

union Generic_Command {
Command_ID cmdid;
Custom_Command_Function * command;
};
Description
Generic_Command acts as a name for a command, and can name an +internal command or a custom command.

Fields
cmdid
If this Generic_Command represents an internal command the cmdid field + will have a value less than cmdid_count, and this field is the command id for the command.

command
If this Generic_Command does not represent an internal command the command + field is the pointer to the custom command..


§3.4.27: Key_Event_Data

struct Key_Event_Data {
Key_Code keycode;
Key_Code character;
Key_Code character_no_caps_lock;
char modifiers[MDFR_INDEX_COUNT];
};
Description
Key_Event_Data describes a key event, including the translation to a character, the translation to a character ignoring the state of caps lock, and an array of all the modifiers that were pressed -at the time of the event.
Fields
keycode
This field is the raw keycode which is always non-zero in valid key events.
character
This field is the keycode after translation to a character, this is 0 if there is no translation.
character_no_caps_lock
This field is like the field character, except that the state of caps lock is ignored in the translation.
modifiers
This field is an array indicating the state of modifiers at the time of the key press. +at the time of the event.

Fields
keycode
This field is the raw keycode which is always non-zero in valid key events.

character
This field is the keycode after translation to a character, this is 0 if there is no translation.

character_no_caps_lock
This field is like the field character, except that the state of caps lock is ignored in the translation.

modifiers
This field is an array indicating the state of modifiers at the time of the key press. The array is indexed using the values of Key_Modifier. A 1 indicates that the corresponding - modifier was held, and a 0 indicates that it was not held.

§3.4.28: Mouse_State

struct Mouse_State {
char l;
char r;
char press_l;
char press_r;
char release_l;
char release_r;
char wheel;
char out_of_window;
int32_t x;
int32_t y;
};
Description
Mouse_State describes an entire mouse state complete with the position, + modifier was held, and a 0 indicates that it was not held.


§3.4.28: Mouse_State

struct Mouse_State {
char l;
char r;
char press_l;
char press_r;
char release_l;
char release_r;
char wheel;
char out_of_window;
int32_t x;
int32_t y;
};
Description
Mouse_State describes an entire mouse state complete with the position, left and right button states, the wheel state, and whether or not the -mouse if in the window.
Fields
l
This field indicates that the left button is held.
r
This field indicates that the right button is held.
press_l
This field indicates that the left button was pressed this frame.
press_r
This field indicates that the right button was pressed this frame.
release_l
This field indicates that the left button was released this frame.
release_r
This field indicates that the right button was released this frame.
wheel
This field is 0 when the wheel has not moved, it is 1 for a downward motion and -1 for an upward motion.
out_of_window
This field indicates that the mouse is outside of the window.
x
This field contains the x position of the mouse relative to the window where the left side is 0.
y
This field contains the y position of the mouse relative to the window where the top side is 0.

§3.4.29: Range

union Range {
struct {
int32_t min;
int32_t max;
};
struct {
int32_t start;
int32_t end;
};
};
Description
Range describes an integer range typically used for ranges within a buffer. +mouse if in the window.

Fields
l
This field indicates that the left button is held.

r
This field indicates that the right button is held.

press_l
This field indicates that the left button was pressed this frame.

press_r
This field indicates that the right button was pressed this frame.

release_l
This field indicates that the left button was released this frame.

release_r
This field indicates that the right button was released this frame.

wheel
This field is 0 when the wheel has not moved, it is 1 for a downward motion and -1 for an upward motion.

out_of_window
This field indicates that the mouse is outside of the window.

x
This field contains the x position of the mouse relative to the window where the left side is 0.

y
This field contains the y position of the mouse relative to the window where the top side is 0.


§3.4.29: Range

union Range {
struct {
int32_t min;
int32_t max;
};
struct {
int32_t start;
int32_t end;
};
};
Description
Range describes an integer range typically used for ranges within a buffer. Ranges tend are usually not passed as a Range struct into the API, but this -struct is used to return ranges. - -Throughout the API ranges are thought of in the form [min,max
Fields
min
This is the smaller value in the range, it is also the 'start'.
max
This is the larger value in the range, it is also the 'end'.
start
This is the start of the range, it is also the 'min'.
end
This is the end of the range, it is also the 'max'.

§3.4.30: File_Info

struct File_Info {
char * filename;
int32_t filename_len;
int32_t folder;
};
Description
File_Info describes the name and type of a file.
Fields
filename
This field is a null terminated string specifying the name of the file.
filename_len
This field specifies the length of the filename string not counting the null terminator.
folder
This field indicates that the description is for a folder not a file.
See Also

§3.4.31: File_List

struct File_List {
void * block;
File_Info * infos;
int32_t count;
int32_t block_size;
};
Description
File_List is a list of File_Info structs.
Fields
block
This field is for inernal use.
infos
This field is an array of File_Info structs.
count
This field specifies the number of struts in the info array.
block_size
This field is for internal use.

§3.4.32: Buffer_Identifier

struct Buffer_Identifier {
char * name;
int32_t name_len;
int32_t id;
};
Description
Buffer_Identifier acts as a loosely typed description of a buffer that -can either be a name or an id. If the
Fields
name
This field is the name of the buffer; it need not be null terminated. - If id is specified this pointer should be NULL.
name_len
This field specifies the length of the name string.
id
This field is the id of the buffer. If name is specified this should be 0.

§3.4.33: GUI_Scroll_Vars

struct GUI_Scroll_Vars {
float scroll_y;
int32_t target_y;
int32_t prev_target_y;
float scroll_x;
int32_t target_x;
int32_t prev_target_x;
};
Description
This struct is a part of an incomplete feature.
Fields
scroll_y
TODO
target_y
TODO
prev_target_y
TODO
scroll_x
TODO
target_x
TODO
prev_target_x
TODO

§3.4.34: Full_Cursor

struct Full_Cursor {
int32_t pos;
int32_t line;
int32_t character;
float unwrapped_x;
float unwrapped_y;
float wrapped_x;
float wrapped_y;
};
Description
Full_Cursor describes the position of a cursor in every buffer +struct is used to return ranges.

+Throughout the API ranges are thought of in the form [min,max

Fields
min
This is the smaller value in the range, it is also the 'start'.

max
This is the larger value in the range, it is also the 'end'.

start
This is the start of the range, it is also the 'min'.

end
This is the end of the range, it is also the 'max'.


§3.4.30: File_Info

struct File_Info {
char * filename;
int32_t filename_len;
int32_t folder;
};
Description
File_Info describes the name and type of a file.

Fields
filename
This field is a null terminated string specifying the name of the file.

filename_len
This field specifies the length of the filename string not counting the null terminator.

folder
This field indicates that the description is for a folder not a file.

See Also

§3.4.31: File_List

struct File_List {
void * block;
File_Info * infos;
int32_t count;
int32_t block_size;
};
Description
File_List is a list of File_Info structs.

Fields
block
This field is for inernal use.

infos
This field is an array of File_Info structs.

count
This field specifies the number of struts in the info array.

block_size
This field is for internal use.


§3.4.32: Buffer_Identifier

struct Buffer_Identifier {
char * name;
int32_t name_len;
int32_t id;
};
Description
Buffer_Identifier acts as a loosely typed description of a buffer that +can either be a name or an id. If the

Fields
name
This field is the name of the buffer; it need not be null terminated. + If id is specified this pointer should be NULL.

name_len
This field specifies the length of the name string.

id
This field is the id of the buffer. If name is specified this should be 0.


§3.4.33: GUI_Scroll_Vars

struct GUI_Scroll_Vars {
float scroll_y;
int32_t target_y;
int32_t prev_target_y;
float scroll_x;
int32_t target_x;
int32_t prev_target_x;
};
Description
This struct is a part of an incomplete feature.

Fields
scroll_y
TODO

target_y
TODO

prev_target_y
TODO

scroll_x
TODO

target_x
TODO

prev_target_x
TODO


§3.4.34: Full_Cursor

struct Full_Cursor {
int32_t pos;
int32_t line;
int32_t character;
float unwrapped_x;
float unwrapped_y;
float wrapped_x;
float wrapped_y;
};
Description
Full_Cursor describes the position of a cursor in every buffer coordinate system supported by 4coder. This cursor type requires that -the buffer is associated with a view to give the x/y values meaning.
Fields
pos
This field contains the cursor's position in absolute positioning.
line
This field contains the number of the line where the cursor is located. This field is one based.
character
This field contains the number of the column where the cursor is located. This field is one based.
unwrapped_x
This field contains the x position measured with unwrapped lines.
unwrapped_y
This field contains the y position measured with unwrapped lines.
wrapped_x
This field contains the x position measured with wrapped lines.
wrapped_y
This field contains the y position measured with wrapped lines.
See Also

§3.4.35: Partial_Cursor

struct Partial_Cursor {
int32_t pos;
int32_t line;
int32_t character;
};
Description
Partial_Cursor describes the position of a cursor in all of +the buffer is associated with a view to give the x/y values meaning.

Fields
pos
This field contains the cursor's position in absolute positioning.

line
This field contains the number of the line where the cursor is located. This field is one based.

character
This field contains the number of the column where the cursor is located. This field is one based.

unwrapped_x
This field contains the x position measured with unwrapped lines.

unwrapped_y
This field contains the y position measured with unwrapped lines.

wrapped_x
This field contains the x position measured with wrapped lines.

wrapped_y
This field contains the y position measured with wrapped lines.

See Also

§3.4.35: Partial_Cursor

struct Partial_Cursor {
int32_t pos;
int32_t line;
int32_t character;
};
Description
Partial_Cursor describes the position of a cursor in all of the coordinate systems that a invariant to the View. In other words the coordinate systems available here can be used on a buffer that is -not currently associated with a View.
Fields
pos
This field contains the cursor's position in absolute positioning.
line
This field contains the number of the line where the cursor is located. This field is one based.
character
This field contains the number of the column where the cursor is located. This field is one based.
See Also

§3.4.36: Buffer_Seek

struct Buffer_Seek {
Buffer_Seek_Type type;
union {
struct {
int32_t pos;
};
struct {
bool32 round_down;
float x;
float y;
};
struct {
int32_t line;
int32_t character;
};
};
};
Description
Buffer_Seek describes the destination of a seek operation. There are helpers -for concisely creating Buffer_Seek structs. They can be found in 4coder_buffer_types.h.
Fields
type
The type field determines the coordinate system of the seek operation.
pos
The pos field specified the pos when the seek is in absolute position.
round_down
For xy coordinate seeks, rounding down means that any x in the box of the +not currently associated with a View.

Fields
pos
This field contains the cursor's position in absolute positioning.

line
This field contains the number of the line where the cursor is located. This field is one based.

character
This field contains the number of the column where the cursor is located. This field is one based.

See Also

§3.4.36: Buffer_Seek

struct Buffer_Seek {
Buffer_Seek_Type type;
union {
struct {
int32_t pos;
};
struct {
bool32 round_down;
float x;
float y;
};
struct {
int32_t line;
int32_t character;
};
};
};
Description
Buffer_Seek describes the destination of a seek operation. There are helpers +for concisely creating Buffer_Seek structs. They can be found in 4coder_buffer_types.h.

Fields
type
The type field determines the coordinate system of the seek operation.

pos
The pos field specified the pos when the seek is in absolute position.

round_down
For xy coordinate seeks, rounding down means that any x in the box of the character lands on that character. For instance when clicking rounding down is the user's expected behavior. Not rounding down means that the right hand portion of the character's box, which is closer to the next character, will land on that next character. The unrounded behavior is the expected behavior when moving vertically - and keeping the preferred x.
x
The x coordinate for xy type seeks.
y
The y coordinate for xy type seeks.
line
The line number of a line-character type seek.
character
The character number of a line-character type seek.
See Also

§3.4.37: Buffer_Edit

struct Buffer_Edit {
int32_t str_start;
int32_t len;
int32_t start;
int32_t end;
};
Description
Buffer_Edit describes a range of a buffer and string to replace that range. + and keeping the preferred x.

x
The x coordinate for xy type seeks.

y
The y coordinate for xy type seeks.

line
The line number of a line-character type seek.

character
The character number of a line-character type seek.

See Also

§3.4.37: Buffer_Edit

struct Buffer_Edit {
int32_t str_start;
int32_t len;
int32_t start;
int32_t end;
};
Description
Buffer_Edit describes a range of a buffer and string to replace that range. A Buffer_Edit has to be paired with a string that contains the actual text that -will be replaced into the buffer.
Fields
str_start
The str_start field specifies the first character in the accompanying string that corresponds with this edit.
len
The len field specifies the length of the string being written into the buffer.
start
The start field specifies the start of the range in the buffer to replace in absolute position.
end
The end field specifies one past the end of the range in the buffer to replace in absolute position.

§3.4.38: Buffer_Summary

struct Buffer_Summary {
bool32 exists;
bool32 ready;
int32_t buffer_id;
Access_Flag lock_flags;
int32_t size;
int32_t line_count;
char * file_name;
int32_t file_name_len;
char * buffer_name;
int32_t buffer_name_len;
bool32 is_lexed;
int32_t map_id;
bool32 unwrapped_lines;
};
Description
Buffer_Summary acts as a handle to a buffer and describes the state of the buffer.
Fields
exists
This field indicates whether the Buffer_Summary describes a buffer that is open in 4coder. - When this field is false the summary is referred to as a "null summary".
ready
If this is not a null summary, this field indicates whether the buffer has finished loading.
buffer_id
If this is not a null summary this field is the id of the associated buffer. - If this is a null summary then buffer_id is 0.
lock_flags
If this is not a null summary, this field contains flags describing the protection status of the buffer.
size
If this is not a null summary, this field specifies the size of the text in the buffer.
line_count
If this is not a null summary, this field specifies the number of lines in the buffer.
file_name
If this is not a null summary, this field specifies the file name associated to this buffer.
file_name_len
This field specifies the length of the file_name string.
buffer_name
If this is not a null summary, this field specifies the name of the buffer.
buffer_name_len
This field specifies the length of the buffer_name string.
is_lexed
If this is not a null summary, this field indicates whether the buffer is set to lex tokens.
map_id
If this is not a null summary, this field specifies the id of the command map for this buffer.
unwrapped_lines
If this is not a null summary, this field indicates whether the buffer 'prefers' wrapped lines.
See Also

§3.4.39: View_Summary

struct View_Summary {
bool32 exists;
int32_t view_id;
int32_t buffer_id;
Access_Flag lock_flags;
Full_Cursor cursor;
Full_Cursor mark;
float preferred_x;
float line_height;
bool32 unwrapped_lines;
bool32 show_whitespace;
i32_Rect file_region;
GUI_Scroll_Vars scroll_vars;
};
Description
View_Summary acts as a handle to a view and describes the state of the view.
Fields
exists
This field indicates whether the View_Summary describes a view that is open in 4coder. - When this field is false the summary is referred to as a "null summary".
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. +will be replaced into the buffer.

Fields
str_start
The str_start field specifies the first character in the accompanying string that corresponds with this edit.

len
The len field specifies the length of the string being written into the buffer.

start
The start field specifies the start of the range in the buffer to replace in absolute position.

end
The end field specifies one past the end of the range in the buffer to replace in absolute position.


§3.4.38: Buffer_Summary

struct Buffer_Summary {
bool32 exists;
bool32 ready;
int32_t buffer_id;
Access_Flag lock_flags;
int32_t size;
int32_t line_count;
char * file_name;
int32_t file_name_len;
char * buffer_name;
int32_t buffer_name_len;
bool32 is_lexed;
int32_t map_id;
bool32 unwrapped_lines;
};
Description
Buffer_Summary acts as a handle to a buffer and describes the state of the buffer.

Fields
exists
This field indicates whether the Buffer_Summary describes a buffer that is open in 4coder. + When this field is false the summary is referred to as a "null summary".

ready
If this is not a null summary, this field indicates whether the buffer has finished loading.

buffer_id
If this is not a null summary this field is the id of the associated buffer. + If this is a null summary then buffer_id is 0.

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

size
If this is not a null summary, this field specifies the size of the text in the buffer.

line_count
If this is not a null summary, this field specifies the number of lines in the buffer.

file_name
If this is not a null summary, this field specifies the file name associated to this buffer.

file_name_len
This field specifies the length of the file_name string.

buffer_name
If this is not a null summary, this field specifies the name of the buffer.

buffer_name_len
This field specifies the length of the buffer_name string.

is_lexed
If this is not a null summary, this field indicates whether the buffer is set to lex tokens.

map_id
If this is not a null summary, this field specifies the id of the command map for this buffer.

unwrapped_lines
If this is not a null summary, this field indicates whether the buffer 'prefers' wrapped lines.

See Also

§3.4.39: View_Summary

struct View_Summary {
bool32 exists;
int32_t view_id;
int32_t buffer_id;
Access_Flag lock_flags;
Full_Cursor cursor;
Full_Cursor mark;
float preferred_x;
float line_height;
bool32 unwrapped_lines;
bool32 show_whitespace;
i32_Rect file_region;
GUI_Scroll_Vars scroll_vars;
};
Description
View_Summary acts as a handle to a view and describes the state of the view.

Fields
exists
This field indicates whether the View_Summary describes a view that is open in 4coder. + When this field is false the summary is referred to as a "null summary".

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. 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.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. 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.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, 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.20: 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.21: 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.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, 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.45: 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.46: 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.47: 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.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. 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.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. 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.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. 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.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. 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.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. 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.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 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.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 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.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 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.80: 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.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. 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.83: 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.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. 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.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 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.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. 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

-

§5 Lexer Library

§5.1 Lexer Intro

Coming Soon

§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_Stack *token_stack,
int32_t pos
)
No documentation generated for this function.

§5.4.2: cpp_shift_token_starts

void cpp_shift_token_starts(
Cpp_Token_Stack *stack,
int32_t from_token_i,
int32_t shift_amount
)
No documentation generated for this function.

§5.4.3: cpp_pp_directive_to_state

Lex_PP_State cpp_pp_directive_to_state(
Cpp_Token_Type type
)
No documentation generated for this function.

§5.4.4: cpp_place_token_nonalloc

int32_t cpp_place_token_nonalloc(
Cpp_Token *out_tokens,
int32_t token_i,
Cpp_Token token
)
No documentation generated for this function.

§5.4.5: cpp_push_token_nonalloc

bool cpp_push_token_nonalloc(
Cpp_Token_Stack *out_tokens,
Cpp_Token token
)
No documentation generated for this function.

§5.4.6: lex_data_init

Lex_Data lex_data_init(
char *tb
)
No documentation generated for this function.

§5.4.7: cpp_lex_nonalloc

int32_t cpp_lex_nonalloc(
Lex_Data *S_ptr,
char *chunk,
int32_t size,
Cpp_Token_Stack *token_stack_out
)
No documentation generated for this function.

§5.4.8: cpp_lex_nonalloc

int32_t cpp_lex_nonalloc(
Lex_Data *S_ptr,
char *chunk,
int32_t size,
Cpp_Token_Stack *token_stack_out,
int32_t max_tokens
)
No documentation generated for this function.

§5.4.9: cpp_lex_size_nonalloc

int32_t cpp_lex_size_nonalloc(
Lex_Data *S_ptr,
char *chunk,
int32_t size,
int32_t full_size,
Cpp_Token_Stack *token_stack_out
)
No documentation generated for this function.

§5.4.10: cpp_lex_size_nonalloc

int32_t cpp_lex_size_nonalloc(
Lex_Data *S_ptr,
char *chunk,
int32_t size,
int32_t full_size,
Cpp_Token_Stack *token_stack_out,
int32_t max_tokens
)
No documentation generated for this function.

§5.4.11: cpp_relex_nonalloc_start

Cpp_Relex_State cpp_relex_nonalloc_start(
char *data,
int32_t size,
Cpp_Token_Stack *stack,
int32_t start,
int32_t end,
int32_t amount,
int32_t tolerance
)
No documentation generated for this function.

§5.4.12: cpp_token_get_pp_state

char cpp_token_get_pp_state(
uint16_t bitfield
)
No documentation generated for this function.

§5.4.13: cpp_index_stack

Cpp_Token cpp_index_stack(
Cpp_Token_Stack *stack,
int32_t file_size,
int32_t index
)
No documentation generated for this function.

§5.4.14: cpp_relex_nonalloc_main

int32_t cpp_relex_nonalloc_main(
Cpp_Relex_State *state,
Cpp_Token_Stack *relex_stack,
int32_t *relex_end,
char *spare
)
No documentation generated for this function.

§5.4.15: cpp_make_token_stack

Cpp_Token_Stack cpp_make_token_stack(
int32_t starting_max
)
No documentation generated for this function.

§5.4.16: cpp_free_token_stack

void cpp_free_token_stack(
Cpp_Token_Stack token_stack
)
No documentation generated for this function.

§5.4.17: cpp_resize_token_stack

void cpp_resize_token_stack(
Cpp_Token_Stack *token_stack,
int32_t new_max
)
No documentation generated for this function.

§5.4.18: cpp_push_token

void cpp_push_token(
Cpp_Token_Stack *token_stack,
Cpp_Token token
)
No documentation generated for this function.

§5.4.19: cpp_lex_file

void cpp_lex_file(
char *data,
int32_t size,
Cpp_Token_Stack *token_stack_out
)
No documentation generated for this function.

§5.5 Lexer Type Descriptions

§5.5.1: Cpp_Token_Type

enum Cpp_Token_Type;
Description
A Cpp_Token_Type classifies a token to make parsing easier. Some types are not +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

+

§5 Lexer Library

§5.1 Lexer Intro

Coming Soon

§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 +or in whitespace after the token.
Description
This call performs a binary search over all of the tokens looking +for the token that contains the specified position. If the position +is in whitespace between the tokens, the returned token index is the +index of the token immediately before the provided position. The returned +index can be -1 if the position is before the first token.

See Also

§5.4.2: cpp_lex_data_init

Cpp_Lex_Data cpp_lex_data_init(
char *mem_buffer
)
Parameters
tb
The memory to use for initializing the lex state's temp memory buffer.
Return
A brand new lex state ready to begin lexing a file from the beginning.
Description
Creates a new lex state in the form of a Cpp_Lex_Data struct and returns the struct. +The system needs a temporary buffer that is as long as the longest token. 4096 is usually +enough but the buffer is not checked, so to be 100% bullet proof it has to be the same length +as the file being lexed.


§5.4.3: cpp_lex_nonalloc

Cpp_Lex_Result cpp_lex_nonalloc(
Cpp_Lex_Data *S_ptr,
char *chunk,
int32_t size,
int32_t full_size,
Cpp_Token_Array *token_array_out,
int32_t max_tokens_out
)
Parameters
S_ptr
The lexer state. Go to the Cpp_Lex_Data section to see how to initialize the state.
chunk
The first or next chunk of the file being lexed.
size
The number of bytes in the chunk including the null terminator if the chunk ends in a null terminator. +If the chunk ends in a null terminator the system will interpret it as the end of the file.
full_size
If the final chunk is not null terminated this parameter should specify the length of the +file in bytes. To rely on an eventual null terminator use HAS_NULL_TERM for this parameter.
token_array_out
The token array structure that will receive the tokens output by the lexer.
max_tokens_out
The maximum number of tokens to be output to the token array. To rely on the +max built into the token array pass NO_OUT_LIMIT here.
Description
This call is the primary interface of the lexing system. It is quite general so it can be used in +a lot of different ways. I will explain the general rules first, and then give some examples of common +ways it might be used.

+First a lexing state, Cpp_Lex_Data, must be initialized. The file to lex must be read into N contiguous chunks +of memory. An output Cpp_Token_Array must be allocated and initialized with the appropriate count and max_count values. +Then each chunk of the file must be passed to cpp_lex_nonalloc in order using the same lexing state for each call. +Every time a call to cpp_lex_nonalloc returns LexResult_NeedChunk, the next call to cpp_lex_nonalloc should use the +next chunk. If the return is some other value, the lexer hasn't finished with the current chunk and it sopped for some +other reason, so the same chunk should be used again in the next call.

+If the file chunks contain a null terminator the lexer will return LexResult_Finished when it finds this character. +At this point calling the lexer again with the same state will result in an error. If you do not have a null +terminated chunk to end the file, you may instead pass the exact size in bytes of the entire file to the full_size +parameter and it will automatically handle the termination of the lexing state when it has read that many bytes. +If a full_size is specified and the system terminates for having seen that many bytes, it will return LexResult_Finished. +If a full_size is specified and a null character is read before the total number of bytes have been read the system will +still terminate as usual and return LexResult_Finished.

+If the system has filled the entire output array it will return LexResult_NeedTokenMemory. When this happens if you +want to continue lexing the file you can grow the token array, or switch to a new output array and then call +cpp_lex_nonalloc again with the chunk that was being lexed and the new output. You can also specify a max_tokens_out +which is limits how many new tokens will be added to the token array. Even if token_array_out still had more space +to hold tokens, if the max_tokens_out limit is hit, the lexer will stop and return LexResult_HitTokenLimit. If this +happens there is still space left in the token array, so you can resume simply by calling cpp_lex_nonalloc again with +the same chunk and the same output array. Also note that, unlike the chunks which must only be replaced when the system +says it needs a chunk. You may switch to or modify the output array in between calls as much as you like.

+The most basic use of this system is to get it all done in one big chunk and try to allocate a nearly "infinite" output +array so that it will not run out of memory. This way you can get the entire job done in one call and then just assert +to make sure it returns LexResult_Finished to you: +

Cpp_Token_Array lex_file(char *file_name){
    File_Data file = read_whole_file(file_name);
    
    Cpp_Lex_Data lex_state =
        cpp_lex_data_init((char*)malloc(4096)); // hopefully big enough
    
    Cpp_Token_Array array = {0};
    array.tokens = (Cpp_Token*)malloc(1 << 20); // hopefully big enough
    array.max_count = (1 << 20)/sizeof(Cpp_Token);
    
    Cpp_Lex_Result result =
        cpp_lex_nonalloc(&lex_state, file.data, file.size, file.size,
                         &array, NO_OUT_LIMIT);
    Assert(result == LexResult_Finished);
    
    free(lex_state.tb);
    
    return(array);
}
See Also

§5.4.4: cpp_make_token_array

Cpp_Token_Array cpp_make_token_array(
int32_t starting_max
)
Parameters
starting_max
The number of tokens to initialize the array with.
Return
An empty Cpp_Token_Array with memory malloc'd for storing tokens.
Description
This call allocates a Cpp_Token_Array with malloc for use in other +convenience functions. Stacks that are not allocated this way should not be +used in the convenience functions.

+This call is a part of the FCPP_ALLOW_MALLOC convenience functions. +If you want to use it defined the macro FCPP_ALLOW_MALLOC before including 4cpp_lexer.h


§5.4.5: cpp_free_token_array

void cpp_free_token_array(
Cpp_Token_Array token_array
)
Parameters
token_array
An array previously allocated by cpp_make_token_array
Description
This call frees a Cpp_Token_Array.

+This call is a part of the FCPP_ALLOW_MALLOC convenience functions. +If you want to use it defined the macro FCPP_ALLOW_MALLOC before including 4cpp_lexer.h

See Also

§5.4.6: cpp_resize_token_array

void cpp_resize_token_array(
Cpp_Token_Array *token_array,
int32_t new_max
)
Parameters
token_array
An array previously allocated by cpp_make_token_array.
new_max
The new maximum size the array should support. If this is not greater +than the current size of the array the operation is ignored.
Description
This call allocates a new memory chunk and moves the existing tokens in the array +over to the new chunk.

+This call is a part of the FCPP_ALLOW_MALLOC convenience functions. +If you want to use it defined the macro FCPP_ALLOW_MALLOC before including 4cpp_lexer.h

See Also

§5.4.7: cpp_lex_file

void cpp_lex_file(
char *data,
int32_t size,
Cpp_Token_Array *token_array_out
)
Parameters
data
The file data to be lexed in a single contiguous block.
size
The number of bytes in data.
token_array_out
The token array where the output tokens will be pushed. +This token array must be previously allocated with cpp_make_token_array
Description
Lexes an entire file and manages the interaction with the lexer system so that +it is quick and convenient to lex files.

+This call is a part of the FCPP_ALLOW_MALLOC convenience functions. +If you want to use it defined the macro FCPP_ALLOW_MALLOC before including 4cpp_lexer.h

See Also

§5.5 Lexer Type Descriptions

§5.5.1: Cpp_Token_Type

enum Cpp_Token_Type;
Description
A Cpp_Token_Type classifies a token to make parsing easier. Some types are not actually output by the lexer, but exist because parsers will also make use of token -types in their own output.
Values
CPP_TOKEN_JUNK
CPP_TOKEN_COMMENT
CPP_PP_INCLUDE
CPP_PP_DEFINE
CPP_PP_UNDEF
CPP_PP_IF
CPP_PP_IFDEF
CPP_PP_IFNDEF
CPP_PP_ELSE
CPP_PP_ELIF
CPP_PP_ENDIF
CPP_PP_ERROR
CPP_PP_IMPORT
CPP_PP_USING
CPP_PP_LINE
CPP_PP_PRAGMA
CPP_PP_STRINGIFY
CPP_PP_CONCAT
CPP_PP_UNKNOWN
CPP_TOKEN_KEY_TYPE
CPP_TOKEN_KEY_MODIFIER
CPP_TOKEN_KEY_QUALIFIER
CPP_TOKEN_KEY_OPERATOR
This type is not stored in token output from the lexer.
CPP_TOKEN_KEY_CONTROL_FLOW
CPP_TOKEN_KEY_CAST
CPP_TOKEN_KEY_TYPE_DECLARATION
CPP_TOKEN_KEY_ACCESS
CPP_TOKEN_KEY_LINKAGE
CPP_TOKEN_KEY_OTHER
CPP_TOKEN_IDENTIFIER
CPP_TOKEN_INTEGER_CONSTANT
CPP_TOKEN_CHARACTER_CONSTANT
CPP_TOKEN_FLOATING_CONSTANT
CPP_TOKEN_STRING_CONSTANT
CPP_TOKEN_BOOLEAN_CONSTANT
CPP_TOKEN_STATIC_ASSERT
CPP_TOKEN_BRACKET_OPEN
CPP_TOKEN_BRACKET_CLOSE
CPP_TOKEN_PARENTHESE_OPEN
CPP_TOKEN_PARENTHESE_CLOSE
CPP_TOKEN_BRACE_OPEN
CPP_TOKEN_BRACE_CLOSE
CPP_TOKEN_SEMICOLON
CPP_TOKEN_ELLIPSIS
CPP_TOKEN_STAR
This is an 'ambiguous' token type because it requires - parsing to determine the full nature of the token.
CPP_TOKEN_AMPERSAND
This is an 'ambiguous' token type because it requires - parsing to determine the full nature of the token.
CPP_TOKEN_TILDE
This is an 'ambiguous' token type because it requires - parsing to determine the full nature of the token.
CPP_TOKEN_PLUS
This is an 'ambiguous' token type because it requires - parsing to determine the full nature of the token.
CPP_TOKEN_MINUS
This is an 'ambiguous' token type because it requires - parsing to determine the full nature of the token.
CPP_TOKEN_INCREMENT
This is an 'ambiguous' token type because it requires - parsing to determine the full nature of the token.
CPP_TOKEN_DECREMENT
This is an 'ambiguous' token type because it requires - parsing to determine the full nature of the token.
CPP_TOKEN_SCOPE
CPP_TOKEN_POSTINC
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_POSTDEC
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_FUNC_STYLE_CAST
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_CPP_STYLE_CAST
CPP_TOKEN_CALL
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_INDEX
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_DOT
CPP_TOKEN_ARROW
CPP_TOKEN_PREINC
This token is for parser use, it is not output by the lexer.
CPP_TOKEN_PREDEC
This token is for parser use, it is not output by the lexer.
CPP_TOKEN_POSITIVE
This token is for parser use, it is not output by the lexer.
CPP_TOKEN_NEGAITVE
This token is for parser use, it is not output by the lexer.
CPP_TOKEN_NOT
CPP_TOKEN_BIT_NOT
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_CAST
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_DEREF
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_TYPE_PTR
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_ADDRESS
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_TYPE_REF
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_SIZEOF
CPP_TOKEN_ALIGNOF
CPP_TOKEN_DECLTYPE
CPP_TOKEN_TYPEID
CPP_TOKEN_NEW
CPP_TOKEN_DELETE
CPP_TOKEN_NEW_ARRAY
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_DELETE_ARRAY
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_PTRDOT
CPP_TOKEN_PTRARROW
CPP_TOKEN_MUL
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_DIV
CPP_TOKEN_MOD
CPP_TOKEN_ADD
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_SUB
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_LSHIFT
CPP_TOKEN_RSHIFT
CPP_TOKEN_LESS
CPP_TOKEN_GRTR
CPP_TOKEN_GRTREQ
CPP_TOKEN_LESSEQ
CPP_TOKEN_EQEQ
CPP_TOKEN_NOTEQ
CPP_TOKEN_BIT_AND
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_BIT_XOR
CPP_TOKEN_BIT_OR
CPP_TOKEN_AND
CPP_TOKEN_OR
CPP_TOKEN_TERNARY_QMARK
CPP_TOKEN_COLON
CPP_TOKEN_THROW
CPP_TOKEN_EQ
CPP_TOKEN_ADDEQ
CPP_TOKEN_SUBEQ
CPP_TOKEN_MULEQ
CPP_TOKEN_DIVEQ
CPP_TOKEN_MODEQ
CPP_TOKEN_LSHIFTEQ
CPP_TOKEN_RSHIFTEQ
CPP_TOKEN_ANDEQ
CPP_TOKEN_OREQ
CPP_TOKEN_XOREQ
CPP_TOKEN_COMMA
CPP_TOKEN_DEFINED
CPP_TOKEN_INCLUDE_FILE
CPP_TOKEN_ERROR_MESSAGE
CPP_TOKEN_EOF
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_TYPE_COUNT

§5.5.2: Cpp_Token

struct Cpp_Token {
Cpp_Token_Type type;
int32_t start, size;
uint16_t state_flags;
uint16_t flags;
};
Fields
type
size
state_flags
flags

§5.5.3: Cpp_Token_Flag

enum Cpp_Token_Flag;
Values
CPP_TFLAG_IGNORE = 0x1
CPP_TFLAG_PP_DIRECTIVE = 0x2
CPP_TFLAG_PP_BODY = 0x4
CPP_TFLAG_BAD_ENDING = 0x8
CPP_TFLAG_MULTILINE = 0x10
CPP_TFLAG_PARAMETERIZED = 0x20
CPP_TFLAG_IS_OPERATOR = 0x40
CPP_TFLAG_IS_KEYWORD = 0x80

§5.5.4: Cpp_Preprocessor_State

enum Cpp_Preprocessor_State;
Values
CPP_LEX_PP_DEFAULT
CPP_LEX_PP_IDENTIFIER
CPP_LEX_PP_MACRO_IDENTIFIER
CPP_LEX_PP_INCLUDE
CPP_LEX_PP_BODY
CPP_LEX_PP_BODY_IF
CPP_LEX_PP_NUMBER
CPP_LEX_PP_ERROR
CPP_LEX_PP_JUNK
CPP_LEX_PP_COUNT

§5.5.5: Cpp_Token_Stack

struct Cpp_Token_Stack {
Cpp_Token * tokens;
int32_t count, max_count;
};
Fields
tokens
max_count

§5.5.6: Cpp_Get_Token_Result

struct Cpp_Get_Token_Result {
int32_t token_index;
int32_t in_whitespace;
};
Fields
token_index
in_whitespace

§5.5.7: Cpp_Relex_State

struct Cpp_Relex_State {
char * data;
int32_t size;
Cpp_Token_Stack * stack;
int32_t start, end, amount;
int32_t start_token_i;
int32_t end_token_i;
int32_t relex_start;
int32_t tolerance;
int32_t space_request;
};
Fields
data
size
stack
amount
start_token_i
end_token_i
relex_start
tolerance
space_request

\ No newline at end of file +types in their own output.

Values
CPP_TOKEN_JUNK
CPP_TOKEN_COMMENT
CPP_PP_INCLUDE
CPP_PP_DEFINE
CPP_PP_UNDEF
CPP_PP_IF
CPP_PP_IFDEF
CPP_PP_IFNDEF
CPP_PP_ELSE
CPP_PP_ELIF
CPP_PP_ENDIF
CPP_PP_ERROR
CPP_PP_IMPORT
CPP_PP_USING
CPP_PP_LINE
CPP_PP_PRAGMA
CPP_PP_STRINGIFY
CPP_PP_CONCAT
CPP_PP_UNKNOWN
CPP_TOKEN_KEY_TYPE
CPP_TOKEN_KEY_MODIFIER
CPP_TOKEN_KEY_QUALIFIER
CPP_TOKEN_KEY_OPERATOR
This type is not stored in token output from the lexer.

CPP_TOKEN_KEY_CONTROL_FLOW
CPP_TOKEN_KEY_CAST
CPP_TOKEN_KEY_TYPE_DECLARATION
CPP_TOKEN_KEY_ACCESS
CPP_TOKEN_KEY_LINKAGE
CPP_TOKEN_KEY_OTHER
CPP_TOKEN_IDENTIFIER
CPP_TOKEN_INTEGER_CONSTANT
CPP_TOKEN_CHARACTER_CONSTANT
CPP_TOKEN_FLOATING_CONSTANT
CPP_TOKEN_STRING_CONSTANT
CPP_TOKEN_BOOLEAN_CONSTANT
CPP_TOKEN_STATIC_ASSERT
CPP_TOKEN_BRACKET_OPEN
CPP_TOKEN_BRACKET_CLOSE
CPP_TOKEN_PARENTHESE_OPEN
CPP_TOKEN_PARENTHESE_CLOSE
CPP_TOKEN_BRACE_OPEN
CPP_TOKEN_BRACE_CLOSE
CPP_TOKEN_SEMICOLON
CPP_TOKEN_ELLIPSIS
CPP_TOKEN_STAR
This is an 'ambiguous' token type because it requires + parsing to determine the full nature of the token.

CPP_TOKEN_AMPERSAND
This is an 'ambiguous' token type because it requires + parsing to determine the full nature of the token.

CPP_TOKEN_TILDE
This is an 'ambiguous' token type because it requires + parsing to determine the full nature of the token.

CPP_TOKEN_PLUS
This is an 'ambiguous' token type because it requires + parsing to determine the full nature of the token.

CPP_TOKEN_MINUS
This is an 'ambiguous' token type because it requires + parsing to determine the full nature of the token.

CPP_TOKEN_INCREMENT
This is an 'ambiguous' token type because it requires + parsing to determine the full nature of the token.

CPP_TOKEN_DECREMENT
This is an 'ambiguous' token type because it requires + parsing to determine the full nature of the token.

CPP_TOKEN_SCOPE
CPP_TOKEN_POSTINC
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_POSTDEC
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_FUNC_STYLE_CAST
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_CPP_STYLE_CAST
CPP_TOKEN_CALL
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_INDEX
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_DOT
CPP_TOKEN_ARROW
CPP_TOKEN_PREINC
This token is for parser use, it is not output by the lexer.

CPP_TOKEN_PREDEC
This token is for parser use, it is not output by the lexer.

CPP_TOKEN_POSITIVE
This token is for parser use, it is not output by the lexer.

CPP_TOKEN_NEGAITVE
This token is for parser use, it is not output by the lexer.

CPP_TOKEN_NOT
CPP_TOKEN_BIT_NOT
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_CAST
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_DEREF
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_TYPE_PTR
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_ADDRESS
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_TYPE_REF
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_SIZEOF
CPP_TOKEN_ALIGNOF
CPP_TOKEN_DECLTYPE
CPP_TOKEN_TYPEID
CPP_TOKEN_NEW
CPP_TOKEN_DELETE
CPP_TOKEN_NEW_ARRAY
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_DELETE_ARRAY
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_PTRDOT
CPP_TOKEN_PTRARROW
CPP_TOKEN_MUL
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_DIV
CPP_TOKEN_MOD
CPP_TOKEN_ADD
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_SUB
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_LSHIFT
CPP_TOKEN_RSHIFT
CPP_TOKEN_LESS
CPP_TOKEN_GRTR
CPP_TOKEN_GRTREQ
CPP_TOKEN_LESSEQ
CPP_TOKEN_EQEQ
CPP_TOKEN_NOTEQ
CPP_TOKEN_BIT_AND
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_BIT_XOR
CPP_TOKEN_BIT_OR
CPP_TOKEN_AND
CPP_TOKEN_OR
CPP_TOKEN_TERNARY_QMARK
CPP_TOKEN_COLON
CPP_TOKEN_THROW
CPP_TOKEN_EQ
CPP_TOKEN_ADDEQ
CPP_TOKEN_SUBEQ
CPP_TOKEN_MULEQ
CPP_TOKEN_DIVEQ
CPP_TOKEN_MODEQ
CPP_TOKEN_LSHIFTEQ
CPP_TOKEN_RSHIFTEQ
CPP_TOKEN_ANDEQ
CPP_TOKEN_OREQ
CPP_TOKEN_XOREQ
CPP_TOKEN_COMMA
CPP_TOKEN_DEFINED
CPP_TOKEN_INCLUDE_FILE
CPP_TOKEN_ERROR_MESSAGE
CPP_TOKEN_EOF
This type is for parser use, it is not output by the lexer.

CPP_TOKEN_TYPE_COUNT

§5.5.2: Cpp_Token

struct Cpp_Token {
Cpp_Token_Type type;
int32_t start, size;
uint16_t state_flags;
uint16_t flags;
};
Fields
type
size
state_flags
flags

§5.5.3: Cpp_Token_Flag

enum Cpp_Token_Flag;
Values
CPP_TFLAG_IGNORE = 0x1
CPP_TFLAG_PP_DIRECTIVE = 0x2
CPP_TFLAG_PP_BODY = 0x4
CPP_TFLAG_BAD_ENDING = 0x8
CPP_TFLAG_MULTILINE = 0x10
CPP_TFLAG_PARAMETERIZED = 0x20
CPP_TFLAG_IS_OPERATOR = 0x40
CPP_TFLAG_IS_KEYWORD = 0x80

§5.5.4: Cpp_Preprocessor_State

enum Cpp_Preprocessor_State;
Values
CPP_LEX_PP_DEFAULT
CPP_LEX_PP_IDENTIFIER
CPP_LEX_PP_MACRO_IDENTIFIER
CPP_LEX_PP_INCLUDE
CPP_LEX_PP_BODY
CPP_LEX_PP_BODY_IF
CPP_LEX_PP_NUMBER
CPP_LEX_PP_ERROR
CPP_LEX_PP_JUNK
CPP_LEX_PP_COUNT

§5.5.5: Cpp_Token_Array

struct Cpp_Token_Array {
Cpp_Token * tokens;
int32_t count, max_count;
};
Fields
tokens
max_count

§5.5.6: Cpp_Get_Token_Result

struct Cpp_Get_Token_Result {
int32_t token_index;
int32_t in_whitespace;
};
Fields
token_index
in_whitespace

§5.5.7: Cpp_Relex_State

struct Cpp_Relex_State {
char * data;
int32_t size;
Cpp_Token_Array * array;
int32_t start, end, amount;
int32_t start_token_i;
int32_t end_token_i;
int32_t relex_start;
int32_t tolerance;
int32_t space_request;
};
Fields
data
size
array
amount
start_token_i
end_token_i
relex_start
tolerance
space_request

§5.5.8: Cpp_Lex_FSM

struct Cpp_Lex_FSM {
uint8_t state;
uint8_t int_state;
uint8_t emit_token;
uint8_t multi_line;
};
Fields
state
int_state
emit_token
multi_line

§5.5.9: Cpp_Lex_Data

struct Cpp_Lex_Data {
char * tb;
int32_t tb_pos;
int32_t token_start;
int32_t pos;
int32_t pos_overide;
int32_t chunk_pos;
Cpp_Lex_FSM fsm;
uint8_t white_done;
uint8_t pp_state;
uint8_t completed;
Cpp_Token token;
int32_t __pc__;
};
Fields
tb
tb_pos
token_start
pos
pos_overide
chunk_pos
fsm
white_done
pp_state
completed
token
__pc__

§5.5.10: Cpp_Lex_Result

enum Cpp_Lex_Result;
Values
LexResult_Finished
LexResult_NeedChunk
LexResult_NeedTokenMemory
LexResult_HitTokenLimit

\ No newline at end of file diff --git a/4cpp_lexer.h b/4cpp_lexer.h index 2d7cd6f6..36afc847 100644 --- a/4cpp_lexer.h +++ b/4cpp_lexer.h @@ -12,8 +12,9 @@ # define FCPP_LINK static #endif +#define FCPP_INTERNAL FCPP_LINK + #include "4cpp_lexer_types.h" -#include "4cpp_lexer_fsms.h" #include "4cpp_lexer_tables.c" // TODO(allen): revisit this keyword data declaration system @@ -145,12 +146,26 @@ static String_And_Flag keywords[] = { FCPP_LINK Cpp_Get_Token_Result -cpp_get_token(Cpp_Token_Stack *token_stack, int32_t pos){ +cpp_get_token(Cpp_Token_Array *token_array_in, int32_t pos)/* +DOC_PARAM(token_array, The array of tokens from which to get a token.) +DOC_PARAM(pos, The position, measured in bytes, to get the token for.) +DOC_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 +or in whitespace after the token.) + +DOC(This call performs a binary search over all of the tokens looking +for the token that contains the specified position. If the position +is in whitespace between the tokens, the returned token index is the +index of the token immediately before the provided position. The returned +index can be -1 if the position is before the first token.) + +DOC_SEE(Cpp_Get_Token_Result) +*/{ Cpp_Get_Token_Result result = {}; - Cpp_Token *token_array = token_stack->tokens; + Cpp_Token *token_array = token_array_in->tokens; Cpp_Token *token = 0; int32_t first = 0; - int32_t count = token_stack->count; + int32_t count = token_array_in->count; int32_t last = count; int32_t this_start = 0, next_start = 0; @@ -200,19 +215,23 @@ cpp_get_token(Cpp_Token_Stack *token_stack, int32_t pos){ return(result); } -FCPP_LINK void -cpp_shift_token_starts(Cpp_Token_Stack *stack, int32_t from_token_i, int32_t shift_amount){ - Cpp_Token *token = stack->tokens + from_token_i; - int32_t count = stack->count, i; - - for (i = from_token_i; i < count; ++i, ++token){ - token->start += shift_amount; - } +FCPP_LINK Cpp_Lex_Data +cpp_lex_data_init(char *mem_buffer)/* +DOC_PARAM(tb, The memory to use for initializing the lex state's temp memory buffer.) +DOC_RETURN(A brand new lex state ready to begin lexing a file from the beginning.) +DOC(Creates a new lex state in the form of a Cpp_Lex_Data struct and returns the struct. +The system needs a temporary buffer that is as long as the longest token. 4096 is usually +enough but the buffer is not checked, so to be 100% bullet proof it has to be the same length +as the file being lexed.) +*/{ + Cpp_Lex_Data data = {0}; + data.tb = mem_buffer; + return(data); } -FCPP_LINK Lex_PP_State +FCPP_INTERNAL Cpp_Lex_PP_State cpp_pp_directive_to_state(Cpp_Token_Type type){ - Lex_PP_State result = LSPP_default; + Cpp_Lex_PP_State result = LSPP_default; switch (type){ case CPP_PP_INCLUDE: case CPP_PP_IMPORT: @@ -256,85 +275,27 @@ cpp_pp_directive_to_state(Cpp_Token_Type type){ return(result); } -FCPP_LINK int32_t -cpp_place_token_nonalloc(Cpp_Token *out_tokens, int32_t token_i, Cpp_Token token){ - Cpp_Token prev_token = {(Cpp_Token_Type)0}; - - if (token_i > 0){ - prev_token = out_tokens[token_i - 1]; - } - - out_tokens[token_i++] = token; - - return(token_i); -} - -FCPP_LINK bool -cpp_push_token_nonalloc(Cpp_Token_Stack *out_tokens, Cpp_Token token){ - bool result = 0; - if (out_tokens->count == out_tokens->max_count){ - out_tokens->count = - cpp_place_token_nonalloc(out_tokens->tokens, out_tokens->count, token); - result = 1; - } - return(result); -} - -struct Lex_Data{ - char *tb; - int32_t tb_pos; - int32_t token_start; - - int32_t pos; - int32_t pos_overide; - int32_t chunk_pos; - - Lex_FSM fsm; - unsigned char white_done; - unsigned char pp_state; - unsigned char completed; - - Cpp_Token token; - - int32_t __pc__; -}; - -FCPP_LINK Lex_Data -lex_data_init(char *tb){ - Lex_Data data = {0}; - data.tb = tb; - return(data); -} - - #define DrCase(PC) case PC: goto resumespot_##PC #define DrYield(PC, n) { \ - token_stack_out->count = token_i; \ + token_array_out->count = token_i; \ *S_ptr = S; S_ptr->__pc__ = PC; return(n); resumespot_##PC:; } #define DrReturn(n) { \ - token_stack_out->count = token_i; \ + token_array_out->count = token_i; \ *S_ptr = S; S_ptr->__pc__ = -1; return(n); } enum Lex_Result{ - LexFinished, - LexNeedChunk, - LexNeedTokenMemory, - LexHitTokenLimit }; -FCPP_LINK int32_t -cpp_lex_nonalloc(Lex_Data *S_ptr, - char *chunk, int32_t size, - Cpp_Token_Stack *token_stack_out){ - Lex_Data S = *S_ptr; +FCPP_INTERNAL Cpp_Lex_Result +cpp_lex_nonalloc_null_end_no_limit(Cpp_Lex_Data *S_ptr, char *chunk, int32_t size, + Cpp_Token_Array *token_array_out){ + Cpp_Lex_Data S = *S_ptr; - Cpp_Token *out_tokens = token_stack_out->tokens; - int32_t token_i = token_stack_out->count; - int32_t max_token_i = token_stack_out->max_count; - - //Pos_Update_Rule pos_update_rule = PUR_none; + Cpp_Token *out_tokens = token_array_out->tokens; + int32_t token_i = token_array_out->count; + int32_t max_token_i = token_array_out->max_count; char c = 0; @@ -362,7 +323,7 @@ cpp_lex_nonalloc(Lex_Data *S_ptr, if (S.white_done == 0){ S.chunk_pos += size; - DrYield(4, LexNeedChunk); + DrYield(4, LexResult_NeedChunk); } else break; } @@ -394,7 +355,7 @@ cpp_lex_nonalloc(Lex_Data *S_ptr, if (S.fsm.emit_token == 0){ S.chunk_pos += size; - DrYield(3, LexNeedChunk); + DrYield(3, LexResult_NeedChunk); } else break; } @@ -449,7 +410,7 @@ cpp_lex_nonalloc(Lex_Data *S_ptr, if (S.white_done == 0){ S.chunk_pos += size; - DrYield(1, LexNeedChunk); + DrYield(1, LexResult_NeedChunk); } else break; } @@ -560,7 +521,7 @@ cpp_lex_nonalloc(Lex_Data *S_ptr, if (S.fsm.emit_token == 0){ S.chunk_pos += size; - DrYield(5, LexNeedChunk); + DrYield(5, LexResult_NeedChunk); } else break; } @@ -905,13 +866,13 @@ cpp_lex_nonalloc(Lex_Data *S_ptr, S.token.flags |= (S.pp_state != LSPP_default)?(CPP_TFLAG_PP_BODY):(0); } - token_i = cpp_place_token_nonalloc(out_tokens, token_i, S.token); + out_tokens[token_i++] = S.token; if (token_i == max_token_i){ if (S.pos == end_pos){ S.chunk_pos += size; - DrYield(7, LexNeedChunk); + DrYield(7, LexResult_NeedChunk); } - DrYield(2, LexNeedTokenMemory); + DrYield(2, LexResult_NeedTokenMemory); } } @@ -920,109 +881,203 @@ cpp_lex_nonalloc(Lex_Data *S_ptr, } } - DrReturn(LexFinished); + DrReturn(LexResult_Finished); } #undef DrYield #undef DrReturn #undef DrCase -FCPP_LINK int32_t -cpp_lex_nonalloc(Lex_Data *S_ptr, - char *chunk, int32_t size, - Cpp_Token_Stack *token_stack_out, int32_t max_tokens){ - Cpp_Token_Stack temp_stack = *token_stack_out; - if (temp_stack.max_count > temp_stack.count + max_tokens){ - temp_stack.max_count = temp_stack.count + max_tokens; +FCPP_INTERNAL Cpp_Lex_Result +cpp_lex_nonalloc_null_end_out_limit(Cpp_Lex_Data *S_ptr, char *chunk, int32_t size, + Cpp_Token_Array *token_array_out, int32_t max_tokens_out){ + Cpp_Token_Array temp_array = *token_array_out; + if (temp_array.max_count > temp_array.count + max_tokens_out){ + temp_array.max_count = temp_array.count + max_tokens_out; } - int32_t result = cpp_lex_nonalloc(S_ptr, chunk, size, &temp_stack); + Cpp_Lex_Result result = cpp_lex_nonalloc_null_end_no_limit(S_ptr, chunk, size, &temp_array); - token_stack_out->count = temp_stack.count; - - if (result == LexNeedTokenMemory){ - if (token_stack_out->count < token_stack_out->max_count){ - result = LexHitTokenLimit; + token_array_out->count = temp_array.count; + if (result == LexResult_NeedTokenMemory){ + if (token_array_out->count < token_array_out->max_count){ + result = LexResult_HitTokenLimit; } } return(result); } -FCPP_LINK int32_t -cpp_lex_size_nonalloc(Lex_Data *S_ptr, - char *chunk, int32_t size, int32_t full_size, - Cpp_Token_Stack *token_stack_out){ - int32_t result = 0; +FCPP_INTERNAL Cpp_Lex_Result +cpp_lex_nonalloc_no_null_no_limit(Cpp_Lex_Data *S_ptr, char *chunk, int32_t size, int32_t full_size, + Cpp_Token_Array *token_array_out){ + Cpp_Lex_Result result = 0; if (S_ptr->pos >= full_size){ char end_null = 0; - result = cpp_lex_nonalloc(S_ptr, &end_null, 1, token_stack_out); + result = cpp_lex_nonalloc_null_end_no_limit(S_ptr, &end_null, 1, token_array_out); } else{ - result = cpp_lex_nonalloc(S_ptr, chunk, size, token_stack_out); - if (result == LexNeedChunk){ + result = cpp_lex_nonalloc_null_end_no_limit(S_ptr, chunk, size, token_array_out); + if (result == LexResult_NeedChunk){ if (S_ptr->pos >= full_size){ char end_null = 0; - result = cpp_lex_nonalloc(S_ptr, &end_null, 1, token_stack_out); + result = cpp_lex_nonalloc_null_end_no_limit(S_ptr, &end_null, 1, token_array_out); } } } return(result); } -FCPP_LINK int32_t -cpp_lex_size_nonalloc(Lex_Data *S_ptr, - char *chunk, int32_t size, int32_t full_size, - Cpp_Token_Stack *token_stack_out, int32_t max_tokens){ - Cpp_Token_Stack temp_stack = *token_stack_out; - if (temp_stack.max_count > temp_stack.count + max_tokens){ - temp_stack.max_count = temp_stack.count + max_tokens; +FCPP_INTERNAL Cpp_Lex_Result +cpp_lex_nonalloc_no_null_out_limit(Cpp_Lex_Data *S_ptr, char *chunk, int32_t size, int32_t full_size, + Cpp_Token_Array *token_array_out, int32_t max_tokens_out){ + Cpp_Token_Array temp_stack = *token_array_out; + if (temp_stack.max_count > temp_stack.count + max_tokens_out){ + temp_stack.max_count = temp_stack.count + max_tokens_out; } - int32_t result = cpp_lex_size_nonalloc(S_ptr, chunk, size, full_size, - &temp_stack); + Cpp_Lex_Result result = cpp_lex_nonalloc_no_null_no_limit(S_ptr, chunk, size, full_size, + &temp_stack); - token_stack_out->count = temp_stack.count; + token_array_out->count = temp_stack.count; - if (result == LexNeedTokenMemory){ - if (token_stack_out->count < token_stack_out->max_count){ - result = LexHitTokenLimit; + if (result == LexResult_NeedTokenMemory){ + if (token_array_out->count < token_array_out->max_count){ + result = LexResult_HitTokenLimit; } } return(result); } -FCPP_LINK Cpp_Relex_State -cpp_relex_nonalloc_start(char *data, int32_t size, Cpp_Token_Stack *stack, +#define HAS_NULL_TERM ((int32_t)(-1)) +#define NO_OUT_LIMIT ((int32_t)(-1)) + +FCPP_LINK Cpp_Lex_Result +cpp_lex_nonalloc(Cpp_Lex_Data *S_ptr, char *chunk, int32_t size, int32_t full_size, + Cpp_Token_Array *token_array_out, int32_t max_tokens_out)/* +DOC_PARAM(S_ptr, The lexer state. Go to the Cpp_Lex_Data section to see how to initialize the state.) +DOC_PARAM(chunk, The first or next chunk of the file being lexed.) +DOC_PARAM(size, The number of bytes in the chunk including the null terminator if the chunk ends in a null terminator. +If the chunk ends in a null terminator the system will interpret it as the end of the file.) +DOC_PARAM(full_size, If the final chunk is not null terminated this parameter should specify the length of the +file in bytes. To rely on an eventual null terminator use HAS_NULL_TERM for this parameter.) +DOC_PARAM(token_array_out, The token array structure that will receive the tokens output by the lexer.) +DOC_PARAM(max_tokens_out, The maximum number of tokens to be output to the token array. To rely on the +max built into the token array pass NO_OUT_LIMIT here.) + +DOC(This call is the primary interface of the lexing system. It is quite general so it can be used in +a lot of different ways. I will explain the general rules first, and then give some examples of common +ways it might be used. + +First a lexing state, Cpp_Lex_Data, must be initialized. The file to lex must be read into N contiguous chunks +of memory. An output Cpp_Token_Array must be allocated and initialized with the appropriate count and max_count values. +Then each chunk of the file must be passed to cpp_lex_nonalloc in order using the same lexing state for each call. +Every time a call to cpp_lex_nonalloc returns LexResult_NeedChunk, the next call to cpp_lex_nonalloc should use the +next chunk. If the return is some other value, the lexer hasn't finished with the current chunk and it sopped for some +other reason, so the same chunk should be used again in the next call. + +If the file chunks contain a null terminator the lexer will return LexResult_Finished when it finds this character. +At this point calling the lexer again with the same state will result in an error. If you do not have a null +terminated chunk to end the file, you may instead pass the exact size in bytes of the entire file to the full_size +parameter and it will automatically handle the termination of the lexing state when it has read that many bytes. +If a full_size is specified and the system terminates for having seen that many bytes, it will return LexResult_Finished. +If a full_size is specified and a null character is read before the total number of bytes have been read the system will +still terminate as usual and return LexResult_Finished. + +If the system has filled the entire output array it will return LexResult_NeedTokenMemory. When this happens if you +want to continue lexing the file you can grow the token array, or switch to a new output array and then call +cpp_lex_nonalloc again with the chunk that was being lexed and the new output. You can also specify a max_tokens_out +which is limits how many new tokens will be added to the token array. Even if token_array_out still had more space +to hold tokens, if the max_tokens_out limit is hit, the lexer will stop and return LexResult_HitTokenLimit. If this +happens there is still space left in the token array, so you can resume simply by calling cpp_lex_nonalloc again with +the same chunk and the same output array. Also note that, unlike the chunks which must only be replaced when the system +says it needs a chunk. You may switch to or modify the output array in between calls as much as you like. + +The most basic use of this system is to get it all done in one big chunk and try to allocate a nearly "infinite" output +array so that it will not run out of memory. This way you can get the entire job done in one call and then just assert +to make sure it returns LexResult_Finished to you: +CODE_EXAMPLE( +Cpp_Token_Array lex_file(char *file_name){ + File_Data file = read_whole_file(file_name); + + Cpp_Lex_Data lex_state = + cpp_lex_data_init((char*)malloc(4096)); // hopefully big enough + + Cpp_Token_Array array = {0}; + array.tokens = (Cpp_Token*)malloc(1 << 20); // hopefully big enough + array.max_count = (1 << 20)/sizeof(Cpp_Token); + + Cpp_Lex_Result result = + cpp_lex_nonalloc(&lex_state, file.data, file.size, file.size, + &array, NO_OUT_LIMIT); + Assert(result == LexResult_Finished); + + free(lex_state.tb); + + return(array); +}) +) + +DOC_SEE(Cpp_Lex_Data) +DOC_SEE(cpp_lex_file) +DOC_SEE(cpp_lex_nonalloc_null_end_no_limit) +DOC_SEE(cpp_lex_nonalloc_no_null_no_limit) +DOC_SEE(cpp_lex_nonalloc_null_end_out_limit) +DOC_SEE(cpp_lex_nonalloc_no_null_out_limit) + +*/{ + Cpp_Lex_Result result = 0; + if (full_size == HAS_NULL_TERM){ + if (max_tokens_out == NO_OUT_LIMIT){ + result = cpp_lex_nonalloc_null_end_no_limit(S_ptr, chunk, size, token_array_out); + } + else{ + result = cpp_lex_nonalloc_null_end_out_limit(S_ptr, chunk, size, token_array_out, max_tokens_out); + } + } + else{ + if (max_tokens_out == NO_OUT_LIMIT){ + result = cpp_lex_nonalloc_no_null_no_limit(S_ptr, chunk, size, full_size, token_array_out); + } + else{ + result = cpp_lex_nonalloc_no_null_out_limit(S_ptr, chunk, size, full_size, token_array_out, max_tokens_out); + } + } + return(result); +} + +// TODO(allen): Get the relex system ready to work in chunks. +FCPP_INTERNAL Cpp_Relex_State +cpp_relex_nonalloc_start(char *data, int32_t size, Cpp_Token_Array *array, int32_t start, int32_t end, int32_t amount, int32_t tolerance){ Cpp_Relex_State state; state.data = data; state.size = size; - state.stack = stack; + state.array = array; state.start = start; state.end = end; state.amount = amount; state.tolerance = tolerance; - Cpp_Get_Token_Result result = cpp_get_token(stack, start); + Cpp_Get_Token_Result result = cpp_get_token(array, start); state.start_token_i = result.token_index-1; if (state.start_token_i < 0){ state.start_token_i = 0; } - result = cpp_get_token(stack, end); + result = cpp_get_token(array, end); state.end_token_i = result.token_index; - if (end > stack->tokens[state.end_token_i].start){ + if (end > array->tokens[state.end_token_i].start){ ++state.end_token_i; } if (state.end_token_i < 0){ state.end_token_i = 0; } - state.relex_start = stack->tokens[state.start_token_i].start; + state.relex_start = array->tokens[state.start_token_i].start; if (start < state.relex_start){ state.relex_start = start; } @@ -1032,18 +1087,18 @@ cpp_relex_nonalloc_start(char *data, int32_t size, Cpp_Token_Stack *stack, return(state); } -FCPP_LINK char +FCPP_INTERNAL char cpp_token_get_pp_state(uint16_t bitfield){ return (char)(bitfield); } // TODO(allen): Eliminate this once we actually store the EOF token // in the token stack. -FCPP_LINK Cpp_Token -cpp_index_stack(Cpp_Token_Stack *stack, int32_t file_size, int32_t index){ +FCPP_INTERNAL Cpp_Token +cpp_index_array(Cpp_Token_Array *array, int32_t file_size, int32_t index){ Cpp_Token result; - if (index < stack->count){ - result = stack->tokens[index]; + if (index < array->count){ + result = array->tokens[index]; } else{ result.start = file_size; @@ -1055,60 +1110,68 @@ cpp_index_stack(Cpp_Token_Stack *stack, int32_t file_size, int32_t index){ return(result); } -FCPP_LINK int32_t +FCPP_INTERNAL void +cpp_shift_token_starts(Cpp_Token_Array *array, int32_t from_token_i, int32_t shift_amount){ + Cpp_Token *token = array->tokens + from_token_i; + int32_t count = array->count, i = 0; + + for (i = from_token_i; i < count; ++i, ++token){ + token->start += shift_amount; + } +} + +FCPP_INTERNAL int32_t cpp_relex_nonalloc_main(Cpp_Relex_State *state, - Cpp_Token_Stack *relex_stack, + Cpp_Token_Array *relex_array, int32_t *relex_end, char *spare){ - Cpp_Token_Stack *stack = state->stack; - Cpp_Token *tokens = stack->tokens; + Cpp_Token_Array *array = state->array; + Cpp_Token *tokens = array->tokens; - cpp_shift_token_starts(stack, state->end_token_i, state->amount); + cpp_shift_token_starts(array, state->end_token_i, state->amount); - Lex_Data lex = lex_data_init(spare); + Cpp_Lex_Data lex = cpp_lex_data_init(spare); lex.pp_state = cpp_token_get_pp_state(tokens[state->start_token_i].state_flags); lex.pos = state->relex_start; int32_t relex_end_i = state->end_token_i; - Cpp_Token match_token = cpp_index_stack(stack, state->size, relex_end_i); + Cpp_Token match_token = cpp_index_array(array, state->size, relex_end_i); Cpp_Token end_token = match_token; int32_t went_too_far = false; // TODO(allen): This can be better I suspect. for (;;){ int32_t result = - cpp_lex_size_nonalloc(&lex, - state->data, - state->size, - state->size, - relex_stack, 1); + cpp_lex_nonalloc_no_null_out_limit(&lex, state->data, + state->size, state->size, + relex_array, 1); switch (result){ - case LexHitTokenLimit: + case LexResult_HitTokenLimit: { - Cpp_Token token = relex_stack->tokens[relex_stack->count-1]; + Cpp_Token token = relex_array->tokens[relex_array->count-1]; if (token.start == end_token.start && token.size == end_token.size && token.flags == end_token.flags && token.state_flags == end_token.state_flags){ - --relex_stack->count; + --relex_array->count; goto double_break; } - while (lex.pos > end_token.start && relex_end_i < stack->count){ + while (lex.pos > end_token.start && relex_end_i < array->count){ ++relex_end_i; - end_token = cpp_index_stack(stack, state->size, relex_end_i); + end_token = cpp_index_array(array, state->size, relex_end_i); } } break; - case LexNeedChunk: Assert(!"Invalid path"); break; + case LexResult_NeedChunk: Assert(!"Invalid path"); break; - case LexNeedTokenMemory: + case LexResult_NeedTokenMemory: went_too_far = true; goto double_break; - case LexFinished: + case LexResult_Finished: goto double_break; } } @@ -1118,78 +1181,117 @@ cpp_relex_nonalloc_main(Cpp_Relex_State *state, *relex_end = relex_end_i; } else{ - cpp_shift_token_starts(stack, state->end_token_i, -state->amount); + cpp_shift_token_starts(array, state->end_token_i, -state->amount); } return(went_too_far); } + + #if defined(FCPP_ALLOW_MALLOC) #include #include -FCPP_LINK Cpp_Token_Stack -cpp_make_token_stack(int32_t starting_max){ - Cpp_Token_Stack token_stack; - token_stack.count = 0; - token_stack.max_count = starting_max; - token_stack.tokens = (Cpp_Token*)malloc(sizeof(Cpp_Token)*starting_max); - return(token_stack); +FCPP_LINK Cpp_Token_Array +cpp_make_token_array(int32_t starting_max)/* +DOC_PARAM(starting_max, The number of tokens to initialize the array with.) +DOC_RETURN(An empty Cpp_Token_Array with memory malloc'd for storing tokens.) +DOC(This call allocates a Cpp_Token_Array with malloc for use in other +convenience functions. Stacks that are not allocated this way should not be +used in the convenience functions. + +This call is a part of the FCPP_ALLOW_MALLOC convenience functions. +If you want to use it defined the macro FCPP_ALLOW_MALLOC before including 4cpp_lexer.h) +*/{ + Cpp_Token_Array token_array; + token_array.tokens = (Cpp_Token*)malloc(sizeof(Cpp_Token)*starting_max); + token_array.count = 0; + token_array.max_count = starting_max; + return(token_array); } FCPP_LINK void -cpp_free_token_stack(Cpp_Token_Stack token_stack){ - free(token_stack.tokens); +cpp_free_token_array(Cpp_Token_Array token_array)/* +DOC_PARAM(token_array, An array previously allocated by cpp_make_token_array) +DOC(This call frees a Cpp_Token_Array. + +This call is a part of the FCPP_ALLOW_MALLOC convenience functions. +If you want to use it defined the macro FCPP_ALLOW_MALLOC before including 4cpp_lexer.h) +DOC_SEE(cpp_make_token_array) +*/{ + free(token_array.tokens); } FCPP_LINK void -cpp_resize_token_stack(Cpp_Token_Stack *token_stack, int32_t new_max){ - Cpp_Token *new_tokens = (Cpp_Token*)malloc(sizeof(Cpp_Token)*new_max); - - if (new_tokens){ - memcpy(new_tokens, token_stack->tokens, sizeof(Cpp_Token)*token_stack->count); - free(token_stack->tokens); - token_stack->tokens = new_tokens; - token_stack->max_count = new_max; - } -} +cpp_resize_token_array(Cpp_Token_Array *token_array, int32_t new_max)/* +DOC_PARAM(token_array, An array previously allocated by cpp_make_token_array.) +DOC_PARAM(new_max, The new maximum size the array should support. If this is not greater +than the current size of the array the operation is ignored.) +DOC(This call allocates a new memory chunk and moves the existing tokens in the array +over to the new chunk. -FCPP_LINK void -cpp_push_token(Cpp_Token_Stack *token_stack, Cpp_Token token){ - if (!cpp_push_token_nonalloc(token_stack, token)){ - int32_t new_max = 2*token_stack->max_count + 1; - cpp_resize_token_stack(token_stack, new_max); - cpp_push_token_nonalloc(token_stack, token); +This call is a part of the FCPP_ALLOW_MALLOC convenience functions. +If you want to use it defined the macro FCPP_ALLOW_MALLOC before including 4cpp_lexer.h) +DOC_SEE(cpp_make_token_array) +*/{ + if (new_max > token_array->count){ + Cpp_Token *new_tokens = (Cpp_Token*)malloc(sizeof(Cpp_Token)*new_max); + + if (new_tokens){ + memcpy(new_tokens, token_array->tokens, sizeof(Cpp_Token)*token_array->count); + free(token_array->tokens); + token_array->tokens = new_tokens; + token_array->max_count = new_max; + } } } FCPP_LINK void -cpp_lex_file(char *data, int32_t size, Cpp_Token_Stack *token_stack_out){ - Lex_Data S = {0}; +cpp_lex_file(char *data, int32_t size, Cpp_Token_Array *token_array_out)/* +DOC_PARAM(data, The file data to be lexed in a single contiguous block.) +DOC_PARAM(size, The number of bytes in data.) +DOC_PARAM(token_array_out, The token array where the output tokens will be pushed. +This token array must be previously allocated with cpp_make_token_array) +DOC(Lexes an entire file and manages the interaction with the lexer system so that +it is quick and convenient to lex files. + +This call is a part of the FCPP_ALLOW_MALLOC convenience functions. +If you want to use it defined the macro FCPP_ALLOW_MALLOC before including 4cpp_lexer.h) +DOC_SEE(cpp_make_token_array) +*/{ + Cpp_Lex_Data S = {0}; S.tb = (char*)malloc(size); int32_t quit = 0; - token_stack_out->count = 0; + token_array_out->count = 0; for (;!quit;){ - int32_t result = cpp_lex_nonalloc(&S, data, size, token_stack_out); + int32_t result = cpp_lex_nonalloc(&S, data, size, HAS_NULL_TERM, token_array_out, NO_OUT_LIMIT); switch (result){ - case LexFinished: + case LexResult_Finished: { quit = 1; }break; - case LexNeedChunk: + case LexResult_NeedChunk: { + Assert(token_array_out->count < token_array_out->max_count); + + // NOTE(allen): We told the system we would provide the null + // terminator, but we didn't actually, so provide the null + // terminator via this one byte chunk. char empty = 0; - cpp_lex_nonalloc(&S, &empty, 1, token_stack_out); - quit = 1; + cpp_lex_nonalloc(&S, &empty, 1, HAS_NULL_TERM, token_array_out, NO_OUT_LIMIT); }break; - case LexNeedTokenMemory: + case LexResult_NeedTokenMemory: { - int32_t new_max = 2*token_stack_out->max_count + 1; - cpp_resize_token_stack(token_stack_out, new_max); + // NOTE(allen): We told the system to use all of the output memory + // but we ran out anyway, so allocate more memory. We hereby assume + // the stack was allocated using cpp_make_token_array. + int32_t new_max = 2*token_array_out->max_count + 1; + cpp_resize_token_array(token_array_out, new_max); }break; } } diff --git a/4cpp_lexer_fsms.h b/4cpp_lexer_fsms.h deleted file mode 100644 index 9448d972..00000000 --- a/4cpp_lexer_fsms.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * FSMs for 4cpp lexer - * - * 23.03.2016 (dd.mm.yyyy) - * - */ - -// TOP - -#if !defined(FCPP_LEXER_FSMS_H) -#define FCPP_LEXER_FSMS_H - -enum Lex_State{ - LS_default, - LS_identifier, - LS_pound, - LS_pp, - LS_ppdef, - LS_char, - LS_char_multiline, - LS_char_slashed, - LS_string, - LS_string_multiline, - LS_string_slashed, - LS_number, - LS_number0, - LS_float, - LS_crazy_float0, - LS_crazy_float1, - LS_hex, - LS_comment_pre, - LS_comment, - LS_comment_slashed, - LS_comment_block, - LS_comment_block_ending, - LS_dot, - LS_ellipsis, - LS_less, - LS_less_less, - LS_more, - LS_more_more, - LS_minus, - LS_arrow, - LS_and, - LS_or, - LS_plus, - LS_colon, - LS_star, - LS_modulo, - LS_caret, - LS_eq, - LS_bang, - LS_error_message, - // - LS_count -}; - -enum Lex_Int_State{ - LSINT_default, - LSINT_u, - LSINT_l, - LSINT_L, - LSINT_ul, - LSINT_uL, - LSINT_ll, - LSINT_extra, - // - LSINT_count -}; - -enum Lex_PP_State{ - LSPP_default, - LSPP_include, - LSPP_macro_identifier, - LSPP_identifier, - LSPP_body_if, - LSPP_body, - LSPP_number, - LSPP_error, - LSPP_junk, - // - LSPP_count -}; - -struct Lex_FSM{ - uint8_t state; - uint8_t int_state; - uint8_t emit_token; - uint8_t multi_line; -}; -static Lex_FSM null_lex_fsm = {0}; - -#endif - -// BOTTOM - - diff --git a/4cpp_lexer_types.h b/4cpp_lexer_types.h index 8d58de15..401b48f8 100644 --- a/4cpp_lexer_types.h +++ b/4cpp_lexer_types.h @@ -8,6 +8,10 @@ #define ENUM(type,name) typedef type name; enum name##_ #endif +#ifndef INTERNAL_ENUM +#define INTERNAL_ENUM(type,name) typedef type name; enum name##_ +#endif + /* DOC(A Cpp_Token_Type classifies a token to make parsing easier. Some types are not actually output by the lexer, but exist because parsers will also make use of token types in their own output.) */ @@ -255,11 +259,11 @@ ENUM(uint16_t, Cpp_Preprocessor_State){ CPP_LEX_PP_COUNT }; -struct Cpp_Token_Stack{ +struct Cpp_Token_Array{ Cpp_Token *tokens; int32_t count, max_count; }; -static Cpp_Token_Stack null_cpp_token_stack = {0}; +static Cpp_Token_Array null_cpp_token_array = {0}; struct Cpp_Get_Token_Result{ int32_t token_index; @@ -270,7 +274,7 @@ struct Cpp_Relex_State{ char *data; int32_t size; - Cpp_Token_Stack *stack; + Cpp_Token_Array *array; int32_t start, end, amount; int32_t start_token_i; int32_t end_token_i; @@ -279,6 +283,112 @@ struct Cpp_Relex_State{ int32_t space_request; }; +struct Cpp_Lex_FSM{ + uint8_t state; + uint8_t int_state; + uint8_t emit_token; + uint8_t multi_line; +}; +static Cpp_Lex_FSM null_lex_fsm = {0}; + +struct Cpp_Lex_Data{ + char *tb; + int32_t tb_pos; + int32_t token_start; + + int32_t pos; + int32_t pos_overide; + int32_t chunk_pos; + + Cpp_Lex_FSM fsm; + uint8_t white_done; + uint8_t pp_state; + uint8_t completed; + + Cpp_Token token; + + int32_t __pc__; +}; + +ENUM(int32_t, Cpp_Lex_Result){ + LexResult_Finished, + LexResult_NeedChunk, + LexResult_NeedTokenMemory, + LexResult_HitTokenLimit, +}; + +INTERNAL_ENUM(uint8_t, Cpp_Lex_State){ + LS_default, + LS_identifier, + LS_pound, + LS_pp, + LS_ppdef, + LS_char, + LS_char_multiline, + LS_char_slashed, + LS_string, + LS_string_multiline, + LS_string_slashed, + LS_number, + LS_number0, + LS_float, + LS_crazy_float0, + LS_crazy_float1, + LS_hex, + LS_comment_pre, + LS_comment, + LS_comment_slashed, + LS_comment_block, + LS_comment_block_ending, + LS_dot, + LS_ellipsis, + LS_less, + LS_less_less, + LS_more, + LS_more_more, + LS_minus, + LS_arrow, + LS_and, + LS_or, + LS_plus, + LS_colon, + LS_star, + LS_modulo, + LS_caret, + LS_eq, + LS_bang, + LS_error_message, + // + LS_count +}; + +INTERNAL_ENUM(uint8_t, Cpp_Lex_Int_State){ + LSINT_default, + LSINT_u, + LSINT_l, + LSINT_L, + LSINT_ul, + LSINT_uL, + LSINT_ll, + LSINT_extra, + // + LSINT_count +}; + +INTERNAL_ENUM(uint8_t, Cpp_Lex_PP_State){ + LSPP_default, + LSPP_include, + LSPP_macro_identifier, + LSPP_identifier, + LSPP_body_if, + LSPP_body, + LSPP_number, + LSPP_error, + LSPP_junk, + // + LSPP_count +}; + #endif // BOTTOM diff --git a/4ed.cpp b/4ed.cpp index efe3c9a8..07c13046 100644 --- a/4ed.cpp +++ b/4ed.cpp @@ -502,7 +502,7 @@ case_change_range(System_Functions *system, } } - if (file->state.token_stack.tokens) + if (file->state.token_array.tokens) file_relex_parallel(system, mem, file, range.start, range.end, 0); } #endif diff --git a/4ed_api_implementation.cpp b/4ed_api_implementation.cpp index 5038a30a..3c0dab5b 100644 --- a/4ed_api_implementation.cpp +++ b/4ed_api_implementation.cpp @@ -541,7 +541,7 @@ DOC_SEE(Access_Flag) } internal i32 -seek_token_left(Cpp_Token_Stack *tokens, i32 pos){ +seek_token_left(Cpp_Token_Array *tokens, i32 pos){ Cpp_Get_Token_Result get = cpp_get_token(tokens, pos); if (get.token_index == -1){ get.token_index = 0; @@ -556,7 +556,7 @@ seek_token_left(Cpp_Token_Stack *tokens, i32 pos){ } internal i32 -seek_token_right(Cpp_Token_Stack *tokens, i32 pos){ +seek_token_right(Cpp_Token_Array *tokens, i32 pos){ Cpp_Get_Token_Result get = cpp_get_token(tokens, pos); if (get.in_whitespace){ ++get.token_index; @@ -609,7 +609,7 @@ DOC_SEE(4coder_Buffer_Positioning_System) if (flags & (1 << 1)){ if (file->state.tokens_complete){ - pos[1] = seek_token_right(&file->state.token_stack, start_pos); + pos[1] = seek_token_right(&file->state.token_array, start_pos); } else{ pos[1] = buffer_seek_whitespace_right(&file->state.buffer, start_pos); @@ -640,7 +640,7 @@ DOC_SEE(4coder_Buffer_Positioning_System) if (flags & (1 << 1)){ if (file->state.tokens_complete){ - pos[1] = seek_token_left(&file->state.token_stack, start_pos); + pos[1] = seek_token_left(&file->state.token_array, start_pos); } else{ pos[1] = buffer_seek_whitespace_left(&file->state.buffer, start_pos); @@ -942,7 +942,7 @@ DOC_SEE(4coder_Buffer_Positioning_System) bool32 result = false; Editing_File *file = imp_get_file(cmd, buffer); - if (file && file->state.token_stack.tokens && + if (file && file->state.token_array.tokens && file->state.tokens_complete && !file->state.still_lexing){ result = true; diff --git a/4ed_file.cpp b/4ed_file.cpp index 277f20e5..eab17260 100644 --- a/4ed_file.cpp +++ b/4ed_file.cpp @@ -135,8 +135,8 @@ struct Editing_File_State{ Undo_Data undo; - Cpp_Token_Stack token_stack; - Cpp_Token_Stack swap_stack; + Cpp_Token_Array token_array; + Cpp_Token_Array swap_array; u32 lex_job; b32 tokens_complete; b32 still_lexing; diff --git a/4ed_file_view.cpp b/4ed_file_view.cpp index 2ff9ee7f..45577bac 100644 --- a/4ed_file_view.cpp +++ b/4ed_file_view.cpp @@ -1083,13 +1083,13 @@ internal void file_close(System_Functions *system, General_Memory *general, Editing_File *file){ if (file->state.still_lexing){ system->cancel_job(BACKGROUND_THREADS, file->state.lex_job); - if (file->state.swap_stack.tokens){ - general_memory_free(general, file->state.swap_stack.tokens); - file->state.swap_stack.tokens = 0; + if (file->state.swap_array.tokens){ + general_memory_free(general, file->state.swap_array.tokens); + file->state.swap_array.tokens = 0; } } - if (file->state.token_stack.tokens){ - general_memory_free(general, file->state.token_stack.tokens); + if (file->state.token_array.tokens){ + general_memory_free(general, file->state.token_array.tokens); } Buffer_Type *buffer = &file->state.buffer; @@ -1136,25 +1136,25 @@ Job_Callback_Sig(job_full_lex){ char *tb = (char*)memory->data; - Cpp_Token_Stack tokens; + Cpp_Token_Array tokens; tokens.tokens = (Cpp_Token*)((char*)memory->data + buffer_size); tokens.max_count = (memory->size - buffer_size) / sizeof(Cpp_Token); tokens.count = 0; b32 still_lexing = 1; - Lex_Data lex = lex_data_init(tb); + Cpp_Lex_Data lex = cpp_lex_data_init(tb); do{ i32 result = - cpp_lex_size_nonalloc(&lex, - text_data, text_size, text_size, - &tokens, 2048); + cpp_lex_nonalloc(&lex, + text_data, text_size, text_size, + &tokens, 2048); switch (result){ - case LexNeedChunk: Assert(!"Invalid Path"); break; + case LexResult_NeedChunk: Assert(!"Invalid Path"); break; - case LexNeedTokenMemory: + case LexResult_NeedTokenMemory: if (system->check_cancel(thread)){ return; } @@ -1164,13 +1164,13 @@ Job_Callback_Sig(job_full_lex){ tokens.max_count = (memory->size - buffer_size) / sizeof(Cpp_Token); break; - case LexHitTokenLimit: + case LexResult_HitTokenLimit: if (system->check_cancel(thread)){ return; } break; - case LexFinished: still_lexing = 0; break; + case LexResult_Finished: still_lexing = 0; break; } } while (still_lexing); @@ -1178,27 +1178,27 @@ Job_Callback_Sig(job_full_lex){ system->acquire_lock(FRAME_LOCK); { - Assert(file->state.swap_stack.tokens == 0); - file->state.swap_stack.tokens = (Cpp_Token*) + Assert(file->state.swap_array.tokens == 0); + file->state.swap_array.tokens = (Cpp_Token*) general_memory_allocate(general, new_max*sizeof(Cpp_Token)); } system->release_lock(FRAME_LOCK); - u8 *dest = (u8*)file->state.swap_stack.tokens; + u8 *dest = (u8*)file->state.swap_array.tokens; u8 *src = (u8*)tokens.tokens; memcpy(dest, src, tokens.count*sizeof(Cpp_Token)); system->acquire_lock(FRAME_LOCK); { - Cpp_Token_Stack *file_stack = &file->state.token_stack; - file_stack->count = tokens.count; - file_stack->max_count = new_max; - if (file_stack->tokens){ - general_memory_free(general, file_stack->tokens); + Cpp_Token_Array *file_token_array = &file->state.token_array; + file_token_array->count = tokens.count; + file_token_array->max_count = new_max; + if (file_token_array->tokens){ + general_memory_free(general, file_token_array->tokens); } - file_stack->tokens = file->state.swap_stack.tokens; - file->state.swap_stack.tokens = 0; + file_token_array->tokens = file->state.swap_array.tokens; + file->state.swap_array.tokens = 0; } system->release_lock(FRAME_LOCK); @@ -1216,16 +1216,16 @@ file_kill_tokens(System_Functions *system, file->settings.tokens_exist = 0; if (file->state.still_lexing){ system->cancel_job(BACKGROUND_THREADS, file->state.lex_job); - if (file->state.swap_stack.tokens){ - general_memory_free(general, file->state.swap_stack.tokens); - file->state.swap_stack.tokens = 0; + if (file->state.swap_array.tokens){ + general_memory_free(general, file->state.swap_array.tokens); + file->state.swap_array.tokens = 0; } } - if (file->state.token_stack.tokens){ - general_memory_free(general, file->state.token_stack.tokens); + if (file->state.token_array.tokens){ + general_memory_free(general, file->state.token_array.tokens); } file->state.tokens_complete = 0; - file->state.token_stack = null_cpp_token_stack; + file->state.token_array = null_cpp_token_array; } #if BUFFER_EXPERIMENT_SCALPEL <= 0 @@ -1235,7 +1235,7 @@ file_first_lex_parallel(System_Functions *system, file->settings.tokens_exist = 1; if (file->is_loading == 0 && file->state.still_lexing == 0){ - Assert(file->state.token_stack.tokens == 0); + Assert(file->state.token_array.tokens == 0); file->state.tokens_complete = 0; file->state.still_lexing = 1; @@ -1256,7 +1256,7 @@ file_relex_parallel(System_Functions *system, General_Memory *general = &mem->general; Partition *part = &mem->part; - if (file->state.token_stack.tokens == 0){ + if (file->state.token_array.tokens == 0){ file_first_lex_parallel(system, general, file); return(false); } @@ -1267,15 +1267,15 @@ file_relex_parallel(System_Functions *system, char *data = file->state.buffer.data; i32 size = file->state.buffer.size; - Cpp_Token_Stack *stack = &file->state.token_stack; + Cpp_Token_Array *array = &file->state.token_array; Cpp_Relex_State state = - cpp_relex_nonalloc_start(data, size, stack, + cpp_relex_nonalloc_start(data, size, array, start_i, end_i, amount, 100); Temp_Memory temp = begin_temp_memory(part); i32 relex_end; - Cpp_Token_Stack relex_space; + Cpp_Token_Array relex_space; relex_space.count = 0; relex_space.max_count = state.space_request; relex_space.tokens = push_array(part, Cpp_Token, relex_space.max_count); @@ -1289,27 +1289,27 @@ file_relex_parallel(System_Functions *system, i32 shift_amount = relex_space.count - delete_amount; if (shift_amount != 0){ - i32 new_count = stack->count + shift_amount; - if (new_count > stack->max_count){ + i32 new_count = array->count + shift_amount; + if (new_count > array->max_count){ i32 new_max = LargeRoundUp(new_count, Kbytes(1)); - stack->tokens = (Cpp_Token*) - general_memory_reallocate(general, stack->tokens, - stack->count*sizeof(Cpp_Token), + array->tokens = (Cpp_Token*) + general_memory_reallocate(general, array->tokens, + array->count*sizeof(Cpp_Token), new_max*sizeof(Cpp_Token)); - stack->max_count = new_max; + array->max_count = new_max; } - i32 shift_size = stack->count - relex_end; + i32 shift_size = array->count - relex_end; if (shift_size > 0){ - Cpp_Token *old_base = stack->tokens + relex_end; + Cpp_Token *old_base = array->tokens + relex_end; memmove(old_base + shift_amount, old_base, sizeof(Cpp_Token)*shift_size); } - stack->count += shift_amount; + array->count += shift_amount; } - memcpy(state.stack->tokens + state.start_token_i, relex_space.tokens, + memcpy(state.array->tokens + state.start_token_i, relex_space.tokens, sizeof(Cpp_Token)*relex_space.count); } @@ -1317,17 +1317,21 @@ file_relex_parallel(System_Functions *system, } if (!inline_lex){ - Cpp_Token_Stack *stack = &file->state.token_stack; - Cpp_Get_Token_Result get_token_result = cpp_get_token(stack, end_i); + Cpp_Token_Array *array = &file->state.token_array; + Cpp_Get_Token_Result get_token_result = cpp_get_token(array, end_i); i32 end_token_i = get_token_result.token_index; - if (end_token_i < 0) end_token_i = 0; - else if (end_i > stack->tokens[end_token_i].start) ++end_token_i; + if (end_token_i < 0){ + end_token_i = 0; + } + else if (end_i > array->tokens[end_token_i].start){ + ++end_token_i; + } - cpp_shift_token_starts(stack, end_token_i, amount); + cpp_shift_token_starts(array, end_token_i, amount); --end_token_i; if (end_token_i >= 0){ - Cpp_Token *token = stack->tokens + end_token_i; + Cpp_Token *token = array->tokens + end_token_i; if (token->start < end_i && token->start + token->size > end_i){ token->size += amount; } @@ -1914,9 +1918,9 @@ file_pre_edit_maintenance(System_Functions *system, Editing_File *file){ if (file->state.still_lexing){ system->cancel_job(BACKGROUND_THREADS, file->state.lex_job); - if (file->state.swap_stack.tokens){ - general_memory_free(general, file->state.swap_stack.tokens); - file->state.swap_stack.tokens = 0; + if (file->state.swap_array.tokens){ + general_memory_free(general, file->state.swap_array.tokens); + file->state.swap_array.tokens = 0; } file->state.still_lexing = 0; } @@ -2175,7 +2179,7 @@ file_do_batch_edit(System_Functions *system, Models *models, Editing_File *file, case BatchEdit_PreserveTokens: { if (file->state.tokens_complete){ - Cpp_Token_Stack tokens = file->state.token_stack; + Cpp_Token_Array tokens = file->state.token_array; Cpp_Token *token = tokens.tokens; Cpp_Token *end_token = tokens.tokens + tokens.count; Cpp_Token original = {(Cpp_Token_Type)0}; @@ -2531,21 +2535,21 @@ struct Make_Batch_Result{ }; internal Cpp_Token* -get_first_token_at_line(Buffer *buffer, Cpp_Token_Stack tokens, i32 line){ - Cpp_Token *result = 0; - i32 start_pos = 0; - Cpp_Get_Token_Result get_token = {0}; +get_first_token_at_line(Buffer *buffer, Cpp_Token_Array tokens, i32 line){ + i32 start_pos = buffer->line_starts[line]; + Cpp_Get_Token_Result get_token = cpp_get_token(&tokens, start_pos); - start_pos = buffer->line_starts[line]; - get_token = cpp_get_token(&tokens, start_pos); - if (get_token.in_whitespace) get_token.token_index += 1; - result = tokens.tokens + get_token.token_index; + if (get_token.in_whitespace){ + get_token.token_index += 1; + } + + Cpp_Token *result = tokens.tokens + get_token.token_index; return(result); } internal Cpp_Token* -seek_matching_token_backwards(Cpp_Token_Stack tokens, Cpp_Token *token, +seek_matching_token_backwards(Cpp_Token_Array tokens, Cpp_Token *token, Cpp_Token_Type open_type, Cpp_Token_Type close_type){ int32_t nesting_level = 0; if (token <= tokens.tokens){ @@ -2667,7 +2671,7 @@ compute_this_indent(Buffer *buffer, Indent_Parse_State indent, } internal i32* -get_line_indentation_marks(Partition *part, Buffer *buffer, Cpp_Token_Stack tokens, +get_line_indentation_marks(Partition *part, Buffer *buffer, Cpp_Token_Array tokens, i32 line_start, i32 line_end, i32 tab_width){ i32 indent_mark_count = line_end - line_start; @@ -2935,7 +2939,7 @@ file_auto_tab_tokens(System_Functions *system, Models *models, Buffer *buffer = &file->state.buffer; Assert(file && !file->is_dummy); - Cpp_Token_Stack tokens = file->state.token_stack; + Cpp_Token_Array tokens = file->state.token_array; Assert(tokens.tokens); i32 line_start = buffer_get_line_index(buffer, start); @@ -3138,7 +3142,7 @@ init_normal_file(System_Functions *system, Models *models, Editing_File *file, String val = make_string(buffer, size); file_create_from_string(system, models, file, val); - if (file->settings.tokens_exist && file->state.token_stack.tokens == 0){ + if (file->settings.tokens_exist && file->state.token_array.tokens == 0){ file_first_lex_parallel(system, general, file); } @@ -3156,7 +3160,7 @@ init_read_only_file(System_Functions *system, Models *models, Editing_File *file String val = null_string; file_create_from_string(system, models, file, val, 1); - if (file->settings.tokens_exist && file->state.token_stack.tokens == 0){ + if (file->settings.tokens_exist && file->state.token_array.tokens == 0){ file_first_lex_parallel(system, general, file); } @@ -3467,7 +3471,7 @@ update_highlighting(View *view){ } else if (file->state.tokens_complete){ - Cpp_Token_Stack *tokens = &file->state.token_stack; + Cpp_Token_Stack *tokens = &file->state.token_array; Cpp_Get_Token_Result result = cpp_get_token(tokens, pos); Cpp_Token token = tokens->tokens[result.token_index]; if (!result.in_whitespace){ @@ -5299,10 +5303,10 @@ draw_file_loaded(View *view, i32_Rect rect, b32 is_active, Render_Target *target Assert(view->edit_pos); b32 tokens_use = 0; - Cpp_Token_Stack token_stack = {}; + Cpp_Token_Array token_array = {}; if (file){ - tokens_use = file->state.tokens_complete && (file->state.token_stack.count > 0); - token_stack = file->state.token_stack; + tokens_use = file->state.tokens_complete && (file->state.token_array.count > 0); + token_array = file->state.token_array; } Partition *part = &models->mem.part; @@ -5372,8 +5376,8 @@ draw_file_loaded(View *view, i32_Rect rect, b32 is_active, Render_Target *target u32 main_color = style->main.default_color; u32 special_color = style->main.special_character_color; if (tokens_use){ - Cpp_Get_Token_Result result = cpp_get_token(&token_stack, items->index); - main_color = *style_get_color(style, token_stack.tokens[result.token_index]); + Cpp_Get_Token_Result result = cpp_get_token(&token_array, items->index); + main_color = *style_get_color(style, token_array.tokens[result.token_index]); token_i = result.token_index + 1; } @@ -5388,13 +5392,13 @@ draw_file_loaded(View *view, i32_Rect rect, b32 is_active, Render_Target *target i32 ind = item->index; highlight_this_color = 0; if (tokens_use && ind != prev_ind){ - Cpp_Token current_token = token_stack.tokens[token_i-1]; + Cpp_Token current_token = token_array.tokens[token_i-1]; - if (token_i < token_stack.count){ - if (ind >= token_stack.tokens[token_i].start){ + if (token_i < token_array.count){ + if (ind >= token_array.tokens[token_i].start){ main_color = - *style_get_color(style, token_stack.tokens[token_i]); - current_token = token_stack.tokens[token_i]; + *style_get_color(style, token_array.tokens[token_i]); + current_token = token_array.tokens[token_i]; ++token_i; } else if (ind >= current_token.start + current_token.size){ diff --git a/4ed_metagen.cpp b/4ed_metagen.cpp index 416bfc28..a9f3d452 100644 --- a/4ed_metagen.cpp +++ b/4ed_metagen.cpp @@ -410,7 +410,7 @@ typedef struct Item_Set{ typedef struct Parse{ String code; - Cpp_Token_Stack tokens; + Cpp_Token_Array tokens; int32_t item_count; } Parse; @@ -440,10 +440,10 @@ get_lexeme(Cpp_Token token, char *code){ } static Parse_Context -setup_parse_context(char *data, Cpp_Token_Stack stack){ +setup_parse_context(char *data, Cpp_Token_Array array){ Parse_Context context; - context.token_s = stack.tokens; - context.token_e = stack.tokens + stack.count; + context.token_s = array.tokens; + context.token_e = array.tokens + array.count; context.token = context.token_s; context.data = data; return(context); @@ -536,7 +536,7 @@ static Parse meta_lex(char *filename){ Parse result = {0}; result.code = file_dump(filename); - result.tokens = cpp_make_token_stack(1024); + result.tokens = cpp_make_token_array(1024); cpp_lex_file(result.code.str, result.code.size, &result.tokens); return(result); } @@ -584,9 +584,19 @@ typedef enum Doc_Note_Type{ DOC_PARAM, DOC_RETURN, DOC, - DOC_SEE + DOC_SEE, + DOC_HIDE } Doc_Note_Type; +static String +doc_note_string[] = { + make_lit_string("DOC_PARAM"), + make_lit_string("DOC_RETURN"), + make_lit_string("DOC"), + make_lit_string("DOC_SEE"), + make_lit_string("DOC_HIDE"), +}; + static int32_t check_and_fix_docs(String *doc_string){ int32_t result = false; @@ -628,14 +638,6 @@ get_doc_string_from_prev(Parse_Context *context, String *doc_string){ return(result); } -static String -doc_note_string[] = { - make_lit_string("DOC_PARAM"), - make_lit_string("DOC_RETURN"), - make_lit_string("DOC"), - make_lit_string("DOC_SEE"), -}; - static String doc_parse_note(String source, int32_t *pos){ String result = {0}; @@ -1781,6 +1783,7 @@ print_macro_html(String *out, String name, Argument_Breakdown breakdown){ #define BACK_COLOR "#FAFAFA" #define TEXT_COLOR "#0D0D0D" #define CODE_BACK "#DFDFDF" +#define EXAMPLE_BACK "#EFEFDF" #define POP_COLOR_1 "#309030" #define POP_BACK_1 "#E0FFD0" @@ -1790,9 +1793,12 @@ print_macro_html(String *out, String name, Argument_Breakdown breakdown){ #define CODE_STYLE "font-family: \"Courier New\", Courier, monospace; text-align: left;" -#define DESCRIPT_SECTION_STYLE \ -"margin-top: 3mm; margin-bottom: 3mm; font-size: .95em; " \ -"background: "CODE_BACK"; padding: 0.25em;" +#define CODE_BLOCK_STYLE(back) \ +"margin-top: 3mm; margin-bottom: 3mm; font-size: .95em; " \ +"background: "back"; padding: 0.25em;" + +#define DESCRIPT_SECTION_STYLE CODE_BLOCK_STYLE(CODE_BACK) +#define EXAMPLE_CODE_STYLE CODE_BLOCK_STYLE(EXAMPLE_BACK) #define DOC_HEAD_OPEN "
" #define DOC_HEAD_CLOSE "
" @@ -1808,6 +1814,227 @@ print_macro_html(String *out, String name, Argument_Breakdown breakdown){ #define DOC_ITEM_OPEN "
" #define DOC_ITEM_CLOSE "
" +#define EXAMPLE_CODE_OPEN "
" +#define EXAMPLE_CODE_CLOSE "
" + +static String +get_first_double_line(String source){ + String line = {0}; + int32_t pos0 = find_substr_s(source, 0, make_lit_string("\n\n")); + int32_t pos1 = find_substr_s(source, 0, make_lit_string("\r\n\r\n")); + if (pos1 < pos0){ + pos0 = pos1; + } + line = substr(source, 0, pos0); + return(line); +} + +static String +get_next_double_line(String source, String line){ + String next = {0}; + int32_t pos = (int32_t)(line.str - source.str) + line.size; + int32_t start = 0, pos0 = 0, pos1 = 0; + + if (pos < source.size){ + assert(source.str[pos] == '\n' || source.str[pos] == '\r'); + start = pos + 1; + + if (start < source.size){ + pos0 = find_substr_s(source, start, make_lit_string("\n\n")); + pos1 = find_substr_s(source, start, make_lit_string("\r\n\r\n")); + if (pos1 < pos0){ + pos0 = pos1; + } + next = substr(source, start, pos0 - start); + } + } + + return(next); +} + +static String +get_next_word(String source, String prev_word){ + String word = {0}; + int32_t pos0 = (int32_t)(prev_word.str - source.str) + prev_word.size; + int32_t pos1 = 0; + char c = 0; + + for (; pos0 < source.size; ++pos0){ + c = source.str[pos0]; + if (!(char_is_whitespace(c) || c == '(' || c == ')')){ + break; + } + } + + if (pos0 < source.size){ + for (pos1 = pos0; pos1 < source.size; ++pos1){ + c = source.str[pos1]; + if (char_is_whitespace(c) || c == '(' || c == ')'){ + break; + } + } + + word = substr(source, pos0, pos1 - pos0); + } + + return(word); +} + +static String +get_first_word(String source){ + String start_str = make_string(source.str, 0); + String word = get_next_word(source, start_str); + return(word); +} + +enum Doc_Chunk_Type{ + DocChunk_PlainText, + DocChunk_CodeExample, + + DocChunk_Count +}; + +static String doc_chunk_headers[] = { + make_lit_string(""), + make_lit_string("CODE_EXAMPLE"), +}; + +static String +get_next_doc_chunk(String source, String prev_chunk, Doc_Chunk_Type *type){ + String chunk = {0}; + String word = {0}; + int32_t pos = source.size; + int32_t word_index = 0; + Doc_Chunk_Type t = DocChunk_PlainText; + + int32_t start_pos = (int32_t)(prev_chunk.str - source.str) + prev_chunk.size; + String source_tail = substr_tail(source, start_pos); + + Assert(DocChunk_Count == ArrayCount(doc_chunk_headers)); + + for (word = get_first_word(source_tail); + word.str; + word = get_next_word(source_tail, word), ++word_index){ + + for (int32_t i = 1; i < DocChunk_Count; ++i){ + if (match_ss(word, doc_chunk_headers[i])){ + pos = (int32_t)(word.str - source.str); + t = (Doc_Chunk_Type)i; + goto doublebreak; + } + } + } + doublebreak:; + + *type = DocChunk_PlainText; + if (word_index == 0){ + *type = t; + + int32_t nest_level = 1; + int32_t i = find_s_char(source, pos, '('); + for (++i; i < source.size; ++i){ + if (source.str[i] == '('){ + ++nest_level; + } + else if (source.str[i] == ')'){ + --nest_level; + if (nest_level == 0){ + break; + } + } + } + + pos = i+1; + } + + chunk = substr(source, start_pos, pos - start_pos); + + int32_t is_all_white = 1; + for (int32_t i = 0; i < chunk.size; ++i){ + if (!char_is_whitespace(chunk.str[i])){ + is_all_white = 0; + break; + } + } + + if (is_all_white){ + chunk = null_string; + } + + return(chunk); +} + +static String +get_first_doc_chunk(String source, Doc_Chunk_Type *type){ + String start_str = make_string(source.str, 0); + String chunk = get_next_doc_chunk(source, start_str, type); + return(chunk); +} + + +static void +print_doc_description(String *out, Partition *part, String src){ + Doc_Chunk_Type type; + + for (String chunk = get_first_doc_chunk(src, &type); + chunk.str; + chunk = get_next_doc_chunk(src, chunk, &type)){ + + switch (type){ + case DocChunk_PlainText: + { + for (String line = get_first_double_line(chunk); + line.str; + line = get_next_double_line(chunk, line)){ + append_ss(out, line); + append_sc(out, "

"); + } + }break; + + case DocChunk_CodeExample: + { + int32_t start = 0; + int32_t end = chunk.size-1; + while (start < end && chunk.str[start] != '(') ++start; + start += 1; + while (end > start && chunk.str[end] != ')') --end; + + + append_sc(out, EXAMPLE_CODE_OPEN); + + if (start < end){ + String code_example = substr(chunk, start, end - start); + int32_t first_line = 1; + + for (String line = get_first_line(code_example); + line.str; + line = get_next_line(code_example, line)){ + + if (!(first_line && line.size == 0)){ + int32_t space_i = 0; + for (; space_i < line.size; ++space_i){ + if (line.str[space_i] == ' '){ + append_sc(out, " "); + } + else{ + break; + } + } + + String line_tail = substr_tail(line, space_i); + append_ss(out, line_tail); + append_sc(out, "
"); + } + first_line = 0; + } + } + + append_sc(out, EXAMPLE_CODE_CLOSE); + }break; + } + } +} + static void print_struct_docs(String *out, Partition *part, Item_Node *member){ for (Item_Node *member_iter = member->first_child; @@ -1829,7 +2056,8 @@ print_struct_docs(String *out, Partition *part, Item_Node *member){ append_sc(out, DOC_ITEM_HEAD_INL_CLOSE"
"); append_sc(out, "
"DOC_ITEM_OPEN); - append_ss(out, doc.main_doc); + // TODO(allen): append_ss(out, doc.main_doc); + print_doc_description(out, part, doc.main_doc); append_sc(out, DOC_ITEM_CLOSE"
"); append_sc(out, "
"); @@ -1854,30 +2082,6 @@ print_see_also(String *out, Documentation *doc){ } } -static void -print_see_also(FILE *file, Documentation *doc){ - int32_t doc_see_count = doc->see_also_count; - if (doc_see_count > 0){ - fprintf(file, DOC_HEAD_OPEN"See Also"DOC_HEAD_CLOSE); - - for (int32_t j = 0; j < doc_see_count; ++j){ - String see_also = doc->see_also[j]; - fprintf(file, - DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE, - see_also.size, see_also.str, - see_also.size, see_also.str - ); - } - } -} - -static void -print_str(FILE *file, String str){ - if (str.size > 0){ - fprintf(file, "%.*s", str.size, str.str); - } -} - static void print_function_body_code(String *out, Parse_Context *context, int32_t start){ String pstr = {0}, lexeme = {0}; @@ -1968,7 +2172,8 @@ print_function_docs(String *out, Partition *part, String name, String doc_string String main_doc = doc.main_doc; if (main_doc.size != 0){ append_sc(out, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE DOC_ITEM_OPEN); - append_ss(out, main_doc); + // TODO(allen): append_ss(out, main_doc); + print_doc_description(out, part, main_doc); append_sc(out, DOC_ITEM_CLOSE); } @@ -2076,9 +2281,13 @@ print_item(String *out, Partition *part, Used_Links *used, append_sc(out, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE); append_sc(out, DOC_ITEM_OPEN); - append_ss(out, main_doc); + // TODO(allen): append_ss(out, main_doc); + print_doc_description(out, part, main_doc); append_sc(out, DOC_ITEM_CLOSE); } + else{ + fprintf(stderr, "warning: no documentation string for %.*s\n", name.size, name.str); + } print_see_also(out, &doc); @@ -2104,9 +2313,13 @@ print_item(String *out, Partition *part, Used_Links *used, append_sc(out, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE); append_sc(out, DOC_ITEM_OPEN); - append_ss(out, main_doc); + // TODO(allen): append_ss(out, main_doc); + print_doc_description(out, part, main_doc); append_sc(out, DOC_ITEM_CLOSE); } + else{ + fprintf(stderr, "warning: no documentation string for %.*s\n", name.size, name.str); + } if (item->first_child){ append_sc(out, DOC_HEAD_OPEN"Values"DOC_HEAD_CLOSE); @@ -2132,7 +2345,8 @@ print_item(String *out, Partition *part, Used_Links *used, append_sc(out, "
"); append_sc(out, "
"DOC_ITEM_OPEN); - append_ss(out, doc.main_doc); + // TODO(allen): append_ss(out, doc.main_doc); + print_doc_description(out, part, doc.main_doc); append_sc(out, DOC_ITEM_CLOSE"
"); append_sc(out, "
"); @@ -2164,9 +2378,13 @@ print_item(String *out, Partition *part, Used_Links *used, append_sc(out, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE); append_sc(out, DOC_ITEM_OPEN); - append_ss(out, main_doc); + // TODO(allen): append_ss(out, main_doc); + print_doc_description(out, part, main_doc); append_sc(out, DOC_ITEM_CLOSE); } + else{ + fprintf(stderr, "warning: no documentation string for %.*s\n", name.size, name.str); + } if (member->first_child){ append_sc(out, DOC_HEAD_OPEN"Fields"DOC_HEAD_CLOSE); diff --git a/build.c b/build.c index 4255b113..38f578c4 100644 --- a/build.c +++ b/build.c @@ -713,12 +713,9 @@ build_main(char *cdir, uint32_t flags){ static void standard_build(char *cdir, uint32_t flags){ fsm_generator(cdir); - metagen(cdir); - - //do_buildsuper(cdir); - - //build_main(cdir, flags); + do_buildsuper(cdir); + build_main(cdir, flags); } #define PACK_DIR "../distributions" diff --git a/fsm_table_generator.cpp b/fsm_table_generator.cpp index c682d033..d7bcf0ee 100644 --- a/fsm_table_generator.cpp +++ b/fsm_table_generator.cpp @@ -15,7 +15,6 @@ #define ArrayCount(a) (sizeof(a)/sizeof(*a)) #include "4cpp_lexer_types.h" -#include "4cpp_lexer_fsms.h" #include "4ed_mem_ansi.c" typedef struct Whitespace_FSM{ @@ -34,8 +33,8 @@ whitespace_skip_fsm(Whitespace_FSM wfsm, char c){ return(wfsm); } -Lex_FSM -int_fsm(Lex_FSM fsm, char c){ +Cpp_Lex_FSM +int_fsm(Cpp_Lex_FSM fsm, char c){ switch (fsm.int_state){ case LSINT_default: switch (c){ @@ -98,8 +97,8 @@ int_fsm(Lex_FSM fsm, char c){ return(fsm); } -Lex_FSM -main_fsm(Lex_FSM fsm, unsigned char pp_state, unsigned char c){ +Cpp_Lex_FSM +main_fsm(Cpp_Lex_FSM fsm, uint8_t pp_state, uint8_t c){ if (c == 0){ fsm.emit_token = 1; } @@ -610,8 +609,8 @@ generate_int_table(){ allocate_full_tables(&table, state_count); int32_t i = 0; - Lex_FSM fsm = {0}; - Lex_FSM new_fsm; + Cpp_Lex_FSM fsm = {0}; + Cpp_Lex_FSM new_fsm = {0}; for (uint16_t c = 0; c < 256; ++c){ for (uint8_t state = 0; state < state_count; ++state){ fsm.int_state = state; @@ -633,8 +632,8 @@ generate_fsm_table(uint8_t pp_state){ allocate_full_tables(&table, state_count); int32_t i = 0; - Lex_FSM fsm = {0}; - Lex_FSM new_fsm; + Cpp_Lex_FSM fsm = {0}; + Cpp_Lex_FSM new_fsm = {0}; for (uint16_t c = 0; c < 256; ++c){ for (uint8_t state = 0; state < state_count; ++state){ fsm.state = state; diff --git a/win32_api_impl.cpp b/win32_api_impl.cpp index d353e762..0d61c08e 100644 --- a/win32_api_impl.cpp +++ b/win32_api_impl.cpp @@ -213,7 +213,7 @@ Stream mode can be enabled with -S or -F flags on the command line to 4ed.) API_EXPORT bool32 Is_Fullscreen(Application_Links *app)/* -DOC_SEE(This call returns true if the 4coder is in full screen mode. This call +DOC(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 @@ -229,7 +229,7 @@ frame if the state is not changed.) API_EXPORT void Send_Exit_Signal(Application_Links *app)/* -DOC_SEE(This call sends a signal to 4coder to attempt to exit. If there are unsaved +DOC(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.) */{ win32vars.send_exit_signal = 1;