diff --git a/4coder_API.html b/4coder_API.html index 6a5d6085..a34af9b9 100644 --- a/4coder_API.html +++ b/4coder_API.html @@ -1027,14 +1027,6 @@ the range [1,16].
cmdid_left_adjust_view adjusts the view to be just left of the cursor's position.
-
cmdid_page_up
-
cmdid_page_up moves the view up one whole screen height and centers the cursor there.
-
-
-
cmdid_page_down
-
cmdid_page_down moves the view down one whole screen height and centers the cursor there.
-
-
cmdid_word_complete
cmdid_word_complete begins or continues cycling through completions for a partial word.
@@ -1196,16 +1188,23 @@ the range [1,16].
BufferSetting_Lex
-
The BufferSetting_Lex setting is used to determine whether to store C++ tokens from with the buffer.
+
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.
+
The BufferSetting_WrapLine setting is used to determine whether a buffer prefers + to be viewed with wrapped lines, individual views can be set to override this value after + being tied to the buffer.
BufferSetting_MapID
-
The BufferSetting_MapID setting specifies the id of the command map that should be active when a buffer is active.
+
The BufferSetting_MapID setting specifies the id of the command map that should be + active when a buffer is active.
+
+
+
BufferSetting_Eol
+

@@ -1216,8 +1215,20 @@ the range [1,16].

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

@@ -1235,23 +1246,24 @@ the range [1,16].

§3.4.13: Buffer_Seek_Type

enum Buffer_Seek_Type;
-
Description
UNDOCUMENTED.
Values
+
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
-
UNDOCUMENTED.
+
This value indicates absolute positioning where positions are measured as the number of bytes from the start of the file.
buffer_seek_wrapped_xy
-
UNDOCUMENTED.
+
This value indicates xy positioning with wrapped lines where the x and y values are in pixels.
buffer_seek_unwrapped_xy
-
UNDOCUMENTED.
+
This value indicates xy positioning with unwrapped lines where the x and y values are in pixels.
buffer_seek_line_char
-
UNDOCUMENTED.
+
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: Key_Modifier_Flag

enum Key_Modifier_Flag;
@@ -1725,35 +1737,36 @@ float wrapped_y;
};
-
Description
UNDOCUMENTED.
Fields
+
Description
Full_Cursor describes the position of a cursor in every buffer +coordinate system supported by 4coder.
Fields
pos
-
UNDOCUMENTED.
+
This field contains the cursor's position in absolute positioning.
line
-
UNDOCUMENTED.
+
This field contains the number of the line where the cursor is located. This field is one based.
character
-
UNDOCUMENTED.
+
This field contains the number of the column where the cursor is located. This field is one based.
unwrapped_x
-
UNDOCUMENTED.
+
This field contains the x position measured with unwrapped lines.
unwrapped_y
-
UNDOCUMENTED.
+
This field contains the y position measured with unwrapped lines.
wrapped_x
-
UNDOCUMENTED.
+
This field contains the x position measured with wrapped lines.
wrapped_y
-
UNDOCUMENTED.
+
This field contains the y position measured with wrapped lines.
-

+
See Also
4coder_Buffer_Positioning_System

§3.4.32: Buffer_Seek

struct Buffer_Seek {
@@ -1784,35 +1797,41 @@ int32_t character;
};
-
Description
UNDOCUMENTED.
Fields
+
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
-
UNDOCUMENTED.
+
The type field determines the coordinate system of the seek operation.
pos
-
UNDOCUMENTED.
+
The pos field specified the pos when the seek is in absolute position.
round_down
-
UNDOCUMENTED.
+
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
-
UNDOCUMENTED.
+
The x coordinate for xy type seeks.
y
-
UNDOCUMENTED.
+
The y coordinate for xy type seeks.
line
-
UNDOCUMENTED.
+
The line number of a line-character type seek.
character
-
UNDOCUMENTED.
+
The character number of a line-character type seek.
-

+
See Also
Buffer_Seek_Type
4coder_Buffer_Positioning_System

§3.4.33: Buffer_Summary

struct Buffer_Summary {
@@ -1828,6 +1847,7 @@ char * buffer_name;
int32_t buffer_name_len;
bool32 is_lexed;
int32_t map_id;
+bool32 unwrapped_lines;
};
@@ -1877,7 +1897,11 @@ int32_t map_id;
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.34: View_Summary

struct View_Summary {
@@ -1947,7 +1971,7 @@ GUI_Scroll_Vars scroll_vars;
scroll_vars
This feature is not fully implemented yet.
-

+
See Also
Access_Flag

§3.4.35: User_Input

struct User_Input {
diff --git a/4coder_default_bindings.cpp b/4coder_default_bindings.cpp index aa39d095..b7b1672f 100644 --- a/4coder_default_bindings.cpp +++ b/4coder_default_bindings.cpp @@ -23,6 +23,10 @@ CUSTOM_COMMAND_SIG(write_allen_note){ write_string(app, make_lit_string("// NOTE(allen): ")); } +CUSTOM_COMMAND_SIG(write_allen_doc){ + write_string(app, make_lit_string("/* DOC() */")); +} + CUSTOM_COMMAND_SIG(write_zero_struct){ write_string(app, make_lit_string(" = {0};")); } @@ -294,6 +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, '[', MDFR_CTRL, open_long_braces); bind(context, '{', MDFR_CTRL, open_long_braces_semicolon); bind(context, '}', MDFR_CTRL, open_long_braces_break); @@ -327,8 +332,8 @@ default_keys(Bind_Helper *context){ bind(context, key_down, MDFR_NONE, move_down); bind(context, key_end, MDFR_NONE, seek_end_of_line); bind(context, key_home, MDFR_NONE, seek_beginning_of_line); - bind(context, key_page_up, MDFR_NONE, cmdid_page_up); - bind(context, key_page_down, MDFR_NONE, cmdid_page_down); + bind(context, key_page_up, MDFR_NONE, page_up); + bind(context, key_page_down, MDFR_NONE, page_down); bind(context, key_right, MDFR_CTRL, seek_whitespace_right); bind(context, key_left, MDFR_CTRL, seek_whitespace_left); @@ -354,7 +359,7 @@ default_keys(Bind_Helper *context){ bind(context, 'H', MDFR_CTRL, cmdid_history_forward); bind(context, 'j', MDFR_CTRL, cmdid_to_lowercase); bind(context, 'K', MDFR_CTRL, cmdid_kill_buffer); - bind(context, 'l', MDFR_CTRL, cmdid_toggle_line_wrap); + bind(context, 'l', MDFR_CTRL, toggle_line_wrap); bind(context, 'm', MDFR_CTRL, cursor_mark_swap); bind(context, 'O', MDFR_CTRL, cmdid_reopen); bind(context, 'q', MDFR_CTRL, query_replace); @@ -371,11 +376,11 @@ default_keys(Bind_Helper *context){ bind(context, 'z', MDFR_CTRL, cmdid_undo); - bind(context, '1', MDFR_CTRL, cmdid_eol_dosify); + bind(context, '1', MDFR_CTRL, eol_dosify); + bind(context, '!', MDFR_CTRL, eol_nixify); - bind(context, '?', MDFR_CTRL, cmdid_toggle_show_whitespace); + bind(context, '?', MDFR_CTRL, toggle_show_whitespace); bind(context, '~', MDFR_CTRL, cmdid_clean_all_lines); - bind(context, '!', MDFR_CTRL, cmdid_eol_nixify); bind(context, '\n', MDFR_SHIFT, write_and_auto_tab); bind(context, ' ', MDFR_SHIFT, write_character); diff --git a/4coder_default_include.cpp b/4coder_default_include.cpp index 1ed0e377..78d46f42 100644 --- a/4coder_default_include.cpp +++ b/4coder_default_include.cpp @@ -199,6 +199,36 @@ CUSTOM_COMMAND_SIG(move_down_10){ move_vertical(app, 10.f); } +static float +get_page_jump(View_Summary *view){ + i32_Rect region = view->file_region; + float page_jump = 1; + + if (view->line_height > 0){ + page_jump = (float)(region.y1 - region.y0) / view->line_height; + page_jump -= 3.f; + if (page_jump <= 0){ + page_jump = 1.f; + } + } + + return(page_jump); +} + +CUSTOM_COMMAND_SIG(page_up){ + unsigned int access = AccessProtected; + View_Summary view = app->get_active_view(app, access); + float page_jump = get_page_jump(&view); + move_vertical(app, -page_jump); +} + +CUSTOM_COMMAND_SIG(page_down){ + unsigned int access = AccessProtected; + View_Summary view = app->get_active_view(app, access); + float page_jump = get_page_jump(&view); + move_vertical(app, page_jump); +} + CUSTOM_COMMAND_SIG(move_left){ unsigned int access = AccessProtected; @@ -1265,44 +1295,6 @@ CUSTOM_COMMAND_SIG(execute_previous_cli){ } } -CUSTOM_COMMAND_SIG(execute_arbitrary_command){ - // NOTE(allen): This isn't a super powerful version of this command, I will expand - // upon it so that it has all the cmdid_* commands by default. However, with this - // as an example you have everything you need to make it work already. You could - // even use app->memory to create a hash table in the start hook. - Query_Bar bar; - char space[1024]; - bar.prompt = make_lit_string("Command: "); - bar.string = make_fixed_width_string(space); - - if (!query_user_string(app, &bar)) return; - - // NOTE(allen): Here I chose to end this query bar because when I call another - // command it might ALSO have query bars and I don't want this one hanging - // around at that point. Since the bar exists on my stack the result of the query - // is still available in bar.string though. - app->end_query_bar(app, &bar, 0); - - if (match(bar.string, make_lit_string("open all code"))){ - exec_command(app, open_all_code); - } - else if(match(bar.string, make_lit_string("close all code"))){ - exec_command(app, close_all_code); - } - else if (match(bar.string, make_lit_string("open menu"))){ - exec_command(app, cmdid_open_menu); - } - else if (match(bar.string, make_lit_string("dos lines"))){ - exec_command(app, cmdid_eol_dosify); - } - else if (match(bar.string, make_lit_string("nix lines"))){ - exec_command(app, cmdid_eol_nixify); - } - else{ - app->print_message(app, literal("unrecognized command\n")); - } -} - CUSTOM_COMMAND_SIG(open_in_other_regular){ exec_command(app, cmdid_change_active_panel); exec_command(app, cmdid_interactive_open); @@ -1524,6 +1516,76 @@ CUSTOM_COMMAND_SIG(change_active_panel_regular){ #endif +// +// Common Settings Commands +// + +CUSTOM_COMMAND_SIG(toggle_line_wrap){ + View_Summary view = app->get_active_view(app, AccessProtected); + Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, AccessProtected); + + bool32 unwrapped = view.unwrapped_lines; + if (buffer.exists){ + unwrapped = buffer.unwrapped_lines; + } + + app->view_set_setting(app, &view, ViewSetting_WrapLine, unwrapped); +} + +CUSTOM_COMMAND_SIG(toggle_show_whitespace){ + View_Summary view = app->get_active_view(app, AccessProtected); + app->view_set_setting(app, &view, ViewSetting_ShowWhitespace, !view.show_whitespace); +} + +CUSTOM_COMMAND_SIG(eol_dosify){ + View_Summary view = app->get_active_view(app, AccessOpen); + Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, AccessOpen); + app->buffer_set_setting(app, &buffer, BufferSetting_Eol, true); +} + +CUSTOM_COMMAND_SIG(eol_nixify){ + View_Summary view = app->get_active_view(app, AccessOpen); + Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, AccessOpen); + app->buffer_set_setting(app, &buffer, BufferSetting_Eol, false); +} + +CUSTOM_COMMAND_SIG(execute_arbitrary_command){ + // NOTE(allen): This isn't a super powerful version of this command, I will expand + // upon it so that it has all the cmdid_* commands by default. However, with this + // as an example you have everything you need to make it work already. You could + // even use app->memory to create a hash table in the start hook. + Query_Bar bar; + char space[1024]; + bar.prompt = make_lit_string("Command: "); + bar.string = make_fixed_width_string(space); + + if (!query_user_string(app, &bar)) return; + + // NOTE(allen): Here I chose to end this query bar because when I call another + // command it might ALSO have query bars and I don't want this one hanging + // around at that point. Since the bar exists on my stack the result of the query + // is still available in bar.string though. + app->end_query_bar(app, &bar, 0); + + if (match(bar.string, make_lit_string("open all code"))){ + exec_command(app, open_all_code); + } + else if(match(bar.string, make_lit_string("close all code"))){ + exec_command(app, close_all_code); + } + else if (match(bar.string, make_lit_string("open menu"))){ + exec_command(app, cmdid_open_menu); + } + else if (match(bar.string, make_lit_string("dos lines"))){ + exec_command(app, eol_dosify); + } + else if (match(bar.string, make_lit_string("nix lines"))){ + exec_command(app, eol_nixify); + } + else{ + app->print_message(app, literal("unrecognized command\n")); + } +} // NOTE(allen|a4): scroll rule information // diff --git a/4coder_types.h b/4coder_types.h index a1773271..82033f2d 100644 --- a/4coder_types.h +++ b/4coder_types.h @@ -54,10 +54,6 @@ ENUM(uint64_t, Command_ID){ cmdid_center_view, /* DOC(cmdid_left_adjust_view adjusts the view to be just left of the cursor's position.) */ cmdid_left_adjust_view, - /* DOC(cmdid_page_up moves the view up one whole screen height and centers the cursor there.) */ - cmdid_page_up, - /* DOC(cmdid_page_down moves the view down one whole screen height and centers the cursor there.) */ - cmdid_page_down, /* DOC(cmdid_word_complete begins or continues cycling through completions for a partial word.) */ cmdid_word_complete, @@ -76,16 +72,22 @@ 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, @@ -152,20 +154,41 @@ ENUM(int32_t, Event_Message_Type_ID){ ENUM(int32_t, Buffer_Setting_ID){ /* DOC(BufferSetting_Null is not a valid setting, it is reserved to detect errors.) */ BufferSetting_Null, - /* DOC(The BufferSetting_Lex setting is used to determine whether to store C++ tokens from with the buffer.) */ + + /* DOC(The BufferSetting_Lex setting is used to determine whether to store C++ tokens + from with the buffer.) */ BufferSetting_Lex, - /* DOC(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.) */ + + /* DOC(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_WrapLine, - /* DOC(The BufferSetting_MapID setting specifies the id of the command map that should be active when a buffer is active.) */ + + /* DOC(The BufferSetting_MapID setting specifies the id of the command map that should be + active when a buffer is active.) */ BufferSetting_MapID, + + /* DOC(The BufferSetting_Eol setting spcifies how line ends should be saved to the backing file. + A 1 indicates dos endings "\r\n" and a 0 indicates nix endings "\n".*/ + BufferSetting_Eol, }; /* DOC(A View_Setting_ID names a setting in a view.) */ ENUM(int32_t, View_Setting_ID){ /* DOC(ViewSetting_Null is not a valid setting, it is reserved to detect errors.) */ ViewSetting_Null, - /* DOC(The ViewSetting_ShowScrollbar setting determines whether a scroll bar is attached to a view in it's scrollable section.) */ + + /* DOC(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_WrapLine, + + /* DOC(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_ShowWhitespace, + + /* DOC(The ViewSetting_ShowScrollbar setting determines whether a scroll bar is + attached to a view in it's scrollable section.) */ ViewSetting_ShowScrollbar, }; @@ -286,15 +309,19 @@ ENUM(int32_t, Mouse_Cursor_Show_Type){ // MouseCursorShow_WhenActive,// TODO(allen): coming soon }; -/* DOC(UNDOCUMENTED.) */ +/* DOC(The Buffer_Seek_Type is is used in a Buffer_Seek to identify which +coordinates are suppose to be used for the seek.) +DOC_SEE(Buffer_Seek) +DOC_SEE(4coder_Buffer_Positioning_System) +*/ ENUM(int32_t, Buffer_Seek_Type){ - /* DOC(UNDOCUMENTED.) */ + /* DOC(This value indicates absolute positioning where positions are measured as the number of bytes from the start of the file.) */ buffer_seek_pos, - /* DOC(UNDOCUMENTED.) */ + /* DOC(This value indicates xy positioning with wrapped lines where the x and y values are in pixels.) */ buffer_seek_wrapped_xy, - /* DOC(UNDOCUMENTED.) */ + /* DOC(This value indicates xy positioning with unwrapped lines where the x and y values are in pixels.) */ buffer_seek_unwrapped_xy, - /* DOC(UNDOCUMENTED.) */ + /* DOC(This value indicates line-character, or line-column positioning. These coordinates are 1 based to match standard line numbering.) */ buffer_seek_line_char }; @@ -457,53 +484,62 @@ struct GUI_Scroll_Vars{ int32_t prev_target_x; }; -/* DOC(UNDOCUMENTED.) */ +/* DOC(Full_Cursor describes the position of a cursor in every buffer +coordinate system supported by 4coder.) +DOC_SEE(4coder_Buffer_Positioning_System) */ struct Full_Cursor{ - /* DOC(UNDOCUMENTED.) */ + /* DOC(This field contains the cursor's position in absolute positioning.) */ int32_t pos; - /* DOC(UNDOCUMENTED.) */ + /* DOC(This field contains the number of the line where the cursor is located. This field is one based.) */ int32_t line; - /* DOC(UNDOCUMENTED.) */ + /* DOC(This field contains the number of the column where the cursor is located. This field is one based.) */ int32_t character; - /* DOC(UNDOCUMENTED.) */ + /* DOC(This field contains the x position measured with unwrapped lines.) */ float unwrapped_x; - /* DOC(UNDOCUMENTED.) */ + /* DOC(This field contains the y position measured with unwrapped lines.) */ float unwrapped_y; - /* DOC(UNDOCUMENTED.) */ + /* DOC(This field contains the x position measured with wrapped lines.) */ float wrapped_x; - /* DOC(UNDOCUMENTED.) */ + /* DOC(This field contains the y position measured with wrapped lines.) */ float wrapped_y; }; -/* DOC(UNDOCUMENTED.) */ +/* DOC(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.) +DOC_SEE(Buffer_Seek_Type) +DOC_SEE(4coder_Buffer_Positioning_System)*/ struct Buffer_Seek{ - /* DOC(UNDOCUMENTED.) */ + /* DOC(The type field determines the coordinate system of the seek operation.) */ Buffer_Seek_Type type; union{ struct { - /* DOC(UNDOCUMENTED.) */ + /* DOC(The pos field specified the pos when the seek is in absolute position.) */ int32_t pos; }; struct { - /* DOC(UNDOCUMENTED.) */ + /* DOC(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.) */ bool32 round_down; - /* DOC(UNDOCUMENTED.) */ + /* DOC(The x coordinate for xy type seeks.) */ float x; - /* DOC(UNDOCUMENTED.) */ + /* DOC(The y coordinate for xy type seeks.) */ float y; }; struct { - /* DOC(UNDOCUMENTED.) */ + /* DOC(The line number of a line-character type seek.) */ int32_t line; - /* DOC(UNDOCUMENTED.) */ + /* DOC(The character number of a line-character type seek.) */ int32_t character; }; }; }; -/* DOC( -Buffer_Summary acts as a handle to a buffer and describes the state of the buffer. -) */ +/* DOC(Buffer_Summary acts as a handle to a buffer and describes the state of the buffer.) +DOC_SEE(Access_Flag)*/ struct Buffer_Summary{ /* DOC( This field indicates whether the Buffer_Summary describes a buffer that is open in 4coder. @@ -519,7 +555,6 @@ struct Buffer_Summary{ int32_t buffer_id; /* DOC(If this is not a null summary, this field contains flags describing the protection status of the buffer.) - DOC_SEE(Access_Flag) */ Access_Flag lock_flags; @@ -540,9 +575,12 @@ struct Buffer_Summary{ bool32 is_lexed; /* DOC(If this is not a null summary, this field specifies the id of the command map for this buffer.) */ int32_t map_id; + /* DOC(If this is not a null summary, this field indicates whether the buffer 'prefers' wrapped lines.) */ + bool32 unwrapped_lines; }; -/* DOC(View_Summary acts as a handle to a view and describes the state of the view.) */ +/* DOC(View_Summary acts as a handle to a view and describes the state of the view.) +DOC_SEE(Access_Flag)*/ struct View_Summary{ /* DOC( This field indicates whether the View_Summary describes a view that is open in 4coder. @@ -558,7 +596,6 @@ struct View_Summary{ int32_t buffer_id; /* DOC(If this is not a null summary, this field contains flags describing the protection status of the view.) - DOC_SEE(Access_Flag) */ Access_Flag lock_flags; diff --git a/4ed.cpp b/4ed.cpp index 4aae7e0e..272b3221 100644 --- a/4ed.cpp +++ b/4ed.cpp @@ -659,10 +659,13 @@ 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 @@ -734,6 +737,7 @@ 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); @@ -749,6 +753,7 @@ COMMAND_DECL(eol_nixify){ 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); @@ -1059,21 +1064,13 @@ setup_command_table(){ SET(to_uppercase); SET(to_lowercase); - SET(toggle_line_wrap); - SET(toggle_show_whitespace); - SET(clean_all_lines); - SET(eol_dosify); - SET(eol_nixify); SET(open_panel_vsplit); SET(open_panel_hsplit); SET(close_panel); SET(change_active_panel); - SET(page_up); - SET(page_down); - SET(open_color_tweaker); SET(open_config); SET(open_menu); diff --git a/4ed_api_implementation.cpp b/4ed_api_implementation.cpp index 127ccd8c..57abcd59 100644 --- a/4ed_api_implementation.cpp +++ b/4ed_api_implementation.cpp @@ -22,7 +22,6 @@ fill_buffer_summary(Buffer_Summary *buffer, Editing_File *file, Working_Set *wor buffer->exists = 1; buffer->ready = file_is_ready(file); - buffer->is_lexed = file->settings.tokens_exist; buffer->buffer_id = file->id.id; buffer->size = file->state.buffer.size; @@ -31,7 +30,9 @@ fill_buffer_summary(Buffer_Summary *buffer, Editing_File *file, Working_Set *wor buffer->file_name = file->name.source_path.str; buffer->buffer_name = file->name.live_name.str; + buffer->is_lexed = file->settings.tokens_exist; buffer->map_id = file->settings.base_map_id; + buffer->unwrapped_lines = file->settings.unwrapped_lines; buffer->lock_flags = 0; if (file->settings.read_only){ @@ -765,6 +766,12 @@ DOC_SEE(Buffer_Setting_ID) iter.view->map = get_map(models, file->settings.base_map_id); } }break; + + case BufferSetting_Eol: + { + file->settings.dos_write_mode = value; + file->state.last_4ed_edit_time = system->now_time_stamp(); + }break; } fill_buffer_summary(buffer, file, cmd); } @@ -1136,12 +1143,42 @@ DOC_SEE(View_Setting_ID) bool32 result = false; if (vptr){ + result = true; switch (setting){ + case ViewSetting_WrapLine: + { + Relative_Scrolling scrolling = view_get_relative_scrolling(vptr); + if (value){ + if (vptr->file_data.unwrapped_lines){ + vptr->file_data.unwrapped_lines = 0; + vptr->edit_pos->scroll.target_x = 0; + view_cursor_move(vptr, vptr->edit_pos->cursor.pos); + view_set_relative_scrolling(vptr, scrolling); + } + } + else{ + if (!vptr->file_data.unwrapped_lines){ + vptr->file_data.unwrapped_lines = 1; + view_cursor_move(vptr, vptr->edit_pos->cursor.pos); + view_set_relative_scrolling(vptr, scrolling); + } + } + }break; + + case ViewSetting_ShowWhitespace: + { + vptr->file_data.show_whitespace = value; + }break; + case ViewSetting_ShowScrollbar: { - result = true; vptr->hide_scrollbar = !value; }break; + + default: + { + result = false; + }break; } fill_view_summary(view, vptr, cmd); diff --git a/4ed_file.cpp b/4ed_file.cpp index c5b9eb05..8b9685c0 100644 --- a/4ed_file.cpp +++ b/4ed_file.cpp @@ -129,7 +129,6 @@ struct Editing_File_Settings{ // NOTE(allen): This part of the Editing_File is cleared whenever // the contents of the file is set. struct Editing_File_State{ - i16 font_id; Buffer_Type buffer; Undo_Data undo; diff --git a/4ed_file_view.cpp b/4ed_file_view.cpp index 8b989e99..314884a8 100644 --- a/4ed_file_view.cpp +++ b/4ed_file_view.cpp @@ -1050,11 +1050,10 @@ file_create_from_string(System_Functions *system, Models *models, file_set_name(working_set, file, (char*)name); - file->state.font_id = models->global_font.font_id; - file_synchronize_times(system, file, name); - Render_Font *font = get_font_info(font_set, file->state.font_id)->font; + i16 font_id = models->global_font.font_id; + Render_Font *font = get_font_info(font_set, font_id)->font; float *advance_data = 0; if (font) advance_data = font->advance_data; file_measure_starts_widths(system, general, &file->state.buffer, advance_data); @@ -2124,7 +2123,8 @@ file_do_single_edit(System_Functions *system, i32 new_line_count = buffer_count_newlines(&file->state.buffer, start, start+str_len); i32 line_shift = new_line_count - replaced_line_count; - Render_Font *font = get_font_info(models->font_set, file->state.font_id)->font; + i16 font_id = models->global_font.font_id; + Render_Font *font = get_font_info(models->font_set, font_id)->font; file_grow_starts_widths_as_needed(general, buffer, line_shift); buffer_remeasure_starts(buffer, line_start, line_end, line_shift, shift_amount); @@ -2196,7 +2196,8 @@ file_do_white_batch_edit(System_Functions *system, Models *models, Editing_File // NOTE(allen): meta data { Buffer_Measure_Starts state = {}; - Render_Font *font = get_font_info(models->font_set, file->state.font_id)->font; + i16 font_id = models->global_font.font_id; + Render_Font *font = get_font_info(models->font_set, font_id)->font; float *advance_data = 0; if (font) advance_data = font->advance_data; buffer_measure_starts_widths(&state, &file->state.buffer, advance_data); diff --git a/buffer/4coder_buffer_abstract.cpp b/buffer/4coder_buffer_abstract.cpp index 436891a5..efd0adaf 100644 --- a/buffer/4coder_buffer_abstract.cpp +++ b/buffer/4coder_buffer_abstract.cpp @@ -682,7 +682,7 @@ buffer_measure_starts_zero_widths_(Buffer_Measure_Starts *state, Buffer_Type *bu internal_4tech int buffer_measure_starts_widths(Buffer_Measure_Starts *state, Buffer_Type *buffer, float *advance_data){ - int result; + int result = 0; if (advance_data){ result = buffer_measure_starts_widths_(state, buffer, advance_data); @@ -697,14 +697,11 @@ buffer_measure_starts_widths(Buffer_Measure_Starts *state, Buffer_Type *buffer, internal_4tech void buffer_remeasure_starts(Buffer_Type *buffer, int line_start, int line_end, int line_shift, int text_shift){ Buffer_Stringify_Type loop; - int *starts; - int line_count; - char *data; - int size, end; - int line_i, char_i, start; - - starts = buffer->line_starts; - line_count = buffer->line_count; + int *starts = buffer->line_starts; + int line_count = buffer->line_count; + char *data = 0; + int size = 0, end = 0; + int line_i = 0, char_i = 0, start = 0; assert_4tech(0 <= line_start); assert_4tech(line_start <= line_end); @@ -760,20 +757,15 @@ internal_4tech void buffer_remeasure_widths(Buffer_Type *buffer, float *advance_data, int line_start, int line_end, int line_shift){ Buffer_Stringify_Type loop; - int *starts; - float *widths; - int line_count; - int widths_count; - char *data; - int size, end; - int i, j; - float width; - char ch; - - starts = buffer->line_starts; - widths = buffer->line_widths; - line_count = buffer->line_count; - widths_count = buffer->widths_count; + int *starts = buffer->line_starts; + float *widths = buffer->line_widths; + int line_count = buffer->line_count; + int widths_count = buffer->widths_count; + char *data = 0; + int size = 0, end = 0; + int i = 0, j = 0; + float width = 0; + char ch = 0; assert_4tech(0 <= line_start); assert_4tech(line_start <= line_end); @@ -814,6 +806,11 @@ buffer_remeasure_widths(Buffer_Type *buffer, float *advance_data, } } } + + if (j == buffer_size(buffer)){ + widths[i] = width; + assert_4tech(i+1 == line_count); + } } #if 0