start of arrow navigation plan
This commit is contained in:
parent
14e35d7eec
commit
9513517374
|
@ -1,6 +1,6 @@
|
||||||
#define MAJOR 4
|
#define MAJOR 4
|
||||||
#define MINOR 0
|
#define MINOR 0
|
||||||
#define PATCH 2
|
#define PATCH 3
|
||||||
|
|
||||||
#define VN__(a,b,c) #a"."#b"."#c
|
#define VN__(a,b,c) #a"."#b"."#c
|
||||||
#define VN_(a,b,c) VN__(a,b,c)
|
#define VN_(a,b,c) VN__(a,b,c)
|
||||||
|
|
1
4ed.cpp
1
4ed.cpp
|
@ -4174,7 +4174,6 @@ App_Step_Sig(app_step){
|
||||||
preload_settings = ed_file->preload;
|
preload_settings = ed_file->preload;
|
||||||
if (data){
|
if (data){
|
||||||
String val = make_string((char*)data, size);
|
String val = make_string((char*)data, size);
|
||||||
// TODO(allen): reduce to just passing models
|
|
||||||
file_create_from_string(system, models, ed_file, filename, val);
|
file_create_from_string(system, models, ed_file, filename, val);
|
||||||
|
|
||||||
if (ed_file->settings.tokens_exist){
|
if (ed_file->settings.tokens_exist){
|
||||||
|
|
|
@ -76,6 +76,7 @@ struct View{
|
||||||
GUI_Target gui_target;
|
GUI_Target gui_target;
|
||||||
void *gui_mem;
|
void *gui_mem;
|
||||||
GUI_Scroll_Vars gui_scroll;
|
GUI_Scroll_Vars gui_scroll;
|
||||||
|
i32 list_i;
|
||||||
|
|
||||||
Interactive_Interaction interaction;
|
Interactive_Interaction interaction;
|
||||||
Interactive_Action action;
|
Interactive_Action action;
|
||||||
|
@ -497,13 +498,6 @@ view_measure_wraps(System_Functions *system,
|
||||||
view->line_count = line_count;
|
view->line_count = line_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void*
|
|
||||||
alloc_for_buffer(void *context, int *size){
|
|
||||||
*size = LargeRoundUp(*size, Kbytes(4));
|
|
||||||
void *data = general_memory_allocate((General_Memory*)context, *size, BUBBLE_BUFFER);
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
file_create_from_string(System_Functions *system, Models *models,
|
file_create_from_string(System_Functions *system, Models *models,
|
||||||
Editing_File *file, char *filename, String val, b8 read_only = 0){
|
Editing_File *file, char *filename, String val, b8 read_only = 0){
|
||||||
|
@ -550,6 +544,7 @@ file_create_from_string(System_Functions *system, Models *models,
|
||||||
|
|
||||||
file->settings.read_only = read_only;
|
file->settings.read_only = read_only;
|
||||||
if (!read_only){
|
if (!read_only){
|
||||||
|
// TODO(allen): Redo undo system (if you don't mind the pun)
|
||||||
i32 request_size = Kbytes(64);
|
i32 request_size = Kbytes(64);
|
||||||
file->state.undo.undo.max = request_size;
|
file->state.undo.undo.max = request_size;
|
||||||
file->state.undo.undo.strings = (u8*)general_memory_allocate(general, request_size, BUBBLE_UNDO_STRING);
|
file->state.undo.undo.strings = (u8*)general_memory_allocate(general, request_size, BUBBLE_UNDO_STRING);
|
||||||
|
@ -2642,6 +2637,7 @@ view_show_interactive(System_Functions *system, View *view,
|
||||||
view->action = action;
|
view->action = action;
|
||||||
view->interaction = interaction;
|
view->interaction = interaction;
|
||||||
view->dest = make_fixed_width_string(view->dest_);
|
view->dest = make_fixed_width_string(view->dest_);
|
||||||
|
view->list_i = 0;
|
||||||
|
|
||||||
view->map_for_file = view->map;
|
view->map_for_file = view->map;
|
||||||
view->map = gui_map;
|
view->map = gui_map;
|
||||||
|
@ -2657,7 +2653,7 @@ view_show_theme(View *view, Command_Map *gui_map){
|
||||||
view->showing_ui = VUI_Theme;
|
view->showing_ui = VUI_Theme;
|
||||||
view->color_mode = CV_Mode_Library;
|
view->color_mode = CV_Mode_Library;
|
||||||
view->color = super_color_create(0xFF000000);
|
view->color = super_color_create(0xFF000000);
|
||||||
view->current_color_editing = -1;
|
view->current_color_editing = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2739,7 +2735,7 @@ interactive_view_complete(View *view, String dest, i32 user_action){
|
||||||
view_show_file(view, 0);
|
view_show_file(view, 0);
|
||||||
|
|
||||||
// TODO(allen): This is here to prevent the key press from being passed to the
|
// TODO(allen): This is here to prevent the key press from being passed to the
|
||||||
// underlying file which is a giant pain.
|
// underlying file which is a giant pain. But I want a better system.
|
||||||
view->file = 0;
|
view->file = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3932,41 +3928,74 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
|
||||||
Exhaustive_File_Loop loop;
|
Exhaustive_File_Loop loop;
|
||||||
Exhaustive_File_Info file_info;
|
Exhaustive_File_Info file_info;
|
||||||
|
|
||||||
GUI_id file_option_id, str_edit_id;
|
GUI_id id;
|
||||||
i32 i;
|
GUI_Item_Update update = {0};
|
||||||
b32 do_new_directory = 0;
|
|
||||||
Hot_Directory *hdir = &models->hot_directory;
|
Hot_Directory *hdir = &models->hot_directory;
|
||||||
|
b32 do_new_directory = 0;
|
||||||
|
i32 i = 0;
|
||||||
|
|
||||||
gui_do_text_field(target, message, hdir->string);
|
gui_do_text_field(target, message, hdir->string);
|
||||||
|
|
||||||
str_edit_id.id[0] = (u64)(hdir);
|
id.id[0] = (u64)(hdir);
|
||||||
if (gui_do_file_input(target, str_edit_id, hdir)){
|
if (gui_do_file_input(target, id, hdir)){
|
||||||
interactive_view_complete(view, hdir->string, 0);
|
interactive_view_complete(view, hdir->string, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
gui_get_scroll_vars(target, view->showing_ui, &view->gui_scroll);
|
gui_get_scroll_vars(target, view->showing_ui, &view->gui_scroll);
|
||||||
gui_begin_scrollable(target, view->showing_ui, view->gui_scroll, 9.f * view->font_height);
|
gui_begin_scrollable(target, view->showing_ui, view->gui_scroll, 9.f * view->font_height);
|
||||||
|
|
||||||
begin_exhaustive_loop(&loop, hdir);
|
id.id[0] = (u64)(hdir) + 1;
|
||||||
for (i = 0; i < loop.count; ++i){
|
if (gui_begin_list(target, id, view->list_i, 0, &update)){
|
||||||
file_info = get_exhaustive_info(system, &models->working_set, &loop, i);
|
if (update.has_adjustment){
|
||||||
|
view->list_i = update.adjustment_value;
|
||||||
|
}
|
||||||
|
|
||||||
if (file_info.name_match){
|
b32 indirectly_activate = 0;
|
||||||
file_option_id.id[0] = (u64)(file_info.info);
|
for (i32 j = 0; j < keys.count; ++j){
|
||||||
if (gui_do_file_option(target, file_option_id,
|
i16 key = keys.keys[j].keycode;
|
||||||
file_info.info->filename, file_info.is_folder, file_info.message)){
|
switch (key){
|
||||||
if (file_info.is_folder){
|
case key_up:
|
||||||
append(&hdir->string, file_info.info->filename);
|
--view->list_i;
|
||||||
append(&hdir->string, "/");
|
break;
|
||||||
do_new_directory = 1;
|
|
||||||
}
|
case key_down:
|
||||||
else{
|
++view->list_i;
|
||||||
interactive_view_complete(view, loop.full_path, 0);
|
break;
|
||||||
|
|
||||||
|
case '\n':
|
||||||
|
indirectly_activate = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gui_rollback(target, &update);
|
||||||
|
gui_begin_list(target, id, view->list_i, indirectly_activate, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
begin_exhaustive_loop(&loop, hdir);
|
||||||
|
for (i = 0; i < loop.count; ++i){
|
||||||
|
file_info = get_exhaustive_info(system, &models->working_set, &loop, i);
|
||||||
|
|
||||||
|
if (file_info.name_match){
|
||||||
|
id.id[0] = (u64)(file_info.info);
|
||||||
|
if (gui_do_file_option(target, id,
|
||||||
|
file_info.info->filename, file_info.is_folder, file_info.message)){
|
||||||
|
if (file_info.is_folder){
|
||||||
|
append(&hdir->string, file_info.info->filename);
|
||||||
|
append(&hdir->string, "/");
|
||||||
|
do_new_directory = 1;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
interactive_view_complete(view, loop.full_path, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gui_end_list(target);
|
||||||
|
|
||||||
if (do_new_directory){
|
if (do_new_directory){
|
||||||
hot_directory_reload(system, hdir, &models->working_set);
|
hot_directory_reload(system, hdir, &models->working_set);
|
||||||
}
|
}
|
||||||
|
|
53
4ed_gui.cpp
53
4ed_gui.cpp
|
@ -145,6 +145,9 @@ struct GUI_Target{
|
||||||
|
|
||||||
struct GUI_Item_Update{
|
struct GUI_Item_Update{
|
||||||
i32 partition_point;
|
i32 partition_point;
|
||||||
|
b32 activate;
|
||||||
|
b32 has_adjustment;
|
||||||
|
i32 adjustment_value;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GUI_Header{
|
struct GUI_Header{
|
||||||
|
@ -177,6 +180,8 @@ enum GUI_Command_Type{
|
||||||
guicom_color_button,
|
guicom_color_button,
|
||||||
guicom_font_button,
|
guicom_font_button,
|
||||||
guicom_text_with_cursor,
|
guicom_text_with_cursor,
|
||||||
|
guicom_begin_list,
|
||||||
|
guicom_end_list,
|
||||||
guicom_file_option,
|
guicom_file_option,
|
||||||
guicom_fixed_option,
|
guicom_fixed_option,
|
||||||
guicom_button,
|
guicom_button,
|
||||||
|
@ -228,9 +233,23 @@ gui_rollback(GUI_Target *target, GUI_Item_Update *update){
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
gui_fill_item_update(GUI_Item_Update *update, GUI_Target *target, GUI_Header *h){
|
gui_fill_item_update(GUI_Item_Update *update, GUI_Target *target, GUI_Header *h,
|
||||||
|
b32 activate){
|
||||||
if (update){
|
if (update){
|
||||||
update->partition_point = (i32)((char*)h - (char*)target->push.base);
|
update->partition_point = (i32)((char*)h - (char*)target->push.base);
|
||||||
|
update->activate = activate;
|
||||||
|
update->has_adjustment = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void
|
||||||
|
gui_fill_item_update(GUI_Item_Update *update, GUI_Target *target, GUI_Header *h,
|
||||||
|
b32 active, i32 adjustment_value){
|
||||||
|
if (update){
|
||||||
|
update->partition_point = (i32)((char*)h - (char*)target->push.base);
|
||||||
|
update->activate = active;
|
||||||
|
update->has_adjustment = 1;
|
||||||
|
update->adjustment_value = adjustment_value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -398,13 +417,16 @@ gui_do_text_field(GUI_Target *target, String prompt, String text){
|
||||||
|
|
||||||
internal b32
|
internal b32
|
||||||
gui_do_text_with_cursor(GUI_Target *target, i32 pos, String text, GUI_Item_Update *update){
|
gui_do_text_with_cursor(GUI_Target *target, i32 pos, String text, GUI_Item_Update *update){
|
||||||
b32 result = 1;
|
b32 result = 0;
|
||||||
GUI_Header *h = gui_push_simple_command(target, guicom_text_with_cursor);
|
GUI_Header *h = gui_push_simple_command(target, guicom_text_with_cursor);
|
||||||
gui_push_string(target, h, text);
|
gui_push_string(target, h, text);
|
||||||
gui_push_item(target, h, &pos, sizeof(i32));
|
gui_push_item(target, h, &pos, sizeof(i32));
|
||||||
|
|
||||||
result = target->has_keys;
|
result = target->has_keys;
|
||||||
gui_fill_item_update(update, target, h);
|
if (result){
|
||||||
|
gui_fill_item_update(update, target, h, 0);
|
||||||
|
}
|
||||||
|
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -460,6 +482,31 @@ gui_do_font_button(GUI_Target *target, GUI_id id, i16 font_id, String text){
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal b32
|
||||||
|
gui_begin_list(GUI_Target *target, GUI_id id, i32 list_i, b32 activate_item, GUI_Item_Update *update){
|
||||||
|
b32 result = 0;
|
||||||
|
b32 active = 0;
|
||||||
|
GUI_Interactive *b = gui_push_button_command(target, guicom_begin_list, id);
|
||||||
|
GUI_Header *h = (GUI_Header*)b;
|
||||||
|
|
||||||
|
result = target->has_keys;
|
||||||
|
if (gui_id_eq(id, target->active)){
|
||||||
|
active = 1;
|
||||||
|
result = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result){
|
||||||
|
gui_fill_item_update(update, target, h, active);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void
|
||||||
|
gui_end_list(GUI_Target *target){
|
||||||
|
gui_push_simple_command(target, guicom_end_list);
|
||||||
|
}
|
||||||
|
|
||||||
internal b32
|
internal b32
|
||||||
gui_do_file_option(GUI_Target *target, GUI_id id, String filename, b32 is_folder, String message){
|
gui_do_file_option(GUI_Target *target, GUI_id id, String filename, b32 is_folder, String message){
|
||||||
b32 result = 0;
|
b32 result = 0;
|
||||||
|
|
Loading…
Reference in New Issue