diff --git a/4coder_API.html b/4coder_API.html index a34af9b9..8b2c90aa 100644 --- a/4coder_API.html +++ b/4coder_API.html @@ -51,6 +51,8 @@ Coming Soon
  • get_view_next
  • get_view
  • get_active_view
  • +
  • open_view
  • +
  • close_view
  • set_active_view
  • view_set_setting
  • view_set_split_proportion
  • @@ -93,6 +95,7 @@ Coming Soon
  • View_Setting_ID
  • Mouse_Cursor_Show_Type
  • Buffer_Seek_Type
  • +
  • View_Split_Position
  • Key_Modifier_Flag
  • Buffer_Create_Flag
  • Buffer_Kill_Flag
  • @@ -247,13 +250,13 @@ Buffers should not be killed durring a buffer loop.
    Parameters
    buffer
    -
    The buffer summary pointed to by buffer is iterated to the next buffer or to a null summary if this is the last buffer.
    +
    The Buffer_Summary pointed to by buffer is iterated to the next buffer or to a null summary if this is the last buffer.
    access
    The access parameter determines what levels of protection this call can access. The buffer outputted will be the next buffer that is accessible.
    -
    Description
    This call steps a buffer summary to the next buffer in the global buffer order. +
    Description
    This call steps a Buffer_Summary to the next buffer in the global buffer order. The global buffer order is kept roughly in the order of most recently used to least recently used. If the buffer outputted does not exist, the loop is finished. @@ -438,7 +441,7 @@ completed this function will fail.
    The flags parameter specifies behaviors for buffer creation.
    Return
    This call returns the summary of the created buffer.
    Description
    Tries to create a new buffer and associate it to the given filename. If such a buffer already -exists the existing buffer is returned in the buffer summary and no new buffer is created. +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

    @@ -495,7 +498,7 @@ If the view is not open the kill fails.
    Return
    This call returns the summary of the first view in a view loop.
    Description
    This call begins a loop across all the open views. -If the view summary returned is a null summary, the loop is finished. +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

    §3.3.19: get_view_next

    @@ -504,13 +507,13 @@ Views should not be closed or opened durring a view loop.
    Parameters
    view
    -
    pointer to the loop view originally returned by get_view_first
    +
    The View_Summary pointed to by view is iterated to the next view or to a null summary if this is the last view.
    access
    The access parameter determines what levels of protection this call can access. The view outputted will be the next view that is accessible.
    -
    Description
    This call steps a view summary to the next view in the global view order. +
    Description
    This call steps a View_Summary to the next view in the global view order. If the view outputted does not exist, the loop is finished. Views should not be closed or opened durring a view loop.
    See Also
    Access_Flag
    get_view_first

    @@ -538,8 +541,37 @@ Views should not be closed or opened durring a view loop.
    The access parameter determines what levels of protection this call can access.
    Return
    This call returns a summary that describes the active view.
    See Also
    set_active_view
    Access_Flag

    +
    +

    §3.3.22: open_view

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

    +
    +

    §3.3.23: close_view

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

    -

    §3.3.22: set_active_view

    +

    §3.3.24: set_active_view

    bool32 app->set_active_view(
    Application_Links *app,
    View_Summary *view
    )
    @@ -551,7 +583,7 @@ Views should not be closed or opened durring a view loop.
    See Also
    get_active_view

    -

    §3.3.23: view_set_setting

    +

    §3.3.25: view_set_setting

    bool32 app->view_set_setting(
    Application_Links *app,
    View_Summary *view,
    View_Setting_ID setting,
    int32_t value
    )
    @@ -569,7 +601,7 @@ from get_active_view.
    Return
    This call returns non-zero on success.
    See Also
    View_Setting_ID

    -

    §3.3.24: view_set_split_proportion

    +

    §3.3.26: view_set_split_proportion

    bool32 app->view_set_split_proportion(
    Application_Links *app,
    View_Summary *view,
    float t
    )
    @@ -583,7 +615,7 @@ from get_active_view.
    Return
    This call returns non-zero on success.

    -

    §3.3.25: view_compute_cursor

    +

    §3.3.27: view_compute_cursor

    bool32 app->view_compute_cursor(
    Application_Links *app,
    View_Summary *view,
    Buffer_Seek seek,
    Full_Cursor *cursor_out
    )
    @@ -601,7 +633,7 @@ from get_active_view.
    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

    -

    §3.3.26: view_set_cursor

    +

    §3.3.28: view_set_cursor

    bool32 app->view_set_cursor(
    Application_Links *app,
    View_Summary *view,
    Buffer_Seek seek,
    bool32 set_preferred_x
    )
    @@ -621,7 +653,7 @@ from get_active_view.
    See Also
    Buffer_Seek

    -

    §3.3.27: view_set_mark

    +

    §3.3.29: view_set_mark

    bool32 app->view_set_mark(
    Application_Links *app,
    View_Summary *view,
    Buffer_Seek seek
    )
    @@ -635,7 +667,7 @@ cursor in the same column or x position.
    Return
    This call returns non-zero on success.
    Description
    This call sets the the view's mark position.
    See Also
    Buffer_Seek

    -

    §3.3.28: view_set_highlight

    +

    §3.3.30: view_set_highlight

    bool32 app->view_set_highlight(
    Application_Links *app,
    View_Summary *view,
    int32_t start,
    int32_t end,
    bool32 turn_on
    )
    @@ -660,7 +692,7 @@ 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.

    -

    §3.3.29: view_set_buffer

    +

    §3.3.31: view_set_buffer

    bool32 app->view_set_buffer(
    Application_Links *app,
    View_Summary *view,
    Buffer_ID buffer_id,
    Set_Buffer_Flag flags
    )
    @@ -679,7 +711,7 @@ the turn_on set to false, will switch back to showing the cursor.

    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
    Set_Buffer_Flag

    -

    §3.3.30: view_post_fade

    +

    §3.3.32: 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
    )
    @@ -705,7 +737,7 @@ cancels and dialogue shown in the view and displays the file.
    Return
    This call returns non-zero on success.
    See Also
    int_color

    -

    §3.3.31: get_user_input

    +

    §3.3.33: get_user_input

    User_Input app->get_user_input(
    Application_Links *app,
    Input_Type_Flag get_type,
    Input_Type_Flag abort_type
    )
    @@ -723,19 +755,19 @@ command is executed an abort signal is returned. If an abort signal is ever ret 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
    Input_Type_Flag
    User_Input

    -

    §3.3.32: get_command_input

    +

    §3.3.34: get_command_input

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

    -

    §3.3.33: get_mouse_state

    +

    §3.3.35: get_mouse_state

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

    -

    §3.3.34: start_query_bar

    +

    §3.3.36: start_query_bar

    bool32 app->start_query_bar(
    Application_Links *app,
    Query_Bar *bar,
    uint32_t flags
    )
    @@ -755,7 +787,7 @@ can be changed after the call to start_query_bar and the query bar shown by 4cod will reflect the change. Since the bar stops showing when the command exits the only use for this call is in an interactive command that makes calls to get_user_input.

    -

    §3.3.35: end_query_bar

    +

    §3.3.37: end_query_bar

    void app->end_query_bar(
    Application_Links *app,
    Query_Bar *bar,
    uint32_t flags
    )
    @@ -769,7 +801,7 @@ only use for this call is in an interactive command that makes calls to get_user
    Description
    Stops showing the particular query bar specified by the bar parameter.

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

    -

    §3.3.37: change_theme

    +

    §3.3.39: change_theme

    void app->change_theme(
    Application_Links *app,
    char *name,
    int32_t len
    )
    @@ -797,7 +829,7 @@ only use for this call is in an interactive command that makes calls to get_user
    Description
    This call changes 4coder's theme to one of the built in themes.

    -

    §3.3.38: change_font

    +

    §3.3.40: change_font

    void app->change_font(
    Application_Links *app,
    char *name,
    int32_t len
    )
    @@ -811,7 +843,7 @@ only use for this call is in an interactive command that makes calls to get_user
    Description
    This call changes 4coder's font to one of the built in fonts.

    -

    §3.3.39: set_theme_colors

    +

    §3.3.41: set_theme_colors

    void app->set_theme_colors(
    Application_Links *app,
    Theme_Color *colors,
    int32_t count
    )
    @@ -827,7 +859,7 @@ only use for this call is in an interactive command that makes calls to get_user struct's tag is set to the color code in the struct. If the tag value is invalid no change is made to the color pallet.

    -

    §3.3.40: get_theme_colors

    +

    §3.3.42: get_theme_colors

    void app->get_theme_colors(
    Application_Links *app,
    Theme_Color *colors,
    int32_t count
    )
    @@ -843,7 +875,7 @@ no change is made to the color pallet.

    color from the slot in the main color pallet specified by the tag. If the tag value is invalid the color is filled with black.
    -

    §3.3.41: directory_get_hot

    +

    §3.3.43: directory_get_hot

    int32_t app->directory_get_hot(
    Application_Links *app,
    char *out,
    int32_t capacity
    )
    @@ -861,7 +893,7 @@ accessed in the GUI. Whenever the GUI is opened it shows the hot directory. In the future this will be deprecated and eliminated in favor of more flexible directories controlled on the custom side.

    -

    §3.3.42: get_file_list

    +

    §3.3.44: get_file_list

    File_List app->get_file_list(
    Application_Links *app,
    char *dir,
    int32_t len
    )
    @@ -877,7 +909,7 @@ directories controlled on the custom side.

    the specified directory. The File_List returned should be passed to free_file_list when it is no longer in use.
    -

    §3.3.43: free_file_list

    +

    §3.3.45: free_file_list

    void app->free_file_list(
    Application_Links *app,
    File_List list
    )
    @@ -887,7 +919,7 @@ when it is no longer in use.

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

    -

    §3.3.44: file_exists

    +

    §3.3.46: file_exists

    bool32 app->file_exists(
    Application_Links *app,
    char *filename,
    int len
    )
    @@ -901,7 +933,7 @@ when it is no longer in use.

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

    -

    §3.3.45: directory_cd

    +

    §3.3.47: directory_cd

    bool32 app->directory_cd(
    Application_Links *app,
    char *dir,
    int *len,
    int capacity,
    char *rel_path,
    int rel_len
    )
    @@ -934,7 +966,7 @@ will contain "C:/Users/MySelf/Documents" and len will contain the length of that string. This call can also be used with rel set to ".." to traverse to parent folders.

    -

    §3.3.46: get_4ed_path

    +

    §3.3.48: get_4ed_path

    bool32 app->get_4ed_path(
    Application_Links *app,
    char *out,
    int32_t capacity
    )
    @@ -948,7 +980,7 @@ folders.

    Return
    This call returns non-zero on success.

    -

    §3.3.47: show_mouse_cursor

    +

    §3.3.49: show_mouse_cursor

    void app->show_mouse_cursor(
    Application_Links *app,
    Mouse_Cursor_Show_Type show
    )
    @@ -1055,26 +1087,10 @@ the range [1,16].

    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.
    @@ -1135,10 +1151,6 @@ the range [1,16].
    cmdid_close_panel closes the active panel.
    -
    cmdid_change_active_panel
    -
    cmdid_change_active_panel cycles to the next open panel.
    -
    -
    cmdid_count
    @@ -1264,8 +1276,29 @@ coordinates are suppose to be used for the seek.
    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.14: 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.14: Key_Modifier_Flag

    +

    §3.4.15: 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
    @@ -1286,7 +1319,7 @@ Flags can be combined with bit or to specify a state with multiple modifiers.

    -

    §3.4.15: Buffer_Create_Flag

    +

    §3.4.16: Buffer_Create_Flag

    enum Buffer_Create_Flag;
    Description
    A Buffer_Create_Flag field specifies how a buffer should be created.
    Flags
    BufferCreate_Background = 0x1
    @@ -1299,7 +1332,7 @@ Flags can be combined with bit or to specify a state with multiple modifiers.

    -

    §3.4.16: Buffer_Kill_Flag

    +

    §3.4.17: Buffer_Kill_Flag

    enum Buffer_Kill_Flag;
    Description
    A Buffer_Kill_Flag field specifies how a buffer should be killed.
    Flags
    BufferKill_Background = 0x1
    @@ -1312,7 +1345,7 @@ Flags can be combined with bit or to specify a state with multiple modifiers.

    -

    §3.4.17: Access_Flag

    +

    §3.4.18: 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 @@ -1342,7 +1375,7 @@ that protection flag, the object is still returned from the access call.

    -

    §3.4.18: Seek_Boundary_Flag

    +

    §3.4.19: 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
    @@ -1363,7 +1396,7 @@ beginning or end of different types of words.
    -

    §3.4.19: Command_Line_Input_Flag

    +

    §3.4.20: 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
    @@ -1384,7 +1417,7 @@ beginning or end of different types of words.
    -

    §3.4.20: Auto_Indent_Flag

    +

    §3.4.21: 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
    @@ -1400,7 +1433,7 @@ beginning or end of different types of words.
    -

    §3.4.21: Set_Buffer_Flag

    +

    §3.4.22: 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
    @@ -1410,7 +1443,7 @@ beginning or end of different types of words.
    -

    §3.4.22: Input_Type_Flag

    +

    §3.4.23: Input_Type_Flag

    enum Input_Type_Flag;
    Description
    A Input_Type_Flag field specifies a set of input event types.
    Flags
    EventOnAnyKey = 0x1
    @@ -1450,7 +1483,7 @@ beginning or end of different types of words.
    -

    §3.4.23: Generic_Command

    +

    §3.4.24: Generic_Command

    union Generic_Command {
    Command_ID cmdid;
    @@ -1471,7 +1504,7 @@ internal command or a custom command.
    -

    §3.4.24: Key_Event_Data

    +

    §3.4.25: Key_Event_Data

    struct Key_Event_Data {
    Key_Code keycode;
    @@ -1505,7 +1538,7 @@ at the time of the event.
    -

    §3.4.25: Mouse_State

    +

    §3.4.26: Mouse_State

    struct Mouse_State {
    char l;
    @@ -1565,7 +1598,7 @@ mouse if in the window.
    -

    §3.4.26: Range

    +

    §3.4.27: Range

    union Range {
    struct {
    @@ -1605,7 +1638,7 @@ Throughout the API ranges are thought of in the form [min,max
    -

    §3.4.27: File_Info

    +

    §3.4.28: File_Info

    struct File_Info {
    char * filename;
    @@ -1628,7 +1661,7 @@ int folder;
    See Also

    -

    §3.4.28: File_List

    +

    §3.4.29: File_List

    struct File_List {
    void * block;
    @@ -1656,7 +1689,7 @@ int block_size;

    -

    §3.4.29: Buffer_Identifier

    +

    §3.4.30: Buffer_Identifier

    struct Buffer_Identifier {
    char * name;
    @@ -1681,7 +1714,7 @@ can either be a name or an id. If the
    -

    §3.4.30: GUI_Scroll_Vars

    +

    §3.4.31: GUI_Scroll_Vars

    struct GUI_Scroll_Vars {
    float scroll_y;
    @@ -1724,7 +1757,7 @@ int32_t prev_target_x;

    -

    §3.4.31: Full_Cursor

    +

    §3.4.32: Full_Cursor

    struct Full_Cursor {
    int32_t pos;
    @@ -1768,7 +1801,7 @@ coordinate system supported by 4coder.
    See Also

    -

    §3.4.32: Buffer_Seek

    +

    §3.4.33: Buffer_Seek

    struct Buffer_Seek {
    Buffer_Seek_Type type;
    @@ -1833,7 +1866,7 @@ for concisely creating Buffer_Seek structs. They can be found in 4coder_buffer_
    See Also

    -

    §3.4.33: Buffer_Summary

    +

    §3.4.34: Buffer_Summary

    struct Buffer_Summary {
    bool32 exists;
    @@ -1903,7 +1936,7 @@ bool32 unwrapped_lines;
    See Also

    -

    §3.4.34: View_Summary

    +

    §3.4.35: View_Summary

    struct View_Summary {
    bool32 exists;
    @@ -1973,7 +2006,7 @@ GUI_Scroll_Vars scroll_vars;
    See Also

    -

    §3.4.35: User_Input

    +

    §3.4.36: User_Input

    struct User_Input {
    User_Input_Type_ID type;
    @@ -2010,7 +2043,7 @@ Generic_Command command;
    See Also

    -

    §3.4.36: Query_Bar

    +

    §3.4.37: Query_Bar

    struct Query_Bar {
    String prompt;
    @@ -2029,7 +2062,7 @@ that will be displayed as a drop down bar durring an interactive command.
    <

    -

    §3.4.37: Event_Message

    +

    §3.4.38: Event_Message

    struct Event_Message {
    int type;
    @@ -2042,7 +2075,7 @@ int type;

    -

    §3.4.38: Theme_Color

    +

    §3.4.39: Theme_Color

    struct Theme_Color {
    Style_Tag tag;
    diff --git a/4coder_custom_api.h b/4coder_custom_api.h index a6ed9295..45c7282e 100644 --- a/4coder_custom_api.h +++ b/4coder_custom_api.h @@ -19,6 +19,8 @@ #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 OPEN_VIEW_SIG(n) View_Summary n(Application_Links *app, View_Summary *view_location, View_Split_Position position) +#define CLOSE_VIEW_SIG(n) bool32 n(Application_Links *app, View_Summary *view) #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) @@ -67,6 +69,8 @@ extern "C"{ typedef GET_VIEW_NEXT_SIG(Get_View_Next_Function); typedef GET_VIEW_SIG(Get_View_Function); typedef GET_ACTIVE_VIEW_SIG(Get_Active_View_Function); + typedef OPEN_VIEW_SIG(Open_View_Function); + typedef CLOSE_VIEW_SIG(Close_View_Function); typedef SET_ACTIVE_VIEW_SIG(Set_Active_View_Function); typedef VIEW_SET_SETTING_SIG(View_Set_Setting_Function); typedef VIEW_SET_SPLIT_PROPORTION_SIG(View_Set_Split_Proportion_Function); @@ -118,6 +122,8 @@ struct Application_Links{ Get_View_Next_Function *get_view_next; Get_View_Function *get_view; Get_Active_View_Function *get_active_view; + Open_View_Function *open_view; + Close_View_Function *close_view; Set_Active_View_Function *set_active_view; View_Set_Setting_Function *view_set_setting; View_Set_Split_Proportion_Function *view_set_split_proportion; @@ -171,6 +177,8 @@ app_links->get_view_first = Get_View_First;\ app_links->get_view_next = Get_View_Next;\ app_links->get_view = Get_View;\ app_links->get_active_view = Get_Active_View;\ +app_links->open_view = Open_View;\ +app_links->close_view = Close_View;\ app_links->set_active_view = Set_Active_View;\ app_links->view_set_setting = View_Set_Setting;\ app_links->view_set_split_proportion = View_Set_Split_Proportion;\ diff --git a/4coder_default_bindings.cpp b/4coder_default_bindings.cpp index b7b1672f..e5df52ac 100644 --- a/4coder_default_bindings.cpp +++ b/4coder_default_bindings.cpp @@ -125,9 +125,9 @@ CUSTOM_COMMAND_SIG(seek_whitespace_down_end_line){ } HOOK_SIG(my_start){ - exec_command(app, cmdid_open_panel_vsplit); + exec_command(app, open_panel_vsplit); exec_command(app, hide_scrollbar); - exec_command(app, cmdid_change_active_panel); + exec_command(app, change_active_panel); exec_command(app, hide_scrollbar); app->change_theme(app, literal("4coder")); @@ -246,9 +246,9 @@ void default_keys(Bind_Helper *context){ begin_map(context, mapid_global); - bind(context, 'p', MDFR_CTRL, cmdid_open_panel_vsplit); - bind(context, '_', MDFR_CTRL, cmdid_open_panel_hsplit); - bind(context, 'P', MDFR_CTRL, cmdid_close_panel); + bind(context, 'p', MDFR_CTRL, open_panel_vsplit); + bind(context, '_', MDFR_CTRL, open_panel_hsplit); + bind(context, 'P', MDFR_CTRL, close_panel); bind(context, 'n', MDFR_CTRL, cmdid_interactive_new); bind(context, 'o', MDFR_CTRL, cmdid_interactive_open); bind(context, ',', MDFR_CTRL, change_active_panel); @@ -298,7 +298,7 @@ default_keys(Bind_Helper *context){ bind(context, '=', MDFR_CTRL, write_increment); bind(context, 't', MDFR_ALT, write_allen_todo); bind(context, 'y', MDFR_ALT, write_allen_note); - bind(context, 'r', MDFR_ALT, write_allen_note); + bind(context, 'r', MDFR_ALT, write_allen_doc); bind(context, '[', MDFR_CTRL, open_long_braces); bind(context, '{', MDFR_CTRL, open_long_braces_semicolon); bind(context, '}', MDFR_CTRL, open_long_braces_break); diff --git a/4coder_default_include.cpp b/4coder_default_include.cpp index 78d46f42..666f3058 100644 --- a/4coder_default_include.cpp +++ b/4coder_default_include.cpp @@ -857,7 +857,54 @@ CUSTOM_COMMAND_SIG(hide_scrollbar){ } // +// Panel Management // + +CUSTOM_COMMAND_SIG(change_active_panel_regular){ + View_Summary view = app->get_active_view(app, AccessAll); + app->get_view_next(app, &view, AccessAll); + if (!view.exists){ + view = app->get_view_first(app, AccessAll); + } + if (view.exists){ + app->set_active_view(app, &view); + } +} + +// TODO(allen): This is a bit nasty. I want a system for picking +// the most advanced and correct version of a command to bind to a +// name based on which files are included. +#ifndef CHANGE_ACTIVE_PANEL +# define CHANGE_ACTIVE_PANEL 1 +#elif CHANGE_ACTIVE_PANEL <= 1 +# undef CHANGE_ACTIVE_PANEL +# define CHANGE_ACTIVE_PANEL 1 +#endif + +#if CHANGE_ACTIVE_PANEL <= 1 +# ifdef change_active_panel +# undef change_active_panel +# endif +# define change_active_panel change_active_panel_regular +#endif + +CUSTOM_COMMAND_SIG(close_panel){ + View_Summary view = app->get_active_view(app, AccessAll); + app->close_view(app, &view); +} + +CUSTOM_COMMAND_SIG(open_panel_vsplit){ + View_Summary view = app->get_active_view(app, AccessAll); + app->open_view(app, &view, ViewSplit_Right); +} + +CUSTOM_COMMAND_SIG(open_panel_hsplit){ + View_Summary view = app->get_active_view(app, AccessAll); + app->open_view(app, &view, ViewSplit_Bottom); +} + +// +// Open File In Quotes // static int @@ -898,7 +945,7 @@ CUSTOM_COMMAND_SIG(open_file_in_quotes_regular){ String file_name = make_fixed_width_string(file_name_); if (file_name_in_quotes(app, &file_name)){ - exec_command(app, cmdid_change_active_panel); + exec_command(app, change_active_panel_regular); View_Summary view = app->get_active_view(app, AccessAll); view_open_file(app, &view, expand_str(file_name), false); } @@ -1296,7 +1343,7 @@ CUSTOM_COMMAND_SIG(execute_previous_cli){ } CUSTOM_COMMAND_SIG(open_in_other_regular){ - exec_command(app, cmdid_change_active_panel); + exec_command(app, change_active_panel_regular); exec_command(app, cmdid_interactive_open); } @@ -1494,28 +1541,6 @@ CUSTOM_COMMAND_SIG(build_search_regular){ #endif -CUSTOM_COMMAND_SIG(change_active_panel_regular){ - exec_command(app, cmdid_change_active_panel); -} - -// TODO(allen): This is a bit nasty. I want a system for picking -// the most advanced and correct version of a command to bind to a -// name based on which files are included. -#ifndef CHANGE_ACTIVE_PANEL -# define CHANGE_ACTIVE_PANEL 1 -#elif CHANGE_ACTIVE_PANEL <= 1 -# undef CHANGE_ACTIVE_PANEL -# define CHANGE_ACTIVE_PANEL 1 -#endif - -#if CHANGE_ACTIVE_PANEL <= 1 -# ifdef change_active_panel -# undef change_active_panel -# endif -# define change_active_panel change_active_panel_regular -#endif - - // // Common Settings Commands // @@ -1530,6 +1555,7 @@ CUSTOM_COMMAND_SIG(toggle_line_wrap){ } app->view_set_setting(app, &view, ViewSetting_WrapLine, unwrapped); + app->buffer_set_setting(app, &buffer, BufferSetting_WrapLine, unwrapped); } CUSTOM_COMMAND_SIG(toggle_show_whitespace){ diff --git a/4coder_types.h b/4coder_types.h index 82033f2d..2aa85ca0 100644 --- a/4coder_types.h +++ b/4coder_types.h @@ -72,23 +72,9 @@ ENUM(uint64_t, Command_ID){ /* DOC(cmdid_to_uppercase makes all the alphabetic characters in the cursor/mark range lowercase.) */ cmdid_to_lowercase, -#if 0 - /* DOC(cmdid_toggle_line_wrap toggles the line wrap setting of the active view. ) */ - cmdid_toggle_line_wrap, - /* DOC(cmdid_toggle_line_wrap toggles the show whitespace setting of the active view.) */ - cmdid_toggle_show_whitespace, -#endif - /* DOC(cmdid_clean_all_lines deletes extra whitespace out the currently active buffer.) */ cmdid_clean_all_lines, -#if 0 - /* DOC(cmdid_eol_dosify sets the currently active buffer to dos save mode where the end of a line is "\r\n") */ - cmdid_eol_dosify, - /* DOC(cmdid_eol_nixify sets the currently active buffer to nix save mode where the end of a line is "\n") */ - cmdid_eol_nixify, -#endif - /* DOC(cmdid_interactive_new begins an interactive dialogue to create a new buffer.) */ cmdid_interactive_new, /* DOC(cmdid_interactive_open begins an interactive dialogue to open a file into a buffer.) */ @@ -115,15 +101,15 @@ ENUM(uint64_t, Command_ID){ /* DOC(cmdid_open_debug opens the debug information viewer mode.) */ cmdid_open_debug, +#if 0 /* DOC(cmdid_open_panel_vsplit splits the current panel into two with a vertical divider.) */ cmdid_open_panel_vsplit, /* DOC(cmdid_open_panel_hsplit splits the current panel into two with a horizontal divider.) */ cmdid_open_panel_hsplit, /* DOC(cmdid_close_panel closes the active panel.) */ cmdid_close_panel, - /* DOC(cmdid_change_active_panel cycles to the next open panel.) */ - cmdid_change_active_panel, - +#endif + // count cmdid_count }; @@ -325,6 +311,19 @@ ENUM(int32_t, Buffer_Seek_Type){ buffer_seek_line_char }; +/* DOC(A View_Split_Position specifies where a new view should be placed as a result of +a view split operation.) */ +ENUM(int32_t, View_Split_Position){ + /* DOC(This value indicates that the new view should be above the existing view.) */ + ViewSplit_Top, + /* DOC(This value indicates that the new view should be below the existing view.) */ + ViewSplit_Bottom, + /* DOC(This value indicates that the new view should be left of the existing view.) */ + ViewSplit_Left, + /* DOC(This value indicates that the new view should be right of the existing view.) */ + ViewSplit_Right +}; + /* DOC( Generic_Command acts as a name for a command, and can name an internal command or a custom command. diff --git a/4ed.cpp b/4ed.cpp index 272b3221..c2fe5976 100644 --- a/4ed.cpp +++ b/4ed.cpp @@ -659,14 +659,6 @@ COMMAND_DECL(toggle_line_wrap){ view_set_relative_scrolling(view, scrolling); } -#if 0 -COMMAND_DECL(toggle_show_whitespace){ - REQ_READABLE_VIEW(view); - - view->file_data.show_whitespace = !view->file_data.show_whitespace; -} -#endif - COMMAND_DECL(toggle_tokens){ #if BUFFER_EXPERIMENT_SCALPEL <= 0 USE_MODELS(models); @@ -737,24 +729,6 @@ COMMAND_DECL(clean_all_lines){ view_clean_whitespace(system, models, view); } -#if 0 -COMMAND_DECL(eol_dosify){ - REQ_READABLE_VIEW(view); - REQ_FILE(file, view); - - file->settings.dos_write_mode = 1; - file->state.last_4ed_edit_time = system->now_time_stamp(); -} - -COMMAND_DECL(eol_nixify){ - REQ_READABLE_VIEW(view); - REQ_FILE(file, view); - - file->settings.dos_write_mode = 0; - file->state.last_4ed_edit_time = system->now_time_stamp(); -} -#endif - COMMAND_DECL(open_panel_vsplit){ USE_VARS(vars); USE_MODELS(models); @@ -1066,11 +1040,6 @@ setup_command_table(){ SET(clean_all_lines); - SET(open_panel_vsplit); - SET(open_panel_hsplit); - SET(close_panel); - SET(change_active_panel); - SET(open_color_tweaker); SET(open_config); SET(open_menu); diff --git a/4ed_api_implementation.cpp b/4ed_api_implementation.cpp index 57abcd59..c2a37000 100644 --- a/4ed_api_implementation.cpp +++ b/4ed_api_implementation.cpp @@ -453,11 +453,11 @@ DOC_SEE(get_buffer_next) API_EXPORT void 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(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 ( -This call steps a buffer summary to the next buffer in the global buffer order. +This call steps a Buffer_Summary to the next buffer in the global buffer order. The global buffer order is kept roughly in the order of most recently used to least recently used. If the buffer outputted does not exist, the loop is finished. @@ -830,7 +830,7 @@ 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 -exists the existing buffer is returned in the buffer summary and no new buffer is created. +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. @@ -1021,7 +1021,7 @@ DOC ( This call begins a loop across all the open views. -If the view summary returned is a null summary, 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) @@ -1040,11 +1040,11 @@ DOC_SEE(get_view_next) API_EXPORT void 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(view, The View_Summary pointed to by view is iterated to the next view or to a null summary if this is the last view.) 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 ( -This call steps a view summary to the next view in the global view order. +This call steps a View_Summary to the next view in the global view order. If the view outputted does not exist, the loop is finished. Views should not be closed or opened durring a view loop. @@ -1101,6 +1101,164 @@ DOC_SEE(Access_Flag) return(view); } +API_EXPORT View_Summary +Open_View(Application_Links *app, View_Summary *view_location, View_Split_Position position)/* +DOC_PARAM(view_location, The view_location parameter specifies the view to split to open the new view.) +DOC_PARAM(position, The position parameter specifies how to split the view and where to place the new view.) +DOC_RETURN(If this call succeeds it returns a View_Summary describing the newly created view, if it fails it +returns a null summary.) +DOC(4coder is built with a limit of 16 views. If 16 views are already open when this is called the +call will fail.) +DOC_SEE(View_Split_Position) +*/{ + Command_Data *cmd = (Command_Data*)app->cmd_context; + System_Functions *system = cmd->system; + Models *models = cmd->models; + View *vptr = imp_get_view(cmd, view_location); + Panel *panel = vptr->panel; + View_Summary result = {0}; + + if (models->layout.panel_count < models->layout.panel_max_count){ + b32 vsplit = ((position == ViewSplit_Left) || (position == ViewSplit_Right)); + b32 grtsplit = ((position == ViewSplit_Bottom) || (position == ViewSplit_Right)); + + Split_Result split = layout_split_panel(&models->layout, panel, vsplit); + + Panel *grtpanel = split.panel; + Panel *lsrpanel = panel; + + if (!grtsplit){ + Swap(i32, panel->which_child, split.panel->which_child); + Swap(Panel*, grtpanel, lsrpanel); + } + + split.panel->screen_region = panel->screen_region; + if (vsplit){ + i32 x_pos = ROUND32(lerp((f32)lsrpanel->full.x0, + split.divider->pos, + (f32)lsrpanel->full.x1)); + + grtpanel->full.x0 = x_pos; + grtpanel->full.x1 = lsrpanel->full.x1; + lsrpanel->full.x1 = x_pos; + } + else{ + i32 y_pos = ROUND32(lerp((f32)lsrpanel->full.y0, + split.divider->pos, + (f32)lsrpanel->full.y1)); + + grtpanel->full.y0 = y_pos; + grtpanel->full.y1 = lsrpanel->full.y1; + lsrpanel->full.y1 = y_pos; + } + + panel_fix_internal_area(panel); + panel_fix_internal_area(split.panel); + split.panel->prev_inner = split.panel->inner; + + models->layout.active_panel = (i32)(split.panel - models->layout.panels); + panel_make_empty(system, cmd->vars, split.panel); + } + + update_command_data(cmd->vars, cmd); + + return(result); +} + +API_EXPORT bool32 +Close_View(Application_Links *app, View_Summary *view)/* +DOC_PARAM(view, The view parameter specifies which view to close.) +DOC_RETURN(This call returns non-zero on success.) +DOC( +If the given view is open and is not the last view, it will be closed. +If the given view is the active view, the next active view in the global +order of view will be made active. +If the given view is the last open view in the system, the call will fail. +) +*/{ + Command_Data *cmd = (Command_Data*)app->cmd_context; + System_Functions *system = cmd->system; + Models *models = cmd->models; + View *vptr = imp_get_view(cmd, view); + Panel *panel = vptr->panel; + bool32 result = false; + + Divider_And_ID div, parent_div, child_div; + i32 child; + i32 parent; + i32 which_child; + i32 active; + + if (models->layout.panel_count > 1){ + live_set_free_view(system, models->live_set, vptr); + panel->view = 0; + + div = layout_get_divider(&models->layout, panel->parent); + + // This divider cannot have two child dividers. + Assert(div.divider->child1 == -1 || div.divider->child2 == -1); + + // Get the child who needs to fill in this node's spot + child = div.divider->child1; + if (child == -1) child = div.divider->child2; + + parent = div.divider->parent; + which_child = div.divider->which_child; + + // Fill the child in the slot this node use to hold + if (parent == -1){ + Assert(models->layout.root == div.id); + models->layout.root = child; + } + else{ + parent_div = layout_get_divider(&models->layout, parent); + if (which_child == -1){ + parent_div.divider->child1 = child; + } + else{ + parent_div.divider->child2 = child; + } + } + + // If there was a child divider, give it information about it's new parent. + if (child != -1){ + child_div = layout_get_divider(&models->layout, child); + child_div.divider->parent = parent; + child_div.divider->which_child = div.divider->which_child; + } + + // What is the new active panel? + active = -1; + if (child == -1){ + Panel *panel_ptr = 0; + Panel *used_panels = &models->layout.used_sentinel; + for (dll_items(panel_ptr, used_panels)){ + if (panel_ptr != panel && panel_ptr->parent == div.id){ + panel_ptr->parent = parent; + panel_ptr->which_child = which_child; + active = (i32)(panel_ptr - models->layout.panels); + break; + } + } + } + else{ + Panel *panel_ptr = panel->next; + if (panel_ptr == &models->layout.used_sentinel) panel_ptr = panel_ptr->next; + Assert(panel_ptr != panel); + active = (i32)(panel_ptr - models->layout.panels); + } + + Assert(active != -1 && panel != models->layout.panels + active); + models->layout.active_panel = active; + + layout_free_divider(&models->layout, div.divider); + layout_free_panel(&models->layout, panel); + layout_fix_all_panels(&models->layout); + } + + return(result); +} + API_EXPORT bool32 Set_Active_View(Application_Links *app, View_Summary *view)/* DOC_PARAM(view, The view parameter specifies which view to make active.) diff --git a/4ed_layout.cpp b/4ed_layout.cpp index d8776f39..3b5463b6 100644 --- a/4ed_layout.cpp +++ b/4ed_layout.cpp @@ -188,25 +188,22 @@ layout_split_panel(Editing_Layout *layout, Panel *panel, b32 vertical){ div.divider->which_child = panel->which_child; if (vertical){ div.divider->v_divider = 1; - //div.divider->pos = (panel->full.x0 + panel->full.x1) / 2; - div.divider->pos = 0.5f; } else{ div.divider->v_divider = 0; - //div.divider->pos = (panel->full.y0 + panel->full.y1) / 2; - div.divider->pos = 0.5f; } - + div.divider->pos = 0.5f; + new_panel = layout_alloc_panel(layout); panel->parent = div.id; panel->which_child = -1; new_panel.panel->parent = div.id; new_panel.panel->which_child = 1; - + result.divider = div.divider; result.panel = new_panel.panel; - return result; + return(result); } internal void diff --git a/README.txt b/README.txt index 9ab48f1b..8189b338 100644 --- a/README.txt +++ b/README.txt @@ -1,4 +1,4 @@ -Distribution Date: 3.7.2016 (dd.mm.yyyy) +Distribution Date: 4.7.2016 (dd.mm.yyyy) Thank you for contributing to the 4coder project! diff --git a/SUPERREADME.txt b/SUPERREADME.txt index ce004739..d31dd804 100644 --- a/SUPERREADME.txt +++ b/SUPERREADME.txt @@ -1,4 +1,4 @@ -Distribution Date: 3.7.2016 (dd.mm.yyyy) +Distribution Date: 4.7.2016 (dd.mm.yyyy) Thank you for contributing to the 4coder project! diff --git a/TODO.txt b/TODO.txt index bf123c30..c53e3b61 100644 --- a/TODO.txt +++ b/TODO.txt @@ -104,6 +104,7 @@ ; [] generate documentation for custom API ; [] OS font rendering ; [] support full length unicode file names +; [] switch based word complete ; ; [] file status in custom API ; [] user file bar string diff --git a/power/4coder_default_building.cpp b/power/4coder_default_building.cpp index 0f3113a0..641e8570 100644 --- a/power/4coder_default_building.cpp +++ b/power/4coder_default_building.cpp @@ -35,7 +35,7 @@ CUSTOM_COMMAND_SIG(build_in_build_panel){ } if (!build_view.exists){ - exec_command(app, cmdid_open_panel_hsplit); + exec_command(app, open_panel_hsplit); exec_command(app, hide_scrollbar); build_view = app->get_active_view(app, AccessAll); app->view_set_split_proportion(app, &build_view, .2f); @@ -69,13 +69,13 @@ CUSTOM_COMMAND_SIG(build_in_build_panel){ CUSTOM_COMMAND_SIG(close_build_panel){ Buffer_Summary buffer = GET_COMP_BUFFER(); + View_Summary build_view = get_first_view_with_buffer(app, buffer.buffer_id); - if (buffer.exists){ - View_Summary build_view = get_first_view_with_buffer(app, buffer.buffer_id); + if (build_view.exists){ View_Summary original_view = app->get_active_view(app, AccessAll); app->set_active_view(app, &build_view); - exec_command(app, cmdid_close_panel); + exec_command(app, close_panel); app->set_active_view(app, &original_view); } } @@ -99,18 +99,18 @@ CUSTOM_COMMAND_SIG(change_active_panel_build){ View_Summary view = app->get_active_view(app, AccessAll); int prev_view_id = view.view_id; - exec_command(app, cmdid_change_active_panel); + exec_command(app, change_active_panel_regular); view = app->get_active_view(app, AccessAll); for (;(view.view_id != prev_view_id && build_view.view_id == view.view_id);){ prev_view_id = view.view_id; - exec_command(app, cmdid_change_active_panel); + exec_command(app, change_active_panel_regular); view = app->get_active_view(app, AccessAll); } } else{ - exec_command(app, cmdid_change_active_panel); + exec_command(app, change_active_panel_regular); } }