diff --git a/4coder_API.html b/4coder_API.html index 24252cbb..ab990ab1 100644 --- a/4coder_API.html +++ b/4coder_API.html @@ -24,8 +24,9 @@ This is the documentation for alpha 4.0.9 super! The documentation has been made

-

§2 Types and Functions

-

§2.1 Function List

+

§2 4coder Systems

+

§3 Types and Functions

+

§3.1 Function List

-

§2.2 Type List

+

§3.2 Type List

-

§2.3 Function Descriptions

+

§3.3 Function Descriptions

-

§2.3.1: exec_command

-
void app->exec_command( -
Application_Links *app,
uint64_t command_id
) +

§3.3.1: exec_command

+
bool32 app->exec_command( +
Application_Links *app,
Command_ID command_id
)
Parameters
command_id
-
an integer id enumerated in 4coder_custom.h starting with cmdid
+
The command_id parameter specifies which internal command to execute.
-
Description
Executes the command associated with the command_id passed in

+
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

-

§2.3.2: exec_system_command

-
int app->exec_system_command( -
Application_Links *app,
View_Summary *view,
Buffer_Identifier buffer,
char *path,
int path_len,
char *command,
int command_len,
unsigned int flags
) +

§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
-
the target view that will display the output buffer, may be NULL, see description for details
+
If the view parameter is non-null it specifies a view to display the command's output buffer.
buffer
-
a buffer identifier for the buffer that will be filled with the output from the command
+
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 from which the command is executed
+
The path parameter specifies the path in which the command shall be executed. The string need not be null terminated.
path_len
-
the length of the path string
+
The parameter path_len specifies the length of the path string.
command
-
the command to be executed
+
The command parameter specifies the command that shall be executed. The string need not be null terminated.
command_len
-
the length of the command string
+
The parameter command_len specifies the length of the command string.
flags
-
may be zero or one or more CLI flags ORed together
+
Flags for the behavior of the call are specified in the flags parameter.
-
Return
returns non-zero if the command is successfully started, returns zero otherwise
Description
Executes a system 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. If the buffer already exists the command will fail, unless -CLI_OverlapWithConflict is set in the flags. +
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. -If the buffer is not already in an open view, and the view parameter is no NULL, then the provided view -will display the output buffer. If the view parameter is NULL, no view will display the output. +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 CLI_OverlapWithConflict is set in the flags, the command will always be executed even if another command -was outputting to the same buffer still. - -If CLI_AlwaysBindToView is set and the view parameter is not NULL, then the specified view will always -begin displaying the output buffer, even if another open view already displays that buffer. - -If CLI_CursorAtEnd is set the cursor in the output buffer will be placed at the end of the buffer instead -of at the beginning.

+If the view parameter is NULL, no view will switch to the output.
See Also
Buffer_Identifier
Command_Line_Input_Flag

-

§2.3.3: clipboard_post

+

§3.3.3: clipboard_post

void app->clipboard_post( -
Application_Links *app,
char *str,
int len
) +
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 string to post to the clipboard
+
The str parameter specifies the string to be posted to the clipboard, it need not be null terminated.
len
-
the length of the string str
+
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.

+be pasted into other applications.
See Also
The_4coder_Clipboard

-

§2.3.4: clipboard_count

-
int app->clipboard_count( -
Application_Links *app
) -
-
Description
returns the number of items in the clipboard

-
-

§2.3.5: clipboard_index

-
int app->clipboard_index( -
Application_Links *app,
int index,
char *out,
int len
) +

§3.3.4: clipboard_count

+
int32_t app->clipboard_count( +
Application_Links *app,
int32_t clipboard_id
)
Parameters
-
index
-
the index of the item to be read
+
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
The_4coder_Clipboard

+
+

§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
@@ -206,286 +218,283 @@ be pasted into other applications.

len
the length of the out buffer
-
Return
returns the size of the item on the clipboard associated with the given index
Description
There are multiple items on the 4coder clipboard. The most recent copy is always at -index 0. The second most recent is at index 1, and so on for all the stored clipboard items. -This function reads one of the clipboard items and stores it into the out buffer, if the out -buffer is not NULL. This function always returns the size of the clipboard item specified -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.

+
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
The_4coder_Clipboard

-

§2.3.6: get_buffer_first

+

§3.3.6: get_buffer_first

Buffer_Summary app->get_buffer_first( -
Application_Links *app,
unsigned int access
) +
Application_Links *app,
Access_Flag access
)
Parameters
access
-
the access flags for the access
+
The access parameter determines what levels of protection this call can access.
-
Return
returns the summary of the first buffer in a buffer loop
Description
Begins a loop across all the buffers. +
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
Access_Flag
get_buffer_next

+If the buffer returned does not exist, the loop is finished. +Buffers should not be killed durring a buffer loop.
See Also
Access_Flag
get_buffer_next

-

§2.3.7: get_buffer_next

+

§3.3.7: get_buffer_next

void app->get_buffer_next( -
Application_Links *app,
Buffer_Summary *buffer,
unsigned int access
) +
Application_Links *app,
Buffer_Summary *buffer,
Access_Flag access
)
Parameters
buffer
-
pointer to the loop buffer originally returned by get_buffer_first
+
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 flags for the 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
Writes the next buffer into the buffer struct. To get predictable results every -call to get_buffer_first and get_buffer_next in the loop should have the same -access flags. +
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 returned does not exist, the loop is finished. Buffers -should not be killed durring a buffer loop.
See Also
Access_Flag
get_buffer_first

+If the buffer outputted does not exist, the loop is finished. +Buffers should not be killed or created durring a buffer loop.
See Also
Access_Flag
get_buffer_first

-

§2.3.8: get_buffer

+

§3.3.8: get_buffer

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

+
Return
This call returns a summary that describes the indicated buffer if it exists and is accessible.
See Also
Access_Flag
Buffer_ID

-

§2.3.9: get_buffer_by_name

+

§3.3.9: get_buffer_by_name

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

+
Return
This call returns a summary that describes the indicated buffer if it exists and is accessible.
See Also
Access_Flag

-

§2.3.10: buffer_boundary_seek

-
int app->buffer_boundary_seek( -
Application_Links *app,
Buffer_Summary *buffer,
int start_pos,
int seek_forward,
unsigned int flags
) +

§3.3.10: 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 to seek through
+
The buffer parameter specifies the buffer through which to seek.
start_pos
-
the absolute position in the buffer to begin the seek
+
The beginning position of the seek is specified by start_pos measured in absolute position.
seek_forward
-
non-zero indicates to seek forward otherwise the seek goes backward
+
If this parameter is non-zero it indicates that the seek should move foward through the buffer.
flags
-
one or more types of boundaries to use for stopping the seek
+
This field specifies the types of boundaries at which the seek should stop.
-
Return
returns the position where the seek stops
See Also
Seek_Boundary_Flag

+
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
Seek_Boundary_Flag
4coder_Buffer_Positioning_System

-

§2.3.11: buffer_read_range

-
int app->buffer_read_range( -
Application_Links *app,
Buffer_Summary *buffer,
int start,
int end,
char *out
) +

§3.3.11: buffer_read_range

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

+This call fails if the buffer does not exist, +or if the read range is not within the bounds of the buffer.
See Also
4coder_Buffer_Positioning_System

-

§2.3.12: buffer_replace_range

-
int app->buffer_replace_range( -
Application_Links *app,
Buffer_Summary *buffer,
int start,
int end,
char *str,
int len
) +

§3.3.12: buffer_replace_range

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

+range is not within the bounds of the buffer.
See Also
4coder_Buffer_Positioning_System

-

§2.3.13: buffer_set_setting

-
int app->buffer_set_setting( -
Application_Links *app,
Buffer_Summary *buffer,
int setting,
int value
) +

§3.3.13: 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 on which to set a setting.
+
The buffer parameter specifies the buffer on which to set a setting.
setting
-
One of the Buffer_Setting_ID enum values that identifies the setting to set.
+
The setting parameter identifies the setting that shall be changed.
value
-
The value to set the specified setting to.
+
The value parameter specifies the value to which the setting shall be changed.
See Also
Buffer_Setting_ID

-

§2.3.14: buffer_auto_indent

-
int app->buffer_auto_indent( -
Application_Links *app,
Buffer_Summary *buffer,
int start,
int end,
int tab_width,
unsigned int flags
) +

§3.3.14: 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 in which to apply the auto indenting
+
The buffer specifies the buffer in which to apply auto indentation.
start
-
the position to start the auto indenting
+
This parameter specifies the absolute position of the start of the indentation range.
end
-
the position to end the auto indenting
+
This parameter specifies the absolute position of the end of the indentation range.
tab_width
-
the number of spaces to place as a tab
+
The tab_width parameter specifies how many spaces should be used for one indentation in space mode.
flags
-
the auto tab behavior flags
+
This parameter specifies behaviors for the indentation.
-
Return
returns non-zero when the call succeeds
Description
Applies the built in auto-indentation rule to the code in the range from +
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
Auto_Indent_Flag

+completed this function will fail.
See Also
Auto_Indent_Flag
4coder_Buffer_Positioning_System

-

§2.3.15: create_buffer

+

§3.3.15: create_buffer

Buffer_Summary app->create_buffer( -
Application_Links *app,
char *filename,
int filename_len,
unsigned int flags
) +
Application_Links *app,
char *filename,
int32_t filename_len,
Buffer_Create_Flag flags
)
Parameters
filename
-
the name of the file to be opened or created
+
The filename parameter specifies the name of the file to be opened or created; it need not be null terminated.
filename_len
-
the length of the filename string
+
The filename_len parameter spcifies the length of the filename string.
flags
-
flags for buffer creation behavior
+
The flags parameter specifies behaviors for buffer creation.
-
Return
returns the summary of the created buffer on success or a NULL buffer otherwise
Description
Tries to create a new buffer and associate it to the given filename. If such a buffer already +
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
Buffer_Create_Flag

-

§2.3.16: save_buffer

-
int app->save_buffer( -
Application_Links *app,
Buffer_Summary *buffer,
char *filename,
int filename_len,
unsigned int flags
) +

§3.3.16: 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 to save to a file
+
The buffer parameter specifies the buffer to save to a file.
filename
-
the name of the file to save the buffer into
+
The filename parameter specifies the name of the file to associated to the buffer; it need not be null terminated.
filename_len
-
length of the filename string
+
The filename_len parameter specifies the length of the filename string.
flags
-
not currently used
+
This parameter is not currently used and should be set to 0 for now.
-
Return
returns non-zero if the save succeeds

+
Return
This call returns non-zero on success.

-

§2.3.17: kill_buffer

-
int app->kill_buffer( -
Application_Links *app,
Buffer_Identifier buffer,
int view_id,
unsigned int flags
) +

§3.3.17: kill_buffer

+
bool32 app->kill_buffer( +
Application_Links *app,
Buffer_Identifier buffer,
View_ID view_id,
Buffer_Kill_Flag flags
)
Parameters
buffer
-
A buffer identifier specifying the buffer to try to kill.
+
The buffer parameter specifies the buffer to try to kill.
view_id
-
The id of view that will contain the "are you sure" dialogue.
+
The view_id parameter specifies the view that will contain the "are you sure" dialogue if the buffer is dirty.
flags
-
Flags for buffer kill behavior.
+
The flags parameter specifies behaviors for the buffer kill.
-
Return
Returns non-zero if the kill succeeds.
Description
Tries to kill the idenfied buffer. If the buffer is dirty and the "are you sure" +
Return
This call returns non-zero on success.
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

+If the view is not open the kill fails.
See Also
Buffer_Kill_Flag
Buffer_Identifier

-

§2.3.18: get_view_first

+

§3.3.18: get_view_first

View_Summary app->get_view_first( -
Application_Links *app,
unsigned int access
) +
Application_Links *app,
Access_Flag access
)
Parameters
access
-
the access flags for the access
+
The access parameter determines what levels of protection this call can access.
-
Return
returns the summary of the first view in a view loop
Description
Begins a loop across all the open views. +
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 NULL, the loop is finished. +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
Access_Flag
get_view_next

-

§2.3.19: get_view_next

+

§3.3.19: get_view_next

void app->get_view_next( -
Application_Links *app,
View_Summary *view,
unsigned int access
) +
Application_Links *app,
View_Summary *view,
Access_Flag access
)
Parameters
view
@@ -493,323 +502,328 @@ Views should not be closed or opened durring a view loop.
access
-
the access flags for the 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
Writes the next view into the view struct. To get predictable results every -call to get_view_first and get_view_next in the loop should have the same -access flags. +
Description
This call steps a view summary to the next view in the global view order. -If the view summary returned is NULL, the loop is finished. +If the view outputted does not exist, the loop is finished. Views should not be closed or opened durring a view loop.
See Also
Access_Flag
get_view_first

-

§2.3.20: get_view

+

§3.3.20: get_view

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

+
Return
This call returns a summary that describes the indicated view if it is open and accessible.
See Also
Access_Flag

-

§2.3.21: get_active_view

+

§3.3.21: get_active_view

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

+
Return
This call returns a summary that describes the active view.
See Also
set_active_view
Access_Flag

-

§2.3.22: set_active_view

-
int app->set_active_view( +

§3.3.22: set_active_view

+
bool32 app->set_active_view(
Application_Links *app,
View_Summary *view
)
Parameters
view
-
the view to set as active
+
The view parameter specifies which view to make active.
-
Return
returns non-zero on success
Description
If the given view is a currently open view, it is set as the +
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
get_active_view

-

§2.3.23: view_set_setting

-
int app->view_set_setting( -
Application_Links *app,
View_Summary *view,
int setting,
int value
) +

§3.3.23: 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 on which to set a setting.
+
The view parameter specifies the view on which to set a setting.
setting
-
One of the View_Setting_ID enum values that identifies the setting to set.
+
The setting parameter identifies the setting that shall be changed.
value
-
The value to set the specified setting to.
+
The value parameter specifies the value to which the setting shall be changed.
-
See Also

+
Return
This call returns non-zero on success.
See Also
View_Setting_ID

-

§2.3.24: view_set_split_proportion

-
int app->view_set_split_proportion( +

§3.3.24: view_set_split_proportion

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

+
Return
This call returns non-zero on success.

-

§2.3.25: view_compute_cursor

-
int app->view_compute_cursor( +

§3.3.25: 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 on which to run the cursor computation.
+
The view parameter specifies the view on which to run the cursor computation.
seek
-
The seek position.
+
The seek parameter specifies the target position for the seek.
cursor_out
-
On success this is filled with result of the seek.
+
On success this struct is filled with the result of the seek.
-
Return
Returns non-zero on success.
Description
Computes a full cursor for the given seek position.
See Also

+
Return
This call returns non-zero on success.
Description
Computes a Full_Cursor for the given seek position with no side effects.
See Also
Buffer_Seek
Full_Cursor

-

§2.3.26: view_set_cursor

-
int app->view_set_cursor( -
Application_Links *app,
View_Summary *view,
Buffer_Seek seek,
int set_preferred_x
) +

§3.3.26: 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 in which to set the cursor
+
The view parameter specifies the view in which to set the cursor.
seek
-
the seek position
+
The seek parameter specifies the target position for the seek.
set_preferred_x
-
if true the preferred x is updated to match the new cursor position
+
If this parameter is true the preferred x is updated to match the new cursor x.
-
Return
returns non-zero on success
Description
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

+
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
Buffer_Seek

-

§2.3.27: view_set_mark

-
int app->view_set_mark( +

§3.3.27: view_set_mark

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

+
Return
This call returns non-zero on success.
Description
This call sets the the view's mark position.
See Also
Buffer_Seek

-

§2.3.28: view_set_highlight

-
int app->view_set_highlight( -
Application_Links *app,
View_Summary *view,
int start,
int end,
int turn_on
) +

§3.3.28: 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 to set the highlight in
+
The view parameter specifies the view in which to set the highlight.
start
-
the start of the highlight range
+
This parameter specifies the absolute position of the first character of the highlight range.
end
-
the end of the highlight range
+
This parameter specifies the absolute position of the character one past the end of the highlight range.
turn_on
-
indicates whether the highlight is being turned on or off
+
This parameter indicates whether the highlight is being turned on or off.
-
Return
returns non-zero on success
Description
The highlight is mutually exclusive to the cursor. When the turn_on parameter +
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 with view_set_cursor or calling view_set_highlight and the turn_on set to false, will switch back to showing the cursor.

-

§2.3.29: view_set_buffer

-
int app->view_set_buffer( -
Application_Links *app,
View_Summary *view,
int buffer_id,
unsigned int flags
) +

§3.3.29: 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 to display the buffer in
+
The view parameter specifies the view in which to display the buffer.
buffer_id
-
the buffer to show in the view
+
The buffer_id parameter specifies which buffer to show in the view.
flags
-
set buffer behavior flags
+
The flags parameter specifies behaviors for setting the buffer.
-
Return
returns non-zero on success
Description
On success view_set_buffer sets the specified view's current buffer and +
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

-

§2.3.30: view_post_fade

-
int app->view_post_fade( -
Application_Links *app,
View_Summary *view,
float seconds,
int start,
int end,
unsigned int color
) +

§3.3.30: 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 veiw to post a fade effect to
+
The view parameter specifies the view onto which the fade effect shall be posted.
seconds
-
the number of seconds the fade effect should last
+
This parameter specifies the number of seconds the fade effect should last.
start
-
the first character in the fade range
+
This parameter specifies the absolute position of the first character of the fade range.
end
-
one after the last character in the fade range
+
This parameter specifies the absolute position of the character one past the end of the fdae range.
color
-
the color to fade from
+
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

-

§2.3.31: get_user_input

+

§3.3.31: get_user_input

User_Input app->get_user_input( -
Application_Links *app,
unsigned int get_type,
unsigned int abort_type
) +
Application_Links *app,
Input_Type_Flag get_type,
Input_Type_Flag abort_type
)
Parameters
get_type
-
input type flag that specifies the types of inputs that should be returned
+
The get_type parameter specifies the set of input types that should be returned.
abort_type
-
input type flag that specifies the types of inputs that should cause an abort signal
+
The get_type parameter specifies the set of input types that should trigger an abort signal.
-
Return
returns a User_Input that describes an event passed to the command
Description
This call preempts the command. The command is resumed if either a get or abort condition +
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

+If a get condition is met the user input is returned.
See Also

-

§2.3.32: get_command_input

+

§3.3.32: get_command_input

User_Input app->get_command_input(
Application_Links *app
)
-
Return
returns the input that triggered the command in execution.
See Also

+
Return
This call returns the input that triggered the currently executing command.
See Also

-

§2.3.33: get_mouse_state

+

§3.3.33: get_mouse_state

Mouse_State app->get_mouse_state(
Application_Links *app
)
-
Return
returns the current mouse state
See Also

+
Return
This call returns the current mouse state as of the beginning of the frame.
See Also

-

§2.3.34: start_query_bar

-
int app->start_query_bar( -
Application_Links *app,
Query_Bar *bar,
unsigned int flags
) +

§3.3.34: start_query_bar

+
bool32 app->start_query_bar( +
Application_Links *app,
Query_Bar *bar,
uint32_t flags
)
Parameters
bar
-
a pointer to the Query_Bar struct that defines the bar's contents
+
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
-
not currently used
+
This parameter is not currently used and should be 0 for now.
-
Return
returns non-zero on success
Description
The memory pointed to by bar must remain valid until a call to end_query_bar or -until the command returns.

+
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.

-

§2.3.35: end_query_bar

+

§3.3.35: end_query_bar

void app->end_query_bar( -
Application_Links *app,
Query_Bar *bar,
unsigned int flags
) +
Application_Links *app,
Query_Bar *bar,
uint32_t flags
)
Parameters
bar
-
a pointer to the Query_Bar struct to end
+
This parameter should be a bar pointer of a currently active query bar.
flags
-
not currently used
+
This parameter is not currently used and should be 0 for now.
-
Description
bar must be a pointer previously passed to start_query_bar previously in the same command.

+
Description
Stops showing the particular query bar specified by the bar parameter.


+
Description
This call posts a string to the *messages* buffer.

-

§2.3.37: change_theme

+

§3.3.37: change_theme

void app->change_theme( -
Application_Links *app,
char *name,
int len
) +
Application_Links *app,
char *name,
int32_t len
)
Parameters
name
-
the name of the built in theme to change to
+
The name parameter specifies the name of the theme to begin using; it need not be null terminated.
len
-
the length of the name string
+
The len parameter specifies the length of the name string.
-

+
Description
This call changes 4coder's theme to one of the built in themes.

-

§2.3.38: change_font

+

§3.3.38: change_font

void app->change_font( -
Application_Links *app,
char *name,
int len
) +
Application_Links *app,
char *name,
int32_t len
)
Parameters
name
-
the name of the built in font to change to
+
The name parameter specifies the name of the font to begin using; it need not be null terminated.
len
-
the length of the name string
+
The len parameter specifies the length of the name string.
-

+
Description
This call changes 4coder's font to one of the built in fonts.

-

§2.3.39: set_theme_colors

+

§3.3.39: set_theme_colors

void app->set_theme_colors( -
Application_Links *app,
Theme_Color *colors,
int count
) +
Application_Links *app,
Theme_Color *colors,
int32_t count
)
Parameters
colors
-
an array of color structs pairing differet style tags to color codes
+
The colors pointer provides an array of color structs pairing differet style tags to color codes.
count
-
the number of color structs in the colors array
+
The count parameter specifies the number of Theme_Color structs in the colors array.
-
Description
For each color struct in the array, the color in the style pallet is set to the color -code paired with the tag.

+
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.

-

§2.3.40: get_theme_colors

+

§3.3.40: get_theme_colors

void app->get_theme_colors( -
Application_Links *app,
Theme_Color *colors,
int count
) +
Application_Links *app,
Theme_Color *colors,
int32_t count
)
Parameters
colors
@@ -819,193 +833,607 @@ code paired with the tag.

count
the number of color structs in the colors array
-
Description
For each color struct in the array, the color field of the struct is filled with the -color from the specified color in the pallet.

+
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.

-

§2.3.41: directory_get_hot

-
int app->directory_get_hot( -
Application_Links *app,
char *out,
int capacity
) +

§3.3.41: directory_get_hot

+
int32_t app->directory_get_hot( +
Application_Links *app,
char *out,
int32_t capacity
)
Parameters
out
-
a buffer that receives the 4coder 'hot directory'
+
This parameter provides a character buffer that receives the 4coder 'hot directory'.
capacity
-
the maximum size to be output to the output buffer
+
This parameter specifies the maximum size to be output to the out buffer.
-
Return
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 +
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 by the custom side.

+directories controlled on the custom side.

-

§2.3.42: get_file_list

+

§3.3.42: get_file_list

File_List app->get_file_list( -
Application_Links *app,
char *dir,
int len
) +
Application_Links *app,
char *dir,
int32_t len
)
Parameters
dir
-
the directory whose files will be enumerated in the returned list
+
This parameter specifies the directory whose files will be enumerated in the returned list; it need not be null terminated.
len
-
the length of the dir string
+
This parameter the length of the dir string.
-
Return
returns a File_List struct containing pointers to the names of the files in +
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.

-

§2.3.43: free_file_list

+

§3.3.43: free_file_list

void app->free_file_list(
Application_Links *app,
File_List list
)
Parameters
list
-
the file list to be freed
+
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

+
Description
After this call the file list passed in should not be read or written to.

-

§2.3.44: file_exists

-
int app->file_exists( +

§3.3.44: file_exists

+
bool32 app->file_exists(
Application_Links *app,
char *filename,
int len
)
Parameters
filename
-
the full path to a file
+
This parameter specifies the full path to a file; it need not be null terminated.
len
-
the number of characters in the filename string
+
This parameter specifies the length of the filename string.
-
Return
returns non-zero if the file exists, returns zero if the file does not exist

+
Return
This call returns non-zero if and only if the file exists.

-

§2.3.45: directory_cd

-
int app->directory_cd( +

§3.3.45: directory_cd

+
bool32 app->directory_cd(
Application_Links *app,
char *dir,
int *len,
int capacity,
char *rel_path,
int rel_len
)
Parameters
dir
-
a string buffer containing a directory
+
This parameter provides a character buffer that stores a directory; it need not be null terminated.
len
-
the length of the string in the string buffer
+
This parameter specifies the length of the dir string.
capacity
-
the maximum size of the string buffer
+
This parameter specifies the maximum size of the dir string.
rel_path
-
the path to change to, may include '.' or '..'
+
This parameter specifies the path to change to, may include '.' or '..'; it need not be null terminated.
rel_len
-
the length of the rel_path string
+
This parameter specifies the length of the rel_path string.
-
Return
returns non-zero if the call succeeds, returns zero otherwise
Description
This call succeeds if the directory exists and the new directory fits inside the dir buffer. -If the call succeeds the dir buffer is filled with the new directory and len contains the -length of the string in the buffer. +
Return
This call returns non-zero if the call succeeds.
Description
This call succeeds if the new directory exists and the it fits inside the +dir buffer. If the call succeeds the dir buffer is filled with the new +directory and len is overwritten with the length of the new string in the buffer. -For instance if dir contains "C:/Users/MySelf" and rel is "Documents" the buffer will contain -"C:/Users/MySelf/Documents" and len will contain the length of that string. This call can -also be used with rel set to ".." to traverse to parent folders.

+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.

-

§2.3.46: get_4ed_path

-
int app->get_4ed_path( -
Application_Links *app,
char *out,
int capacity
) +

§3.3.46: get_4ed_path

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

+
Return
This call returns non-zero on success.

-

§2.3.47: show_mouse_cursor

+

§3.3.47: show_mouse_cursor

void app->show_mouse_cursor( -
Application_Links *app,
int show
) +
Application_Links *app,
Mouse_Cursor_Show_Type show
)
Parameters
show
-
The show state to put the mouse cursor into, should be one of the Mouse_Cursor_Show_Type enum values.
+
This parameter specifies the new state of the mouse cursor.
See Also
Mouse_Cursor_Show_Type

-

§2.4 Type Descriptions

+

§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.

-

§2.4.1: Key_Code

+

§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 range [1,16].

-

§2.4.2: Key_Modifier

+

§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.
+

-

§2.4.3: Command_ID

+

§3.4.7: 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_center_view
+
cmdid_center_view centers the view vertically on the cursor.
+
+
+
cmdid_left_adjust_view
+
cmdid_left_adjust_view adjusts the view to be just left of the cursor's position.
+
+
+
cmdid_page_up
+
cmdid_page_up moves the view up one whole screen height and centers the cursor there.
+
+
+
cmdid_page_down
+
cmdid_page_down moves the view down one whole screen height and centers the cursor there.
+
+
+
cmdid_word_complete
+
cmdid_word_complete begins or continues cycling through completions for a partial word.
+
+
+
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_to_uppercase
+
cmdid_to_uppercase makes all the alphabetic characters in the cursor/mark range uppercase.
+
+
+
cmdid_to_lowercase
+
cmdid_to_uppercase makes all the alphabetic characters in the cursor/mark range lowercase.
+
+
+
cmdid_toggle_line_wrap
+
cmdid_toggle_line_wrap toggles the line wrap setting of the active view.
+
+
+
cmdid_toggle_show_whitespace
+
cmdid_toggle_line_wrap toggles the show whitespace setting of the active view.
+
+
+
cmdid_clean_all_lines
+
cmdid_clean_all_lines deletes extra whitespace out the currently active buffer.
+
+
+
cmdid_eol_dosify
+
cmdid_eol_dosify sets the currently active buffer to dos save mode where the end of a line is "\r\n"
+
+
+
cmdid_eol_nixify
+
cmdid_eol_nixify sets the currently active buffer to nix save mode where the end of a line is "\n"
+
+
+
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_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_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_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_open_panel_vsplit
+
cmdid_open_panel_vsplit splits the current panel into two with a vertical divider.
+
+
+
cmdid_open_panel_hsplit
+
cmdid_open_panel_hsplit splits the current panel into two with a horizontal divider.
+
+
+
cmdid_close_panel
+
cmdid_close_panel closes the active panel.
+
+
+
cmdid_change_active_panel
+
cmdid_change_active_panel cycles to the next open panel.
+
+
+
cmdid_count
+
+

-

§2.4.4: User_Input_Type_ID

+

§3.4.8: 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.
+

-

§2.4.5: Event_Message_Type_ID

+

§3.4.9: 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.
+

-

§2.4.6: Buffer_Setting_ID

+

§3.4.10: 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.
+

-

§2.4.7: View_Setting_ID

+

§3.4.11: 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_ShowScrollbar
+
The ViewSetting_ShowScrollbar setting determines whether a scroll bar is attached to a view in it's scrollable section.
+

-

§2.4.8: Mouse_Cursor_Show_Type

+

§3.4.12: 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.
+

-

§2.4.9: Key_Modifier_Flag

+

§3.4.13: 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.
Flags
+
MDFR_NONE = 0x0
+
MDFR_NONE specifies that no modifiers are pressed.
+
+
+
MDFR_CTRL = 0x1
+
+
+
+
MDFR_ALT = 0x2
+
+
+
+
MDFR_SHIFT = 0x4
+
+

-

§2.4.10: Buffer_Create_Flag

+

§3.4.14: Buffer_Create_Flag

enum Buffer_Create_Flag;
+
Description
A Buffer_Create_Flag field specifies how a buffer should be created.
Flags
+
BufferCreate_Background = 0x1
+
BufferCreate_Background is not currently implemented.
+
+
+
BufferCreate_AlwaysNew = 0x2
+
When BufferCreate_AlwaysNew is et it indicates the buffer should be + cleared to empty even if it's associated file already has content.
+

-

§2.4.11: Buffer_Kill_Flag

+

§3.4.15: Buffer_Kill_Flag

enum Buffer_Kill_Flag;
+
Description
A Buffer_Kill_Flag field specifies how a buffer should be killed.
Flags
+
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.
+

-

§2.4.12: Access_Flag

+

§3.4.16: 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.
Flags
+
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.
+

-

§2.4.13: Seek_Boundary_Flag

+

§3.4.17: 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.
Flags
+
BoundaryWhitespace = 0x1
+
+
+
+
BoundaryToken = 0x2
+
+
+
+
BoundaryAlphanumeric = 0x4
+
+
+
+
BoundaryCamelCase = 0x8
+
+

-

§2.4.14: Command_Line_Input_Flag

+

§3.4.18: 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.
Flags
+
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.
+

-

§2.4.15: Auto_Indent_Flag

+

§3.4.19: Auto_Indent_Flag

enum Auto_Indent_Flag;
+
Description
An Auto_Indent_Flag field specifies the behavior of an auto indentation operation.
Flags
+
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 + code, as many tabs will be used as possible until the fine grained control of spaces + is needed to finish the alignment.
+

-

§2.4.16: Set_Buffer_Flag

+

§3.4.20: 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.
Flags
+
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.
+

-

§2.4.17: Input_Type_Flag

+

§3.4.21: Input_Type_Flag

enum Input_Type_Flag;
+
Description
A Input_Type_Flag field specifies a set of input event types.
Flags
+
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.22: 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..
+

-

§2.4.18: Key_Event_Data

+

§3.4.23: Key_Event_Data

struct Key_Event_Data {
Key_Code keycode;
@@ -1015,9 +1443,31 @@ 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. + 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.
+

-

§2.4.19: Mouse_State

+

§3.4.24: Mouse_State

struct Mouse_State {
char l;
@@ -1033,9 +1483,51 @@ int 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.
+

-

§2.4.20: Range

+

§3.4.25: Range

union Range {
struct {
@@ -1053,9 +1545,29 @@ int 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'.
+

-

§2.4.21: File_Info

+

§3.4.26: File_Info

struct File_Info {
char * filename;
@@ -1064,9 +1576,21 @@ int 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
File_List

-

§2.4.22: File_List

+

§3.4.27: File_List

struct File_List {
void * block;
@@ -1076,9 +1600,25 @@ int 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.
+

-

§2.4.23: Buffer_Identifier

+

§3.4.28: Buffer_Identifier

struct Buffer_Identifier {
char * name;
@@ -1087,66 +1627,200 @@ int 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, need not be null terminated. + If id is specified this should be NULL.
+
+
+
name_len
+
This field is specifies the length of the name string.
+
+
+
id
+
This field is the id of the buffer. If name is specified this should be 0.
+

-

§2.4.24: Buffer_Summary

+

§3.4.29: Buffer_Summary

struct Buffer_Summary {
-int exists;
-int ready;
-int buffer_id;
-unsigned int lock_flags;
-int size;
+bool32 exists;
+bool32 ready;
+int32_t buffer_id;
+Access_Flag lock_flags;
+int32_t size;
char * file_name;
-int file_name_len;
+int32_t file_name_len;
char * buffer_name;
-int buffer_name_len;
-int buffer_cursor_pos;
-int is_lexed;
-int map_id;
+int32_t buffer_name_len;
+int32_t buffer_cursor_pos;
+bool32 is_lexed;
+int32_t map_id;
};
+
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.
+
+
+
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.
+
+
+
buffer_cursor_pos
+
This is a hold over from an old system, consider it deprecated.
+
+
+
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.
+

-

§2.4.25: View_Summary

+

§3.4.30: View_Summary

struct View_Summary {
-int exists;
-int view_id;
-int buffer_id;
-unsigned int lock_flags;
+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;
-int unwrapped_lines;
-int show_whitespace;
+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, and this view looks at a buffer, this is the id of the buffer.
+
+
+
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
+
This feature is not fully implemented yet.
+
+
+
scroll_vars
+
This feature is not fully implemented yet.
+

-

§2.4.26: User_Input

+

§3.4.31: User_Input

struct User_Input {
-int type;
-int abort;
+User_Input_Type_ID type;
+bool32 abort;
union {
Key_Event_Data key;
Mouse_State mouse;
};
-unsigned long long command;
+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
User_Input_Type_ID
Generic_Command

-

§2.4.27: Query_Bar

+

§3.4.32: Query_Bar

struct Query_Bar {
String prompt;
@@ -1154,26 +1828,47 @@ 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.
+

-

§2.4.28: Event_Message

+

§3.4.33: Event_Message

struct Event_Message {
int type;
};
+
Description
This feature is not implemented.
Fields
+
type
+
This feature is not implemented.
+

-

§2.4.29: Theme_Color

+

§3.4.34: Theme_Color

struct Theme_Color {
Style_Tag tag;
-uint32_t color;
+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
Style_Tag
int_color

diff --git a/4coder_custom.h b/4coder_custom.h index ac90f8ea..a6f140d3 100644 --- a/4coder_custom.h +++ b/4coder_custom.h @@ -26,8 +26,35 @@ typedef struct Offset_String{ } Offset_String; #endif +// These are regular hooks, any of them can be set to any function +// that matches the HOOK_SIG pattern. +enum Hook_ID{ + hook_start, + hook_file_out_of_sync, + // never below this + hook_type_count +}; + +// These are for special hooks, each must bind to specialized signatures +// that do not necessarily have access to the app pointer. +enum Special_Hook_ID{ + _hook_scroll_rule = hook_type_count, + _hook_new_file, + _hook_open_file, + _hook_command_caller, + _hook_input_filter, +}; + +#define CommandEqual(c1,c2) ((unsigned long long)(c1) == (unsigned long long)(c2)) + +#define CUSTOM_COMMAND_SIG(name) void name(struct Application_Links *app) +typedef CUSTOM_COMMAND_SIG(Custom_Command_Function); + #include "4coder_types.h" +#define COMMAND_CALLER_HOOK(name) int name(struct Application_Links *app, Generic_Command cmd) +typedef COMMAND_CALLER_HOOK(Command_Caller_Hook_Function); + inline Key_Event_Data key_event_data_zero(){ Key_Event_Data data={0}; @@ -51,50 +78,26 @@ make_range(int p1, int p2){ } return(range); } - -// These are regular hooks, any of them can be set to any function -// that matches the HOOK_SIG pattern. -enum Hook_ID{ - hook_start, - hook_file_out_of_sync, - // never below this - hook_type_count -}; - -// These are for special hooks, each must bind to specialized signatures -// that do not necessarily have access to the app pointer. -enum Special_Hook_ID{ - _hook_scroll_rule = hook_type_count, - _hook_new_file, - _hook_open_file, - _hook_command_caller, - _hook_input_filter, -}; - inline Buffer_Summary buffer_summary_zero(){ Buffer_Summary summary={0}; return(summary); } - inline View_Summary view_summary_zero(){ View_Summary summary={0}; return(summary); } -#define CommandEqual(c1,c2) ((unsigned long long)(c1) == (unsigned long long)(c2)) - #define VIEW_ROUTINE_SIG(name) void name(struct Application_Links *app, int view_id) #define GET_BINDING_DATA(name) int name(void *data, int size) -#define CUSTOM_COMMAND_SIG(name) void name(struct Application_Links *app) #define HOOK_SIG(name) int name(struct Application_Links *app) #define OPEN_FILE_HOOK_SIG(name) int name(struct Application_Links *app, int buffer_id) #define SCROLL_RULE_SIG(name) int name(float target_x, float target_y, float *scroll_x, float *scroll_y, int view_id, int is_new_target, float dt) #define INPUT_FILTER_SIG(name) void name(Mouse_State *mouse) typedef VIEW_ROUTINE_SIG(View_Routine_Function); -typedef CUSTOM_COMMAND_SIG(Custom_Command_Function); + typedef GET_BINDING_DATA(Get_Binding_Data_Function); typedef HOOK_SIG(Hook_Function); @@ -102,13 +105,6 @@ typedef OPEN_FILE_HOOK_SIG(Open_File_Hook_Function); typedef SCROLL_RULE_SIG(Scroll_Rule_Function); typedef INPUT_FILTER_SIG(Input_Filter_Function); -union Generic_Command{ - Command_ID cmdid; - Custom_Command_Function *command; -}; - -#define COMMAND_CALLER_HOOK(name) int name(struct Application_Links *app, Generic_Command cmd) -typedef COMMAND_CALLER_HOOK(Command_Caller_Hook_Function); diff --git a/4coder_custom_api.h b/4coder_custom_api.h index 84aa0753..a6ed9295 100644 --- a/4coder_custom_api.h +++ b/4coder_custom_api.h @@ -1,50 +1,50 @@ -#define EXEC_COMMAND_SIG(n) void n(Application_Links *app, uint64_t command_id) -#define EXEC_SYSTEM_COMMAND_SIG(n) int n(Application_Links *app, View_Summary *view, Buffer_Identifier buffer, char *path, int path_len, char *command, int command_len, unsigned int flags) -#define CLIPBOARD_POST_SIG(n) void n(Application_Links *app, char *str, int len) -#define CLIPBOARD_COUNT_SIG(n) int n(Application_Links *app) -#define CLIPBOARD_INDEX_SIG(n) int n(Application_Links *app, int index, char *out, int len) -#define GET_BUFFER_FIRST_SIG(n) Buffer_Summary n(Application_Links *app, unsigned int access) -#define GET_BUFFER_NEXT_SIG(n) void n(Application_Links *app, Buffer_Summary *buffer, unsigned int access) -#define GET_BUFFER_SIG(n) Buffer_Summary n(Application_Links *app, int buffer_id, unsigned int access) -#define GET_BUFFER_BY_NAME_SIG(n) Buffer_Summary n(Application_Links *app, char *name, int len, unsigned int access) -#define BUFFER_BOUNDARY_SEEK_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int start_pos, int seek_forward, unsigned int flags) -#define BUFFER_READ_RANGE_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int start, int end, char *out) -#define BUFFER_REPLACE_RANGE_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int start, int end, char *str, int len) -#define BUFFER_SET_SETTING_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int setting, int value) -#define BUFFER_AUTO_INDENT_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int start, int end, int tab_width, unsigned int flags) -#define CREATE_BUFFER_SIG(n) Buffer_Summary n(Application_Links *app, char *filename, int filename_len, unsigned int flags) -#define SAVE_BUFFER_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, char *filename, int filename_len, unsigned int flags) -#define KILL_BUFFER_SIG(n) int n(Application_Links *app, Buffer_Identifier buffer, int view_id, unsigned int flags) -#define GET_VIEW_FIRST_SIG(n) View_Summary n(Application_Links *app, unsigned int access) -#define GET_VIEW_NEXT_SIG(n) void n(Application_Links *app, View_Summary *view, unsigned int access) -#define GET_VIEW_SIG(n) View_Summary n(Application_Links *app, int view_id, unsigned int access) -#define GET_ACTIVE_VIEW_SIG(n) View_Summary n(Application_Links *app, unsigned int access) -#define SET_ACTIVE_VIEW_SIG(n) int n(Application_Links *app, View_Summary *view) -#define VIEW_SET_SETTING_SIG(n) int n(Application_Links *app, View_Summary *view, int setting, int value) -#define VIEW_SET_SPLIT_PROPORTION_SIG(n) int n(Application_Links *app, View_Summary *view, float t) -#define VIEW_COMPUTE_CURSOR_SIG(n) int n(Application_Links *app, View_Summary *view, Buffer_Seek seek, Full_Cursor *cursor_out) -#define VIEW_SET_CURSOR_SIG(n) int n(Application_Links *app, View_Summary *view, Buffer_Seek seek, int set_preferred_x) -#define VIEW_SET_MARK_SIG(n) int n(Application_Links *app, View_Summary *view, Buffer_Seek seek) -#define VIEW_SET_HIGHLIGHT_SIG(n) int n(Application_Links *app, View_Summary *view, int start, int end, int turn_on) -#define VIEW_SET_BUFFER_SIG(n) int n(Application_Links *app, View_Summary *view, int buffer_id, unsigned int flags) -#define VIEW_POST_FADE_SIG(n) int n(Application_Links *app, View_Summary *view, float seconds, int start, int end, unsigned int color) -#define GET_USER_INPUT_SIG(n) User_Input n(Application_Links *app, unsigned int get_type, unsigned int abort_type) +#define EXEC_COMMAND_SIG(n) bool32 n(Application_Links *app, Command_ID command_id) +#define EXEC_SYSTEM_COMMAND_SIG(n) bool32 n(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) +#define CLIPBOARD_POST_SIG(n) void n(Application_Links *app, int32_t clipboard_id, char *str, int32_t len) +#define CLIPBOARD_COUNT_SIG(n) int32_t n(Application_Links *app, int32_t clipboard_id) +#define CLIPBOARD_INDEX_SIG(n) int32_t n(Application_Links *app, int32_t clipboard_id, int32_t item_index, char *out, int32_t len) +#define GET_BUFFER_FIRST_SIG(n) Buffer_Summary n(Application_Links *app, Access_Flag access) +#define GET_BUFFER_NEXT_SIG(n) void n(Application_Links *app, Buffer_Summary *buffer, Access_Flag access) +#define GET_BUFFER_SIG(n) Buffer_Summary n(Application_Links *app, Buffer_ID buffer_id, Access_Flag access) +#define GET_BUFFER_BY_NAME_SIG(n) Buffer_Summary n(Application_Links *app, char *name, int32_t len, Access_Flag access) +#define BUFFER_BOUNDARY_SEEK_SIG(n) int32_t n(Application_Links *app, Buffer_Summary *buffer, int32_t start_pos, bool32 seek_forward, Seek_Boundary_Flag flags) +#define BUFFER_READ_RANGE_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, char *out) +#define BUFFER_REPLACE_RANGE_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, char *str, int32_t len) +#define BUFFER_SET_SETTING_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting, int32_t value) +#define BUFFER_AUTO_INDENT_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, int32_t tab_width, Auto_Indent_Flag flags) +#define CREATE_BUFFER_SIG(n) Buffer_Summary n(Application_Links *app, char *filename, int32_t filename_len, Buffer_Create_Flag flags) +#define SAVE_BUFFER_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, char *filename, int32_t filename_len, uint32_t flags) +#define KILL_BUFFER_SIG(n) bool32 n(Application_Links *app, Buffer_Identifier buffer, View_ID view_id, Buffer_Kill_Flag flags) +#define GET_VIEW_FIRST_SIG(n) View_Summary n(Application_Links *app, Access_Flag access) +#define GET_VIEW_NEXT_SIG(n) void n(Application_Links *app, View_Summary *view, Access_Flag access) +#define GET_VIEW_SIG(n) View_Summary n(Application_Links *app, View_ID view_id, Access_Flag access) +#define GET_ACTIVE_VIEW_SIG(n) View_Summary n(Application_Links *app, Access_Flag access) +#define SET_ACTIVE_VIEW_SIG(n) bool32 n(Application_Links *app, View_Summary *view) +#define VIEW_SET_SETTING_SIG(n) bool32 n(Application_Links *app, View_Summary *view, View_Setting_ID setting, int32_t value) +#define VIEW_SET_SPLIT_PROPORTION_SIG(n) bool32 n(Application_Links *app, View_Summary *view, float t) +#define VIEW_COMPUTE_CURSOR_SIG(n) bool32 n(Application_Links *app, View_Summary *view, Buffer_Seek seek, Full_Cursor *cursor_out) +#define VIEW_SET_CURSOR_SIG(n) bool32 n(Application_Links *app, View_Summary *view, Buffer_Seek seek, bool32 set_preferred_x) +#define VIEW_SET_MARK_SIG(n) bool32 n(Application_Links *app, View_Summary *view, Buffer_Seek seek) +#define VIEW_SET_HIGHLIGHT_SIG(n) bool32 n(Application_Links *app, View_Summary *view, int32_t start, int32_t end, bool32 turn_on) +#define VIEW_SET_BUFFER_SIG(n) bool32 n(Application_Links *app, View_Summary *view, Buffer_ID buffer_id, Set_Buffer_Flag flags) +#define VIEW_POST_FADE_SIG(n) bool32 n(Application_Links *app, View_Summary *view, float seconds, int32_t start, int32_t end, int_color color) +#define GET_USER_INPUT_SIG(n) User_Input n(Application_Links *app, Input_Type_Flag get_type, Input_Type_Flag abort_type) #define GET_COMMAND_INPUT_SIG(n) User_Input n(Application_Links *app) #define GET_MOUSE_STATE_SIG(n) Mouse_State n(Application_Links *app) -#define START_QUERY_BAR_SIG(n) int n(Application_Links *app, Query_Bar *bar, unsigned int flags) -#define END_QUERY_BAR_SIG(n) void n(Application_Links *app, Query_Bar *bar, unsigned int flags) -#define PRINT_MESSAGE_SIG(n) void n(Application_Links *app, char *str, int len) -#define CHANGE_THEME_SIG(n) void n(Application_Links *app, char *name, int len) -#define CHANGE_FONT_SIG(n) void n(Application_Links *app, char *name, int len) -#define SET_THEME_COLORS_SIG(n) void n(Application_Links *app, Theme_Color *colors, int count) -#define GET_THEME_COLORS_SIG(n) void n(Application_Links *app, Theme_Color *colors, int count) -#define DIRECTORY_GET_HOT_SIG(n) int n(Application_Links *app, char *out, int capacity) -#define GET_FILE_LIST_SIG(n) File_List n(Application_Links *app, char *dir, int len) +#define START_QUERY_BAR_SIG(n) bool32 n(Application_Links *app, Query_Bar *bar, uint32_t flags) +#define END_QUERY_BAR_SIG(n) void n(Application_Links *app, Query_Bar *bar, uint32_t flags) +#define PRINT_MESSAGE_SIG(n) void n(Application_Links *app, char *str, int32_t len) +#define CHANGE_THEME_SIG(n) void n(Application_Links *app, char *name, int32_t len) +#define CHANGE_FONT_SIG(n) void n(Application_Links *app, char *name, int32_t len) +#define SET_THEME_COLORS_SIG(n) void n(Application_Links *app, Theme_Color *colors, int32_t count) +#define GET_THEME_COLORS_SIG(n) void n(Application_Links *app, Theme_Color *colors, int32_t count) +#define DIRECTORY_GET_HOT_SIG(n) int32_t n(Application_Links *app, char *out, int32_t capacity) +#define GET_FILE_LIST_SIG(n) File_List n(Application_Links *app, char *dir, int32_t len) #define FREE_FILE_LIST_SIG(n) void n(Application_Links *app, File_List list) -#define FILE_EXISTS_SIG(n) int n(Application_Links *app, char *filename, int len) -#define DIRECTORY_CD_SIG(n) int n(Application_Links *app, char *dir, int *len, int capacity, char *rel_path, int rel_len) -#define GET_4ED_PATH_SIG(n) int n(Application_Links *app, char *out, int capacity) -#define SHOW_MOUSE_CURSOR_SIG(n) void n(Application_Links *app, int show) +#define FILE_EXISTS_SIG(n) bool32 n(Application_Links *app, char *filename, int len) +#define DIRECTORY_CD_SIG(n) bool32 n(Application_Links *app, char *dir, int *len, int capacity, char *rel_path, int rel_len) +#define GET_4ED_PATH_SIG(n) bool32 n(Application_Links *app, char *out, int32_t capacity) +#define SHOW_MOUSE_CURSOR_SIG(n) void n(Application_Links *app, Mouse_Cursor_Show_Type show) extern "C"{ typedef EXEC_COMMAND_SIG(Exec_Command_Function); typedef EXEC_SYSTEM_COMMAND_SIG(Exec_System_Command_Function); diff --git a/4coder_default_include.cpp b/4coder_default_include.cpp index 7f7b2ea3..82e6fb04 100644 --- a/4coder_default_include.cpp +++ b/4coder_default_include.cpp @@ -236,7 +236,7 @@ clipboard_copy(Application_Links *app, int start, int end, Buffer_Summary *buffe if (size <= app->memory_size){ app->buffer_read_range(app, &buffer, start, end, str); - app->clipboard_post(app, str, size); + app->clipboard_post(app, 0, str, size); if (buffer_out){*buffer_out = buffer;} result = true; } @@ -285,7 +285,7 @@ View_Paste_Index *view_paste_index = view_paste_index_ - 1; CUSTOM_COMMAND_SIG(paste){ unsigned int access = AccessOpen; - int count = app->clipboard_count(app); + int count = app->clipboard_count(app, 0); if (count > 0){ View_Summary view = app->get_active_view(app, access); @@ -294,7 +294,7 @@ CUSTOM_COMMAND_SIG(paste){ int paste_index = 0; view_paste_index[view.view_id].index = paste_index; - int len = app->clipboard_index(app, paste_index, 0, 0); + int len = app->clipboard_index(app, 0, paste_index, 0, 0); char *str = 0; if (len <= app->memory_size){ @@ -302,7 +302,7 @@ CUSTOM_COMMAND_SIG(paste){ } if (str){ - app->clipboard_index(app, paste_index, str, len); + app->clipboard_index(app, 0, paste_index, str, len); Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access); int pos = view.cursor.pos; @@ -321,7 +321,7 @@ CUSTOM_COMMAND_SIG(paste){ CUSTOM_COMMAND_SIG(paste_next){ unsigned int access = AccessOpen; - int count = app->clipboard_count(app); + int count = app->clipboard_count(app, 0); if (count > 0){ View_Summary view = app->get_active_view(app, access); @@ -334,7 +334,7 @@ CUSTOM_COMMAND_SIG(paste_next){ int paste_index = view_paste_index[view.view_id].index + 1; view_paste_index[view.view_id].index = paste_index; - int len = app->clipboard_index(app, paste_index, 0, 0); + int len = app->clipboard_index(app, 0, paste_index, 0, 0); char *str = 0; if (len <= app->memory_size){ @@ -342,7 +342,7 @@ CUSTOM_COMMAND_SIG(paste_next){ } if (str){ - app->clipboard_index(app, paste_index, str, len); + app->clipboard_index(app, 0, paste_index, str, len); Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access); Range range = get_range(&view); @@ -970,9 +970,9 @@ isearch(Application_Links *app, int start_reversed){ int step_forward = 0; int step_backward = 0; - if (CommandEqual(in.command, search) || + if ((in.command.command == search) || in.key.keycode == key_page_down || in.key.keycode == key_down) step_forward = 1; - if (CommandEqual(in.command, reverse_search) || + if ((in.command.command == reverse_search) || in.key.keycode == key_page_up || in.key.keycode == key_up) step_backward = 1; int start_pos = pos; @@ -1365,6 +1365,39 @@ CUSTOM_COMMAND_SIG(write_and_auto_tab){ // Default Building Stuff // +// NOTE(allen|a4.0.9): This is provided to establish a default method of getting +// a "build directory". This function tries to setup the build directory in the +// directory of the given buffer, it cannot it get's the 4coder hot directory. +// This behavior is a little different than previous versions of 4coder. +// +// There is requirement that a custom build system in 4coder actually use the +// directory given by this function. +static int +get_build_directory(Application_Links *app, Buffer_Summary *buffer, String *dir_out){ + int result = false; + + if (buffer->file_name){ + if (!match(buffer->file_name, buffer->buffer_name)){ + String dir = make_string(buffer->file_name, + buffer->file_name_len, + buffer->file_name_len+1); + remove_last_folder(&dir); + append(dir_out, dir); + result = true; + } + } + + if (!result){ + int len = app->directory_get_hot(app, dir_out->str, + dir_out->memory_size - dir_out->size); + if (len + dir_out->size < dir_out->memory_size){ + result = true; + } + } + + return(result); +} + CUSTOM_COMMAND_SIG(build_search_regular){ // NOTE(allen|a3.3): An example of traversing the filesystem through parent // directories looking for a file, in this case a batch file to execute. @@ -1401,14 +1434,15 @@ CUSTOM_COMMAND_SIG(build_search_regular){ // This doesn't actually change the hot directory of 4coder, it's only effect is to // modify the string you passed in to reflect the change in directory if that change was possible. - int old_size; + int old_size = 0; int size = app->memory_size/2; unsigned int access = AccessAll; View_Summary view = app->get_active_view(app, access); + Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access); String dir = make_string(app->memory, 0, size); - dir.size = app->directory_get_hot(app, dir.str, dir.memory_size); + get_build_directory(app, &buffer, &dir); String command = make_string((char*)app->memory + size, 0, size); diff --git a/4coder_types.h b/4coder_types.h index 210819d9..5579eaf8 100644 --- a/4coder_types.h +++ b/4coder_types.h @@ -1,8 +1,25 @@ -/* DOC(Key_Code is the type alias for key codes.) */ +/* DOC(bool32 is an alias name to signal that an integer parameter or field is for +true/false vales.) */ +typedef int32_t bool32; + +/* DOC(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.) */ +typedef uint32_t int_color; + +/* DOC(Key_Code is the alias for key codes including raw codes and codes translated +to textual input that takes modifiers into account.) */ typedef unsigned char Key_Code; +/* DOC(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.) */ +typedef int32_t Buffer_ID; + +/* DOC(View_ID is used to name a 4coder view. Each view has a unique id in +the range [1,16].) */ +typedef int32_t View_ID; + #define ENUM(type,name) typedef type name; enum name##_ #define FLAGENUM(name) typedef uint32_t name; enum name##_ @@ -269,14 +286,26 @@ ENUM(int32_t, Mouse_Cursor_Show_Type){ // MouseCursorShow_WhenActive,// TODO(allen): coming soon }; +/* DOC( +Generic_Command acts as a name for a command, and can name an +internal command or a custom command. +)*/ +union Generic_Command{ + /*DOC(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_ID cmdid; + /*DOC(If this Generic_Command does not represent an internal command the command + field is the pointer to the custom command..)*/ + Custom_Command_Function *command; +}; + /* DOC( 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. -) -*/ +)*/ struct Key_Event_Data{ /* DOC(This field is the raw keycode which is always non-zero in valid key events.) */ Key_Code keycode; @@ -405,39 +434,39 @@ struct Buffer_Summary{ 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". ) */ - int exists; + bool32 exists; /* DOC(If this is not a null summary, this field indicates whether the buffer has finished loading.) */ - int ready; + bool32 ready; /* DOC( 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. ) */ - int buffer_id; + int32_t buffer_id; /* DOC(If this is not a null summary, this field contains flags describing the protection status of the buffer.) DOC_SEE(Access_Flag) */ - unsigned int lock_flags; + Access_Flag lock_flags; /* DOC(If this is not a null summary, this field specifies the size of the text in the buffer.) */ - int size; + int32_t size; /* DOC(If this is not a null summary, this field specifies the file name associated to this buffer.) */ char *file_name; /* DOC(This field specifies the length of the file_name string.) */ - int file_name_len; + int32_t file_name_len; /* DOC(If this is not a null summary, this field specifies the name of the buffer.) */ char *buffer_name; /* DOC(This field specifies the length of the buffer_name string.) */ - int buffer_name_len; + int32_t buffer_name_len; /* DOC(This is a hold over from an old system, consider it deprecated.) */ - int buffer_cursor_pos; + int32_t buffer_cursor_pos; /* DOC(If this is not a null summary, this field indicates whether the buffer is set to lex tokens.) */ - int is_lexed; + bool32 is_lexed; /* DOC(If this is not a null summary, this field specifies the id of the command map for this buffer.) */ - int map_id; + int32_t map_id; }; /* DOC( @@ -448,19 +477,19 @@ struct View_Summary{ 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". ) */ - int exists; + bool32 exists; /* DOC( 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. ) */ - int view_id; + int32_t view_id; /* DOC(If this is not a null summary, and this view looks at a buffer, this is the id of the buffer.) */ - int buffer_id; + int32_t buffer_id; /* DOC(If this is not a null summary, this field contains flags describing the protection status of the view.) DOC_SEE(Access_Flag) */ - unsigned int lock_flags; + Access_Flag lock_flags; /* DOC(If this is not a null summary, this describes the position of the cursor.) @@ -477,9 +506,9 @@ struct View_Summary{ /* DOC(If this is not a null summary, this specifies the height of a line rendered in the view.) */ float line_height; /* DOC(If this is not a null summary, this indicates that the view is set to render with unwrapped lines.) */ - int unwrapped_lines; + bool32 unwrapped_lines; /* DOC(If this is not a null summary, this indicates that the view is set to highlight white space.) */ - int show_whitespace; + bool32 show_whitespace; /* DOC(This feature is not fully implemented yet.) */ i32_Rect file_region; @@ -487,15 +516,18 @@ struct View_Summary{ GUI_Scroll_Vars scroll_vars; }; -/* DOC(User_Input describes a user input event which can be either a key press or mouse event.) */ +/* +DOC(User_Input describes a user input event which can be either a key press or mouse event.) +DOC_SEE(User_Input_Type_ID) +DOC_SEE(Generic_Command) +*/ struct User_Input{ /* DOC(This field specifies whether the event was a key press or mouse event.) - DOC_SEE(User_Input_Type_ID) */ - int type; + User_Input_Type_ID type; /* DOC(This field indicates that an abort event has occurred and the command needs to shut down.) */ - int abort; + bool32 abort; union{ /* DOC(This field describes a key press event.) */ Key_Event_Data key; @@ -504,9 +536,8 @@ struct User_Input{ }; /* DOC(If this event would trigger a command, this field specifies what the command would be.) - TODO */ - unsigned long long command; + Generic_Command command; }; /* DOC(Query_Bar is a struct used to store information in the user's control @@ -527,11 +558,11 @@ struct Event_Message{ /* DOC(Theme_Color stores a style tag/color pair, for the purpose of setting and getting colors in the theme .) DOC_SEE(Style_Tag) +DOC_SEE(int_color) */ struct Theme_Color{ Style_Tag tag; - /* DOC(This field specifies a color in a 24, bit 3 channel RGB integer.) */ - uint32_t color; + int_color color; }; diff --git a/4ed.cpp b/4ed.cpp index a153d688..ab780df5 100644 --- a/4ed.cpp +++ b/4ed.cpp @@ -1318,7 +1318,7 @@ app_hardcode_styles(Models *models){ ++style; ///////////////// - style_set_name(style, make_lit_string("Magic")); + style_set_name(style, make_lit_string("Hjortshoej")); style->main.back_color = 0xFFF0F0F0; style->main.margin_color = 0xFF9E9E9E; @@ -2402,7 +2402,7 @@ App_Step_Sig(app_step){ User_Input user_in; user_in.type = UserInputKey; user_in.key = key; - user_in.command = (unsigned long long)cmd_bind.custom; + user_in.command.command = cmd_bind.custom; user_in.abort = 0; if ((EventOnEsc & abort_flags) && key.keycode == key_esc){ @@ -2453,7 +2453,7 @@ App_Step_Sig(app_step){ User_Input user_in; user_in.type = UserInputMouse; user_in.mouse = input->mouse; - user_in.command = 0; + user_in.command.cmdid = 0; user_in.abort = 0; if (abort_flags & EventOnMouseMove){ diff --git a/4ed_api_implementation.cpp b/4ed_api_implementation.cpp index c08d0a2b..e93f95d6 100644 --- a/4ed_api_implementation.cpp +++ b/4ed_api_implementation.cpp @@ -49,7 +49,7 @@ fill_buffer_summary(Buffer_Summary *buffer, Editing_File *file, Command_Data *cm internal void fill_view_summary(View_Summary *view, View *vptr, Live_Views *live_set, Working_Set *working_set){ - int buffer_id; + Buffer_ID buffer_id = 0; File_Viewing_Data *data = &vptr->file_data; *view = view_summary_zero(); @@ -116,7 +116,7 @@ imp_get_file(Command_Data *cmd, Buffer_Summary *buffer){ } internal View* -imp_get_view(Command_Data *cmd, int view_id){ +imp_get_view(Command_Data *cmd, View_ID view_id){ Live_Views *live_set = cmd->live_set; View *vptr = 0; @@ -141,50 +141,59 @@ imp_get_view(Command_Data *cmd, View_Summary *view){ #define API_EXPORT -API_EXPORT void -Exec_Command(Application_Links *app, uint64_t command_id)/* -DOC_PARAM(command_id, an integer id enumerated in 4coder_custom.h starting with cmdid) -DOC(Executes the command associated with the command_id passed in) +API_EXPORT bool32 +Exec_Command(Application_Links *app, Command_ID command_id)/* +DOC_PARAM(command_id, The command_id parameter specifies which internal command to execute.) +DOC_RETURN(This call returns non-zero if command_id named a valid internal command.) +DOC(A call to exec_command executes an internal command. +If command_id is invalid a warning is posted to *messages*.) +DOC_SEE(Command_ID) */{ - Command_Data *cmd = (Command_Data*)app->cmd_context; - Command_Function function = command_table[command_id]; - Command_Binding binding = {}; - binding.function = function; - if (function) function(cmd->system, cmd, binding); + bool32 result = false; - update_command_data(cmd->vars, cmd); + if (command_id < cmdid_count){ + Command_Data *cmd = (Command_Data*)app->cmd_context; + Command_Function function = command_table[command_id]; + Command_Binding binding = {}; + binding.function = function; + if (function) function(cmd->system, cmd, binding); + + update_command_data(cmd->vars, cmd); + + result = true; + } + else{ + app->print_message(app, literal("CUSTOM WARNING: An invalid Command_ID was passed to exec_command.")); + } + + return(result); } // TODO(allen): This is a bit of a mess and needs to be fixed soon -API_EXPORT int -Exec_System_Command(Application_Links *app, View_Summary *view, Buffer_Identifier buffer, char *path, int path_len, char *command, int command_len, unsigned int flags)/* -DOC_PARAM(view, the target view that will display the output buffer, may be NULL, see description for details) -DOC_PARAM(buffer, a buffer identifier for the buffer that will be filled with the output from the command) -DOC_PARAM(path, the path from which the command is executed) -DOC_PARAM(path_len, the length of the path string) -DOC_PARAM(command, the command to be executed) -DOC_PARAM(command_len, the length of the command string) -DOC_PARAM(flags, may be zero or one or more CLI flags ORed together) -DOC_RETURN(returns non-zero if the command is successfully started, returns zero otherwise) +API_EXPORT bool32 +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)/* +DOC_PARAM(view, If the view parameter is non-null it specifies a view to display the command's output buffer.) +DOC_PARAM(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.) +DOC_PARAM(path, The path parameter specifies the path in which the command shall be executed. The string need not be null terminated.) +DOC_PARAM(path_len, The parameter path_len specifies the length of the path string.) +DOC_PARAM(command, The command parameter specifies the command that shall be executed. The string need not be null terminated.) +DOC_PARAM(command_len, The parameter command_len specifies the length of the command string.) +DOC_PARAM(flags, Flags for the behavior of the call are specified in the flags parameter.) +DOC_RETURN(This call returns non-zero on success.) DOC ( -Executes a system 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. If the buffer already exists the command will fail, unless -CLI_OverlapWithConflict is set in the flags. +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. -If the buffer is not already in an open view, and the view parameter is no NULL, then the provided view -will display the output buffer. If the view parameter is NULL, no view will display the output. +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 CLI_OverlapWithConflict is set in the flags, the command will always be executed even if another command -was outputting to the same buffer still. - -If CLI_AlwaysBindToView is set and the view parameter is not NULL, then the specified view will always -begin displaying the output buffer, even if another open view already displays that buffer. - -If CLI_CursorAtEnd is set the cursor in the output buffer will be placed at the end of the buffer instead -of at the beginning. +If the view parameter is NULL, no view will switch to the output. ) +DOC_SEE(Buffer_Identifier) +DOC_SEE(Command_Line_Input_Flag) */{ Command_Data *cmd = (Command_Data*)app->cmd_context; System_Functions *system = cmd->system; @@ -203,7 +212,7 @@ of at the beginning. Partition *part = &models->mem.part; Temp_Memory temp = begin_temp_memory(part); - int result = true; + bool32 result = true; View *vptr = imp_get_view(cmd, view); @@ -326,15 +335,17 @@ of at the beginning. } API_EXPORT void -Clipboard_Post(Application_Links *app, char *str, int len)/* -DOC_PARAM(str, the string to post to the clipboard) -DOC_PARAM(len, the length of the string str) +Clipboard_Post(Application_Links *app, int32_t clipboard_id, char *str, int32_t len)/* +DOC_PARAM(clipboard_id, This parameter is set up to prepare for future features, it should always be 0 for now.) +DOC_PARAM(str, The str parameter specifies the string to be posted to the clipboard, it need not be null terminated.) +DOC_PARAM(len, The len parameter specifies the length of the str string.) DOC ( 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. ) +DOC_SEE(The_4coder_Clipboard) */{ Command_Data *cmd = (Command_Data*)app->cmd_context; System_Functions *system = cmd->system; @@ -347,38 +358,38 @@ be pasted into other applications. system->post_clipboard(*dest); } -API_EXPORT int -Clipboard_Count(Application_Links *app)/* -DOC(returns the number of items in the clipboard) +API_EXPORT int32_t +Clipboard_Count(Application_Links *app, int32_t clipboard_id)/* +DOC_PARAM(clipboard_id, This parameter is set up to prepare for future features, it should always be 0 for now.) +DOC(This call returns the number of items in the clipboard.) +DOC_SEE(The_4coder_Clipboard) */{ Command_Data *cmd = (Command_Data*)app->cmd_context; Working_Set *working = &cmd->models->working_set; - int count = working->clipboard_size; + int32_t count = working->clipboard_size; return(count); } -API_EXPORT int -Clipboard_Index(Application_Links *app, int index, char *out, int len)/* -DOC_PARAM(index, the index of the item to be read) +API_EXPORT int32_t +Clipboard_Index(Application_Links *app, int32_t clipboard_id, int32_t item_index, char *out, int32_t len)/* +DOC_PARAM(clipboard_id, This parameter is set up to prepare for future features, it should always be 0 for now.) +DOC_PARAM(item_index, This parameter specifies which item to read, 0 is the most recent copy, 1 is the second most recent copy, etc.) DOC_PARAM(out, a buffer where the clipboard contents are written or NULL) DOC_PARAM(len, the length of the out buffer) -DOC_RETURN(returns the size of the item on the clipboard associated with the given index) +DOC_RETURN(This call returns the size of the item associated with item_index.) DOC ( -There are multiple items on the 4coder clipboard. The most recent copy is always at -index 0. The second most recent is at index 1, and so on for all the stored clipboard items. -This function reads one of the clipboard items and stores it into the out buffer, if the out -buffer is not NULL. This function always returns the size of the clipboard item specified -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. +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. ) +DOC_SEE(The_4coder_Clipboard) */{ Command_Data *cmd = (Command_Data*)app->cmd_context; Working_Set *working = &cmd->models->working_set; - int size = 0; - String *str = working_set_clipboard_index(working, index); + int32_t size = 0; + String *str = working_set_clipboard_index(working, item_index); if (str){ size = str->size; if (out){ @@ -412,15 +423,15 @@ internal_get_buffer_next(Working_Set *working_set, Buffer_Summary *buffer){ } API_EXPORT Buffer_Summary -Get_Buffer_First(Application_Links *app, unsigned int access)/* -DOC_PARAM(access, the access flags for the access) -DOC_RETURN(returns the summary of the first buffer in a buffer loop) +Get_Buffer_First(Application_Links *app, Access_Flag access)/* +DOC_PARAM(access, The access parameter determines what levels of protection this call can access.) +DOC_RETURN(This call returns the summary of the first buffer in a buffer loop.) DOC ( -Begins a loop across all the buffers. +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. +If the buffer returned does not exist, the loop is finished. +Buffers should not be killed durring a buffer loop. ) DOC_SEE(Access_Flag) DOC_SEE(get_buffer_next) @@ -438,17 +449,16 @@ DOC_SEE(get_buffer_next) } API_EXPORT void -Get_Buffer_Next(Application_Links *app, Buffer_Summary *buffer, unsigned int access)/* -DOC_PARAM(buffer, pointer to the loop buffer originally returned by get_buffer_first) -DOC_PARAM(access, the access flags for the access) +Get_Buffer_Next(Application_Links *app, Buffer_Summary *buffer, Access_Flag access)/* +DOC_PARAM(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. ) +DOC_PARAM(access, The access parameter determines what levels of protection this call can access. The buffer outputted will be the next buffer that is accessible.) DOC ( -Writes the next buffer into the buffer struct. To get predictable results every -call to get_buffer_first and get_buffer_next in the loop should have the same -access flags. +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 returned does not exist, the loop is finished. Buffers -should not be killed durring a buffer loop. +If the buffer outputted does not exist, the loop is finished. +Buffers should not be killed or created durring a buffer loop. ) DOC_SEE(Access_Flag) DOC_SEE(get_buffer_first) @@ -463,10 +473,12 @@ DOC_SEE(get_buffer_first) } API_EXPORT Buffer_Summary -Get_Buffer(Application_Links *app, int buffer_id, unsigned int access)/* -DOC_PARAM(buffer_id, the id of the buffer to get) -DOC_PARAM(access, the access flags for the access) -DOC_RETURN(returns a summary that describes the indicated buffer if it exists and is accessible) +Get_Buffer(Application_Links *app, Buffer_ID buffer_id, Access_Flag access)/* +DOC_PARAM(buffer_id, The parameter buffer_id specifies which buffer to try to get.) +DOC_PARAM(access, The access parameter determines what levels of protection this call can access.) +DOC_RETURN(This call returns a summary that describes the indicated buffer if it exists and is accessible.) +DOC_SEE(Access_Flag) +DOC_SEE(Buffer_ID) */{ Command_Data *cmd = (Command_Data*)app->cmd_context; Working_Set *working_set = &cmd->models->working_set; @@ -485,11 +497,12 @@ DOC_RETURN(returns a summary that describes the indicated buffer if it exists an } API_EXPORT Buffer_Summary -Get_Buffer_By_Name(Application_Links *app, char *name, int len, unsigned int access)/* -DOC_PARAM(name, the name of the buffer) -DOC_PARAM(len, the length of the name string) -DOC_PARAM(access, the access flags for the access) -DOC_RETURN(returns a summary that describes the indicated buffer if it exists and is accessible) +Get_Buffer_By_Name(Application_Links *app, char *name, int32_t len, Access_Flag access)/* +DOC_PARAM(name, The name parameter specifies the buffer name to try to get. The string need not be null terminated.) +DOC_PARAM(len, The len parameter specifies the length of the name string.) +DOC_PARAM(access, The access parameter determines what levels of protection this call can access.) +DOC_RETURN(This call returns a summary that describes the indicated buffer if it exists and is accessible.) +DOC_SEE(Access_Flag) */{ Command_Data *cmd = (Command_Data*)app->cmd_context; Buffer_Summary buffer = {}; @@ -507,18 +520,21 @@ DOC_RETURN(returns a summary that describes the indicated buffer if it exists an return(buffer); } -API_EXPORT int -Buffer_Boundary_Seek(Application_Links *app, Buffer_Summary *buffer, int start_pos, int seek_forward, unsigned int flags)/* -DOC_PARAM(buffer, the buffer to seek through) -DOC_PARAM(start_pos, the absolute position in the buffer to begin the seek) -DOC_PARAM(seek_forward, non-zero indicates to seek forward otherwise the seek goes backward) -DOC_PARAM(flags, one or more types of boundaries to use for stopping the seek) -DOC_RETURN(returns the position where the seek stops) +API_EXPORT int32_t +Buffer_Boundary_Seek(Application_Links *app, Buffer_Summary *buffer, int32_t start_pos, bool32 seek_forward, Seek_Boundary_Flag flags)/* +DOC_PARAM(buffer, The buffer parameter specifies the buffer through which to seek.) +DOC_PARAM(start_pos, The beginning position of the seek is specified by start_pos measured in absolute position.) +DOC_PARAM(seek_forward, If this parameter is non-zero it indicates that the seek should move foward through the buffer.) +DOC_PARAM(flags, This field specifies the types of boundaries at which the seek should stop.) +DOC_RETURN(This call returns the absolute position where the seek stopped. +If the seek goes below 0 the returned value is -1. +If the seek goes past the end the returned value is the size of the buffer.) DOC_SEE(Seek_Boundary_Flag) +DOC_SEE(4coder_Buffer_Positioning_System) */{ Command_Data *cmd = (Command_Data*)app->cmd_context; Editing_File *file; - int result = false; + int32_t result = 0; file = imp_get_file(cmd, buffer); @@ -607,26 +623,27 @@ DOC_SEE(Seek_Boundary_Flag) return(result); } -API_EXPORT int -Buffer_Read_Range(Application_Links *app, Buffer_Summary *buffer, int start, int end, char *out)/* -DOC_PARAM(buffer, The buffer to be read.) -DOC_PARAM(start, The beginning of the read range.) -DOC_PARAM(end, One past the end of the read range.) -DOC_PARAM(out, The output buffer to fill with the result of the read.) -DOC_RETURN(Returns non-zero on success.) +API_EXPORT bool32 +Buffer_Read_Range(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, char *out)/* +DOC_PARAM(buffer, This parameter specifies the buffer to read.) +DOC_PARAM(start, This parameter specifies absolute position of the first character in the read range.) +DOC_PARAM(end, This parameter specifies the absolute position of the the character one past the end of the read range.) +DOC_PARAM(out, This paramter provides the output character buffer to fill with the result of the read.) +DOC_RETURN(This call returns non-zero if the read succeeds.) DOC ( The output buffer must have a capacity of at least (end - start). The output is not null terminated. -This call fails if the buffer does not exist, or if the read range -is not within the bounds of the buffer. +This call fails if the buffer does not exist, +or if the read range is not within the bounds of the buffer. ) +DOC_SEE(4coder_Buffer_Positioning_System) */{ Command_Data *cmd = (Command_Data*)app->cmd_context; Editing_File *file = imp_get_file(cmd, buffer); - int result = false; - int size; + bool32 result = false; + int32_t size = 0; if (file){ size = buffer_size(&file->state.buffer); @@ -640,14 +657,14 @@ is not within the bounds of the buffer. return(result); } -API_EXPORT int -Buffer_Replace_Range(Application_Links *app, Buffer_Summary *buffer, int start, int end, char *str, int len)/* -DOC_PARAM(buffer, the buffer to edit) -DOC_PARAM(start, the start of the range to edit) -DOC_PARAM(end, the end of the range to edit) -DOC_PARAM(str, the string to write into the range) -DOC_PARAM(len, the length of the str string) -DOC_RETURN(returns non-zero if the replacement succeeds) +API_EXPORT bool32 +Buffer_Replace_Range(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, char *str, int32_t len)/* +DOC_PARAM(buffer, This parameter specifies the buffer to edit.) +DOC_PARAM(start, This parameter specifies absolute position of the first character in the replace range.) +DOC_PARAM(end, This parameter specifies the absolute position of the the character one past the end of the replace range.) +DOC_PARAM(str, This parameter specifies the the string to write into the range; it need not be null terminated.) +DOC_PARAM(len, This parameter specifies the length of the str string.) +DOC_RETURN(This call returns non-zero if the replacement succeeds.) DOC ( If this call succeeds it deletes the range from start to end @@ -659,13 +676,14 @@ 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. ) +DOC_SEE(4coder_Buffer_Positioning_System) */{ Command_Data *cmd = (Command_Data*)app->cmd_context; Editing_File *file = imp_get_file(cmd, buffer); - int result = false; - int size = 0; - int next_cursor = 0, pos = 0; + bool32 result = false; + int32_t size = 0; + int32_t next_cursor = 0, pos = 0; if (file){ size = buffer_size(&file->state.buffer); @@ -686,11 +704,11 @@ range is not within the bounds of the buffer. return(result); } -API_EXPORT int -Buffer_Set_Setting(Application_Links *app, Buffer_Summary *buffer, int setting, int value)/* -DOC_PARAM(buffer, The buffer on which to set a setting.) -DOC_PARAM(setting, One of the Buffer_Setting_ID enum values that identifies the setting to set.) -DOC_PARAM(value, The value to set the specified setting to.) +API_EXPORT bool32 +Buffer_Set_Setting(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting, int32_t value)/* +DOC_PARAM(buffer, The buffer parameter specifies the buffer on which to set a setting.) +DOC_PARAM(setting, The setting parameter identifies the setting that shall be changed.) +DOC_PARAM(value, The value parameter specifies the value to which the setting shall be changed.) DOC_SEE(Buffer_Setting_ID) */{ Command_Data *cmd = (Command_Data*)app->cmd_context; @@ -699,7 +717,7 @@ DOC_SEE(Buffer_Setting_ID) Editing_File *file = imp_get_file(cmd, buffer); - int result = false; + bool32 result = false; i32 new_mapid = 0; @@ -758,14 +776,14 @@ DOC_SEE(Buffer_Setting_ID) return(result); } -API_EXPORT int -Buffer_Auto_Indent(Application_Links *app, Buffer_Summary *buffer, int start, int end, int tab_width, unsigned int flags)/* -DOC_PARAM(buffer, the buffer in which to apply the auto indenting) -DOC_PARAM(start, the position to start the auto indenting) -DOC_PARAM(end, the position to end the auto indenting) -DOC_PARAM(tab_width, the number of spaces to place as a tab) -DOC_PARAM(flags, the auto tab behavior flags) -DOC_RETURN(returns non-zero when the call succeeds) +API_EXPORT bool32 +Buffer_Auto_Indent(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, int32_t tab_width, Auto_Indent_Flag flags)/* +DOC_PARAM(buffer, The buffer specifies the buffer in which to apply auto indentation.) +DOC_PARAM(start, This parameter specifies the absolute position of the start of the indentation range.) +DOC_PARAM(end, This parameter specifies the absolute position of the end of the indentation range.) +DOC_PARAM(tab_width, The tab_width parameter specifies how many spaces should be used for one indentation in space mode.) +DOC_PARAM(flags, This parameter specifies behaviors for the indentation.) +DOC_RETURN(This call returns non-zero when the call succeeds.) DOC ( Applies the built in auto-indentation rule to the code in the range from @@ -774,13 +792,14 @@ If the buffer does not have lexing enabled or the lexing job has not completed this function will fail. ) DOC_SEE(Auto_Indent_Flag) +DOC_SEE(4coder_Buffer_Positioning_System) */{ Command_Data *cmd = (Command_Data*)app->cmd_context; System_Functions *system = cmd->system; Models *models = cmd->models; Indent_Options opts = {0}; - int result = false; + bool32 result = false; Editing_File *file = imp_get_file(cmd, buffer); if (file && file->state.token_stack.tokens && @@ -800,11 +819,11 @@ DOC_SEE(Auto_Indent_Flag) } API_EXPORT Buffer_Summary -Create_Buffer(Application_Links *app, char *filename, int filename_len, unsigned int flags)/* -DOC_PARAM(filename, the name of the file to be opened or created) -DOC_PARAM(filename_len, the length of the filename string) -DOC_PARAM(flags, flags for buffer creation behavior) -DOC_RETURN(returns the summary of the created buffer on success or a NULL buffer otherwise) +Create_Buffer(Application_Links *app, char *filename, int32_t filename_len, Buffer_Create_Flag flags)/* +DOC_PARAM(filename, The filename parameter specifies the name of the file to be opened or created; it need not be null terminated.) +DOC_PARAM(filename_len, The filename_len parameter spcifies the length of the filename string.) +DOC_PARAM(flags, The flags parameter specifies behaviors for buffer creation.) +DOC_RETURN(This call returns the summary of the created buffer.) DOC ( Tries to create a new buffer and associate it to the given filename. If such a buffer already @@ -891,18 +910,18 @@ DOC_SEE(Buffer_Create_Flag) return(result); } -API_EXPORT int -Save_Buffer(Application_Links *app, Buffer_Summary *buffer, char *filename, int filename_len, unsigned int flags)/* -DOC_PARAM(buffer, the buffer to save to a file) -DOC_PARAM(filename, the name of the file to save the buffer into) -DOC_PARAM(filename_len, length of the filename string) -DOC_PARAM(flags, not currently used) -DOC_RETURN(returns non-zero if the save succeeds) +API_EXPORT bool32 +Save_Buffer(Application_Links *app, Buffer_Summary *buffer, char *filename, int32_t filename_len, uint32_t flags)/* +DOC_PARAM(buffer, The buffer parameter specifies the buffer to save to a file.) +DOC_PARAM(filename, The filename parameter specifies the name of the file to associated to the buffer; it need not be null terminated.) +DOC_PARAM(filename_len, The filename_len parameter specifies the length of the filename string.) +DOC_PARAM(flags, This parameter is not currently used and should be set to 0 for now.) +DOC_RETURN(This call returns non-zero on success.) */{ Command_Data *cmd = (Command_Data*)app->cmd_context; System_Functions *system = cmd->system; Models *models = cmd->models; - int result = false; + bool32 result = false; Editing_File *file = imp_get_file(cmd, buffer); if (file){ @@ -914,19 +933,20 @@ DOC_RETURN(returns non-zero if the save succeeds) return(result); } -API_EXPORT int -Kill_Buffer(Application_Links *app, Buffer_Identifier buffer, int view_id, unsigned int flags)/* -DOC_PARAM(buffer, A buffer identifier specifying the buffer to try to kill.) -DOC_PARAM(view_id, The id of view that will contain the "are you sure" dialogue.) -DOC_PARAM(flags, Flags for buffer kill behavior.) -DOC_RETURN(Returns non-zero if the kill succeeds.) +API_EXPORT bool32 +Kill_Buffer(Application_Links *app, Buffer_Identifier buffer, View_ID view_id, Buffer_Kill_Flag flags)/* +DOC_PARAM(buffer, The buffer parameter specifies the buffer to try to kill.) +DOC_PARAM(view_id, The view_id parameter specifies the view that will contain the "are you sure" dialogue if the buffer is dirty.) +DOC_PARAM(flags, The flags parameter specifies behaviors for the buffer kill.) +DOC_RETURN(This call returns non-zero on success.) DOC ( 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. ) -DOC_SEE(Buffer_Kill_Flags) +DOC_SEE(Buffer_Kill_Flag) +DOC_SEE(Buffer_Identifier) */{ Command_Data *cmd = (Command_Data*)app->cmd_context; System_Functions *system = cmd->system; @@ -947,7 +967,7 @@ DOC_SEE(Buffer_Kill_Flags) try_kill_file(system, models, file, vptr, string_zero()); } else{ - app->print_message(app, literal("buffer is dirty and no view was specified for a dialogue.")); + app->print_message(app, literal("CUSTOM WARNING: the buffer is dirty and no view was specified for a dialogue.")); } } } @@ -991,14 +1011,14 @@ internal_get_view_next(Command_Data *cmd, View_Summary *view){ } API_EXPORT View_Summary -Get_View_First(Application_Links *app, unsigned int access)/* -DOC_PARAM(access, the access flags for the access) -DOC_RETURN(returns the summary of the first view in a view loop) +Get_View_First(Application_Links *app, Access_Flag access)/* +DOC_PARAM(access, The access parameter determines what levels of protection this call can access.) +DOC_RETURN(This call returns the summary of the first view in a view loop.) DOC ( -Begins a loop across all the open views. +This call begins a loop across all the open views. -If the view summary returned is NULL, the loop is finished. +If the view summary returned is a null summary, the loop is finished. Views should not be closed or opened durring a view loop. ) DOC_SEE(Access_Flag) @@ -1016,16 +1036,14 @@ DOC_SEE(get_view_next) } API_EXPORT void -Get_View_Next(Application_Links *app, View_Summary *view, unsigned int access)/* +Get_View_Next(Application_Links *app, View_Summary *view, Access_Flag access)/* DOC_PARAM(view, pointer to the loop view originally returned by get_view_first) -DOC_PARAM(access, the access flags for the access) +DOC_PARAM(access, The access parameter determines what levels of protection this call can access. The view outputted will be the next view that is accessible.) DOC ( -Writes the next view into the view struct. To get predictable results every -call to get_view_first and get_view_next in the loop should have the same -access flags. +This call steps a view summary to the next view in the global view order. -If the view summary returned is NULL, the loop is finished. +If the view outputted does not exist, the loop is finished. Views should not be closed or opened durring a view loop. ) DOC_SEE(Access_Flag) @@ -1040,15 +1058,16 @@ DOC_SEE(get_view_first) } API_EXPORT View_Summary -Get_View(Application_Links *app, int view_id, unsigned int access)/* -DOC_PARAM(view_id, the id of the view to get) -DOC_PARAM(access, the access flags for the access) -DOC_RETURN(returns a summary that describes the indicated view if it is open and is accessible) +Get_View(Application_Links *app, View_ID view_id, Access_Flag access)/* +DOC_PARAM(view_id, The view_id specifies the view to try to get.) +DOC_PARAM(access, The access parameter determines what levels of protection this call can access.) +DOC_RETURN(This call returns a summary that describes the indicated view if it is open and accessible.) +DOC_SEE(Access_Flag) */{ Command_Data *cmd = (Command_Data*)app->cmd_context; View_Summary view = {0}; Live_Views *live_set = cmd->live_set; - int max = live_set->max; + i32 max = live_set->max; View *vptr = 0; view_id -= 1; @@ -1064,10 +1083,11 @@ DOC_RETURN(returns a summary that describes the indicated view if it is open and } API_EXPORT View_Summary -Get_Active_View(Application_Links *app, unsigned int access)/* -DOC_PARAM(access, the access flags for the access) -DOC_RETURN(returns a summary that describes the active view) +Get_Active_View(Application_Links *app, Access_Flag access)/* +DOC_PARAM(access, The access parameter determines what levels of protection this call can access.) +DOC_RETURN(This call returns a summary that describes the active view.) DOC_SEE(set_active_view) +DOC_SEE(Access_Flag) */{ Command_Data *cmd = (Command_Data*)app->cmd_context; View_Summary view = {0}; @@ -1078,13 +1098,13 @@ DOC_SEE(set_active_view) return(view); } -API_EXPORT int +API_EXPORT bool32 Set_Active_View(Application_Links *app, View_Summary *view)/* -DOC_PARAM(view, the view to set as active) -DOC_RETURN(returns non-zero on success) +DOC_PARAM(view, The view parameter specifies which view to make active.) +DOC_RETURN(This call returns non-zero on success.) DOC ( -If the given view is a currently open view, it is set as the +If the given view is open, it is set as the active view, and takes subsequent commands and is returned from get_active_view. ) @@ -1093,7 +1113,7 @@ DOC_SEE(get_active_view) Command_Data *cmd = (Command_Data*)app->cmd_context; Models *models = cmd->models; View *vptr = imp_get_view(cmd, view); - int result = false; + bool32 result = false; if (vptr){ result = true; @@ -1107,16 +1127,17 @@ DOC_SEE(get_active_view) return(result); } -API_EXPORT int -View_Set_Setting(Application_Links *app, View_Summary *view, int setting, int value)/* -DOC_PARAM(view, The view on which to set a setting.) -DOC_PARAM(setting, One of the View_Setting_ID enum values that identifies the setting to set.) -DOC_PARAM(value, The value to set the specified setting to.) +API_EXPORT bool32 +View_Set_Setting(Application_Links *app, View_Summary *view, View_Setting_ID setting, int32_t value)/* +DOC_PARAM(view, The view parameter specifies the view on which to set a setting.) +DOC_PARAM(setting, The setting parameter identifies the setting that shall be changed.) +DOC_PARAM(value, The value parameter specifies the value to which the setting shall be changed.) +DOC_RETURN(This call returns non-zero on success.) DOC_SEE(View_Setting_ID) */{ Command_Data *cmd = (Command_Data*)app->cmd_context; View *vptr = imp_get_view(cmd, view); - int result = false; + bool32 result = false; if (vptr){ switch (setting){ @@ -1133,51 +1154,52 @@ DOC_SEE(View_Setting_ID) return(result); } -API_EXPORT int +API_EXPORT bool32 View_Set_Split_Proportion(Application_Links *app, View_Summary *view, float t)/* -DOC_PARAM(view, The view on which to adjust size.) -DOC_PARAM(t, The proportion of the view's containing box that it should occupy in [0,1]) -DOC_RETURN(Returns non-zero on success.) +DOC_PARAM(view, The view parameter specifies which view shall have it's size adjusted.) +DOC_PARAM(t, The t parameter specifies the proportion of the containing box that the view should occupy. t should be in [0,1].) +DOC_RETURN(This call returns non-zero on success.) */{ - Command_Data *cmd = (Command_Data*)app->cmd_context; - Models *models = cmd->models; - Editing_Layout *layout = &models->layout; - View *vptr = imp_get_view(cmd, view); - int result = false; + bool32 result = false; - if (vptr){ - result = true; + if (0 <= t && t <= 1.f){ + Command_Data *cmd = (Command_Data*)app->cmd_context; + Models *models = cmd->models; + Editing_Layout *layout = &models->layout; + View *vptr = imp_get_view(cmd, view); - Panel *panel = vptr->panel; - Panel_Divider *div = layout->dividers + panel->parent; - - if (panel->which_child == 1){ - t = 1-t; + if (vptr){ + result = true; + + Panel *panel = vptr->panel; + Panel_Divider *div = layout->dividers + panel->parent; + + if (panel->which_child == 1){ + t = 1-t; + } + + div->pos = t; + layout_fix_all_panels(layout); } - - div->pos = t; - layout_fix_all_panels(layout); } return(result); } -API_EXPORT int +API_EXPORT bool32 View_Compute_Cursor(Application_Links *app, View_Summary *view, Buffer_Seek seek, Full_Cursor *cursor_out)/* -DOC_PARAM(view, The view on which to run the cursor computation.) -DOC_PARAM(seek, The seek position.) -DOC_PARAM(cursor_out, On success this is filled with result of the seek.) -DOC_RETURN(Returns non-zero on success.) -DOC -( -Computes a full cursor for the given seek position. -) +DOC_PARAM(view, The view parameter specifies the view on which to run the cursor computation.) +DOC_PARAM(seek, The seek parameter specifies the target position for the seek.) +DOC_PARAM(cursor_out, On success this struct is filled with the result of the seek.) +DOC_RETURN(This call returns non-zero on success.) +DOC(Computes a Full_Cursor for the given seek position with no side effects.) DOC_SEE(Buffer_Seek) +DOC_SEE(Full_Cursor) */{ Command_Data *cmd = (Command_Data*)app->cmd_context; View *vptr = imp_get_view(cmd, view); Editing_File *file = 0; - int result = false; + bool32 result = false; if (vptr){ file = vptr->file_data.file; @@ -1194,23 +1216,24 @@ DOC_SEE(Buffer_Seek) return(result); } -API_EXPORT int -View_Set_Cursor(Application_Links *app, View_Summary *view, Buffer_Seek seek, int set_preferred_x)/* -DOC_PARAM(view, the view in which to set the cursor) -DOC_PARAM(seek, the seek position) -DOC_PARAM(set_preferred_x, if true the preferred x is updated to match the new cursor position) -DOC_RETURN(returns non-zero on success) +API_EXPORT bool32 +View_Set_Cursor(Application_Links *app, View_Summary *view, Buffer_Seek seek, bool32 set_preferred_x)/* +DOC_PARAM(view, The view parameter specifies the view in which to set the cursor.) +DOC_PARAM(seek, The seek parameter specifies the target position for the seek.) +DOC_PARAM(set_preferred_x, If this parameter is true the preferred x is updated to match the new cursor x.) +DOC_RETURN(This call returns non-zero on success.) DOC ( -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. +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. ) DOC_SEE(Buffer_Seek) */{ Command_Data *cmd = (Command_Data*)app->cmd_context; View *vptr = imp_get_view(cmd, view); Editing_File *file = 0; - int result = false; + bool32 result = false; if (vptr){ file = vptr->file_data.file; @@ -1231,21 +1254,18 @@ DOC_SEE(Buffer_Seek) return(result); } -API_EXPORT int +API_EXPORT bool32 View_Set_Mark(Application_Links *app, View_Summary *view, Buffer_Seek seek)/* -DOC_PARAM(view, the view in which to set the mark) -DOC_PARAM(seek, the seek position) -DOC_RETURN(returns non-zero on success) -DOC -( -Sets the the view's mark position. -) +DOC_PARAM(view, The view parameter specifies the view in which to set the mark.) +DOC_PARAM(seek, The seek parameter specifies the target position for the seek.) +DOC_RETURN(This call returns non-zero on success.) +DOC(This call sets the the view's mark position.) DOC_SEE(Buffer_Seek) */{ Command_Data *cmd = (Command_Data*)app->cmd_context; View *vptr = imp_get_view(cmd, view); Full_Cursor cursor = {0}; - int result = false; + bool32 result = false; if (vptr){ result = true; @@ -1262,13 +1282,13 @@ DOC_SEE(Buffer_Seek) return(result); } -API_EXPORT int -View_Set_Highlight(Application_Links *app, View_Summary *view, int start, int end, int turn_on)/* -DOC_PARAM(view, the view to set the highlight in) -DOC_PARAM(start, the start of the highlight range) -DOC_PARAM(end, the end of the highlight range) -DOC_PARAM(turn_on, indicates whether the highlight is being turned on or off) -DOC_RETURN(returns non-zero on success) +API_EXPORT bool32 +View_Set_Highlight(Application_Links *app, View_Summary *view, int32_t start, int32_t end, bool32 turn_on)/* +DOC_PARAM(view, The view parameter specifies the view in which to set the highlight.) +DOC_PARAM(start, This parameter specifies the absolute position of the first character of the highlight range.) +DOC_PARAM(end, This parameter specifies the absolute position of the character one past the end of the highlight range.) +DOC_PARAM(turn_on, This parameter indicates whether the highlight is being turned on or off.) +DOC_RETURN(This call returns non-zero on success.) DOC ( The highlight is mutually exclusive to the cursor. When the turn_on parameter @@ -1279,7 +1299,7 @@ the turn_on set to false, will switch back to showing the cursor. */{ Command_Data *cmd = (Command_Data*)app->cmd_context; View *vptr = imp_get_view(cmd, view); - int result = false; + bool32 result = false; if (vptr){ result = true; @@ -1295,12 +1315,12 @@ the turn_on set to false, will switch back to showing the cursor. return(result); } -API_EXPORT int -View_Set_Buffer(Application_Links *app, View_Summary *view, int buffer_id, unsigned int flags)/* -DOC_PARAM(view, the view to display the buffer in) -DOC_PARAM(buffer_id, the buffer to show in the view) -DOC_PARAM(flags, set buffer behavior flags) -DOC_RETURN(returns non-zero on success) +API_EXPORT bool32 +View_Set_Buffer(Application_Links *app, View_Summary *view, Buffer_ID buffer_id, Set_Buffer_Flag flags)/* +DOC_PARAM(view, The view parameter specifies the view in which to display the buffer.) +DOC_PARAM(buffer_id, The buffer_id parameter specifies which buffer to show in the view.) +DOC_PARAM(flags, The flags parameter specifies behaviors for setting the buffer.) +DOC_RETURN(This call returns non-zero on success.) DOC ( On success view_set_buffer sets the specified view's current buffer and @@ -1312,7 +1332,7 @@ DOC_SEE(Set_Buffer_Flag) View *vptr = imp_get_view(cmd, view); Models *models = cmd->models; Editing_File *file = 0; - int result = false; + bool32 result = false; if (vptr){ file = working_set_get_active_file(&models->working_set, buffer_id); @@ -1333,24 +1353,26 @@ DOC_SEE(Set_Buffer_Flag) return(result); } -API_EXPORT int -View_Post_Fade(Application_Links *app, View_Summary *view, float seconds, int start, int end, unsigned int color)/* -DOC_PARAM(view, the veiw to post a fade effect to) -DOC_PARAM(seconds, the number of seconds the fade effect should last) -DOC_PARAM(start, the first character in the fade range) -DOC_PARAM(end, one after the last character in the fade range) -DOC_PARAM(color, the color to fade from) +API_EXPORT bool32 +View_Post_Fade(Application_Links *app, View_Summary *view, float seconds, int32_t start, int32_t end, int_color color)/* +DOC_PARAM(view, The view parameter specifies the view onto which the fade effect shall be posted.) +DOC_PARAM(seconds, This parameter specifies the number of seconds the fade effect should last.) +DOC_PARAM(start, This parameter specifies the absolute position of the first character of the fade range.) +DOC_PARAM(end, This parameter specifies the absolute position of the character one past the end of the fdae range.) +DOC_PARAM(color, The color parameter specifies the initial color of the text before it fades to it's natural color.) +DOC_RETURN(This call returns non-zero on success.) +DOC_SEE(int_color) */{ Command_Data *cmd = (Command_Data*)app->cmd_context; View *vptr = imp_get_view(cmd, view); - int result = false; + bool32 result = false; int size = end - start; if (vptr){ if (size > 0){ result = true; - view_post_paste_effect(vptr, seconds, start, size, color); + view_post_paste_effect(vptr, seconds, start, size, color | 0xFF000000); } } @@ -1380,17 +1402,17 @@ View_Get_Paste_Rewrite_(Application_Links *app, View_Summary *view){ */ API_EXPORT User_Input -Get_User_Input(Application_Links *app, unsigned int get_type, unsigned int abort_type)/* -DOC_PARAM(get_type, input type flag that specifies the types of inputs that should be returned) -DOC_PARAM(abort_type, input type flag that specifies the types of inputs that should cause an abort signal) -DOC_RETURN(returns a User_Input that describes an event passed to the command) +Get_User_Input(Application_Links *app, Input_Type_Flag get_type, Input_Type_Flag abort_type)/* +DOC_PARAM(get_type, The get_type parameter specifies the set of input types that should be returned.) +DOC_PARAM(abort_type, The get_type parameter specifies the set of input types that should trigger an abort signal.) +DOC_RETURN(This call returns a User_Input that describes a user input event.) DOC ( 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 +If a get condition is met the user input is returned. ) DOC_SEE(Input_Type_Flag) DOC_SEE(User_Input) @@ -1413,7 +1435,7 @@ DOC_SEE(User_Input) API_EXPORT User_Input Get_Command_Input (Application_Links *app)/* -DOC_RETURN(returns the input that triggered the command in execution.) +DOC_RETURN(This call returns the input that triggered the currently executing command.) DOC_SEE(User_Input) */{ Command_Data *cmd = (Command_Data*)app->cmd_context; @@ -1422,14 +1444,15 @@ DOC_SEE(User_Input) result.type = UserInputKey; result.abort = 0; result.key = cmd->key; - result.command = 0; + // TODO(allen): It would be nice to fill this. + result.command.cmdid = 0; return(result); } API_EXPORT Mouse_State Get_Mouse_State(Application_Links *app)/* -DOC_RETURN(returns the current mouse state) +DOC_RETURN(This call returns the current mouse state as of the beginning of the frame.) DOC_SEE(Mouse_State) */{ Command_Data *cmd = (Command_Data*)app->cmd_context; @@ -1438,9 +1461,8 @@ DOC_SEE(Mouse_State) return(mouse); } -#if 0 -//API_EXPORT -Event_Message +/* +API_EXPORT Event_Message Get_Event_Message (Application_Links *app){ Event_Message message = {0}; System_Functions *system = (System_Functions*)app->system_links; @@ -1454,17 +1476,22 @@ Get_Event_Message (Application_Links *app){ return(message); } -#endif +*/ -API_EXPORT int -Start_Query_Bar(Application_Links *app, Query_Bar *bar, unsigned int flags)/* -DOC_PARAM(bar, a pointer to the Query_Bar struct that defines the bar's contents) -DOC_PARAM(flags, not currently used) -DOC_RETURN(returns non-zero on success) +API_EXPORT bool32 +Start_Query_Bar(Application_Links *app, Query_Bar *bar, uint32_t flags)/* +DOC_PARAM(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.) +DOC_PARAM(flags, This parameter is not currently used and should be 0 for now.) +DOC_RETURN(This call returns non-zero on success.) DOC ( -The memory pointed to by bar must remain valid until a call to end_query_bar or -until the command returns. +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. ) */{ Command_Data *cmd = (Command_Data*)app->cmd_context; @@ -1476,17 +1503,15 @@ until the command returns. slot = alloc_query_slot(&vptr->query_set); slot->query_bar = bar; - return(slot != 0); + bool32 result = (slot != 0); + return(result); } API_EXPORT void -End_Query_Bar(Application_Links *app, Query_Bar *bar, unsigned int flags)/* -DOC_PARAM(bar, a pointer to the Query_Bar struct to end) -DOC_PARAM(flags, not currently used) -DOC -( -bar must be a pointer previously passed to start_query_bar previously in the same command. -) +End_Query_Bar(Application_Links *app, Query_Bar *bar, uint32_t flags)/* +DOC_PARAM(bar, This parameter should be a bar pointer of a currently active query bar.) +DOC_PARAM(flags, This parameter is not currently used and should be 0 for now.) +DOC(Stops showing the particular query bar specified by the bar parameter.) */{ Command_Data *cmd = (Command_Data*)app->cmd_context; View *vptr; @@ -1495,19 +1520,23 @@ bar must be a pointer previously passed to start_query_bar previously in the sam } API_EXPORT void -Print_Message(Application_Links *app, char *str, int len)/* -DOC_PARAM(str, the string to post to *messages*) -DOC_PARAM(len, the length of str string) +Print_Message(Application_Links *app, char *str, int32_t len)/* +DOC_PARAM(str, The str parameter specifies the string to post to *messages*; it need not be null terminated.) +DOC_PARAM(len, The len parameter specifies the length of the str string.) +DOC(This call posts a string to the *messages* buffer.) */{ Command_Data *cmd = (Command_Data*)app->cmd_context; Models *models = cmd->models; do_feedback_message(cmd->system, models, make_string(str, len)); } +// TODO(allen): List the names of built in themes and fonts. + API_EXPORT void -Change_Theme(Application_Links *app, char *name, int len)/* -DOC_PARAM(name, the name of the built in theme to change to) -DOC_PARAM(len, the length of the name string) +Change_Theme(Application_Links *app, char *name, int32_t len)/* +DOC_PARAM(name, The name parameter specifies the name of the theme to begin using; it need not be null terminated.) +DOC_PARAM(len, The len parameter specifies the length of the name string.) +DOC(This call changes 4coder's theme to one of the built in themes.) */{ Command_Data *cmd = (Command_Data*)app->cmd_context; Style_Library *styles = &cmd->models->styles; @@ -1526,9 +1555,10 @@ DOC_PARAM(len, the length of the name string) } API_EXPORT void -Change_Font(Application_Links *app, char *name, int len)/* -DOC_PARAM(name, the name of the built in font to change to) -DOC_PARAM(len, the length of the name string) +Change_Font(Application_Links *app, char *name, int32_t len)/* +DOC_PARAM(name, The name parameter specifies the name of the font to begin using; it need not be null terminated.) +DOC_PARAM(len, The len parameter specifies the length of the name string.) +DOC(This call changes 4coder's font to one of the built in fonts.) */{ Command_Data *cmd = (Command_Data*)app->cmd_context; Font_Set *set = cmd->models->font_set; @@ -1543,36 +1573,40 @@ DOC_PARAM(len, the length of the name string) } API_EXPORT void -Set_Theme_Colors(Application_Links *app, Theme_Color *colors, int count)/* -DOC_PARAM(colors, an array of color structs pairing differet style tags to color codes) -DOC_PARAM(count, the number of color structs in the colors array) +Set_Theme_Colors(Application_Links *app, Theme_Color *colors, int32_t count)/* +DOC_PARAM(colors, The colors pointer provides an array of color structs pairing differet style tags to color codes.) +DOC_PARAM(count, The count parameter specifies the number of Theme_Color structs in the colors array.) DOC ( -For each color struct in the array, the color in the style pallet is set to the color -code paired with the tag. +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. ) */{ Command_Data *cmd = (Command_Data*)app->cmd_context; Style *style = main_style(cmd->models); - u32 *color = 0; + int_color *color = 0; i32 i = 0; Theme_Color *theme_color = colors; for (i = 0; i < count; ++i, ++theme_color){ color = style_index_by_tag(&style->main, theme_color->tag); - if (color) *color = theme_color->color | 0xFF000000; + if (color){ + *color = theme_color->color | 0xFF000000; + } } } API_EXPORT void -Get_Theme_Colors(Application_Links *app, Theme_Color *colors, int count)/* +Get_Theme_Colors(Application_Links *app, Theme_Color *colors, int32_t count)/* DOC_PARAM(colors, an array of color structs listing style tags to get color values for) DOC_PARAM(count, the number of color structs in the colors array) DOC ( -For each color struct in the array, the color field of the struct is filled with the -color from the specified color in the pallet. +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. ) */{ Command_Data *cmd = (Command_Data*)app->cmd_context; @@ -1593,18 +1627,18 @@ color from the specified color in the pallet. } } -API_EXPORT int -Directory_Get_Hot(Application_Links *app, char *out, int capacity)/* -DOC_PARAM(out, a buffer that receives the 4coder 'hot directory') -DOC_PARAM(capacity, the maximum size to be output to the output buffer) -DOC_RETURN(returns the size of the string written into the buffer) +API_EXPORT int32_t +Directory_Get_Hot(Application_Links *app, char *out, int32_t capacity)/* +DOC_PARAM(out, This parameter provides a character buffer that receives the 4coder 'hot directory'.) +DOC_PARAM(capacity, This parameter specifies the maximum size to be output to the out buffer.) +DOC_RETURN(This call returns the size of the string written into the buffer.) DOC ( 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 by the custom side. +directories controlled on the custom side. ) */{ Command_Data *cmd = (Command_Data*)app->cmd_context; @@ -1624,12 +1658,12 @@ directories controlled by the custom side. #define Show_Mouse_Cursor system->show_mouse_cursor API_EXPORT File_List -Get_File_List(Application_Links *app, char *dir, int len)/* -DOC_PARAM(dir, the directory whose files will be enumerated in the returned list) -DOC_PARAM(len, the length of the dir string) +Get_File_List(Application_Links *app, char *dir, int32_t len)/* +DOC_PARAM(dir, This parameter specifies the directory whose files will be enumerated in the returned list; it need not be null terminated.) +DOC_PARAM(len, This parameter the length of the dir string.) DOC_RETURN ( -returns a File_List struct containing pointers to the names of the files in +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. ) @@ -1643,8 +1677,8 @@ when it is no longer in use. API_EXPORT void Free_File_List(Application_Links *app, File_List list)/* -DOC_PARAM(list, the file list to be freed) -DOC(after this call the file list passed in should not be read or written to) +DOC_PARAM(list, This parameter provides the file list to be freed.) +DOC(After this call the file list passed in should not be read or written to.) */{ Command_Data *cmd = (Command_Data*)app->cmd_context; System_Functions *system = cmd->system; diff --git a/4ed_file_view.cpp b/4ed_file_view.cpp index 28257e06..04ae5673 100644 --- a/4ed_file_view.cpp +++ b/4ed_file_view.cpp @@ -163,9 +163,7 @@ file_viewing_data_zero(){ } struct Recent_File_Data{ - u64 unique_buffer_id; GUI_Scroll_Vars scroll; - Full_Cursor cursor; i32 mark; f32 preferred_x; @@ -1600,7 +1598,7 @@ view_move_cursor_to_view(View *view, GUI_Scroll_Vars scroll){ } internal void -view_move_view_to_cursor(View *view, GUI_Scroll_Vars *scroll){ +view_move_view_to_cursor(View *view, GUI_Scroll_Vars *scroll, b32 center_view){ f32 max_x = view_file_width(view); f32 cursor_y = view_get_cursor_y(view); @@ -1613,10 +1611,20 @@ view_move_view_to_cursor(View *view, GUI_Scroll_Vars *scroll){ Cursor_Limits limits = view_cursor_limits(view); if (cursor_y > target_y + limits.max){ - target_y = CEIL32(cursor_y - limits.max + limits.delta); + if (center_view){ + target_y = ROUND32(cursor_y - limits.max*.5f); + } + else{ + target_y = CEIL32(cursor_y - limits.max + limits.delta); + } } if (cursor_y < target_y + limits.min){ - target_y = FLOOR32(cursor_y - limits.delta - limits.min); + if (center_view){ + target_y = ROUND32(cursor_y - limits.max*.5f); + } + else{ + target_y = FLOOR32(cursor_y - limits.delta - limits.min); + } } target_y = clamp(0, target_y, scroll_vars.max_y); @@ -1645,13 +1653,6 @@ file_view_nullify_file(View *view){ internal void view_set_file(View *view, Editing_File *file, Models *models){ -#if 0 - // TODO(allen): This belongs somewhere else. - Font_Info *fnt_info = get_font_info(models->font_set, models->global_font.font_id); - view->font_advance = fnt_info->advance; - view->line_height = fnt_info->height; -#endif - if (view->file_data.file != 0){ touch_file(&models->working_set, view->file_data.file); } @@ -1662,18 +1663,16 @@ view_set_file(View *view, Editing_File *file, Models *models){ if (file){ view->file_data.unwrapped_lines = file->settings.unwrapped_lines; - u64 unique_buffer_id = file->unique_buffer_id; Recent_File_Data *recent = &view->recent; - - view->recent = recent_file_data_zero(); - recent->unique_buffer_id = unique_buffer_id; + *recent = recent_file_data_zero(); if (file_is_ready(file)){ view_measure_wraps(&models->mem.general, view); - view->recent.cursor = view_compute_cursor_from_pos(view, file->state.cursor_pos); - view->recent.scroll.max_y = view_compute_max_target_y(view); + recent->cursor = view_compute_cursor_from_pos(view, file->state.cursor_pos); + recent->scroll.max_y = view_compute_max_target_y(view); + recent->preferred_x = view_get_cursor_x(view); - view_move_view_to_cursor(view, &view->recent.scroll); + view_move_view_to_cursor(view, &recent->scroll, true); view->reinit_scrolling = 1; } } @@ -3581,7 +3580,7 @@ view_end_cursor_scroll_updates(View *view){ if (view->gui_target.did_file){ view->recent.scroll.max_y = view_compute_max_target_y(view); } - view_move_view_to_cursor(view, view->current_scroll); + view_move_view_to_cursor(view, view->current_scroll, false); gui_post_scroll_vars(&view->gui_target, view->current_scroll, view->scroll_region); break; @@ -4385,28 +4384,26 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su &keys, &view->list_i, &update); } - { - begin_exhaustive_loop(&loop, hdir); - for (i = 0; i < loop.count; ++i){ - file_info = get_exhaustive_info(system, &models->working_set, &loop, i); + begin_exhaustive_loop(&loop, hdir); + for (i = 0; i < loop.count; ++i){ + file_info = get_exhaustive_info(system, &models->working_set, &loop, i); + + if (file_info.name_match){ + id.id[0] = (u64)(file_info.info); - if (file_info.name_match){ - id.id[0] = (u64)(file_info.info); - - String filename = make_string(file_info.info->filename, - file_info.info->filename_len, - file_info.info->filename_len+1); - - if (gui_do_file_option(target, id, filename, - file_info.is_folder, file_info.message)){ - if (file_info.is_folder){ - set_last_folder(&hdir->string, file_info.info->filename, '/'); - do_new_directory = 1; - } - else if (use_item_in_list){ - complete = 1; - copy(&comp_dest, loop.full_path); - } + String filename = make_string(file_info.info->filename, + file_info.info->filename_len, + file_info.info->filename_len+1); + + if (gui_do_file_option(target, id, filename, + file_info.is_folder, file_info.message)){ + if (file_info.is_folder){ + set_last_folder(&hdir->string, file_info.info->filename, '/'); + do_new_directory = 1; + } + else if (use_item_in_list){ + complete = 1; + copy(&comp_dest, loop.full_path); } } } @@ -4938,8 +4935,6 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su { Recent_File_Data *recent = &view_ptr->recent; - SHOW_GUI_U64 (2, h_align, "absolute buffer id", recent->unique_buffer_id); - SHOW_GUI_BLANK (2); SHOW_GUI_SCROLL(2, h_align, "scroll:", recent->scroll); SHOW_GUI_BLANK (2); SHOW_GUI_CURSOR(2, h_align, "cursor:", recent->cursor); diff --git a/4ed_metagen.cpp b/4ed_metagen.cpp index 3a40bcfa..3c92980f 100644 --- a/4ed_metagen.cpp +++ b/4ed_metagen.cpp @@ -23,6 +23,12 @@ #include "4coder_mem.h" +struct Global_Settings{ + int generate_docs; +}; + +static Global_Settings global_settings; + struct Struct_Field{ char *type; char *name; @@ -605,7 +611,7 @@ doc_parse_last_parameter(String source, int *pos){ } void -perform_doc_parse(String doc_string, Documentation *doc){ +perform_doc_parse(Partition *part, String doc_string, Documentation *doc){ int keep_parsing = true; int pos = 0; @@ -638,7 +644,7 @@ perform_doc_parse(String doc_string, Documentation *doc){ if (param_count + see_count > 0){ int memory_size = sizeof(String)*(2*param_count + see_count); - doc->param_name = (String*)malloc(memory_size); + doc->param_name = push_array(part, String, memory_size); doc->param_docs = doc->param_name + param_count; doc->see_also = doc->param_docs + param_count; @@ -976,6 +982,80 @@ print_struct_html(FILE *file, Struct_Member *member){ } } +#define BACK_COLOR "#FAFAFA" +#define TEXT_COLOR "#0D0D0D" +#define CODE_BACK "#DFDFDF" + +#define POP_COLOR_1 "#309030" +#define POP_BACK_1 "#E0FFD0" +#define VISITED_LINK "#A0C050" + +#define POP_COLOR_2 "#005000" + +#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 DOC_HEAD_OPEN "
" +#define DOC_HEAD_CLOSE "
" + +#define DOC_ITEM_HEAD_STYLE "font-weight: 600;" + +#define DOC_ITEM_HEAD_INL_OPEN "" +#define DOC_ITEM_HEAD_INL_CLOSE "" + +#define DOC_ITEM_HEAD_OPEN "
" +#define DOC_ITEM_HEAD_CLOSE "
" + +#define DOC_ITEM_OPEN "
" +#define DOC_ITEM_CLOSE "
" + +static void +print_struct_docs(FILE *file, Partition *part, Struct_Member *member){ + for (Struct_Member *member_iter = member->first_child; + member_iter != 0; + member_iter = member_iter->next_sibling){ + String type = member_iter->type; + if (match(type, make_lit_string("struct")) || + match(type, make_lit_string("union"))){ + print_struct_docs(file, part, member_iter); + } + else{ + Documentation doc = {0}; + perform_doc_parse(part, member_iter->doc_string, &doc); + + fprintf(file, + "
\n" + "
"DOC_ITEM_HEAD_INL_OPEN + "%.*s"DOC_ITEM_HEAD_INL_CLOSE"
\n" + "
"DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE"
\n" + "
\n", + member_iter->name.size, member_iter->name.str, + doc.main_doc.size, doc.main_doc.str + ); + } + } +} + +static void +print_see_also(FILE *file, Documentation *doc){ + int doc_see_count = doc->see_also_count; + if (doc_see_count > 0){ + fprintf(file, DOC_HEAD_OPEN"See Also"DOC_HEAD_CLOSE); + + for (int 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 int parse_enum(Partition *part, Cpp_File file, Cpp_Token *tokens, int count, @@ -1101,210 +1181,6 @@ generate_custom_headers(){ char *filename = API_H " & " API_DOC; - Function_Set function_set = {0}; - Typedef_Set typedef_set = {0}; - Struct_Set struct_set = {0}; - Enum_Set flag_set = {0}; - Enum_Set enum_set = {0}; - - - String type_code = file_dump("4coder_types.h"); - - - // TODO(allen): KILL THIS FUCKIN' Cpp_File FUCKIN' NONSENSE HORSE SHIT!!!!! - Cpp_File type_file; - type_file.data = type_code.str; - type_file.size = type_code.size; - - Cpp_Token_Stack types_tokens = cpp_make_token_stack(512); - cpp_lex_file(type_file, &types_tokens); - - int typedef_count = 0; - int struct_count = 0; - int flag_count = 0; - int enum_count = 0; - - { - int count = types_tokens.count; - Cpp_Token *tokens = types_tokens.tokens; - Cpp_Token *token = tokens; - - static String type_spec_keys[] = { - make_lit_string("typedef"), - make_lit_string("struct"), - make_lit_string("union"), - make_lit_string("ENUM"), - make_lit_string("FLAGENUM"), - }; - - for (int i = 0; i < count; ++i, ++token){ - if (!(token->flags & CPP_TFLAG_PP_BODY) && - (token->type == CPP_TOKEN_KEY_TYPE_DECLARATION || - token->type == CPP_TOKEN_IDENTIFIER)){ - - String lexeme = make_string(type_file.data + token->start, token->size); - int match_index = 0; - if (string_set_match(type_spec_keys, ArrayCount(type_spec_keys), - lexeme, &match_index)){ - switch (match_index){ - case 0: //typedef - ++typedef_count; break; - - case 1: case 2: //struct/union - ++struct_count; break; - - case 3: //ENUM - ++enum_count; break; - - case 4: //FLAGENUM - ++flag_count; break; - } - } - } - } - - if (typedef_count > 0){ - typedef_set.type = push_array(part, String, typedef_count); - typedef_set.name = push_array(part, String, typedef_count); - typedef_set.doc_string = push_array(part, String, typedef_count); - } - - if (struct_count > 0){ - struct_set.structs = push_array(part, Struct_Member, struct_count); - } - - if (enum_count > 0){ - enum_set.name = push_array(part, String, enum_count); - enum_set.type = push_array(part, String, enum_count); - enum_set.first_member = push_array(part, Enum_Member*, enum_count); - enum_set.doc_string = push_array(part, String, enum_count); - } - - if (flag_count > 0){ - flag_set.name = push_array(part, String, flag_count); - flag_set.first_member = push_array(part, Enum_Member*, flag_count); - flag_set.doc_string = push_array(part, String, flag_count); - } - - int typedef_index = 0; - int struct_index = 0; - int flag_index = 0; - int enum_index = 0; - - token = tokens; - for (int i = 0; i < count; ++i, ++token){ - if (!(token->flags & CPP_TFLAG_PP_BODY) && - (token->type == CPP_TOKEN_KEY_TYPE_DECLARATION || - token->type == CPP_TOKEN_IDENTIFIER)){ - - String lexeme = make_string(type_file.data + token->start, token->size); - int match_index = 0; - if (string_set_match(type_spec_keys, ArrayCount(type_spec_keys), - lexeme, &match_index)){ - switch (match_index){ - case 0: //typedef - { - String doc_string = {0}; - get_type_doc_string(type_file, tokens, i, &doc_string); - - int start_i = i; - Cpp_Token *start_token = token; - - for (; i < count; ++i, ++token){ - if (token->type == CPP_TOKEN_SEMICOLON){ - break; - } - } - - if (i < count){ - Cpp_Token *token_j = token; - - for (int j = i; j > start_i; --j, --token_j){ - if (token_j->type == CPP_TOKEN_IDENTIFIER){ - break; - } - } - - String name = make_string(type_file.data + token_j->start, token_j->size); - name = skip_chop_whitespace(name); - - int type_start = start_token->start + start_token->size; - int type_end = token_j->start; - String type = make_string(type_file.data + type_start, type_end - type_start); - type = skip_chop_whitespace(type); - - typedef_set.type[typedef_index] = type; - typedef_set.name[typedef_index] = name; - typedef_set.doc_string[typedef_index] = doc_string; - ++typedef_index; - } - }break; - - case 1: case 2: //struct/union - { - if (parse_struct(part, (match_index == 1), - type_file, tokens, count, &token, - struct_set.structs + struct_index)){ - ++struct_index; - } - i = (int)(token - tokens); - }break; - - case 3: //ENUM - { - String doc_string = {0}; - get_type_doc_string(type_file, tokens, i, &doc_string); - - int start_i = i; - - for (; i < count; ++i, ++token){ - if (token->type == CPP_TOKEN_PARENTHESE_CLOSE){ - break; - } - } - - if (parse_enum(part, type_file, - tokens, count, - &token, start_i, - enum_set, enum_index)){ - enum_set.doc_string[enum_index] = doc_string; - ++enum_index; - } - }break; - - case 4: //FLAGENUM - { - String doc_string = {0}; - get_type_doc_string(type_file, tokens, i, &doc_string); - - int start_i = i; - - for (; i < count; ++i, ++token){ - if (token->type == CPP_TOKEN_PARENTHESE_CLOSE){ - break; - } - } - - if (parse_enum(part, type_file, - tokens, count, - &token, start_i, - flag_set, flag_index)){ - flag_set.doc_string[flag_index] = doc_string; - ++flag_index; - } - - }break; - } - } - } - } - - typedef_count = typedef_index; - struct_count = struct_index; - enum_count = enum_index; - flag_count = flag_index; - } - String code_data[2]; code_data[0] = file_dump("4ed_api_implementation.cpp"); @@ -1361,6 +1237,7 @@ generate_custom_headers(){ int memory_size = (sizeof(String)*6 + sizeof(int) + sizeof(Argument_Breakdown) + sizeof(Documentation))*line_count; + Function_Set function_set = {0}; function_set.name = (String*)malloc(memory_size); function_set.ret = function_set.name + line_count; function_set.args = function_set.ret + line_count; @@ -1524,7 +1401,7 @@ generate_custom_headers(){ lexeme = make_string(file.data + token->start, token->size); if (check_and_fix_docs(&lexeme)){ function_set.doc_string[match] = lexeme; - perform_doc_parse(lexeme, &function_set.doc[match]); + perform_doc_parse(part, lexeme, &function_set.doc[match]); break; } } @@ -1626,415 +1503,704 @@ generate_custom_headers(){ fclose(file); // NOTE(allen): Documentation - file = fopen(API_DOC, "wb"); - -#define CODE_STYLE "font-family: \"Courier New\", Courier, monospace; text-align: left;" - -#define BACK_COLOR "#FAFAFA" -#define TEXT_COLOR "#0D0D0D" -#define CODE_BACK "#DFDFDF" - -#define POP_COLOR_1 "#309030" -#define POP_BACK_1 "#E0FFD0" -#define VISITED_LINK "#A0C050" - -#define POP_COLOR_2 "#005000" - - fprintf(file, - "\n" - "\n" - "4coder API Docs\n" - "\n" - "\n" - "\n" - "
\n" - "

4coder API

\n" - ); - - fprintf(file, - "

§1 Introduction

\n" - "
\n" - - "

\n" - "This is the documentation for " VERSION " The documentation has been made as " - "accurate as possible but there may be errors. If you have questions or " - "discover errors please contact editor@4coder.net." - "

\n" - - "

\n" - "

\n" - - "
\n"); - - fprintf(file, "

§2 Types and Functions

\n"); - { -#undef SECTION -#define SECTION "2.1" + if (global_settings.generate_docs){ + Typedef_Set typedef_set = {0}; + Struct_Set struct_set = {0}; + Enum_Set flag_set = {0}; + Enum_Set enum_set = {0}; - fprintf(file, - "

§"SECTION" Function List

\n" - "\n"); -#undef SECTION -#define SECTION "2.2" + + file = fopen(API_DOC, "wb"); fprintf(file, - "

§"SECTION" Type List

\n" - "\n"); - -#define DESCRIPT_SECTION_STYLE \ - "margin-top: 3mm; margin-bottom: 3mm; font-size: .95em; " \ - "background: "CODE_BACK"; padding: 0.25em;" - -#undef SECTION -#define SECTION "2.3" - - fprintf(file, "

§"SECTION" Function Descriptions

\n"); - for (int i = 0; i < sig_count; ++i){ - String name = function_set.public_name[i]; - - fprintf(file, - "
\n" - "

§"SECTION".%d: %.*s

\n" - "
", - name.size, name.str, i+1, - name.size, name.str - ); - - String ret = function_set.ret[i]; - fprintf(file, - "%.*s app->%.*s(\n" - "
", - ret.size, ret.str, name.size, name.str); - - Argument_Breakdown *breakdown = &function_set.breakdown[i]; - int arg_count = breakdown->count; - for (int j = 0; j < arg_count; ++j){ - String param_string = breakdown->param_string[j]; - if (j < arg_count - 1){ - fprintf(file, "%.*s,
", param_string.size, param_string.str); - } - else{ - fprintf(file, "%.*s
", param_string.size, param_string.str); - } - } - - fprintf(file, - "
)\n" - "
\n"); - - if (function_set.doc_string[i].size == 0){ - fprintf(file, "No documentation generated for this function, assume it is non-public.\n"); - fprintf(stderr, "warning: no documentation string for %.*s\n", name.size, name.str); - } - -#define DOC_HEAD_OPEN "
" -#define DOC_HEAD_CLOSE "
" - -#define DOC_ITEM_OPEN "
" -#define DOC_ITEM_CLOSE "
" - - Documentation *doc = &function_set.doc[i]; - - int doc_param_count = doc->param_count; - if (doc_param_count > 0){ - fprintf(file, DOC_HEAD_OPEN"Parameters"DOC_HEAD_CLOSE); + fprintf(file, + "

§"MAJOR_SECTION" Introduction

\n" + "
\n" - for (int j = 0; j < doc_param_count; ++j){ - String param_name = doc->param_name[j]; - String param_docs = doc->param_docs[j]; - - // TODO(allen): check that param_name is actually - // a parameter to this function! - - fprintf(file, - "
\n" - "
%.*s
\n" - "
"DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE"
\n" - "
\n", - param_name.size, param_name.str, - param_docs.size, param_docs.str - ); - } - } + "

\n" + "This is the documentation for " VERSION " The documentation has been made as " + "accurate as possible but there may be errors. If you have questions or " + "discover errors please contact editor@4coder.net." + "

\n" + + "

\n" + "

\n" + + "
\n"); + +#undef MAJOR_SECTION +#define MAJOR_SECTION "2" + // TODO(allen): Write the 4coder system descriptions. + fprintf(file, "

§"MAJOR_SECTION" 4coder Systems

\n"); + { - String ret_doc = doc->return_doc; - if (ret_doc.size != 0){ - fprintf(file, DOC_HEAD_OPEN"Return"DOC_HEAD_CLOSE); + } + +#undef MAJOR_SECTION +#define MAJOR_SECTION "3" + + fprintf(file, "

§"MAJOR_SECTION" Types and Functions

\n"); + { +#undef SECTION +#define SECTION MAJOR_SECTION".1" + + fprintf(file, + "

§"SECTION" Function List

\n" + "\n"); - String main_doc = doc->main_doc; - if (main_doc.size != 0){ - fprintf(file, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE); - fprintf(file, - DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE, - main_doc.size, main_doc.str - ); - } - - int doc_see_count = doc->see_also_count; - if (doc_see_count > 0){ - fprintf(file, DOC_HEAD_OPEN"See Also"DOC_HEAD_CLOSE); - - for (int 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 - ); - } - } - - fprintf(file, "

\n"); - } - #undef SECTION -#define SECTION "2.4" - - fprintf(file, "

§"SECTION" Type Descriptions

\n"); - int I = 1; - for (int i = 0; i < typedef_count; ++i, ++I){ - String name = typedef_set.name[i]; - String type = typedef_set.type[i]; +#define SECTION MAJOR_SECTION".2" fprintf(file, - "
\n" - "

§"SECTION".%d: %.*s

\n" - "
", - name.size, name.str, I, - name.size, name.str + "

§"SECTION" Type List

\n" + "
    \n" ); - // NOTE(allen): Code box - { + for (int i = 0; i < typedef_count; ++i){ + String name = typedef_set.name[i]; fprintf(file, - "typedef %.*s %.*s;", - type.size, type.str, + "
  • " + "%.*s" + "
  • \n", + name.size, name.str, name.size, name.str ); } - fprintf(file, "
\n"); - - // NOTE(allen): Descriptive section - { - - } - - fprintf(file, "

\n"); - } - - for (int i = 0; i < enum_count; ++i, ++I){ - String name = enum_set.name[i]; - - fprintf(file, - "
\n" - "

§"SECTION".%d: %.*s

\n" - "
", - name.size, name.str, I, - name.size, name.str - ); - - // NOTE(allen): Code box - { + for (int i = 0; i < enum_count; ++i){ + String name = enum_set.name[i]; fprintf(file, - "enum %.*s;", - name.size, name.str); + "
  • " + "%.*s" + "
  • \n", + name.size, name.str, + name.size, name.str + ); } - fprintf(file, "
    \n"); - - // NOTE(allen): Descriptive section - { - - } - - fprintf(file, "

    \n"); - } - - for (int i = 0; i < flag_count; ++i, ++I){ - String name = flag_set.name[i]; - - fprintf(file, - "
    \n" - "

    §"SECTION".%d: %.*s

    \n" - "
    ", - name.size, name.str, I, - name.size, name.str - ); - - // NOTE(allen): Code box - { + for (int i = 0; i < flag_count; ++i){ + String name = flag_set.name[i]; fprintf(file, - "enum %.*s;", - name.size, name.str); + "
  • " + "%.*s" + "
  • \n", + name.size, name.str, + name.size, name.str + ); } - fprintf(file, "
    \n"); + for (int i = 0; i < struct_count; ++i){ + String name = struct_set.structs[i].name; + fprintf(file, + "
  • " + "%.*s" + "
  • \n", + name.size, name.str, + name.size, name.str + ); + } - // NOTE(allen): Descriptive section - { + fprintf(file, "\n"); + +#undef SECTION +#define SECTION MAJOR_SECTION".3" + + fprintf(file, "

    §"SECTION" Function Descriptions

    \n"); + for (int i = 0; i < sig_count; ++i){ + String name = function_set.public_name[i]; + fprintf(file, + "
    \n" + "

    §"SECTION".%d: %.*s

    \n" + "
    ", + name.size, name.str, i+1, + name.size, name.str + ); + + String ret = function_set.ret[i]; + fprintf(file, + "%.*s app->%.*s(\n" + "
    ", + ret.size, ret.str, name.size, name.str); + + Argument_Breakdown *breakdown = &function_set.breakdown[i]; + int arg_count = breakdown->count; + for (int j = 0; j < arg_count; ++j){ + String param_string = breakdown->param_string[j]; + if (j < arg_count - 1){ + fprintf(file, "%.*s,
    ", param_string.size, param_string.str); + } + else{ + fprintf(file, "%.*s
    ", param_string.size, param_string.str); + } + } + + fprintf(file, + "
    )\n" + "
    \n"); + + if (function_set.doc_string[i].size == 0){ + fprintf(file, "No documentation generated for this function, assume it is non-public.\n"); + fprintf(stderr, "warning: no documentation string for %.*s\n", name.size, name.str); + } + + Documentation *doc = &function_set.doc[i]; + + int doc_param_count = doc->param_count; + if (doc_param_count > 0){ + fprintf(file, DOC_HEAD_OPEN"Parameters"DOC_HEAD_CLOSE); + + for (int j = 0; j < doc_param_count; ++j){ + String param_name = doc->param_name[j]; + String param_docs = doc->param_docs[j]; + + // TODO(allen): check that param_name is actually + // a parameter to this function! + + fprintf(file, + "
    \n" + DOC_ITEM_HEAD_OPEN"%.*s"DOC_ITEM_HEAD_CLOSE"\n" + "
    "DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE"
    \n" + "
    \n", + param_name.size, param_name.str, + param_docs.size, param_docs.str + ); + } + } + + String ret_doc = doc->return_doc; + if (ret_doc.size != 0){ + fprintf(file, DOC_HEAD_OPEN"Return"DOC_HEAD_CLOSE); + fprintf(file, + DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE, + ret_doc.size, ret_doc.str + ); + } + + String main_doc = doc->main_doc; + if (main_doc.size != 0){ + fprintf(file, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE); + fprintf(file, + DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE, + main_doc.size, main_doc.str + ); + } + + print_see_also(file, doc); + + fprintf(file, "

    \n"); } - fprintf(file, "

    \n"); +#undef SECTION +#define SECTION MAJOR_SECTION".4" + + fprintf(file, "

    §"SECTION" Type Descriptions

    \n"); + int I = 1; + for (int i = 0; i < typedef_count; ++i, ++I){ + String name = typedef_set.name[i]; + String type = typedef_set.type[i]; + + fprintf(file, + "
    \n" + "

    §"SECTION".%d: %.*s

    \n" + "
    ", + name.size, name.str, I, + name.size, name.str + ); + + // NOTE(allen): Code box + { + fprintf(file, + "typedef %.*s %.*s;", + type.size, type.str, + name.size, name.str + ); + } + + fprintf(file, "
    \n"); + + // NOTE(allen): Descriptive section + { + String doc_string = typedef_set.doc_string[i]; + Documentation doc = {0}; + perform_doc_parse(part, doc_string, &doc); + + String main_doc = doc.main_doc; + if (main_doc.size != 0){ + fprintf(file, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE); + fprintf(file, + DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE, + main_doc.size, main_doc.str + ); + } + + print_see_also(file, &doc); + } + + fprintf(file, "

    \n"); + } + + for (int i = 0; i < enum_count; ++i, ++I){ + String name = enum_set.name[i]; + + fprintf(file, + "
    \n" + "

    §"SECTION".%d: %.*s

    \n" + "
    ", + name.size, name.str, I, + name.size, name.str + ); + + // NOTE(allen): Code box + { + fprintf(file, + "enum %.*s;", + name.size, name.str); + } + + fprintf(file, "
    \n"); + + // NOTE(allen): Descriptive section + { + String doc_string = enum_set.doc_string[i]; + Documentation doc = {0}; + perform_doc_parse(part, doc_string, &doc); + + String main_doc = doc.main_doc; + if (main_doc.size != 0){ + fprintf(file, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE); + fprintf(file, + DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE, + main_doc.size, main_doc.str + ); + } + + if (enum_set.first_member[i]){ + fprintf(file, DOC_HEAD_OPEN"Values"DOC_HEAD_CLOSE); + for (Enum_Member *member = enum_set.first_member[i]; + member; + member = member->next){ + Documentation doc = {0}; + perform_doc_parse(part, member->doc_string, &doc); + + fprintf(file, + "
    \n" + "
    "DOC_ITEM_HEAD_INL_OPEN + "%.*s"DOC_ITEM_HEAD_INL_CLOSE"
    \n" + "
    "DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE"
    \n" + "
    \n", + member->name.size, member->name.str, + doc.main_doc.size, doc.main_doc.str + ); + } + } + + print_see_also(file, &doc); + } + + fprintf(file, "

    \n"); + } + + for (int i = 0; i < flag_count; ++i, ++I){ + String name = flag_set.name[i]; + + fprintf(file, + "
    \n" + "

    §"SECTION".%d: %.*s

    \n" + "
    ", + name.size, name.str, I, + name.size, name.str + ); + + // NOTE(allen): Code box + { + fprintf(file, + "enum %.*s;", + name.size, name.str); + } + + fprintf(file, "
    \n"); + + // NOTE(allen): Descriptive section + { + String doc_string = flag_set.doc_string[i]; + Documentation doc = {0}; + perform_doc_parse(part, doc_string, &doc); + + String main_doc = doc.main_doc; + if (main_doc.size != 0){ + fprintf(file, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE); + fprintf(file, + DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE, + main_doc.size, main_doc.str + ); + } + + if (flag_set.first_member[i]){ + fprintf(file, DOC_HEAD_OPEN"Flags"DOC_HEAD_CLOSE); + for (Enum_Member *member = flag_set.first_member[i]; + member; + member = member->next){ + Documentation doc = {0}; + perform_doc_parse(part, member->doc_string, &doc); + + fprintf(file, + "
    \n" + "
    "DOC_ITEM_HEAD_INL_OPEN + "%.*s"DOC_ITEM_HEAD_INL_CLOSE" = %.*s
    \n" + "
    "DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE"
    \n" + "
    \n", + member->name.size, member->name.str, + member->value.size, member->value.str, + doc.main_doc.size, doc.main_doc.str + ); + } + } + + print_see_also(file, &doc); + } + + fprintf(file, "

    \n"); + } + + for (int i = 0; i < struct_count; ++i, ++I){ + Struct_Member *member = &struct_set.structs[i]; + String name = member->name; + fprintf(file, + "
    \n" + "

    §"SECTION".%d: %.*s

    \n" + "
    ", + name.size, name.str, I, + name.size, name.str + ); + + // NOTE(allen): Code box + { + print_struct_html(file, member); + } + + fprintf(file, "
    \n"); + + // NOTE(allen): Descriptive section + { + String doc_string = member->doc_string; + Documentation doc = {0}; + perform_doc_parse(part, doc_string, &doc); + + String main_doc = doc.main_doc; + if (main_doc.size != 0){ + fprintf(file, DOC_HEAD_OPEN"Description"DOC_HEAD_CLOSE); + fprintf(file, + DOC_ITEM_OPEN"%.*s"DOC_ITEM_CLOSE, + main_doc.size, main_doc.str + ); + } + + if (member->first_child){ + fprintf(file, DOC_HEAD_OPEN"Fields"DOC_HEAD_CLOSE); + print_struct_docs(file, part, member); + } + + print_see_also(file, &doc); + } + + fprintf(file, "

    \n"); + } } - for (int i = 0; i < struct_count; ++i, ++I){ - Struct_Member *member = &struct_set.structs[i]; - String name = member->name; - fprintf(file, - "
    \n" - "

    §"SECTION".%d: %.*s

    \n" - "
    ", - name.size, name.str, I, - name.size, name.str - ); - - // NOTE(allen): Code box - { - print_struct_html(file, member); - } - - fprintf(file, "
    \n"); - - // NOTE(allen): Descriptive section - { - - } - - fprintf(file, "

    \n"); - } + fprintf(file, + "
    \n" + "\n" + "\n" + ); + + fclose(file); } - - fprintf(file, - "\n" - "\n" - "\n" - ); - - fclose(file); return(filename); } -int main(){ +int main(int argc, char **argv){ char *filename = 0; + memset(&global_settings, 0, sizeof(global_settings)); + + global_settings.generate_docs = true; + filename = generate_keycode_enum(); filename = generate_style(); filename = generate_custom_headers(); diff --git a/power/4coder_default_building.cpp b/power/4coder_default_building.cpp index b05a27bd..bd721579 100644 --- a/power/4coder_default_building.cpp +++ b/power/4coder_default_building.cpp @@ -61,9 +61,10 @@ CUSTOM_COMMAND_SIG(build_in_build_panel){ # define build_search build_in_build_panel #endif +#define GET_COMP_BUFFER() app->get_buffer_by_name(app, literal("*compilation*"), AccessAll); + CUSTOM_COMMAND_SIG(close_build_panel){ - Buffer_Summary buffer = - app->get_buffer_by_name(app, literal("*compilation*"), AccessAll); + Buffer_Summary buffer = GET_COMP_BUFFER(); if (buffer.exists){ View_Summary build_view = get_first_view_with_buffer(app, buffer.buffer_id); @@ -75,8 +76,18 @@ CUSTOM_COMMAND_SIG(close_build_panel){ } } +CUSTOM_COMMAND_SIG(change_to_build_panel){ + Buffer_Summary buffer = GET_COMP_BUFFER(); + + if (buffer.exists){ + View_Summary build_view = get_first_view_with_buffer(app, buffer.buffer_id); + + app->set_active_view(app, &build_view); + } +} + CUSTOM_COMMAND_SIG(change_active_panel_build){ - Buffer_Summary buffer = app->get_buffer_by_name(app, literal("*compilation*"), AccessAll); + Buffer_Summary buffer = GET_COMP_BUFFER(); if (buffer.exists){ View_Summary build_view = get_first_view_with_buffer(app, buffer.buffer_id); diff --git a/power/4coder_experiments.cpp b/power/4coder_experiments.cpp index ed6ebe9f..55353b6d 100644 --- a/power/4coder_experiments.cpp +++ b/power/4coder_experiments.cpp @@ -286,6 +286,7 @@ get_bindings(void *data, int size){ // begin_map to clear everything that was in the map and // bind new things instead. begin_map(context, mapid_global); + bind(context, '.', MDFR_ALT, change_to_build_panel); bind(context, ',', MDFR_ALT, close_build_panel); bind(context, 'n', MDFR_ALT, msvc_goto_next_error); bind(context, 'N', MDFR_ALT, msvc_goto_prev_error); diff --git a/win32_api_impl.cpp b/win32_api_impl.cpp index 4d1279cc..0ac315fc 100644 --- a/win32_api_impl.cpp +++ b/win32_api_impl.cpp @@ -11,18 +11,16 @@ as this is the only one that will be used for generating headers and docs. #define API_EXPORT -API_EXPORT int +API_EXPORT bool32 File_Exists(Application_Links *app, char *filename, int len)/* -DOC_PARAM(filename, the full path to a file) -DOC_PARAM(len, the number of characters in the filename string) -DOC_RETURN(returns non-zero if the file exists, returns zero if the file does not exist) +DOC_PARAM(filename, This parameter specifies the full path to a file; it need not be null terminated.) +DOC_PARAM(len, This parameter specifies the length of the filename string.) +DOC_RETURN(This call returns non-zero if and only if the file exists.) */{ char full_filename_space[1024]; String full_filename; HANDLE file; - b32 result; - - result = 0; + b32 result = 0; if (len < sizeof(full_filename_space)){ full_filename = make_fixed_width_string(full_filename_space); @@ -41,23 +39,24 @@ DOC_RETURN(returns non-zero if the file exists, returns zero if the file does no return(result); } -API_EXPORT int +API_EXPORT bool32 Directory_CD(Application_Links *app, char *dir, int *len, int capacity, char *rel_path, int rel_len)/* -DOC_PARAM(dir, a string buffer containing a directory) -DOC_PARAM(len, the length of the string in the string buffer) -DOC_PARAM(capacity, the maximum size of the string buffer) -DOC_PARAM(rel_path, the path to change to, may include '.' or '..') -DOC_PARAM(rel_len, the length of the rel_path string) -DOC_RETURN(returns non-zero if the call succeeds, returns zero otherwise) +DOC_PARAM(dir, This parameter provides a character buffer that stores a directory; it need not be null terminated.) +DOC_PARAM(len, This parameter specifies the length of the dir string.) +DOC_PARAM(capacity, This parameter specifies the maximum size of the dir string.) +DOC_PARAM(rel_path, This parameter specifies the path to change to, may include '.' or '..'; it need not be null terminated.) +DOC_PARAM(rel_len, This parameter specifies the length of the rel_path string.) +DOC_RETURN(This call returns non-zero if the call succeeds.) DOC ( -This call succeeds if the directory exists and the new directory fits inside the dir buffer. -If the call succeeds the dir buffer is filled with the new directory and len contains the -length of the string in the buffer. +This call succeeds if the new directory exists and the it fits inside the +dir buffer. If the call succeeds the dir buffer is filled with the new +directory and len is overwritten with the length of the new string in the buffer. -For instance if dir contains "C:/Users/MySelf" and rel is "Documents" the buffer will contain -"C:/Users/MySelf/Documents" and len will contain the length of that string. This call can -also be used with rel set to ".." to traverse to parent folders. +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. ) */{ String directory = make_string(dir, *len, capacity); @@ -97,11 +96,11 @@ also be used with rel set to ".." to traverse to parent folders. return(result); } -API_EXPORT int -Get_4ed_Path(Application_Links *app, char *out, int capacity)/* -DOC_PARAM(out, A char buffer that receives the path to the 4ed executable file.) -DOC_PARAM(capacity, The maximum capacity of the output buffer.) -DOC_RETURN(Returns non-zero on success, returns zero on failure.) +API_EXPORT bool32 +Get_4ed_Path(Application_Links *app, char *out, int32_t capacity)/* +DOC_PARAM(out, This parameter provides a character buffer that receives the path to the 4ed executable file.) +DOC_PARAM(capacity, This parameter specifies the maximum capacity of the out buffer.) +DOC_RETURN(This call returns non-zero on success.) */{ String str = make_string(out, 0, capacity); return(system_get_binary_path(&str)); @@ -109,8 +108,8 @@ DOC_RETURN(Returns non-zero on success, returns zero on failure.) // TODO(allen): add a "shown but auto-hides on timer" setting here. API_EXPORT void -Show_Mouse_Cursor(Application_Links *app, int show)/* -DOC_PARAM(show, The show state to put the mouse cursor into, should be one of the Mouse_Cursor_Show_Type enum values.) +Show_Mouse_Cursor(Application_Links *app, Mouse_Cursor_Show_Type show)/* +DOC_PARAM(show, This parameter specifies the new state of the mouse cursor.) DOC_SEE(Mouse_Cursor_Show_Type) */{ switch (show){