Cleaned up dirty flag usages

This commit is contained in:
Allen Webster 2019-02-25 15:49:16 -08:00
parent 1428fc822f
commit 4b55e6e293
4 changed files with 16 additions and 9 deletions

View File

@ -558,7 +558,7 @@ HOOK_SIG(default_exit){
for (Buffer_Summary buffer = get_buffer_first(app, AccessAll);
buffer.exists;
get_buffer_next(app, &buffer, AccessAll)){
if (buffer.dirty == DirtyState_UnsavedChanges){
if (buffer.dirty & DirtyState_UnsavedChanges){
has_unsaved_changes = true;
break;
}

View File

@ -275,7 +275,7 @@ static Command_Metadata fcoder_metacmd_table[233] = {
{ PROC_LINKS(close_all_code, 0), "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\\4coder_project_commands.cpp", 39, 1060 },
{ PROC_LINKS(close_build_panel, 0), "close_build_panel", 17, "If the special build panel is open, closes it.", 46, "w:\\4ed\\code\\4coder_build_commands.cpp", 37, 203 },
{ PROC_LINKS(close_panel, 0), "close_panel", 11, "Closes the currently active panel if it is not the only panel open.", 67, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 503 },
{ PROC_LINKS(command_lister, 0), "command_lister", 14, "Opens an interactive list of all registered commands.", 53, "w:\\4ed\\code\\4coder_lists.cpp", 28, 979 },
{ PROC_LINKS(command_lister, 0), "command_lister", 14, "Opens an interactive list of all registered commands.", 53, "w:\\4ed\\code\\4coder_lists.cpp", 28, 981 },
{ PROC_LINKS(comment_line, 0), "comment_line", 12, "Insert '//' at the beginning of the line after leading whitespace.", 66, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 135 },
{ PROC_LINKS(comment_line_toggle, 0), "comment_line_toggle", 19, "Turns uncommented lines into commented lines and vice versa for comments starting with '//'.", 92, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 159 },
{ PROC_LINKS(copy, 0), "copy", 4, "Copy the text in the range from the cursor to the mark onto the clipboard.", 74, "w:\\4ed\\code\\4coder_clipboard.cpp", 32, 26 },
@ -318,11 +318,11 @@ static Command_Metadata fcoder_metacmd_table[233] = {
{ PROC_LINKS(if0_off, 0), "if0_off", 7, "Surround the range between the cursor and mark with an '#if 0' and an '#endif'", 78, "w:\\4ed\\code\\4coder_combined_write_commands.cpp", 46, 79 },
{ PROC_LINKS(increase_face_size, 0), "increase_face_size", 18, "Increase the size of the face used by the current buffer.", 57, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 586 },
{ PROC_LINKS(increase_line_wrap, 0), "increase_line_wrap", 18, "Increases the current buffer's width for line wrapping.", 55, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 564 },
{ PROC_LINKS(interactive_kill_buffer, 0), "interactive_kill_buffer", 23, "Interactively kill an open buffer.", 34, "w:\\4ed\\code\\4coder_lists.cpp", 28, 780 },
{ PROC_LINKS(interactive_new, 0), "interactive_new", 15, "Interactively creates a new file.", 33, "w:\\4ed\\code\\4coder_lists.cpp", 28, 890 },
{ PROC_LINKS(interactive_open, 0), "interactive_open", 16, "Interactively opens a file.", 27, "w:\\4ed\\code\\4coder_lists.cpp", 28, 922 },
{ PROC_LINKS(interactive_open_or_new, 0), "interactive_open_or_new", 23, "Interactively open a file out of the file system.", 49, "w:\\4ed\\code\\4coder_lists.cpp", 28, 852 },
{ PROC_LINKS(interactive_switch_buffer, 0), "interactive_switch_buffer", 25, "Interactively switch to an open buffer.", 39, "w:\\4ed\\code\\4coder_lists.cpp", 28, 761 },
{ PROC_LINKS(interactive_kill_buffer, 0), "interactive_kill_buffer", 23, "Interactively kill an open buffer.", 34, "w:\\4ed\\code\\4coder_lists.cpp", 28, 782 },
{ PROC_LINKS(interactive_new, 0), "interactive_new", 15, "Interactively creates a new file.", 33, "w:\\4ed\\code\\4coder_lists.cpp", 28, 892 },
{ PROC_LINKS(interactive_open, 0), "interactive_open", 16, "Interactively opens a file.", 27, "w:\\4ed\\code\\4coder_lists.cpp", 28, 924 },
{ PROC_LINKS(interactive_open_or_new, 0), "interactive_open_or_new", 23, "Interactively open a file out of the file system.", 49, "w:\\4ed\\code\\4coder_lists.cpp", 28, 854 },
{ PROC_LINKS(interactive_switch_buffer, 0), "interactive_switch_buffer", 25, "Interactively switch to an open buffer.", 39, "w:\\4ed\\code\\4coder_lists.cpp", 28, 763 },
{ PROC_LINKS(kill_buffer, 0), "kill_buffer", 11, "Kills the current buffer.", 25, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 1583 },
{ PROC_LINKS(kill_rect, 0), "kill_rect", 9, "Delete characters in a rectangular region. Range testing is done by unwrapped-xy coordinates.", 93, "w:\\4ed\\code\\4coder_experiments.cpp", 34, 26 },
{ PROC_LINKS(left_adjust_view, 0), "left_adjust_view", 16, "Sets the left size of the view near the x position of the cursor.", 65, "w:\\4ed\\code\\4coder_base_commands.cpp", 36, 166 },

View File

@ -462,6 +462,7 @@ generate_all_buffers_list__output_buffer(Lister *lister, Buffer_Summary buffer){
switch (buffer.dirty){
case DirtyState_UnsavedChanges: status = make_lit_string("*"); break;
case DirtyState_UnloadedChanges: status = make_lit_string("!"); break;
case DirtyState_UnsavedChangesAndUnloadedChanges: status = make_lit_string("*!"); break;
}
String buffer_name = make_string(buffer.buffer_name, buffer.buffer_name_len);
lister_add_item(lister, buffer_name, status, IntAsPtr(buffer.buffer_id), 0);
@ -608,6 +609,7 @@ generate_hot_directory_file_list(Application_Links *app, Lister *lister){
switch (buffer.dirty){
case DirtyState_UnsavedChanges: status_flag = " *"; break;
case DirtyState_UnloadedChanges: status_flag = " !"; break;
case DirtyState_UnsavedChangesAndUnloadedChanges: status_flag = " *!"; break;
}
}
int32_t more_than_enough_memory = 32;

View File

@ -159,14 +159,19 @@ draw_file_bar(System_Functions *system, Render_Target *target, View *view, Model
}
switch (file->state.dirty){
case DirtyState_UnsavedChanges:
{
intbar_draw_string(system, target, &bar, lit(" *"), pop2_color);
}break;
case DirtyState_UnloadedChanges:
{
intbar_draw_string(system, target, &bar, lit(" !"), pop2_color);
}break;
case DirtyState_UnsavedChanges:
case DirtyState_UnsavedChangesAndUnloadedChanges:
{
intbar_draw_string(system, target, &bar, lit(" *"), pop2_color);
intbar_draw_string(system, target, &bar, lit(" *!"), pop2_color);
}break;
}
}