file sort experiment

This commit is contained in:
Allen Webster 2016-05-19 12:23:12 -04:00
parent 95f33accb3
commit d6cfdf7413
6 changed files with 91 additions and 47 deletions

View File

@ -272,10 +272,8 @@ HOOK_SIG(my_file_settings){
return(0); return(0);
} }
typedef void (Extension_Bindings)(Bind_Helper *context);
void void
default_keys(Bind_Helper *context, Extension_Bindings *extension = 0){ default_keys(Bind_Helper *context){
begin_map(context, mapid_global); begin_map(context, mapid_global);
bind(context, 'p', MDFR_CTRL, cmdid_open_panel_vsplit); bind(context, 'p', MDFR_CTRL, cmdid_open_panel_vsplit);
@ -423,10 +421,6 @@ default_keys(Bind_Helper *context, Extension_Bindings *extension = 0){
bind(context, '\n', MDFR_SHIFT, write_and_auto_tab); bind(context, '\n', MDFR_SHIFT, write_and_auto_tab);
bind(context, ' ', MDFR_SHIFT, cmdid_write_character); bind(context, ' ', MDFR_SHIFT, cmdid_write_character);
if (extension != 0){
extension(context);
}
end_map(context); end_map(context);
} }

View File

@ -1222,7 +1222,7 @@ COMMAND_DECL(auto_tab_range){
int r_start = 0, r_end = 0; int r_start = 0, r_end = 0;
int start_set = 0, end_set = 0; int start_set = 0, end_set = 0;
Indent_Options opts; Indent_Options opts;
opts.empty_blank_lines = 1; opts.empty_blank_lines = 0;
opts.use_tabs = 0; opts.use_tabs = 0;
opts.tab_width = 4; opts.tab_width = 4;
@ -3199,7 +3199,7 @@ App_Init_Sig(app_init){
{ {
i32 i; i32 i;
panel_max_count = models->layout.panel_max_count = 16; panel_max_count = models->layout.panel_max_count = MAX_VIEWS;
divider_max_count = panel_max_count - 1; divider_max_count = panel_max_count - 1;
models->layout.panel_count = 0; models->layout.panel_count = 0;
@ -4347,9 +4347,7 @@ App_Step_Sig(app_step){
case DACT_TOUCH_FILE: case DACT_TOUCH_FILE:
{ {
if (file){ if (file){
Assert(!file->state.is_dummy); touch_file(working_set, file);
dll_remove(&file->node);
dll_insert(&models->working_set.used_sentinel, &file->node);
} }
}break; }break;

2
4ed.h
View File

@ -12,6 +12,8 @@
#ifndef FRED_H #ifndef FRED_H
#define FRED_H #define FRED_H
#define MAX_VIEWS 16
struct Application_Memory{ struct Application_Memory{
void *vars_memory; void *vars_memory;
i32 vars_memory_size; i32 vars_memory_size;

View File

@ -484,6 +484,13 @@ working_set_lookup_file(Working_Set *working_set, String string){
return (file); return (file);
} }
internal void
touch_file(Working_Set *working_set, Editing_File *file){
Assert(!file->state.is_dummy);
dll_remove(&file->node);
dll_insert(&working_set->used_sentinel, &file->node);
}
// Hot Directory // Hot Directory
struct Hot_Directory{ struct Hot_Directory{

View File

@ -3754,8 +3754,8 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
Absolutes absolutes; Absolutes absolutes;
Editing_File *file; Editing_File *file;
File_Node *node, *used_nodes;
Working_Set *working_set = &models->working_set; Working_Set *working_set = &models->working_set;
Editing_Layout *layout = &models->layout;
GUI_Item_Update update = {0}; GUI_Item_Update update = {0};
{ {
@ -3788,23 +3788,63 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
&keys, &view->list_i, &update); &keys, &view->list_i, &update);
} }
{
Partition *part = &models->mem.part;
Temp_Memory temp = begin_temp_memory(part);
File_Node *node = 0, *used_nodes = 0;
Editing_File **reserved_files = 0;
i32 reserved_top = 0, i = 0;
View_Iter iter = {0};
partition_align(part, sizeof(i32));
reserved_files = (Editing_File**)partition_current(part);
used_nodes = &working_set->used_sentinel; used_nodes = &working_set->used_sentinel;
for (dll_items(node, used_nodes)){ for (dll_items(node, used_nodes)){
file = (Editing_File*)node; file = (Editing_File*)node;
Assert(!file->state.is_dummy); Assert(!file->state.is_dummy);
if (filename_match(view->dest, &absolutes, file->name.live_name, 1)){
iter = file_view_iter_init(layout, file, 0);
if (file_view_iter_good(iter)){
reserved_files[reserved_top++] = file;
}
else{
if (file->name.live_name.str[0] == '*'){
reserved_files[reserved_top++] = file;
}
else{
message = string_zero();
switch (buffer_get_sync(file)){
case SYNC_BEHIND_OS: message = message_unsynced; break;
case SYNC_UNSAVED: message = message_unsaved; break;
}
id.id[0] = (u64)(file);
if (gui_do_file_option(target, id, file->name.live_name, 0, message)){
interactive_view_complete(view, file->name.live_name, 0);
}
}
}
}
}
for (i = 0; i < reserved_top; ++i){
file = reserved_files[i];
message = string_zero(); message = string_zero();
switch (buffer_get_sync(file)){ switch (buffer_get_sync(file)){
case SYNC_BEHIND_OS: message = message_unsynced; break; case SYNC_BEHIND_OS: message = message_unsynced; break;
case SYNC_UNSAVED: message = message_unsaved; break; case SYNC_UNSAVED: message = message_unsaved; break;
} }
if (filename_match(view->dest, &absolutes, file->name.live_name, 1)){
id.id[0] = (u64)(file); id.id[0] = (u64)(file);
if (gui_do_file_option(target, id, file->name.live_name, 0, message)){ if (gui_do_file_option(target, id, file->name.live_name, 0, message)){
interactive_view_complete(view, file->name.live_name, 0); interactive_view_complete(view, file->name.live_name, 0);
} }
} }
end_temp_memory(temp);
} }
gui_end_list(target); gui_end_list(target);
@ -3937,13 +3977,13 @@ scroll_button_input(GUI_Target *target, GUI_Session *session, Input_Summary *use
internal b32 internal b32
do_input_file_view(System_Functions *system, Exchange *exchange, do_input_file_view(System_Functions *system, Exchange *exchange,
View *view, i32_Rect rect, b32 is_active, Input_Summary *user_input){ View *view, i32_Rect rect, b32 is_active,
Input_Summary *user_input){
b32 is_animating = 0; b32 is_animating = 0;
b32 is_file_scroll = 0; b32 is_file_scroll = 0;
GUI_Session gui_session; GUI_Session gui_session = {0};
GUI_Header *h; GUI_Header *h = 0;
GUI_Target *target = &view->gui_target; GUI_Target *target = &view->gui_target;
GUI_Interpret_Result interpret_result = {0}; GUI_Interpret_Result interpret_result = {0};
@ -3956,9 +3996,6 @@ do_input_file_view(System_Functions *system, Exchange *exchange,
h = NextHeader(h)){ h = NextHeader(h)){
interpret_result = gui_interpret(target, &gui_session, h); interpret_result = gui_interpret(target, &gui_session, h);
// TODO(allen): If something is auto hot or auto activated and
// not on screen do some sort of scrolling towards it.
switch (h->type){ switch (h->type){
case guicom_file_option: case guicom_file_option:
case guicom_fixed_option: case guicom_fixed_option:
@ -3986,7 +4023,8 @@ do_input_file_view(System_Functions *system, Exchange *exchange,
case guicom_file: case guicom_file:
{ {
f32 new_min_y = -(f32)(gui_session_get_eclipsed_y(&gui_session) - gui_session.rect.y0); f32 new_min_y = -(f32)(gui_session_get_eclipsed_y(&gui_session) -
gui_session.rect.y0);
f32 new_max_y = view_compute_max_target_y(view); f32 new_max_y = view_compute_max_target_y(view);
view->gui_target.scroll_updated.min_y = new_min_y; view->gui_target.scroll_updated.min_y = new_min_y;

View File

@ -356,8 +356,13 @@ int get_bindings(void *data, int size){
set_scroll_rule(context, smooth_scroll_rule); set_scroll_rule(context, smooth_scroll_rule);
default_keys(context, 0); default_keys(context);
// NOTE(allen|4.0.6): Command maps can be opened more than
// once so that you can extend existing maps very easily.
// You can also use the helper "restart_map" instead of
// begin_map to clear everything that was in the map and
// bind new things instead.
begin_map(context, mapid_file); begin_map(context, mapid_file);
bind(context, 'k', MDFR_ALT, kill_rect); bind(context, 'k', MDFR_ALT, kill_rect);
end_map(context); end_map(context);