From 5b2077c6d719f386b9a9197b2b945ef819e5a5f2 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Thu, 8 Sep 2016 21:02:51 -0400 Subject: [PATCH] some clean up on the indent rule code --- 4coder_API.html | 53 ++--- 4coder_auto_indent.cpp | 467 +++++++++++++++++-------------------- 4coder_default_include.cpp | 40 ++++ 4coder_types.h | 38 ++- 4ed_api_implementation.cpp | 2 +- 4ed_file_view.cpp | 20 -- TODO.txt | 24 +- 7 files changed, 320 insertions(+), 324 deletions(-) diff --git a/4coder_API.html b/4coder_API.html index 2999b488..d252ac8b 100644 --- a/4coder_API.html +++ b/4coder_API.html @@ -2,7 +2,7 @@

4cpp Lexing Library

Table of Contents

§1 Introduction

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

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

§2 4coder Systems

Coming Soon
-

§3 Types and Functions

§3.1 Function List

§3.2 Type List

§3.3 Function Descriptions

§3.3.1: exec_command

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

§3 Types and Functions

§3.1 Function List

§3.2 Type List

§3.3 Function Descriptions

§3.3.1: exec_command

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

See Also

§3.3.2: exec_system_command

bool32 app->exec_system_command(
Application_Links *app,
View_Summary *view,
Buffer_Identifier buffer,
char *path,
int32_t path_len,
char *command,
int32_t command_len,
Command_Line_Input_Flag flags
)
Parameters
view
If the view parameter is non-null it specifies a view to display the command's output buffer.
buffer
The buffer the command will output to is specified by the buffer parameter. See Buffer_Identifier for information on how this type specifies a buffer.
path
The path parameter specifies the path in which the command shall be executed. The string need not be null terminated.
path_len
The parameter path_len specifies the length of the path string.
command
The command parameter specifies the command that shall be executed. The string need not be null terminated.
command_len
The parameter command_len specifies the length of the command string.
flags
Flags for the behavior of the call are specified in the flags parameter.
Return
This call returns non-zero on success.
Description
A call to exec_system_command executes a command as if called from the command line, and sends the output to a buffer. The buffer identifier can either name a new buffer that does not exist, name a buffer that does @@ -102,8 +102,7 @@ a color value, colors are specified as 24 bit integers in 3 channels: 0xRRGGBB.< to textual input that takes modifiers into account.


§3.4.4: Buffer_ID

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


§3.4.5: View_ID

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


§3.4.6: Key_Modifier

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

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


§3.4.7: Key_Modifier_Flag

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

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

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

§3.4.8: Command_ID

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

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

cmdid_undo
cmdid_undo performs a standard undo behavior.

cmdid_redo
cmdid_redo reperforms an edit that was undone.

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

cmdid_history_forward
cmdid_history_forward unperforms the previous cmdid_history_backward step if possib.e

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

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

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

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

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

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

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

cmdid_kill_buffer
cmdid_kill_buffer tries to kill the active buffer.

cmdid_open_color_tweaker
cmdid_open_color_tweaker opens the theme editing GUI.

cmdid_open_config
cmdid_open_config opens the configuration menu.

cmdid_open_menu
cmdid_open_menu opens the top level menu.

cmdid_open_debug
cmdid_open_debug opens the debug information viewer mode.

cmdid_count

§3.4.9: Memory_Protect_Flags

enum Memory_Protect_Flags;
Description
TODO

Values
MemProtect_Read = 0x1
TODO

MemProtect_Write = 0x2
TODO

MemProtect_Execute = 0x4
TODO


§3.4.10: User_Input_Type_ID

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

Values
UserInputNone
UserInputNone indicates that no event has occurred.

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

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


§3.4.11: Event_Message_Type_ID

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

Values
EventMessage_NoMessage
TODO.

EventMessage_OpenView
TODO.

EventMessage_Frame
TODO.

EventMessage_CloseView
TODO.


§3.4.12: Buffer_Batch_Edit_Type

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

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

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


§3.4.13: Buffer_Setting_ID

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

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

BufferSetting_Lex
The BufferSetting_Lex setting is used to determine whether to store C++ tokens +Flags can be combined with bit or to specify a state with multiple modifiers.

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

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

§3.4.8: Command_ID

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

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

cmdid_undo
cmdid_undo performs a standard undo behavior.

cmdid_redo
cmdid_redo reperforms an edit that was undone.

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

cmdid_history_forward
cmdid_history_forward unperforms the previous cmdid_history_backward step if possib.e

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

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

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

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

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

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

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

cmdid_kill_buffer
cmdid_kill_buffer tries to kill the active buffer.

cmdid_open_color_tweaker
cmdid_open_color_tweaker opens the theme editing GUI.

cmdid_open_config
cmdid_open_config opens the configuration menu.

cmdid_open_menu
cmdid_open_menu opens the top level menu.

cmdid_open_debug
cmdid_open_debug opens the debug information viewer mode.

cmdid_count

§3.4.9: Memory_Protect_Flags

enum Memory_Protect_Flags;
Description
TODO

Values
MemProtect_Read = 0x1
TODO

MemProtect_Write = 0x2
TODO

MemProtect_Execute = 0x4
TODO


§3.4.10: User_Input_Type_ID

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

Values
UserInputNone
UserInputNone indicates that no event has occurred.

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

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


§3.4.11: Event_Message_Type_ID

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

Values
EventMessage_NoMessage
TODO.

EventMessage_OpenView
TODO.

EventMessage_Frame
TODO.

EventMessage_CloseView
TODO.


§3.4.12: Buffer_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 @@ -111,14 +110,14 @@ Flags can be combined with bit or to specify a state with multiple modifiers.

BufferSetting_Unimportant
The BufferSetting_Unimportant setting marks a buffer so that it's dirty state will be completely ignored. This means the "dirty" star is hidden and the buffer can be closed without presenting an "are you sure" dialogue screen.

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


§3.4.14: View_Setting_ID

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

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

ViewSetting_WrapLine
The ViewSetting_WrapLine setting determines whether the view applies line wrapping + access calls that include an AccessProtected flag.


§3.4.13: View_Setting_ID

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

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

ViewSetting_WrapLine
The ViewSetting_WrapLine setting determines whether the view applies line wrapping at the border of the panel for long lines. Whenever the view switches to a new buffer it will reset this setting to match the 'preferred' line wrapping setting of the buffer.

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

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


§3.4.15: Buffer_Create_Flag

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

Values
BufferCreate_Background = 0x1
BufferCreate_Background is not currently implemented.

BufferCreate_AlwaysNew = 0x2
When BufferCreate_AlwaysNew is set it indicates the buffer should be + attached to a view in it's scrollable section.


§3.4.14: Buffer_Create_Flag

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

Values
BufferCreate_Background = 0x1
BufferCreate_Background is not currently implemented.

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

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


§3.4.16: Buffer_Kill_Flag

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

Values
BufferKill_Background = 0x1
BufferKill_Background is not currently implemented.

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


§3.4.17: Access_Flag

enum Access_Flag;
Description
An Access_Flag field specifies what sort of permission you grant to an + only be created if it is an existing file or an open buffer.


§3.4.15: Buffer_Kill_Flag

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

Values
BufferKill_Background = 0x1
BufferKill_Background is not currently implemented.

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


§3.4.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 @@ -128,58 +127,60 @@ that protection flag, the object is still returned from the access call.

the output from an app->exec_system_command call such as *build*. This is to prevent the user from accidentally editing output that they might prefer to keep in tact.

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

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


§3.4.18: Seek_Boundary_Flag

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

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

§3.4.19: Command_Line_Input_Flag

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

Values
CLI_OverlapWithConflict = 0x1
If CLI_OverlapWithConflict is set if output buffer of the new command is already + return an object no matter what it's protection flags are.


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

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

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

Values
CLI_OverlapWithConflict = 0x1
If CLI_OverlapWithConflict is set if output buffer of the new command is already in use by another command which is still executing, the older command relinquishes control of the buffer and both operate simultaneously with only the newer command outputting to the buffer.

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

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


§3.4.20: Auto_Indent_Flag

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

Values
AutoIndent_ClearLine = 0x1
If AutoIndent_ClearLine is set, then any line that is only whitespace will + otherwise the cursor is kept at the beginning.


§3.4.19: Auto_Indent_Flag

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

Values
AutoIndent_ClearLine = 0x1
If AutoIndent_ClearLine is set, then any line that is only whitespace will be cleared to contain nothing at all. otherwise the line is filled with whitespace to match the nearby indentation.

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


§3.4.21: Set_Buffer_Flag

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

Values
SetBuffer_KeepOriginalGUI = 0x1
If SetBuffer_KeepOriginalGUI then when the file is set, the view will not switch to it + is needed to finish the alignment.


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

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


§3.4.22: Input_Type_Flag

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

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

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

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

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

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

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

EventOnMouseMove = 0x20
This is not totally implemented yet.

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

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


§3.4.23: Mouse_Cursor_Show_Type

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

Values
MouseCursorShow_Never
The MouseCursorShow_Never mode never shows the cursor.

MouseCursorShow_Always
The MouseCursorShow_Never mode always shows the cursor.


§3.4.24: Buffer_Seek_Type

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

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

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

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

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

See Also

§3.4.25: View_Split_Position

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

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

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

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

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


§3.4.26: Generic_Command

union Generic_Command {
Command_ID cmdid;
Custom_Command_Function * command;
};
Description
Generic_Command acts as a name for a command, and can name an + switches to the file.


§3.4.21: Input_Type_Flag

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

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

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

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

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

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

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

EventOnMouseMove = 0x20
This is not totally implemented yet.

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

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


§3.4.22: Mouse_Cursor_Show_Type

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

Values
MouseCursorShow_Never
The MouseCursorShow_Never mode never shows the cursor.

MouseCursorShow_Always
The MouseCursorShow_Never mode always shows the cursor.


§3.4.23: Buffer_Seek_Type

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

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

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

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

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

See Also
Buffer_Seek
4coder_Buffer_Positioning_System

§3.4.24: View_Split_Position

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

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

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

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

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


§3.4.25: Generic_Command

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

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

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


§3.4.27: Key_Event_Data

struct Key_Event_Data {
Key_Code keycode;
Key_Code character;
Key_Code character_no_caps_lock;
char modifiers[MDFR_INDEX_COUNT];
};
Description
Key_Event_Data describes a key event, including the + field is the pointer to the custom command..


§3.4.26: Key_Event_Data

struct Key_Event_Data {
Key_Code keycode;
Key_Code character;
Key_Code character_no_caps_lock;
char modifiers[MDFR_INDEX_COUNT];
};
Description
Key_Event_Data describes a key event, including the translation to a character, the translation to a character ignoring the state of caps lock, and an array of all the modifiers that were pressed at the time of the event.

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

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

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

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


§3.4.28: Mouse_State

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


§3.4.27: Mouse_State

struct Mouse_State {
char l;
char r;
char press_l;
char press_r;
char release_l;
char release_r;
char wheel;
char out_of_window;
int32_t x;
int32_t y;
};
Description
Mouse_State describes an entire mouse state complete with the position, left and right button states, the wheel state, and whether or not the -mouse if in the window.

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

r
This field indicates that the right button is held.

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

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

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

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

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

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

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

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


§3.4.29: Range

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

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

r
This field indicates that the right button is held.

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

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

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

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

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

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

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

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


§3.4.28: Range

union Range {
struct {
int32_t min;
int32_t max;
};
struct {
int32_t start;
int32_t end;
};
};
Description
Range describes an integer range typically used for ranges within a buffer. Ranges tend are usually not passed as a Range struct into the API, but this struct is used to return ranges.

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

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

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

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

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


§3.4.30: File_Info

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

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

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

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

See Also
File_List

§3.4.31: File_List

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

Fields
block
This field is for inernal use.

infos
This field is an array of File_Info structs.

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

block_size
This field is for internal use.


§3.4.32: Buffer_Identifier

struct Buffer_Identifier {
char * name;
int32_t name_len;
int32_t id;
};
Description
Buffer_Identifier acts as a loosely typed description of a buffer that +Throughout the API ranges are thought of in the form [min,max

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

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

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

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


§3.4.29: File_Info

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

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

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

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

See Also
File_List

§3.4.30: File_List

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

Fields
block
This field is for inernal use.

infos
This field is an array of File_Info structs.

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

block_size
This field is for internal use.


§3.4.31: Buffer_Identifier

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

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

name_len
This field specifies the length of the name string.

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


§3.4.33: GUI_Scroll_Vars

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

Fields
scroll_y
TODO

target_y
TODO

prev_target_y
TODO

scroll_x
TODO

target_x
TODO

prev_target_x
TODO


§3.4.34: Full_Cursor

struct Full_Cursor {
int32_t pos;
int32_t line;
int32_t character;
float unwrapped_x;
float unwrapped_y;
float wrapped_x;
float wrapped_y;
};
Description
Full_Cursor describes the position of a cursor in every buffer + If id is specified this pointer should be NULL.

name_len
This field specifies the length of the name string.

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


§3.4.32: GUI_Scroll_Vars

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

Fields
scroll_y
TODO

target_y
TODO

prev_target_y
TODO

scroll_x
TODO

target_x
TODO

prev_target_x
TODO


§3.4.33: Full_Cursor

struct Full_Cursor {
int32_t pos;
int32_t line;
int32_t character;
float unwrapped_x;
float unwrapped_y;
float wrapped_x;
float wrapped_y;
};
Description
Full_Cursor describes the position of a cursor in every buffer coordinate system supported by 4coder. This cursor type requires that -the buffer is associated with a view to give the x/y values meaning.

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

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

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

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

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

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

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

See Also
4coder_Buffer_Positioning_System

§3.4.35: Partial_Cursor

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

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

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

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

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

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

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

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

See Also
4coder_Buffer_Positioning_System

§3.4.34: Partial_Cursor

struct Partial_Cursor {
int32_t pos;
int32_t line;
int32_t character;
};
Description
Partial_Cursor describes the position of a cursor in all of the coordinate systems that a invariant to the View. In other words the coordinate systems available here can be used on a buffer that is -not currently associated with a View.

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

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

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

See Also
4coder_Buffer_Positioning_System

§3.4.36: Buffer_Seek

struct Buffer_Seek {
Buffer_Seek_Type type;
union {
struct {
int32_t pos;
};
struct {
bool32 round_down;
float x;
float y;
};
struct {
int32_t line;
int32_t character;
};
};
};
Description
Buffer_Seek describes the destination of a seek operation. There are helpers +not currently associated with a View.

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

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

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

See Also
4coder_Buffer_Positioning_System

§3.4.35: Buffer_Seek

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

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

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

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

x
The x coordinate for xy type seeks.

y
The y coordinate for xy type seeks.

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

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

See Also
Buffer_Seek_Type
4coder_Buffer_Positioning_System

§3.4.37: Buffer_Edit

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

x
The x coordinate for xy type seeks.

y
The y coordinate for xy type seeks.

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

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

See Also
Buffer_Seek_Type
4coder_Buffer_Positioning_System

§3.4.36: Buffer_Edit

struct Buffer_Edit {
int32_t str_start;
int32_t len;
int32_t start;
int32_t end;
};
Description
Buffer_Edit describes a range of a buffer and string to replace that range. A Buffer_Edit has to be paired with a string that contains the actual text that -will be replaced into the buffer.

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

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

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

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


§3.4.38: Buffer_Summary

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

Fields
exists
This field indicates whether the Buffer_Summary describes a buffer that is open in 4coder. +will be replaced into the buffer.

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

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

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

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


§3.4.37: Buffer_Summary

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

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

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

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

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

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

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

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

file_name_len
This field specifies the length of the file_name string.

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

buffer_name_len
This field specifies the length of the buffer_name string.

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

tokens_are_ready
If this is not a null summary, this field indicates whether the buffer has up to date tokens available. If this field is false, it may simply mean the tokens are still being generated in a background task and will be available later. If that is the case, is_lexed will be true to indicate that the buffer is trying to get - it's tokens up to date.

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

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

See Also
Access_Flag

§3.4.39: View_Summary

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

Fields
exists
This field indicates whether the View_Summary describes a view that is open in 4coder. + it's tokens up to date.

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

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

See Also
Access_Flag

§3.4.38: View_Summary

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

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

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

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

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

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

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

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

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

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

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

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

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

See Also
Access_Flag
Full_Cursor

§3.4.40: User_Input

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

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

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

key
This field describes a key press event.

mouse
This field describes a mouse input event.

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

See Also
User_Input_Type_ID
Generic_Command

§3.4.41: Query_Bar

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

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

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


§3.4.42: Event_Message

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

Fields
type
This feature is not implemented.


§3.4.43: Theme_Color

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

Fields
tag
color
See Also
Style_Tag
int_color

+ If this is a null summary then view_id is 0.

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

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

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

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

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

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

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

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

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

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

See Also
Access_Flag
Full_Cursor

§3.4.39: User_Input

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

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

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

key
This field describes a key press event.

mouse
This field describes a mouse input event.

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

See Also
User_Input_Type_ID
Generic_Command

§3.4.40: Query_Bar

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

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

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


§3.4.41: Event_Message

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

Fields
type
This feature is not implemented.


§3.4.42: Theme_Color

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

Fields
tag
The style slot in the style palette.

color
The color in the slot.

See Also
Style_Tag
int_color

§3.4.43: Buffer_Batch_Edit_Type

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

Values
BatchEdit_Normal
The BatchEdit_Normal operation is always correct but does the most work if there are tokens to correct.

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


§3.4.44: Buffer_Batch_Edit

struct Buffer_Batch_Edit {
char * str;
int32_t str_len;
Buffer_Edit * edits;
int32_t edit_count;
};
Description
This struct is used to bundle the parameters of the buffer_batch_edit function. It is convenient +for a few functions that return a batch edit to the user.

Fields
str
The pointer to the edit string buffer.

str_len
The length of the edit string buffer.

edits
The array of edits to be applied.

edit_count
The number of edits in the array.

See Also
buffer_batch_edit

§4 String Library

§4.1 String Intro

Coming Soon

§4.2 String Function List

§4.3 String Function Descriptions

§4.3.1: char_is_slash

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


§4.3.2: char_is_upper

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


§4.3.3: char_is_lower

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


§4.3.4: char_to_upper

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


§4.3.5: char_to_lower

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


§4.3.6: char_is_whitespace

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


§4.3.7: char_is_alpha_numeric

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


§4.3.8: char_is_alpha_numeric_true

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


§4.3.9: char_is_alpha

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


§4.3.10: char_is_alpha_true

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


§4.3.11: char_is_hex

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


§4.3.12: char_is_numeric

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


§4.3.13: make_string_cap

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


§4.3.14: make_string

String make_string(
void *str,
int32_t size
)
Parameters
str
The str parameter provides the of memory with which the string shall operate.
size
The size parameter expresses the initial size of the string. If the memory does not already contain a useful string this should be zero. Since this version diff --git a/4coder_auto_indent.cpp b/4coder_auto_indent.cpp index 7f3cd5ae..ba791130 100644 --- a/4coder_auto_indent.cpp +++ b/4coder_auto_indent.cpp @@ -2,6 +2,10 @@ #ifndef FCODER_AUTO_INDENT_INC #define FCODER_AUTO_INDENT_INC +// +// Generic Line Indenter +// + struct Hard_Start_Result{ int32_t char_pos; int32_t indent_pos; @@ -62,36 +66,80 @@ struct Indent_Options{ int32_t tab_width; }; -#include "4cpp_lexer.h" - -static int32_t -buffer_get_line_start(Application_Links *app, Buffer_Summary *buffer, int32_t line){ - Partial_Cursor partial_cursor; - app->buffer_compute_cursor(app, buffer, seek_line_char(line, 1), &partial_cursor); - return(partial_cursor.pos); -} - -static int32_t -buffer_get_line_index(Application_Links *app, Buffer_Summary *buffer, int32_t pos){ - Partial_Cursor partial_cursor; - app->buffer_compute_cursor(app, buffer, seek_pos(pos), &partial_cursor); - return(partial_cursor.line); -} - -static Cpp_Token* -get_first_token_at_line(Application_Links *app, Buffer_Summary *buffer, Cpp_Token_Array tokens, int32_t line){ - int32_t line_start = buffer_get_line_start(app, buffer, line); - Cpp_Get_Token_Result get_token = cpp_get_token(&tokens, line_start); +static Buffer_Batch_Edit +make_batch_from_indent_marks(Application_Links *app, Partition *part, Buffer_Summary *buffer, + int32_t line_start, int32_t line_end, int32_t *indent_marks, + Indent_Options opts){ - if (get_token.in_whitespace){ - get_token.token_index += 1; + Buffer_Batch_Edit result = {0}; + + int32_t edit_max = line_end - line_start; + int32_t edit_count = 0; + + Buffer_Edit *edits = push_array(part, Buffer_Edit, edit_max); + + char *str_base = (char*)part->base + part->pos; + int32_t str_size = 0; + + // NOTE(allen): Shift the array so that line_i can just operate in + // it's natural value range. + indent_marks -= line_start; + + for (int32_t line_i = line_start; line_i < line_end; ++line_i){ + int32_t line_start = buffer_get_line_start(app, buffer, line_i); + Hard_Start_Result hard_start = + buffer_find_hard_start(app, buffer, line_start, opts.tab_width); + + int32_t correct_indentation = indent_marks[line_i]; + if (hard_start.all_whitespace && opts.empty_blank_lines) correct_indentation = 0; + if (correct_indentation == -1) correct_indentation = hard_start.indent_pos; + + // TODO(allen): Only replace spaces if we are using space based indentation. + // TODO(allen): See if the first clause can just be removed because it's dumb. + if (!hard_start.all_space || correct_indentation != hard_start.indent_pos){ + Buffer_Edit new_edit; + new_edit.str_start = str_size; + str_size += correct_indentation; + char *str = push_array(part, char, correct_indentation); + int32_t j = 0; + if (opts.use_tabs){ + int32_t i = 0; + for (; i + opts.tab_width <= correct_indentation; i += opts.tab_width) str[j++] = '\t'; + for (; i < correct_indentation; ++i) str[j++] = ' '; + } + else{ + for (; j < correct_indentation; ++j) str[j] = ' '; + } + new_edit.len = j; + new_edit.start = line_start; + new_edit.end = hard_start.char_pos; + edits[edit_count++] = new_edit; + } + + Assert(edit_count <= edit_max); } - Cpp_Token *result = tokens.tokens + get_token.token_index; + result.str = str_base; + result.str_len = str_size; + + result.edits = edits; + result.edit_count = edit_count; return(result); } +static void +set_line_indents(Application_Links *app, Partition *part, Buffer_Summary *buffer, + int32_t line_start, int32_t line_end, int32_t *indent_marks, Indent_Options opts){ + Buffer_Batch_Edit batch = + make_batch_from_indent_marks(app, part, buffer, line_start, line_end, indent_marks, opts); + + if (batch.edit_count > 0){ + app->buffer_batch_edit(app, buffer, batch.str, batch.str_len, + batch.edits, batch.edit_count, BatchEdit_PreserveTokens); + } +} + static Cpp_Token* seek_matching_token_backwards(Cpp_Token_Array tokens, Cpp_Token *token, Cpp_Token_Type open_type, Cpp_Token_Type close_type){ @@ -119,6 +167,91 @@ seek_matching_token_backwards(Cpp_Token_Array tokens, Cpp_Token *token, return(token); } +static Cpp_Token* +find_anchor_token(Application_Links *app, Buffer_Summary *buffer, Cpp_Token_Array tokens, + int32_t line_start, int32_t tab_width, int32_t *current_indent_out){ + Cpp_Token *token = get_first_token_at_line(app, buffer, tokens, line_start); + + if (token != tokens.tokens){ + --token; + for (; token > tokens.tokens; --token){ + if (!(token->flags & CPP_TFLAG_PP_BODY)){ + switch(token->type){ + case CPP_TOKEN_BRACE_OPEN: + case CPP_TOKEN_BRACE_CLOSE: + goto out_of_loop; + } + } + } + out_of_loop:; + } + + int32_t current_indent = 0; + int32_t found_safe_start_position = 0; + do{ + int32_t line = buffer_get_line_index(app, buffer, token->start); + int32_t start = buffer_get_line_start(app, buffer, line); + + Hard_Start_Result hard_start = buffer_find_hard_start(app, buffer, start, tab_width); + current_indent = hard_start.indent_pos; + + Cpp_Token *start_token = get_first_token_at_line(app, buffer, tokens, line); + Cpp_Token *brace_token = token; + + if (start_token->type == CPP_TOKEN_PARENTHESE_OPEN){ + if (start_token == tokens.tokens){ + found_safe_start_position = 1; + } + else{ + token = start_token-1; + } + } + else{ + int32_t close = 0; + + for (token = brace_token; token > start_token; --token){ + switch(token->type){ + case CPP_TOKEN_PARENTHESE_CLOSE: + case CPP_TOKEN_BRACKET_CLOSE: + case CPP_TOKEN_BRACE_CLOSE: + close = token->type; + goto out_of_loop2; + } + } + out_of_loop2:; + + switch (close){ + case 0: token = start_token; found_safe_start_position = 1; break; + + case CPP_TOKEN_PARENTHESE_CLOSE: + token = seek_matching_token_backwards(tokens, token-1, + CPP_TOKEN_PARENTHESE_OPEN, + CPP_TOKEN_PARENTHESE_CLOSE); + break; + + case CPP_TOKEN_BRACKET_CLOSE: + token = seek_matching_token_backwards(tokens, token-1, + CPP_TOKEN_BRACKET_OPEN, + CPP_TOKEN_BRACKET_CLOSE); + break; + + case CPP_TOKEN_BRACE_CLOSE: + token = seek_matching_token_backwards(tokens, token-1, + CPP_TOKEN_BRACE_OPEN, + CPP_TOKEN_BRACE_CLOSE); + break; + } + } + } while(found_safe_start_position == 0); + *current_indent_out = current_indent; + + return(token); +} + +// +// Indent Rules +// + struct Indent_Parse_State{ int32_t current_indent; int32_t previous_line_indent; @@ -135,14 +268,7 @@ compute_this_indent(Application_Links *app, Buffer_Summary *buffer, Indent_Parse int32_t this_indent = 0; int32_t this_line_start = buffer_get_line_start(app, buffer, line_i); - int32_t next_line_start = 0; - - if (line_i+1 < buffer->line_count){ - next_line_start = buffer_get_line_start(app, buffer, line_i+1); - } - else{ - next_line_start = buffer->size; - } + int32_t next_line_start = buffer_get_line_start(app, buffer, line_i+1); bool32 did_special_behavior = false; @@ -215,134 +341,55 @@ compute_this_indent(Application_Links *app, Buffer_Summary *buffer, Indent_Parse } static int32_t* -get_line_indentation_marks(Application_Links *app, Partition *part, Buffer_Summary *buffer, Cpp_Token_Array tokens, - int32_t line_start, int32_t line_end, int32_t tab_width){ +get_indentation_marks(Application_Links *app, Partition *part, Buffer_Summary *buffer, + Cpp_Token_Array tokens, int32_t line_start, int32_t line_end, int32_t tab_width){ int32_t indent_mark_count = line_end - line_start; int32_t *indent_marks = push_array(part, int32_t, indent_mark_count); - - Indent_Parse_State indent = {0}; - Cpp_Token *token = get_first_token_at_line(app, buffer, tokens, line_start); - - if (token != tokens.tokens){ - --token; - for (; token > tokens.tokens; --token){ - if (!(token->flags & CPP_TFLAG_PP_BODY)){ - switch(token->type){ - case CPP_TOKEN_BRACE_OPEN: - case CPP_TOKEN_BRACE_CLOSE: - goto out_of_loop; - } - } - } - out_of_loop:; - } - - // TODO(allen): This can maybe be it's own function now, so that we - // can do the decls in the order we want and avoid the extra binary search. - int32_t found_safe_start_position = 0; - do{ - int32_t line = buffer_get_line_index(app, buffer, token->start); - int32_t start = buffer_get_line_start(app, buffer, line); - Hard_Start_Result hard_start = buffer_find_hard_start(app, buffer, start, tab_width); - - indent.current_indent = hard_start.indent_pos; - - Cpp_Token *start_token = get_first_token_at_line(app, buffer, tokens, line); - Cpp_Token *brace_token = token; - - if (start_token->type == CPP_TOKEN_PARENTHESE_OPEN){ - if (start_token == tokens.tokens){ - found_safe_start_position = 1; - } - else{ - token = start_token-1; - } - } - else{ - int32_t close = 0; - - for (token = brace_token; token > start_token; --token){ - switch(token->type){ - case CPP_TOKEN_PARENTHESE_CLOSE: - case CPP_TOKEN_BRACKET_CLOSE: - case CPP_TOKEN_BRACE_CLOSE: - close = token->type; - goto out_of_loop2; - } - } - out_of_loop2:; - - switch (close){ - case 0: token = start_token; found_safe_start_position = 1; break; - - case CPP_TOKEN_PARENTHESE_CLOSE: - token = seek_matching_token_backwards(tokens, token-1, - CPP_TOKEN_PARENTHESE_OPEN, - CPP_TOKEN_PARENTHESE_CLOSE); - break; - - case CPP_TOKEN_BRACKET_CLOSE: - token = seek_matching_token_backwards(tokens, token-1, - CPP_TOKEN_BRACKET_OPEN, - CPP_TOKEN_BRACKET_CLOSE); - break; - - case CPP_TOKEN_BRACE_CLOSE: - token = seek_matching_token_backwards(tokens, token-1, - CPP_TOKEN_BRACE_OPEN, - CPP_TOKEN_BRACE_CLOSE); - break; - } - } - } while(found_safe_start_position == 0); - - // NOTE(allen): Shift the array so that line_i can just operate in - // it's natural value range. + // Shift the array so line_i works correctly. indent_marks -= line_start; - int32_t line_i = buffer_get_line_index(app, buffer, token->start); - if (line_i > line_start){ - line_i = line_start; + // Decide where to start indentation parsing. + Indent_Parse_State indent = {0}; + Cpp_Token *token_ptr = find_anchor_token(app, buffer, tokens, line_start, + tab_width, &indent.current_indent); + + int32_t line_index = buffer_get_line_index(app, buffer, token_ptr->start); + + if (line_index > line_start){ + line_index = line_start; } - int32_t next_line_start = buffer->size; - if (line_i+1 < buffer->line_count){ - next_line_start = buffer_get_line_start(app, buffer, line_i+1); - } + int32_t next_line_start_pos = buffer_get_line_start(app, buffer, line_index+1); - switch (token->type){ + switch (token_ptr->type){ case CPP_TOKEN_BRACKET_OPEN: indent.current_indent += tab_width; break; case CPP_TOKEN_BRACE_OPEN: indent.current_indent += tab_width; break; case CPP_TOKEN_PARENTHESE_OPEN: indent.current_indent += tab_width; break; } indent.previous_line_indent = indent.current_indent; - Cpp_Token T; - Cpp_Token prev_token = *token; - ++token; - for (; line_i < line_end; ++token){ - if (token < tokens.tokens + tokens.count){ - T = *token; + for (;line_index < line_end;){ + Cpp_Token prev_token = *token_ptr; + Cpp_Token token; + + ++token_ptr; + if (token_ptr < tokens.tokens + tokens.count){ + token = *token_ptr; } else{ - T.type = CPP_TOKEN_EOF; - T.start = buffer->size; - T.flags = 0; + token.type = CPP_TOKEN_EOF; + token.start = buffer->size; + token.flags = 0; } - for (; T.start >= next_line_start && line_i < line_end;){ - if (line_i+1 < buffer->line_count){ - next_line_start = buffer_get_line_start(app, buffer, line_i+1); - } - else{ - next_line_start = buffer->size; - } + for (;token.start >= next_line_start_pos && line_index < line_end;){ + next_line_start_pos = buffer_get_line_start(app, buffer, line_index+1); int32_t this_indent = - compute_this_indent(app, buffer, indent, T, prev_token, line_i, tab_width); + compute_this_indent(app, buffer, indent, token, prev_token, line_index, tab_width); // NOTE(allen): Rebase the paren anchor if the first token // after an open paren is on the next line. @@ -356,15 +403,16 @@ get_line_indentation_marks(Application_Links *app, Partition *part, Buffer_Summa } } - if (line_i >= line_start){ - indent_marks[line_i] = this_indent; + if (line_index >= line_start){ + indent_marks[line_index] = this_indent; } - ++line_i; + ++line_index; indent.previous_line_indent = this_indent; } - switch (T.type){ + // Update indent state. + switch (token.type){ case CPP_TOKEN_BRACKET_OPEN: indent.current_indent += 4; break; case CPP_TOKEN_BRACKET_CLOSE: indent.current_indent -= 4; break; case CPP_TOKEN_BRACE_OPEN: indent.current_indent += 4; break; @@ -372,18 +420,18 @@ get_line_indentation_marks(Application_Links *app, Partition *part, Buffer_Summa case CPP_TOKEN_COMMENT: { - int32_t line = buffer_get_line_index(app, buffer, T.start); + int32_t line = buffer_get_line_index(app, buffer, token.start); int32_t start = buffer_get_line_start(app, buffer, line); - indent.comment_shift = (indent.current_indent - (T.start - start)); + indent.comment_shift = (indent.current_indent - (token.start - start)); }break; case CPP_TOKEN_PARENTHESE_OPEN: - if (!(T.flags & CPP_TFLAG_PP_BODY)){ + if (!(token.flags & CPP_TFLAG_PP_BODY)){ if (indent.paren_nesting < ArrayCount(indent.paren_anchor_indent)){ - int32_t line = buffer_get_line_index(app, buffer, T.start); + int32_t line = buffer_get_line_index(app, buffer, token.start); int32_t start = buffer_get_line_start(app, buffer, line); - int32_t char_pos = T.start - start; + int32_t char_pos = token.start - start; Hard_Start_Result hard_start = buffer_find_hard_start(app, buffer, start, tab_width); @@ -398,126 +446,31 @@ get_line_indentation_marks(Application_Links *app, Partition *part, Buffer_Summa break; case CPP_TOKEN_PARENTHESE_CLOSE: - if (!(T.flags & CPP_TFLAG_PP_BODY)){ + if (!(token.flags & CPP_TFLAG_PP_BODY)){ --indent.paren_nesting; } break; } - prev_token = T; } - // NOTE(allen): Unshift the indent_marks array so that the return value - // is the exact starting point of the array that was actually allocated. + // Unshift the indent_marks array. indent_marks += line_start; - return(indent_marks); } -struct Make_Batch_Result{ - char *str_base; - int32_t str_size; - - Buffer_Edit *edits; - int32_t edit_max; - int32_t edit_count; -}; - -static Make_Batch_Result -make_batch_from_indent_marks(Application_Links *app, Partition *part, Buffer_Summary *buffer, - int32_t line_start, int32_t line_end, int32_t *indent_marks, Indent_Options opts){ - - Make_Batch_Result result = {0}; - - int32_t edit_max = line_end - line_start; - int32_t edit_count = 0; - - Buffer_Edit *edits = push_array(part, Buffer_Edit, edit_max); - - char *str_base = (char*)part->base + part->pos; - int32_t str_size = 0; - - // NOTE(allen): Shift the array so that line_i can just operate in - // it's natural value range. - indent_marks -= line_start; - - for (int32_t line_i = line_start; line_i < line_end; ++line_i){ - int32_t line_start = buffer_get_line_start(app, buffer, line_i); - Hard_Start_Result hard_start = - buffer_find_hard_start(app, buffer, line_start, opts.tab_width); - - int32_t correct_indentation = indent_marks[line_i]; - if (hard_start.all_whitespace && opts.empty_blank_lines) correct_indentation = 0; - if (correct_indentation == -1) correct_indentation = hard_start.indent_pos; - - // TODO(allen): Only replace spaces if we are using space based indentation. - // TODO(allen): See if the first clause can just be removed because it's dumb. - if ((hard_start.all_whitespace && hard_start.char_pos > line_start) || - !hard_start.all_space || correct_indentation != hard_start.indent_pos){ - - Buffer_Edit new_edit; - new_edit.str_start = str_size; - str_size += correct_indentation; - char *str = push_array(part, char, correct_indentation); - int32_t j = 0; - if (opts.use_tabs){ - int32_t i = 0; - for (; i + opts.tab_width <= correct_indentation; i += opts.tab_width) str[j++] = '\t'; - for (; i < correct_indentation; ++i) str[j++] = ' '; - } - else{ - for (; j < correct_indentation; ++j) str[j] = ' '; - } - new_edit.len = j; - new_edit.start = line_start; - new_edit.end = hard_start.char_pos; - edits[edit_count++] = new_edit; - } - - Assert(edit_count <= edit_max); - } - - result.str_base = str_base; - result.str_size = str_size; - - result.edits = edits; - result.edit_max = edit_max; - result.edit_count = edit_count; - - return(result); -} - static bool32 buffer_auto_indent(Application_Links *app, Partition *part, 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 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.) - -DOC_SEE(Auto_Indent_Flag) -DOC_SEE(4coder_Buffer_Positioning_System) -*/{ - - Indent_Options opts = {0}; + int32_t start, int32_t end, int32_t tab_width, Auto_Indent_Flag flags){ bool32 result = 0; if (buffer->exists && buffer->tokens_are_ready){ result = 1; - opts.empty_blank_lines = (flags & AutoIndent_ClearLine); - opts.use_tabs = (flags & AutoIndent_UseTab); - opts.tab_width = tab_width; - Temp_Memory temp = begin_temp_memory(part); - // TODO(allen): Only read in the tokens in the range we need. + // Stage 1: Setup + // Read the tokens to be used for indentation. + // Get the first and last lines to indent. Cpp_Token_Array tokens; tokens.count = app->buffer_token_count(app, buffer); tokens.max_count = tokens.count; @@ -525,19 +478,21 @@ DOC_SEE(4coder_Buffer_Positioning_System) app->buffer_read_tokens(app, buffer, 0, tokens.count, tokens.tokens); int32_t line_start = buffer_get_line_index(app, buffer, start); - int32_t line_end = buffer_get_line_index(app, buffer, end); + int32_t line_end = buffer_get_line_index(app, buffer, end) + 1; + // Stage 2: Decide Indent Amounts + // Get an array representing how much each line in [line_start,line_end] + // should be indented. int32_t *indent_marks = - get_line_indentation_marks(app, part, buffer, tokens, - line_start, line_end, opts.tab_width); + get_indentation_marks(app, part, buffer, tokens, line_start, line_end, tab_width); - Make_Batch_Result batch = - make_batch_from_indent_marks(app, part, buffer, line_start, line_end, indent_marks, opts); + // Stage 3: Set the Line Indents + Indent_Options opts = {0}; + opts.empty_blank_lines = (flags & AutoIndent_ClearLine); + opts.use_tabs = (flags & AutoIndent_UseTab); + opts.tab_width = tab_width; - if (batch.edit_count > 0){ - app->buffer_batch_edit(app, buffer, batch.str_base, batch.str_size, - batch.edits, batch.edit_count, BatchEdit_PreserveTokens); - } + set_line_indents(app, part, buffer, line_start, line_end, indent_marks, opts); end_temp_memory(temp); } diff --git a/4coder_default_include.cpp b/4coder_default_include.cpp index 82414d4e..1e23d233 100644 --- a/4coder_default_include.cpp +++ b/4coder_default_include.cpp @@ -547,6 +547,46 @@ buffer_seek_string_insensitive_backward(Application_Links *app, Buffer_Summary * } } + +// +// Some Basic Buffer Positioning +// + +#include "4cpp_lexer.h" + +static int32_t +buffer_get_line_start(Application_Links *app, Buffer_Summary *buffer, int32_t line){ + Partial_Cursor partial_cursor; + int32_t result = buffer->size; + if (line < buffer->line_count){ + app->buffer_compute_cursor(app, buffer, seek_line_char(line, 1), &partial_cursor); + result = partial_cursor.pos; + } + return(result); +} + +static int32_t +buffer_get_line_index(Application_Links *app, Buffer_Summary *buffer, int32_t pos){ + Partial_Cursor partial_cursor; + app->buffer_compute_cursor(app, buffer, seek_pos(pos), &partial_cursor); + return(partial_cursor.line); +} + +static Cpp_Token* +get_first_token_at_line(Application_Links *app, Buffer_Summary *buffer, Cpp_Token_Array tokens, int32_t line){ + int32_t line_start = buffer_get_line_start(app, buffer, line); + Cpp_Get_Token_Result get_token = cpp_get_token(&tokens, line_start); + + if (get_token.in_whitespace){ + get_token.token_index += 1; + } + + Cpp_Token *result = tokens.tokens + get_token.token_index; + + return(result); +} + + // // Fundamental Editing // diff --git a/4coder_types.h b/4coder_types.h index 140f2c73..9bf3fe30 100644 --- a/4coder_types.h +++ b/4coder_types.h @@ -123,15 +123,6 @@ ENUM(int32_t, Event_Message_Type_ID){ EventMessage_CloseView }; -/* DOC(A Buffer_Batch_Edit_Type is a type of batch operation.) */ -ENUM(int32_t, Buffer_Batch_Edit_Type){ - /* DOC(The BatchEdit_Normal operation is always correct but does the most work.) */ - BatchEdit_Normal, - /* DOC(The BatchEdit_PreserveTokens operation is one in which none of the edits add, delete, or change any tokens. - This usually applies when whitespace is being replaced with whitespace.) */ - BatchEdit_PreserveTokens -}; - /* DOC(A Buffer_Setting_ID names a setting in a buffer.) */ ENUM(int32_t, Buffer_Setting_ID){ /* DOC(BufferSetting_Null is not a valid setting, it is reserved to detect errors.) */ @@ -702,14 +693,41 @@ struct Event_Message{ }; /* -DOC(Theme_Color stores a style tag/color pair, for the purpose of setting and getting colors in the theme .) +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{ + /* DOC(The style slot in the style palette.) */ Style_Tag tag; + /* DOC(The color in the slot.) */ int_color color; }; +/* DOC(A Buffer_Batch_Edit_Type is a type of batch operation.) */ +ENUM(int32_t, Buffer_Batch_Edit_Type){ + /* DOC(The BatchEdit_Normal operation is always correct but does the most work if there are tokens to correct.) */ + BatchEdit_Normal, + /* DOC(The BatchEdit_PreserveTokens operation is one in which none of the edits add, delete, or change any tokens. + This usually applies when whitespace is being replaced with whitespace.) */ + BatchEdit_PreserveTokens +}; + +/* +DOC(This struct is used to bundle the parameters of the buffer_batch_edit function. It is convenient +for a few functions that return a batch edit to the user.) +DOC_SEE(buffer_batch_edit) +*/ +struct Buffer_Batch_Edit{ + /* DOC(The pointer to the edit string buffer.) */ + char *str; + /* DOC(The length of the edit string buffer.) */ + int32_t str_len; + + /* DOC(The array of edits to be applied.) */ + Buffer_Edit *edits; + /* DOC(The number of edits in the array.) */ + int32_t edit_count; +}; diff --git a/4ed_api_implementation.cpp b/4ed_api_implementation.cpp index 95a4d5ab..3cbdb926 100644 --- a/4ed_api_implementation.cpp +++ b/4ed_api_implementation.cpp @@ -1295,10 +1295,10 @@ in the system, the call will fail.) Assert(panel_ptr != panel); active = (i32)(panel_ptr - models->layout.panels); } + Assert(active != -1 && panel != models->layout.panels + active); // If the panel we're closing was previously active, we have to switch to it's sibling. if (models->layout.active_panel == (i32)(panel - models->layout.panels)){ - Assert(active != -1 && panel != models->layout.panels + active); models->layout.active_panel = active; } diff --git a/4ed_file_view.cpp b/4ed_file_view.cpp index 1c674764..49daf824 100644 --- a/4ed_file_view.cpp +++ b/4ed_file_view.cpp @@ -5123,26 +5123,6 @@ draw_file_bar(Render_Target *target, View *view, Editing_File *file, i32_Rect re append_ss(&bar_text, make_lit_string(" nix")); } - append_ss(&bar_text, make_lit_string(" -")); - - Command_Map *map = view->map; - if (map == &models->map_top){ - append_ss(&bar_text, make_lit_string(" global")); - } - else if (map == &models->map_file){ - append_ss(&bar_text, make_lit_string(" file")); - } - else if (map == &models->map_ui){ - append_ss(&bar_text, make_lit_string(" gui")); - } - else{ - i32 map_index = (i32)(view->map - models->user_maps); - i32 map_id = models->map_id_table[map_index]; - - append_ss (&bar_text, make_lit_string(" user:")); - append_int_to_str(&bar_text, map_id); - } - intbar_draw_string(target, &bar, bar_text, base_color); diff --git a/TODO.txt b/TODO.txt index 374cd31c..4bb20a64 100644 --- a/TODO.txt +++ b/TODO.txt @@ -82,30 +82,32 @@ ; BEFORE I SHIP ; +; [X] killing compilation panel changes active panel ; [X] tokens in the custom API ; [X] token seeking on custom side ; [X] auto indent on the custom side ; [] clean up and comment the auto indent code to allow for customizations ; [] more built in options for auto indenting ; [] expose dirty flags -; [] option to not open *messages* every startup -; [] commands for resizing panels ; [] make panel resizing not whacky with child panels -; [] killing compilation panel changes active panel -; [] control over how mouse effects panel focus -; [] API docs as text file -; [] user file bar string ; [] mouse down/up distinction ; [] hook on exit -; [] read only files ; [] occasionally missing the (!) mark on files on windows ; [] case insensitive interactive switch buffer -; [] option to hide hidden files -; [] tab to complete folder names in the new file dialogue -; [] view fails to follow cursor when the view is shrunk -; [] view fails to follow cursor after deleting long line ; [] scroll down on compilation buffer durring compilation ; +; + +; [] commands for resizing panels +; [] user file bar string +; [] option to not open *messages* every startup +; [] API docs as text file +; [] read only files +; [] tab to complete folder names in the new file dialogue +; [] option to hide hidden files +; [] view fails to follow cursor when the view is shrunk +; [] view fails to follow cursor after deleting long line +; [] control over how mouse effects panel focus ; TODOS ; [X] success message when compiler works