file sort experiment
This commit is contained in:
parent
95f33accb3
commit
d6cfdf7413
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
8
4ed.cpp
8
4ed.cpp
|
@ -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
2
4ed.h
|
@ -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;
|
||||||
|
|
|
@ -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{
|
||||||
|
|
|
@ -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,39 +3788,79 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
|
||||||
&keys, &view->list_i, &update);
|
&keys, &view->list_i, &update);
|
||||||
}
|
}
|
||||||
|
|
||||||
used_nodes = &working_set->used_sentinel;
|
{
|
||||||
for (dll_items(node, used_nodes)){
|
Partition *part = &models->mem.part;
|
||||||
file = (Editing_File*)node;
|
Temp_Memory temp = begin_temp_memory(part);
|
||||||
Assert(!file->state.is_dummy);
|
File_Node *node = 0, *used_nodes = 0;
|
||||||
|
Editing_File **reserved_files = 0;
|
||||||
message = string_zero();
|
i32 reserved_top = 0, i = 0;
|
||||||
switch (buffer_get_sync(file)){
|
View_Iter iter = {0};
|
||||||
case SYNC_BEHIND_OS: message = message_unsynced; break;
|
|
||||||
case SYNC_UNSAVED: message = message_unsaved; break;
|
partition_align(part, sizeof(i32));
|
||||||
|
reserved_files = (Editing_File**)partition_current(part);
|
||||||
|
|
||||||
|
used_nodes = &working_set->used_sentinel;
|
||||||
|
for (dll_items(node, used_nodes)){
|
||||||
|
file = (Editing_File*)node;
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filename_match(view->dest, &absolutes, file->name.live_name, 1)){
|
for (i = 0; i < reserved_top; ++i){
|
||||||
|
file = reserved_files[i];
|
||||||
|
|
||||||
|
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);
|
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);
|
||||||
|
|
||||||
gui_end_scrollable(target);
|
gui_end_scrollable(target);
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
case IInt_Sure_To_Close:
|
case IInt_Sure_To_Close:
|
||||||
{
|
{
|
||||||
i32 action = -1;
|
i32 action = -1;
|
||||||
|
|
||||||
String empty_str = {0};
|
String empty_str = {0};
|
||||||
String message = make_lit_string("There is one or more files unsaved changes, close anyway?");
|
String message = make_lit_string("There is one or more files unsaved changes, close anyway?");
|
||||||
|
|
||||||
gui_do_text_field(target, message, empty_str);
|
gui_do_text_field(target, message, empty_str);
|
||||||
|
|
||||||
id.id[0] = (u64)('y');
|
id.id[0] = (u64)('y');
|
||||||
message = make_lit_string("(Y)es");
|
message = make_lit_string("(Y)es");
|
||||||
if (gui_do_fixed_option(target, id, message, 'y')){
|
if (gui_do_fixed_option(target, id, message, 'y')){
|
||||||
|
@ -3915,11 +3955,11 @@ click_button_input(GUI_Target *target, GUI_Session *session, Input_Summary *user
|
||||||
|
|
||||||
internal b32
|
internal b32
|
||||||
scroll_button_input(GUI_Target *target, GUI_Session *session, Input_Summary *user_input,
|
scroll_button_input(GUI_Target *target, GUI_Session *session, Input_Summary *user_input,
|
||||||
GUI_id id, b32 *is_animating){
|
GUI_id id, b32 *is_animating){
|
||||||
b32 result = 0;
|
b32 result = 0;
|
||||||
i32 mx = user_input->mouse.x;
|
i32 mx = user_input->mouse.x;
|
||||||
i32 my = user_input->mouse.y;
|
i32 my = user_input->mouse.y;
|
||||||
|
|
||||||
if (hit_check(mx, my, session->rect)){
|
if (hit_check(mx, my, session->rect)){
|
||||||
target->hover = id;
|
target->hover = id;
|
||||||
if (user_input->mouse.l){
|
if (user_input->mouse.l){
|
||||||
|
@ -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};
|
||||||
|
|
||||||
|
@ -3952,13 +3992,10 @@ do_input_file_view(System_Functions *system, Exchange *exchange,
|
||||||
target->active = gui_id_zero();
|
target->active = gui_id_zero();
|
||||||
|
|
||||||
for (h = (GUI_Header*)target->push.base;
|
for (h = (GUI_Header*)target->push.base;
|
||||||
h->type;
|
h->type;
|
||||||
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;
|
||||||
|
@ -4001,7 +4039,7 @@ do_input_file_view(System_Functions *system, Exchange *exchange,
|
||||||
}
|
}
|
||||||
is_file_scroll = 1;
|
is_file_scroll = 1;
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
case guicom_color_button:
|
case guicom_color_button:
|
||||||
case guicom_font_button:
|
case guicom_font_button:
|
||||||
case guicom_button:
|
case guicom_button:
|
||||||
|
@ -4330,7 +4368,7 @@ draw_file_loaded(View *view, i32_Rect rect, b32 is_active, Render_Target *target
|
||||||
}
|
}
|
||||||
if (item->glyphid != 0){
|
if (item->glyphid != 0){
|
||||||
font_draw_glyph(target, font_id, (u8)item->glyphid,
|
font_draw_glyph(target, font_id, (u8)item->glyphid,
|
||||||
item->x0, item->y0, char_color);
|
item->x0, item->y0, char_color);
|
||||||
}
|
}
|
||||||
prev_ind = ind;
|
prev_ind = ind;
|
||||||
}
|
}
|
||||||
|
|
|
@ -353,11 +353,16 @@ int get_bindings(void *data, int size){
|
||||||
|
|
||||||
set_hook(context, hook_start, experimental_start_hook);
|
set_hook(context, hook_start, experimental_start_hook);
|
||||||
set_hook(context, hook_open_file, my_file_settings);
|
set_hook(context, hook_open_file, my_file_settings);
|
||||||
|
|
||||||
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);
|
||||||
|
|
Loading…
Reference in New Issue