More carefully controlled virtual whitespace toggling

master
Allen Webster 2020-11-25 16:56:02 -08:00
parent 43913b122a
commit de41152df1
8 changed files with 54 additions and 33 deletions

View File

@ -85,7 +85,8 @@ standard_search_and_build_from_dir(Application_Links *app, View_ID view, String_
String_Const_u8 command = push_u8_stringf(scratch, "\"%.*s/%.*s\"",
string_expand(path),
string_expand(cmd_string));
if (global_config.automatically_save_changes_on_build){
b32 auto_save = def_get_config_b32(vars_save_string_lit("automatically_save_changes_on_build"));
if (auto_save){
save_all_dirty_buffers(app);
}
standard_build_exec_command(app, view, path, command);

View File

@ -1238,12 +1238,6 @@ CUSTOM_DOC("Toggles virtual whitespace for all files.")
String_ID key = vars_save_string_lit("enable_virtual_whitespace");
b32 enable_virtual_whitespace = def_get_config_b32(key);
def_set_config_b32(key, !enable_virtual_whitespace);
for (Buffer_ID buffer = get_buffer_next(app, 0, Access_Always);
buffer != 0;
buffer = get_buffer_next(app, buffer, Access_Always)){
buffer_clear_layout_cache(app, buffer);
}
}
// BOTTOM

View File

@ -777,6 +777,9 @@ def_set_config_var(String_ID key, String_ID val){
_def_config_table_init();
Variable_Handle root = vars_get_root();
Variable_Handle block_var = vars_read_key(root, def_config_lookup_table[0]);
if (vars_is_nil(block_var)){
block_var = vars_new_variable(root, def_config_lookup_table[0]);
}
vars_new_variable(block_var, key, val);
}
@ -1343,11 +1346,6 @@ config_init_default(Config_Data *config){
config->enable_output_wrapping = false;
config->enable_undo_fade_out = true;
config->enable_code_wrapping = true;
config->automatically_indent_text_on_save = true;
config->automatically_save_changes_on_build = true;
config->automatically_load_project = false;
config->cursor_roundness = .45f;
config->mark_thickness = 2.f;
config->lister_roundness = .20f;
@ -1418,12 +1416,6 @@ config_parse__data(Application_Links *app, Arena *arena, String_Const_u8 file_na
config_bool_var(parsed, "enable_output_wrapping", 0, &config->enable_output_wrapping);
config_bool_var(parsed, "enable_undo_fade_out", 0, &config->enable_undo_fade_out);
config_bool_var(parsed, "enable_code_wrapping", 0, &config->enable_code_wrapping);
config_bool_var(parsed, "automatically_indent_text_on_save", 0, &config->automatically_indent_text_on_save);
config_bool_var(parsed, "automatically_save_changes_on_build", 0, &config->automatically_save_changes_on_build);
config_bool_var(parsed, "automatically_load_project", 0, &config->automatically_load_project);
{
i32 x = 0;
if (config_int_var(parsed, "cursor_roundness", 0, &x)){

View File

@ -204,11 +204,6 @@ struct Config_Data{
b8 indent_with_tabs;
b8 enable_undo_fade_out;
b8 enable_code_wrapping;
b8 automatically_indent_text_on_save;
b8 automatically_save_changes_on_build;
b8 automatically_load_project;
f32 cursor_roundness;
f32 mark_thickness;
f32 lister_roundness;

View File

@ -91,6 +91,8 @@ global Mapping framework_mapping = {};
global Buffer_Modified_Set global_buffer_modified_set = {};
global b32 def_enable_virtual_whitespace = false;
////////////////////////////////
global b32 global_keyboard_macro_is_recording = false;

View File

@ -14,7 +14,8 @@ CUSTOM_DOC("Default command for responding to a startup event")
load_themes_default_folder(app);
default_4coder_initialize(app, file_names);
default_4coder_side_by_side_panels(app, file_names);
if (global_config.automatically_load_project){
b32 auto_load = def_get_config_b32(vars_save_string_lit("automatically_load_project"));
if (auto_load){
load_project(app);
}
}
@ -32,6 +33,11 @@ CUSTOM_DOC("Default command for responding to a startup event")
test_control.channel_volume[1] = 1.f;
def_audio_play_clip(test_clip, &test_control);
}
{
def_enable_virtual_whitespace = def_get_config_b32(vars_save_string_lit("enable_virtual_whitespace"));
clear_all_layouts(app);
}
}
CUSTOM_COMMAND_SIG(default_try_exit)
@ -159,10 +165,28 @@ code_index_update_tick(Application_Links *app){
function void
default_tick(Application_Links *app, Frame_Info frame_info){
////////////////////////////////
// NOTE(allen): Update code index
code_index_update_tick(app);
////////////////////////////////
// NOTE(allen): Update fade ranges
if (tick_all_fade_ranges(app, frame_info.animation_dt)){
animate_in_n_milliseconds(app, 0);
}
////////////////////////////////
// NOTE(allen): Clear layouts if virtual whitespace setting changed.
{
b32 enable_virtual_whitespace = def_get_config_b32(vars_save_string_lit("enable_virtual_whitespace"));
if (enable_virtual_whitespace != def_enable_virtual_whitespace){
def_enable_virtual_whitespace = enable_virtual_whitespace;
clear_all_layouts(app);
}
}
}
function Rect_f32
@ -802,7 +826,7 @@ BUFFER_HOOK_SIG(default_begin_buffer){
b32 wrap_lines = true;
b32 use_lexer = false;
if (treat_as_code){
wrap_lines = global_config.enable_code_wrapping;
wrap_lines = def_get_config_b32(vars_save_string_lit("enable_code_wrapping"));
use_lexer = true;
}
@ -895,8 +919,9 @@ BUFFER_HOOK_SIG(default_file_save){
// buffer_id
ProfileScope(app, "default file save");
b32 auto_indent = def_get_config_b32(vars_save_string_lit("automatically_indent_text_on_save"));
b32 is_virtual = def_get_config_b32(vars_save_string_lit("enable_virtual_whitespace"));
if (global_config.automatically_indent_text_on_save && is_virtual){
if (auto_indent && is_virtual){
auto_indent_buffer(app, buffer_id, buffer_range(app, buffer_id));
}

View File

@ -2531,5 +2531,17 @@ font_get_average_glyph_advance_range(Face_Advance_Map *map, Face_Metrics *metric
(f32)global_config.default_tab_width));
}
////////////////////////////////
// NOTE(allen): Layout Invalidate
function void
clear_all_layouts(Application_Links *app){
for (Buffer_ID buffer = get_buffer_next(app, 0, Access_Always);
buffer != 0;
buffer = get_buffer_next(app, buffer, Access_Always)){
buffer_clear_layout_cache(app, buffer);
}
}
// BOTTOM

View File

@ -280,12 +280,12 @@ static Command_Metadata fcoder_metacmd_table[250] = {
{ PROC_LINKS(backspace_char, 0), false, "backspace_char", 14, "Deletes the character to the left of the cursor.", 48, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 96 },
{ PROC_LINKS(basic_change_active_panel, 0), false, "basic_change_active_panel", 25, "Change the currently active panel, moving to the panel with the next highest view_id. Will not skipe the build panel if it is open.", 132, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 666 },
{ PROC_LINKS(begin_clipboard_collection_mode, 0), true, "begin_clipboard_collection_mode", 31, "Allows the user to copy multiple strings from other applications before switching to 4coder and pasting them all.", 113, "W:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 71 },
{ PROC_LINKS(build_in_build_panel, 0), false, "build_in_build_panel", 20, "Looks for a build.bat, build.sh, or makefile in the current and parent directories. Runs the first that it finds and prints the output to *compilation*. Puts the *compilation* buffer in a panel at the footer of the current view.", 230, "W:\\4ed\\code\\custom\\4coder_build_commands.cpp", 44, 159 },
{ PROC_LINKS(build_search, 0), false, "build_search", 12, "Looks for a build.bat, build.sh, or makefile in the current and parent directories. Runs the first that it finds and prints the output to *compilation*.", 153, "W:\\4ed\\code\\custom\\4coder_build_commands.cpp", 44, 122 },
{ PROC_LINKS(build_in_build_panel, 0), false, "build_in_build_panel", 20, "Looks for a build.bat, build.sh, or makefile in the current and parent directories. Runs the first that it finds and prints the output to *compilation*. Puts the *compilation* buffer in a panel at the footer of the current view.", 230, "W:\\4ed\\code\\custom\\4coder_build_commands.cpp", 44, 160 },
{ PROC_LINKS(build_search, 0), false, "build_search", 12, "Looks for a build.bat, build.sh, or makefile in the current and parent directories. Runs the first that it finds and prints the output to *compilation*.", 153, "W:\\4ed\\code\\custom\\4coder_build_commands.cpp", 44, 123 },
{ PROC_LINKS(center_view, 0), false, "center_view", 11, "Centers the view vertically on the line on which the cursor sits.", 65, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 195 },
{ PROC_LINKS(change_active_panel, 0), false, "change_active_panel", 19, "Change the currently active panel, moving to the panel with the next highest view_id.", 85, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 360 },
{ PROC_LINKS(change_active_panel_backwards, 0), false, "change_active_panel_backwards", 29, "Change the currently active panel, moving to the panel with the next lowest view_id.", 84, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 366 },
{ PROC_LINKS(change_to_build_panel, 0), false, "change_to_build_panel", 21, "If the special build panel is open, makes the build panel the active panel.", 75, "W:\\4ed\\code\\custom\\4coder_build_commands.cpp", 44, 180 },
{ PROC_LINKS(change_to_build_panel, 0), false, "change_to_build_panel", 21, "If the special build panel is open, makes the build panel the active panel.", 75, "W:\\4ed\\code\\custom\\4coder_build_commands.cpp", 44, 181 },
{ PROC_LINKS(clean_all_lines, 0), false, "clean_all_lines", 15, "Removes trailing whitespace from all lines and removes all blank lines in the current buffer.", 93, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 646 },
{ PROC_LINKS(clean_trailing_whitespace, 0), false, "clean_trailing_whitespace", 25, "Removes trailing whitespace from all lines in the current buffer.", 65, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 655 },
{ PROC_LINKS(clear_all_themes, 0), false, "clear_all_themes", 16, "Clear the theme list", 20, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 556 },
@ -296,7 +296,7 @@ static Command_Metadata fcoder_metacmd_table[250] = {
{ PROC_LINKS(click_set_mark, 0), false, "click_set_mark", 14, "Sets the mark position to the mouse position.", 45, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 256 },
{ PROC_LINKS(clipboard_record_clip, 0), false, "clipboard_record_clip", 21, "In response to a new clipboard contents events, saves the new clip onto the clipboard history", 93, "W:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 7 },
{ PROC_LINKS(close_all_code, 0), false, "close_all_code", 14, "Closes any buffer with a filename ending with an extension configured to be recognized as a code file type.", 107, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 943 },
{ PROC_LINKS(close_build_panel, 0), false, "close_build_panel", 17, "If the special build panel is open, closes it.", 46, "W:\\4ed\\code\\custom\\4coder_build_commands.cpp", 44, 174 },
{ PROC_LINKS(close_build_panel, 0), false, "close_build_panel", 17, "If the special build panel is open, closes it.", 46, "W:\\4ed\\code\\custom\\4coder_build_commands.cpp", 44, 175 },
{ PROC_LINKS(close_panel, 0), false, "close_panel", 11, "Closes the currently active panel if it is not the only panel open.", 67, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 674 },
{ PROC_LINKS(command_documentation, 0), true, "command_documentation", 21, "Prompts the user to select a command then loads a doc buffer for that item", 74, "W:\\4ed\\code\\custom\\4coder_docs.cpp", 34, 190 },
{ PROC_LINKS(command_lister, 0), true, "command_lister", 14, "Opens an interactive list of all registered commands.", 53, "W:\\4ed\\code\\custom\\4coder_lists.cpp", 35, 760 },
@ -309,8 +309,8 @@ static Command_Metadata fcoder_metacmd_table[250] = {
{ PROC_LINKS(decrease_face_size, 0), false, "decrease_face_size", 18, "Decrease the size of the face used by the current buffer.", 57, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 757 },
{ PROC_LINKS(default_file_externally_modified, 0), false, "default_file_externally_modified", 32, "Notes the external modification of attached files by printing a message.", 72, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 2062 },
{ PROC_LINKS(default_startup, 0), false, "default_startup", 15, "Default command for responding to a startup event", 49, "W:\\4ed\\code\\custom\\4coder_default_hooks.cpp", 43, 7 },
{ PROC_LINKS(default_try_exit, 0), false, "default_try_exit", 16, "Default command for responding to a try-exit event", 50, "W:\\4ed\\code\\custom\\4coder_default_hooks.cpp", 43, 37 },
{ PROC_LINKS(default_view_input_handler, 0), false, "default_view_input_handler", 26, "Input consumption loop for default view behavior", 48, "W:\\4ed\\code\\custom\\4coder_default_hooks.cpp", 43, 81 },
{ PROC_LINKS(default_try_exit, 0), false, "default_try_exit", 16, "Default command for responding to a try-exit event", 50, "W:\\4ed\\code\\custom\\4coder_default_hooks.cpp", 43, 43 },
{ PROC_LINKS(default_view_input_handler, 0), false, "default_view_input_handler", 26, "Input consumption loop for default view behavior", 48, "W:\\4ed\\code\\custom\\4coder_default_hooks.cpp", 43, 87 },
{ PROC_LINKS(delete_alpha_numeric_boundary, 0), false, "delete_alpha_numeric_boundary", 29, "Delete characters between the cursor position and the first alphanumeric boundary to the right.", 95, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 161 },
{ PROC_LINKS(delete_char, 0), false, "delete_char", 11, "Deletes the character to the right of the cursor.", 49, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 79 },
{ PROC_LINKS(delete_current_scope, 0), false, "delete_current_scope", 20, "Deletes the braces surrounding the currently selected scope. Leaves the contents within the scope.", 99, "W:\\4ed\\code\\custom\\4coder_scope_commands.cpp", 44, 112 },
@ -372,7 +372,7 @@ static Command_Metadata fcoder_metacmd_table[250] = {
{ PROC_LINKS(list_all_substring_locations, 0), false, "list_all_substring_locations", 28, "Queries the user for a string and lists all case-sensitive substring matches found in all open buffers.", 103, "W:\\4ed\\code\\custom\\4coder_search.cpp", 36, 174 },
{ PROC_LINKS(list_all_substring_locations_case_insensitive, 0), false, "list_all_substring_locations_case_insensitive", 45, "Queries the user for a string and lists all case-insensitive substring matches found in all open buffers.", 105, "W:\\4ed\\code\\custom\\4coder_search.cpp", 36, 186 },
{ PROC_LINKS(load_project, 0), false, "load_project", 12, "Looks for a project.4coder file in the current directory and tries to load it. Looks in parent directories until a project file is found or there are no more parents.", 167, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 963 },
{ PROC_LINKS(load_theme_current_buffer, 0), false, "load_theme_current_buffer", 25, "Parse the current buffer as a theme file and add the theme to the theme list. If the buffer has a .4coder postfix in it's name, it is removed when the name is saved.", 165, "W:\\4ed\\code\\custom\\4coder_config.cpp", 36, 1682 },
{ PROC_LINKS(load_theme_current_buffer, 0), false, "load_theme_current_buffer", 25, "Parse the current buffer as a theme file and add the theme to the theme list. If the buffer has a .4coder postfix in it's name, it is removed when the name is saved.", 165, "W:\\4ed\\code\\custom\\4coder_config.cpp", 36, 1674 },
{ PROC_LINKS(load_themes_default_folder, 0), false, "load_themes_default_folder", 26, "Loads all the theme files in the default theme folder.", 54, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 533 },
{ PROC_LINKS(load_themes_hot_directory, 0), false, "load_themes_hot_directory", 25, "Loads all the theme files in the current hot directory.", 55, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 545 },
{ PROC_LINKS(make_directory_query, 0), false, "make_directory_query", 20, "Queries the user for a name and creates a new directory with the given name.", 76, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1493 },