eliminated all view types except File_View
This commit is contained in:
parent
f8bc11f543
commit
6575a1cccd
|
@ -72,11 +72,10 @@ CUSTOM_COMMAND_SIG(write_decrement){
|
|||
app->buffer_replace_range(app, &buffer, buffer.buffer_cursor_pos, buffer.buffer_cursor_pos, text, size);
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(open_long_braces){
|
||||
static void
|
||||
long_braces(Application_Links *app, char *text, int size){
|
||||
File_View_Summary view;
|
||||
Buffer_Summary buffer;
|
||||
char text[] = "{\n\n}";
|
||||
int size = sizeof(text) - 1;
|
||||
int pos;
|
||||
|
||||
view = app->get_active_file_view(app);
|
||||
|
@ -92,24 +91,22 @@ CUSTOM_COMMAND_SIG(open_long_braces){
|
|||
exec_command(app, cmdid_auto_tab_range);
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(open_long_braces){
|
||||
char text[] = "{\n\n}";
|
||||
int size = sizeof(text) - 1;
|
||||
long_braces(app, text, size);
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(open_long_braces_semicolon){
|
||||
File_View_Summary view;
|
||||
Buffer_Summary buffer;
|
||||
char text[] = "{\n\n};";
|
||||
int size = sizeof(text) - 1;
|
||||
int pos;
|
||||
long_braces(app, text, size);
|
||||
}
|
||||
|
||||
view = app->get_active_file_view(app);
|
||||
buffer = app->get_buffer(app, view.buffer_id);
|
||||
|
||||
pos = view.cursor.pos;
|
||||
app->buffer_replace_range(app, &buffer, pos, pos, text, size);
|
||||
app->view_set_cursor(app, &view, seek_pos(pos + 2), 1);
|
||||
|
||||
push_parameter(app, par_range_start, pos);
|
||||
push_parameter(app, par_range_end, pos + size);
|
||||
push_parameter(app, par_clear_blank_lines, 0);
|
||||
exec_command(app, cmdid_auto_tab_range);
|
||||
CUSTOM_COMMAND_SIG(open_long_braces_break){
|
||||
char text[] = "{\n\n}break;";
|
||||
int size = sizeof(text) - 1;
|
||||
long_braces(app, text, size);
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(paren_wrap){
|
||||
|
@ -768,7 +765,8 @@ extern "C" GET_BINDING_DATA(get_bindings){
|
|||
bind(context, '=', MDFR_CTRL, write_increment);
|
||||
bind(context, '-', MDFR_CTRL, write_decrement);
|
||||
bind(context, '[', MDFR_CTRL, open_long_braces);
|
||||
bind(context, '{', MDFR_CTRL, open_long_braces);
|
||||
bind(context, '{', MDFR_CTRL, open_long_braces_semicolon);
|
||||
bind(context, '}', MDFR_CTRL, open_long_braces_break);
|
||||
bind(context, '9', MDFR_CTRL, paren_wrap);
|
||||
bind(context, 'i', MDFR_ALT, if0_off);
|
||||
|
||||
|
|
378
4ed.cpp
378
4ed.cpp
|
@ -239,6 +239,36 @@ param_stack_end(Partition *part){
|
|||
return (Command_Parameter*)((char*)part->base + part->pos);
|
||||
}
|
||||
|
||||
internal File_View*
|
||||
panel_make_empty(System_Functions *system, Exchange *exchange,
|
||||
App_Vars *vars, Style *style, Panel *panel){
|
||||
|
||||
Mem_Options *mem = &vars->mem;
|
||||
Live_Views *live_set = &vars->live_set;
|
||||
Editing_Layout *layout = &vars->layout;
|
||||
Working_Set *working_set = &vars->working_set;
|
||||
|
||||
// TODO(allen): vars->delay pointer for directing all delayed actions to appropriate place
|
||||
Delay *delay = &vars->delay1;
|
||||
|
||||
View *new_view;
|
||||
File_View *file_view;
|
||||
|
||||
new_view = live_set_alloc_view(live_set, mem);
|
||||
if (panel->view){
|
||||
view_replace_major(system, exchange, new_view, panel, live_set);
|
||||
}
|
||||
else{
|
||||
view_set_first(new_view, panel);
|
||||
}
|
||||
file_view = file_view_init(new_view, layout, working_set, delay,
|
||||
&vars->settings, &vars->hot_directory, mem, &vars->styles);
|
||||
view_set_file(file_view, 0, vars->font_set, style, 0, 0, 0);
|
||||
new_view->map = app_get_map(vars, mapid_global);
|
||||
|
||||
return(file_view);
|
||||
}
|
||||
|
||||
COMMAND_DECL(null){
|
||||
AllowLocal(command);
|
||||
}
|
||||
|
@ -820,27 +850,18 @@ COMMAND_DECL(save_history){
|
|||
|
||||
COMMAND_DECL(interactive_new){
|
||||
ProfileMomentFunction();
|
||||
USE_FILE_VIEW(fview);
|
||||
USE_VARS(vars);
|
||||
USE_LIVE_SET(live_set);
|
||||
USE_PANEL(panel);
|
||||
USE_MEM(mem);
|
||||
USE_WORKING_SET(working_set);
|
||||
USE_STYLE(style);
|
||||
USE_DELAY(delay);
|
||||
USE_EXCHANGE(exchange);
|
||||
USE_FONT_SET(font_set);
|
||||
|
||||
View *new_view = live_set_alloc_view(live_set, mem);
|
||||
view_replace_minor(system, exchange, new_view, panel, live_set);
|
||||
if (!fview){
|
||||
fview = panel_make_empty(system, exchange, vars, style, panel);
|
||||
}
|
||||
|
||||
new_view->map = &vars->map_ui;
|
||||
Interactive_View *int_view =
|
||||
interactive_view_init(system, new_view, &vars->hot_directory,
|
||||
style, working_set,
|
||||
font_set, delay);
|
||||
int_view->interaction = INTV_SYS_FILE_LIST;
|
||||
int_view->action = INTV_NEW;
|
||||
copy(&int_view->query, "New: ");
|
||||
view_show_interactive(system, fview, &vars->map_ui,
|
||||
IAct_New, IInt_Sys_File_List, make_lit_string("New: "));
|
||||
}
|
||||
|
||||
internal Sys_App_Binding*
|
||||
|
@ -894,14 +915,10 @@ app_open_file_background(App_Vars *vars, Exchange *exchange, Working_Set *workin
|
|||
COMMAND_DECL(interactive_open){
|
||||
ProfileMomentFunction();
|
||||
USE_VARS(vars);
|
||||
USE_LIVE_SET(live_set);
|
||||
USE_PANEL(panel);
|
||||
USE_MEM(mem);
|
||||
USE_WORKING_SET(working_set);
|
||||
USE_STYLE(style);
|
||||
USE_DELAY(delay);
|
||||
USE_EXCHANGE(exchange);
|
||||
USE_FONT_SET(font_set);
|
||||
|
||||
char *filename = 0;
|
||||
int filename_len = 0;
|
||||
|
@ -932,40 +949,18 @@ COMMAND_DECL(interactive_open){
|
|||
}
|
||||
}
|
||||
else{
|
||||
View *new_view = live_set_alloc_view(live_set, mem);
|
||||
view_replace_minor(system, exchange, new_view, panel, live_set);
|
||||
View *view = panel->view;
|
||||
Assert(view);
|
||||
|
||||
new_view->map = &vars->map_ui;
|
||||
Interactive_View *int_view =
|
||||
interactive_view_init(system, new_view, &vars->hot_directory,
|
||||
style, working_set, font_set, delay);
|
||||
int_view->interaction = INTV_SYS_FILE_LIST;
|
||||
int_view->action = INTV_OPEN;
|
||||
copy(&int_view->query, "Open: ");
|
||||
}
|
||||
File_View *fview = view_to_file_view(view);
|
||||
|
||||
if (!fview){
|
||||
fview = panel_make_empty(system, exchange, vars, style, panel);
|
||||
}
|
||||
|
||||
internal void
|
||||
panel_make_empty(System_Functions *system, Exchange *exchange,
|
||||
App_Vars *vars, Style *style, Panel *panel){
|
||||
|
||||
Mem_Options *mem = &vars->mem;
|
||||
Live_Views *live_set = &vars->live_set;
|
||||
Editing_Layout *layout = &vars->layout;
|
||||
|
||||
View *new_view;
|
||||
File_View *file_view;
|
||||
|
||||
new_view = live_set_alloc_view(live_set, mem);
|
||||
if (panel->view){
|
||||
view_replace_major(system, exchange, new_view, panel, live_set);
|
||||
view_show_interactive(system, fview, &vars->map_ui,
|
||||
IAct_Open, IInt_Sys_File_List, make_lit_string("Open: "));
|
||||
}
|
||||
else{
|
||||
view_set_first(new_view, panel);
|
||||
}
|
||||
file_view = file_view_init(new_view, layout);
|
||||
view_set_file(file_view, 0, vars->font_set, style, 0, 0, 0);
|
||||
new_view->map = app_get_map(vars, mapid_global);
|
||||
}
|
||||
|
||||
internal void
|
||||
|
@ -977,6 +972,8 @@ view_file_in_panel(Command_Data *cmd, Panel *panel, Editing_File *file){
|
|||
Editing_Layout *layout = cmd->layout;
|
||||
App_Vars *vars = cmd->vars;
|
||||
Style *style = cmd->style;
|
||||
Working_Set *working_set = &vars->working_set;
|
||||
Delay *delay = &vars->delay1;
|
||||
|
||||
Partition old_part;
|
||||
Temp_Memory temp;
|
||||
|
@ -986,7 +983,8 @@ view_file_in_panel(Command_Data *cmd, Panel *panel, Editing_File *file){
|
|||
new_view = live_set_alloc_view(live_set, mem);
|
||||
view_replace_major(system, exchange, new_view, panel, live_set);
|
||||
|
||||
file_view = file_view_init(new_view, layout);
|
||||
file_view = file_view_init(new_view, layout, working_set, delay,
|
||||
&vars->settings, &vars->hot_directory, mem, &vars->styles);
|
||||
|
||||
old_view = cmd->view;
|
||||
cmd->view = new_view;
|
||||
|
@ -1086,26 +1084,18 @@ COMMAND_DECL(save){
|
|||
|
||||
COMMAND_DECL(interactive_save_as){
|
||||
ProfileMomentFunction();
|
||||
USE_FILE_VIEW(fview);
|
||||
USE_VARS(vars);
|
||||
USE_LIVE_SET(live_set);
|
||||
USE_PANEL(panel);
|
||||
USE_MEM(mem);
|
||||
USE_WORKING_SET(working_set);
|
||||
USE_STYLE(style);
|
||||
USE_DELAY(delay);
|
||||
USE_EXCHANGE(exchange);
|
||||
USE_FONT_SET(font_set);
|
||||
|
||||
View *new_view = live_set_alloc_view(live_set, mem);
|
||||
view_replace_minor(system, exchange, new_view, panel, live_set);
|
||||
if (!fview){
|
||||
fview = panel_make_empty(system, exchange, vars, style, panel);
|
||||
}
|
||||
|
||||
new_view->map = &vars->map_ui;
|
||||
Interactive_View *int_view =
|
||||
interactive_view_init(system, new_view, &vars->hot_directory, style,
|
||||
working_set, font_set, delay);
|
||||
int_view->interaction = INTV_SYS_FILE_LIST;
|
||||
int_view->action = INTV_SAVE_AS;
|
||||
copy(&int_view->query, "Save As: ");
|
||||
view_show_interactive(system, fview, &vars->map_ui,
|
||||
IAct_Save_As, IInt_Sys_File_List, make_lit_string("Save As: "));
|
||||
}
|
||||
|
||||
COMMAND_DECL(change_active_panel){
|
||||
|
@ -1121,50 +1111,34 @@ COMMAND_DECL(change_active_panel){
|
|||
|
||||
COMMAND_DECL(interactive_switch_buffer){
|
||||
ProfileMomentFunction();
|
||||
USE_FILE_VIEW(fview);
|
||||
USE_VARS(vars);
|
||||
USE_LIVE_SET(live_set);
|
||||
USE_PANEL(panel);
|
||||
USE_MEM(mem);
|
||||
USE_WORKING_SET(working_set);
|
||||
USE_STYLE(style);
|
||||
USE_DELAY(delay);
|
||||
USE_EXCHANGE(exchange);
|
||||
USE_FONT_SET(font_set);
|
||||
|
||||
View *new_view = live_set_alloc_view(live_set, mem);
|
||||
view_replace_minor(system, exchange, new_view, panel, live_set);
|
||||
if (!fview){
|
||||
fview = panel_make_empty(system, exchange, vars, style, panel);
|
||||
}
|
||||
|
||||
new_view->map = &vars->map_ui;
|
||||
Interactive_View *int_view =
|
||||
interactive_view_init(system, new_view, &vars->hot_directory, style,
|
||||
working_set, font_set, delay);
|
||||
int_view->interaction = INTV_LIVE_FILE_LIST;
|
||||
int_view->action = INTV_SWITCH;
|
||||
copy(&int_view->query, "Switch File: ");
|
||||
view_show_interactive(system, fview, &vars->map_ui,
|
||||
IAct_Switch, IInt_Live_File_List, make_lit_string("Switch Buffer: "));
|
||||
}
|
||||
|
||||
COMMAND_DECL(interactive_kill_buffer){
|
||||
ProfileMomentFunction();
|
||||
USE_FILE_VIEW(fview);
|
||||
USE_VARS(vars);
|
||||
USE_LIVE_SET(live_set);
|
||||
USE_PANEL(panel);
|
||||
USE_MEM(mem);
|
||||
USE_WORKING_SET(working_set);
|
||||
USE_STYLE(style);
|
||||
USE_DELAY(delay);
|
||||
USE_EXCHANGE(exchange);
|
||||
USE_FONT_SET(font_set);
|
||||
|
||||
View *new_view = live_set_alloc_view(live_set, mem);
|
||||
view_replace_minor(system, exchange, new_view, panel, live_set);
|
||||
if (!fview){
|
||||
fview = panel_make_empty(system, exchange, vars, style, panel);
|
||||
}
|
||||
|
||||
new_view->map = &vars->map_ui;
|
||||
Interactive_View *int_view =
|
||||
interactive_view_init(system, new_view, &vars->hot_directory, style,
|
||||
working_set, font_set, delay);
|
||||
int_view->interaction = INTV_LIVE_FILE_LIST;
|
||||
int_view->action = INTV_KILL;
|
||||
copy(&int_view->query, "Kill File: ");
|
||||
view_show_interactive(system, fview, &vars->map_ui,
|
||||
IAct_Kill, IInt_Live_File_List, make_lit_string("Kill Buffer: "));
|
||||
}
|
||||
|
||||
COMMAND_DECL(kill_buffer){
|
||||
|
@ -1644,13 +1618,21 @@ COMMAND_DECL(page_up){
|
|||
view, 0, view->target_y + (height - view->font_height)*.5f);
|
||||
}
|
||||
|
||||
inline void
|
||||
open_theme_options(System_Functions *system, Exchange *exchange,
|
||||
App_Vars *vars, Live_Views *live_set, Mem_Options *mem, Panel *panel){
|
||||
COMMAND_DECL(open_color_tweaker){
|
||||
#if 0
|
||||
ProfileMomentFunction();
|
||||
USE_VARS(vars);
|
||||
USE_LIVE_SET(live_set);
|
||||
USE_MEM(mem);
|
||||
USE_PANEL(panel);
|
||||
USE_EXCHANGE(exchange);
|
||||
|
||||
{
|
||||
View *new_view = live_set_alloc_view(live_set, mem);
|
||||
view_replace_minor(system, exchange, new_view, panel, live_set);
|
||||
|
||||
new_view->map = &vars->map_ui;
|
||||
|
||||
Color_View *color_view = color_view_init(new_view, &vars->working_set);
|
||||
color_view->hot_directory = &vars->hot_directory;
|
||||
color_view->main_style = &vars->style;
|
||||
|
@ -1659,68 +1641,63 @@ open_theme_options(System_Functions *system, Exchange *exchange,
|
|||
color_view->palette_size = vars->palette_size;
|
||||
color_view->font_set = vars->font_set;
|
||||
}
|
||||
#endif
|
||||
|
||||
COMMAND_DECL(open_color_tweaker){
|
||||
ProfileMomentFunction();
|
||||
USE_FILE_VIEW(fview);
|
||||
USE_VARS(vars);
|
||||
USE_LIVE_SET(live_set);
|
||||
USE_MEM(mem);
|
||||
USE_PANEL(panel);
|
||||
USE_STYLE(style);
|
||||
USE_EXCHANGE(exchange);
|
||||
|
||||
open_theme_options(system, exchange, vars, live_set, mem, panel);
|
||||
if (!fview){
|
||||
fview = panel_make_empty(system, exchange, vars, style, panel);
|
||||
}
|
||||
|
||||
inline void
|
||||
open_config_options(System_Functions *system, Exchange *exchange,
|
||||
App_Vars *vars, Live_Views *live_set, Mem_Options *mem, Panel *panel){
|
||||
View *new_view = live_set_alloc_view(live_set, mem);
|
||||
view_replace_minor(system, exchange, new_view, panel, live_set);
|
||||
|
||||
new_view->map = &vars->map_ui;
|
||||
config_view_init(new_view, &vars->style,
|
||||
&vars->working_set, vars->font_set,
|
||||
&vars->settings);
|
||||
view_show_theme(fview, &vars->map_ui);
|
||||
}
|
||||
|
||||
COMMAND_DECL(open_config){
|
||||
ProfileMomentFunction();
|
||||
USE_FILE_VIEW(fview);
|
||||
USE_VARS(vars);
|
||||
USE_LIVE_SET(live_set);
|
||||
USE_MEM(mem);
|
||||
USE_PANEL(panel);
|
||||
USE_STYLE(style);
|
||||
USE_EXCHANGE(exchange);
|
||||
|
||||
open_config_options(system, exchange, vars, live_set, mem, panel);
|
||||
if (!fview){
|
||||
fview = panel_make_empty(system, exchange, vars, style, panel);
|
||||
}
|
||||
|
||||
view_show_config(fview, &vars->map_ui);
|
||||
}
|
||||
|
||||
COMMAND_DECL(open_menu){
|
||||
ProfileMomentFunction();
|
||||
USE_FILE_VIEW(fview);
|
||||
USE_VARS(vars);
|
||||
USE_LIVE_SET(live_set);
|
||||
USE_PANEL(panel);
|
||||
USE_MEM(mem);
|
||||
USE_WORKING_SET(working_set);
|
||||
USE_STYLE(style);
|
||||
USE_EXCHANGE(exchange);
|
||||
|
||||
View *new_view = live_set_alloc_view(live_set, mem);
|
||||
view_replace_minor(system, exchange, new_view, panel, live_set);
|
||||
if (!fview){
|
||||
fview = panel_make_empty(system, exchange, vars, style, panel);
|
||||
}
|
||||
|
||||
new_view->map = &vars->map_ui;
|
||||
Menu_View *menu_view = menu_view_init(new_view, style, working_set,
|
||||
&vars->delay1, vars->font_set);
|
||||
AllowLocal(menu_view);
|
||||
view_show_menu(fview, &vars->map_ui);
|
||||
}
|
||||
|
||||
COMMAND_DECL(close_minor_view){
|
||||
ProfileMomentFunction();
|
||||
REQ_VIEW(view);
|
||||
USE_PANEL(panel);
|
||||
USE_LIVE_SET(live_set);
|
||||
USE_EXCHANGE(exchange);
|
||||
USE_FILE_VIEW(fview);
|
||||
USE_VARS(vars);
|
||||
|
||||
view_remove_minor(system, exchange, panel, live_set);
|
||||
Command_Map *map = &vars->map_top;
|
||||
if (fview->file){
|
||||
map = app_get_map(vars, fview->file->settings.base_map_id);
|
||||
}
|
||||
view_show_file(fview, map);
|
||||
}
|
||||
|
||||
COMMAND_DECL(cursor_mark_swap){
|
||||
|
@ -3083,11 +3060,7 @@ App_Init_Sig(app_init){
|
|||
|
||||
i32 view_chunk_size = 0;
|
||||
i32 view_sizes[] = {
|
||||
sizeof(File_View),
|
||||
sizeof(Color_View),
|
||||
sizeof(Interactive_View),
|
||||
sizeof(Menu_View),
|
||||
sizeof(Config_View),
|
||||
sizeof(File_View)
|
||||
};
|
||||
|
||||
{
|
||||
|
@ -3096,7 +3069,7 @@ App_Init_Sig(app_init){
|
|||
i32 i = 0, max = 0;
|
||||
|
||||
vars->live_set.count = 0;
|
||||
vars->live_set.max = 1 + 2*panel_max_count;
|
||||
vars->live_set.max = panel_max_count;
|
||||
|
||||
for (i = 0; i < ArrayCount(view_sizes); ++i){
|
||||
view_chunk_size = Max(view_chunk_size, view_sizes[i]);
|
||||
|
@ -3447,9 +3420,9 @@ App_Step_Sig(app_step){
|
|||
i32 panel_count = vars->layout.panel_count;
|
||||
for (i32 i = 0; i < panel_count; ++i, ++panel){
|
||||
View *view = panel->view;
|
||||
if (view && view->is_minor) view = view->major;
|
||||
File_View *fview = view_to_file_view(view);
|
||||
if (fview && fview->file == out_file){
|
||||
Assert(fview);
|
||||
if (fview->file == out_file){
|
||||
view_cursor_move(fview, new_cursor);
|
||||
}
|
||||
}
|
||||
|
@ -3467,26 +3440,26 @@ App_Step_Sig(app_step){
|
|||
i32 current_width = target->width;
|
||||
i32 current_height = target->height;
|
||||
|
||||
View *view;
|
||||
Panel *panel;
|
||||
File_View *fview;
|
||||
i32 i, view_count;
|
||||
i32 i, count;
|
||||
|
||||
vars->layout.full_width = current_width;
|
||||
vars->layout.full_height = current_height;
|
||||
|
||||
view_count = vars->layout.panel_max_count;
|
||||
|
||||
if (prev_width != current_width || prev_height != current_height){
|
||||
layout_refit(&vars->layout, prev_width, prev_height);
|
||||
for (i = 0; i < view_count; ++i){
|
||||
view = live_set_get_view(&vars->live_set, i);
|
||||
if (!view->is_active) continue;
|
||||
fview = view_to_file_view(view);
|
||||
if (!fview) continue;
|
||||
|
||||
count = vars->layout.panel_count;
|
||||
panel = panels;
|
||||
for (i = 0; i < count; ++i, ++panel){
|
||||
fview = view_to_file_view(panel->view);
|
||||
Assert(fview);
|
||||
// TODO(allen): All responses to a panel changing size should
|
||||
// be handled in the same place.
|
||||
view_change_size(system, &vars->mem.general, fview);
|
||||
}
|
||||
|
||||
app_result.redraw = 1;
|
||||
}
|
||||
}
|
||||
|
@ -4178,20 +4151,20 @@ App_Step_Sig(app_step){
|
|||
case DACT_SET_LINE:
|
||||
{
|
||||
// TODO(allen): deduplicate
|
||||
View *view = panel->view;
|
||||
File_View *fview = view_to_file_view(view);
|
||||
if (!fview && view->is_minor) fview = view_to_file_view(view->major);
|
||||
if (!file){
|
||||
if (fview){
|
||||
Editing_File *file = 0;
|
||||
if (panel){
|
||||
File_View *fview = view_to_file_view(panel->view);
|
||||
file = fview->file;
|
||||
}
|
||||
else if (string.str && string.size > 0){
|
||||
file = working_set_lookup_file(working_set, string);
|
||||
}
|
||||
}
|
||||
if (file && !file->state.is_dummy){
|
||||
if (file){
|
||||
if (file->state.is_loading){
|
||||
file->preload.start_line = integer;
|
||||
}
|
||||
else{
|
||||
view_cursor_move(fview, integer, 0);
|
||||
// TODO(allen): write this case
|
||||
}
|
||||
}
|
||||
}break;
|
||||
|
@ -4199,13 +4172,13 @@ App_Step_Sig(app_step){
|
|||
case DACT_SAVE_AS:
|
||||
{
|
||||
// TODO(allen): deduplicate
|
||||
View *view = panel->view;
|
||||
File_View *fview = view_to_file_view(view);
|
||||
if (!fview && view->is_minor) fview = view_to_file_view(view->major);
|
||||
if (!file){
|
||||
if (fview){
|
||||
file = working_set_lookup_file(working_set, string);
|
||||
Editing_File *file = 0;
|
||||
if (panel){
|
||||
File_View *fview = view_to_file_view(panel->view);
|
||||
file = fview->file;
|
||||
}
|
||||
else if (string.str && string.size > 0){
|
||||
file = working_set_lookup_file(working_set, string);
|
||||
}
|
||||
if (file && !file->state.is_dummy){
|
||||
i32 sys_id = file_save_and_set_names(system, exchange, mem, working_set, file, string.str);
|
||||
|
@ -4225,13 +4198,10 @@ App_Step_Sig(app_step){
|
|||
View *view;
|
||||
File_View *fview;
|
||||
view = panel->view;
|
||||
Assert(view);
|
||||
if (view->is_minor) view = view->major;
|
||||
fview = view_to_file_view(view);
|
||||
if (fview){
|
||||
Assert(fview);
|
||||
file = fview->file;
|
||||
}
|
||||
}
|
||||
else{
|
||||
file = working_set_lookup_file(working_set, string);
|
||||
}
|
||||
|
@ -4261,7 +4231,9 @@ App_Step_Sig(app_step){
|
|||
View *new_view = live_set_alloc_view(live_set, mem);
|
||||
view_replace_major(system, exchange, new_view, panel, live_set);
|
||||
|
||||
File_View *file_view = file_view_init(new_view, &vars->layout);
|
||||
File_View *file_view = file_view_init(
|
||||
new_view, &vars->layout, working_set, &vars->delay2,
|
||||
&vars->settings, &vars->hot_directory, mem, &vars->styles);
|
||||
cmd->view = (View*)file_view;
|
||||
view_set_file(file_view, file.file, vars->font_set, style,
|
||||
system, vars->hooks[hook_open_file], &app_links);
|
||||
|
@ -4279,7 +4251,9 @@ App_Step_Sig(app_step){
|
|||
View *new_view = live_set_alloc_view(live_set, mem);
|
||||
view_replace_major(system, exchange, new_view, panel, live_set);
|
||||
|
||||
File_View *file_view = file_view_init(new_view, &vars->layout);
|
||||
File_View *file_view = file_view_init(
|
||||
new_view, &vars->layout, working_set, &vars->delay2,
|
||||
&vars->settings, &vars->hot_directory, mem, &vars->styles);
|
||||
cmd->view = (View*)file_view;
|
||||
|
||||
view_set_file(file_view, file, vars->font_set, style,
|
||||
|
@ -4300,43 +4274,32 @@ App_Step_Sig(app_step){
|
|||
|
||||
case DACT_TRY_KILL:
|
||||
{
|
||||
Editing_File *file = working_set_lookup_file(working_set, string);
|
||||
Editing_File *file = 0;
|
||||
file = working_set_lookup_file(working_set, string);
|
||||
|
||||
View *view = 0;
|
||||
if (panel){
|
||||
view = panel->view;
|
||||
}
|
||||
else{
|
||||
view = (vars->layout.panels + vars->layout.active_panel)->view;
|
||||
}
|
||||
|
||||
File_View *fview = view_to_file_view(view);
|
||||
Assert(fview);
|
||||
|
||||
if (file){
|
||||
if (buffer_needs_save(file)){
|
||||
View *new_view = live_set_alloc_view(live_set, mem);
|
||||
view_replace_minor(system, exchange, new_view, panel, live_set);
|
||||
|
||||
new_view->map = &vars->map_ui;
|
||||
Interactive_View *int_view =
|
||||
interactive_view_init(system, new_view, &vars->hot_directory, style,
|
||||
working_set, vars->font_set, &vars->delay1);
|
||||
int_view->interaction = INTV_SURE_TO_KILL_INTER;
|
||||
int_view->action = INTV_SURE_TO_KILL;
|
||||
copy(&int_view->query, "Are you sure?");
|
||||
copy(&int_view->dest, file->name.live_name);
|
||||
view_show_interactive(system, fview, &vars->map_ui,
|
||||
IAct_Sure_To_Kill, IInt_Sure_To_Kill, make_lit_string("Are you sure?"));
|
||||
copy(&fview->dest, file->name.live_name);
|
||||
}
|
||||
else{
|
||||
table_remove(&working_set->table, file->name.source_path);
|
||||
kill_file(system, exchange, general, file, live_set, &vars->layout);
|
||||
view_remove_minor(system, exchange, panel, live_set);
|
||||
}
|
||||
}
|
||||
}break;
|
||||
|
||||
case DACT_CLOSE_MINOR:
|
||||
{
|
||||
view_remove_minor(system, exchange, panel, live_set);
|
||||
}break;
|
||||
|
||||
case DACT_THEME_OPTIONS:
|
||||
{
|
||||
open_theme_options(system, exchange, vars, live_set, mem, panel);
|
||||
}break;
|
||||
|
||||
case DACT_KEYBOARD_OPTIONS:
|
||||
{
|
||||
open_config_options(system, exchange, vars, live_set, mem, panel);
|
||||
}break;
|
||||
}
|
||||
|
||||
if (string.str){
|
||||
|
@ -4363,12 +4326,6 @@ App_Step_Sig(app_step){
|
|||
view->do_view(system, exchange,
|
||||
view, inner, cmd->view,
|
||||
VMSG_RESIZE, 0, &dead_input, &active_input);
|
||||
view = (view->is_minor)?view->major:0;
|
||||
if (view){
|
||||
view->do_view(system, exchange,
|
||||
view, inner, cmd->view,
|
||||
VMSG_RESIZE, 0, &dead_input, &active_input);
|
||||
}
|
||||
}
|
||||
}
|
||||
panel->prev_inner = inner;
|
||||
|
@ -4394,18 +4351,13 @@ App_Step_Sig(app_step){
|
|||
}
|
||||
|
||||
Panel *panel = panels;
|
||||
for (i32 panel_i = vars->layout.panel_count; panel_i > 0; --panel_i, ++panel){
|
||||
i32 count = vars->layout.panel_count;
|
||||
for (i32 i = 0; i < count; ++i, ++panel){
|
||||
View *view = panel->view;
|
||||
if (view){
|
||||
view->do_view(system, exchange,
|
||||
view, panel->inner, cmd->view,
|
||||
VMSG_STYLE_CHANGE, 0, &dead_input, &active_input);
|
||||
view = (view->is_minor)?view->major:0;
|
||||
if (view){
|
||||
view->do_view(system, exchange,
|
||||
view, panel->inner, cmd->view,
|
||||
VMSG_STYLE_CHANGE, 0, &dead_input, &active_input);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4494,21 +4446,6 @@ App_Step_Sig(app_step){
|
|||
// end-of-app_step
|
||||
}
|
||||
|
||||
#if 0
|
||||
internal
|
||||
App_Alloc_Sig(app_alloc){
|
||||
Mem_Options *mem = (Mem_Options*)(handle);
|
||||
void *result = general_memory_allocate(&mem->general, size, 0);
|
||||
return(result);
|
||||
}
|
||||
|
||||
internal
|
||||
App_Free_Sig(app_free){
|
||||
Mem_Options *mem = (Mem_Options*)(handle);
|
||||
general_memory_free(&mem->general, block);
|
||||
}
|
||||
#endif
|
||||
|
||||
external App_Get_Functions_Sig(app_get_functions){
|
||||
App_Functions result = {};
|
||||
|
||||
|
@ -4516,11 +4453,6 @@ external App_Get_Functions_Sig(app_get_functions){
|
|||
result.init = app_init;
|
||||
result.step = app_step;
|
||||
|
||||
#if 0
|
||||
result.alloc = app_alloc;
|
||||
result.free = app_free;
|
||||
#endif
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
|
9
4ed.h
9
4ed.h
|
@ -115,19 +115,10 @@ struct Application_Step_Result{
|
|||
|
||||
typedef App_Step_Sig(App_Step);
|
||||
|
||||
#define App_Alloc_Sig(name) void *name(void *handle, i32 size)
|
||||
typedef App_Alloc_Sig(App_Alloc);
|
||||
|
||||
#define App_Free_Sig(name) void name(void *handle, void *block)
|
||||
typedef App_Free_Sig(App_Free);
|
||||
|
||||
struct App_Functions{
|
||||
App_Read_Command_Line *read_command_line;
|
||||
App_Init *init;
|
||||
App_Step *step;
|
||||
|
||||
App_Alloc *alloc;
|
||||
App_Free *free;
|
||||
};
|
||||
|
||||
#define App_Get_Functions_Sig(name) App_Functions name()
|
||||
|
|
|
@ -9,16 +9,7 @@
|
|||
|
||||
// TOP
|
||||
|
||||
#define VERSION_NUMBER "alpha 3.4.4"
|
||||
|
||||
#ifdef FRED_SUPER
|
||||
#define VERSION_TYPE " super!"
|
||||
#else
|
||||
#define VERSION_TYPE ""
|
||||
#endif
|
||||
|
||||
#define VERSION VERSION_NUMBER VERSION_TYPE
|
||||
|
||||
#include "4ed_version.h"
|
||||
#include "4ed_config.h"
|
||||
|
||||
#define BUFFER_EXPERIMENT_SCALPEL 0
|
||||
|
@ -53,12 +44,8 @@
|
|||
#include "4ed_file.cpp"
|
||||
#include "4ed_gui.cpp"
|
||||
#include "4ed_delay.cpp"
|
||||
#include "4ed_file_view.cpp"
|
||||
#include "4ed_color_view.cpp"
|
||||
#include "4ed_interactive_view.cpp"
|
||||
#include "4ed_menu_view.cpp"
|
||||
#include "4ed_app_settings.h"
|
||||
#include "4ed_config_view.cpp"
|
||||
#include "4ed_file_view.cpp"
|
||||
#include "4ed.cpp"
|
||||
|
||||
// BOTTOM
|
||||
|
|
1909
4ed_color_view.cpp
1909
4ed_color_view.cpp
File diff suppressed because it is too large
Load Diff
|
@ -1,89 +0,0 @@
|
|||
/*
|
||||
* Mr. 4th Dimention - Allen Webster
|
||||
*
|
||||
* 27.01.2016
|
||||
*
|
||||
* Configuration customizing view for 4coder
|
||||
*
|
||||
*/
|
||||
|
||||
// TOP
|
||||
|
||||
struct Config_View{
|
||||
View view_base;
|
||||
UI_State state;
|
||||
Style *style;
|
||||
Font_Set *font_set;
|
||||
Working_Set *working_set;
|
||||
|
||||
App_Settings *settings;
|
||||
};
|
||||
|
||||
inline Config_View*
|
||||
view_to_config_view(View *view){
|
||||
Config_View *result = 0;
|
||||
if (view->type == VIEW_TYPE_CONFIG){
|
||||
result = (Config_View*)view;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
internal i32
|
||||
step_draw_config_view(Config_View *view, Render_Target *target, i32_Rect rect,
|
||||
Input_Summary *user_input, b32 input_stage){
|
||||
i32 result = 0;
|
||||
|
||||
UI_State state =
|
||||
ui_state_init(&view->state, target, user_input,
|
||||
view->style, view->font_set, view->working_set, input_stage);
|
||||
|
||||
UI_Layout layout;
|
||||
begin_layout(&layout, rect);
|
||||
|
||||
i32 id = 0;
|
||||
|
||||
do_label(&state, &layout, literal("Config"), 2.f);
|
||||
|
||||
if (do_checkbox_list_option(++id, &state, &layout, make_lit_string("Left Ctrl + Left Alt = AltGr"),
|
||||
view->settings->lctrl_lalt_is_altgr)){
|
||||
view->settings->lctrl_lalt_is_altgr = !view->settings->lctrl_lalt_is_altgr;
|
||||
}
|
||||
|
||||
if (ui_finish_frame(&view->state, &state, &layout, rect, 0, 0)){
|
||||
result = 1;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Do_View_Sig(do_config_view){
|
||||
i32 result = 0;
|
||||
|
||||
Config_View *config_view = (Config_View*)view;
|
||||
switch (message){
|
||||
case VMSG_STEP: case VMSG_DRAW:
|
||||
result = step_draw_config_view(config_view, target, rect, user_input,
|
||||
(message == VMSG_STEP));
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
internal Config_View*
|
||||
config_view_init(View *view, Style *style, Working_Set *working_set,
|
||||
Font_Set *font_set, App_Settings *settings){
|
||||
view->type = VIEW_TYPE_CONFIG;
|
||||
view->do_view = do_config_view;
|
||||
|
||||
Config_View *result;
|
||||
result = (Config_View*)view;
|
||||
result->style = style;
|
||||
result->working_set = working_set;
|
||||
result->font_set = font_set;
|
||||
result->settings = settings;
|
||||
return result;
|
||||
}
|
||||
|
||||
// BOTTOM
|
||||
|
|
@ -8,9 +8,6 @@ enum Action_Type{
|
|||
DACT_SWITCH,
|
||||
DACT_TRY_KILL,
|
||||
DACT_KILL,
|
||||
DACT_CLOSE_MINOR,
|
||||
DACT_THEME_OPTIONS,
|
||||
DACT_KEYBOARD_OPTIONS,
|
||||
};
|
||||
|
||||
struct Delayed_Action{
|
||||
|
@ -113,6 +110,3 @@ delayed_action_repush(Delay *delay, Delayed_Action *act){
|
|||
#define delayed_switch(delay, ...) delayed_action_(delay, DACT_SWITCH, __VA_ARGS__)
|
||||
#define delayed_try_kill(delay, ...) delayed_action_(delay, DACT_TRY_KILL, __VA_ARGS__)
|
||||
#define delayed_kill(delay, ...) delayed_action_(delay, DACT_KILL, __VA_ARGS__)
|
||||
#define delayed_close_minor(delay, ...) delayed_action_(delay, DACT_CLOSE_MINOR, __VA_ARGS__)
|
||||
#define delayed_theme_options(delay, ...) delayed_action_(delay, DACT_THEME_OPTIONS, __VA_ARGS__)
|
||||
#define delayed_keyboard_options(delay, ...) delayed_action_(delay, DACT_KEYBOARD_OPTIONS, __VA_ARGS__)
|
||||
|
|
62
4ed_file.cpp
62
4ed_file.cpp
|
@ -254,16 +254,6 @@ struct Hot_Directory{
|
|||
char slash;
|
||||
};
|
||||
|
||||
internal void
|
||||
hot_directory_init(Hot_Directory *hot_directory, String base, String dir, char slash){
|
||||
hot_directory->string = base;
|
||||
hot_directory->string.str[255] = 0;
|
||||
hot_directory->string.size = 0;
|
||||
copy(&hot_directory->string, dir);
|
||||
append(&hot_directory->string, slash);
|
||||
hot_directory->slash = slash;
|
||||
}
|
||||
|
||||
internal void
|
||||
hot_directory_clean_end(Hot_Directory *hot_directory){
|
||||
String *str = &hot_directory->string;
|
||||
|
@ -326,6 +316,16 @@ hot_directory_reload(System_Functions *system, Hot_Directory *hot_directory, Wor
|
|||
hot_directory_fixup(hot_directory, working_set);
|
||||
}
|
||||
|
||||
internal void
|
||||
hot_directory_init(Hot_Directory *hot_directory, String base, String dir, char slash){
|
||||
hot_directory->string = base;
|
||||
hot_directory->string.str[255] = 0;
|
||||
hot_directory->string.size = 0;
|
||||
copy(&hot_directory->string, dir);
|
||||
append(&hot_directory->string, slash);
|
||||
hot_directory->slash = slash;
|
||||
}
|
||||
|
||||
struct Hot_Directory_Match{
|
||||
String filename;
|
||||
b32 is_folder;
|
||||
|
@ -404,5 +404,47 @@ buffer_needs_save(Editing_File *file){
|
|||
return(result);
|
||||
}
|
||||
|
||||
inline b32
|
||||
file_is_ready(Editing_File *file){
|
||||
b32 result = 0;
|
||||
if (file && file->state.is_loading == 0){
|
||||
result = 1;
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
inline Editing_File*
|
||||
working_set_contains(Working_Set *working, String filename){
|
||||
Editing_File *result = 0;
|
||||
i32 id;
|
||||
if (table_find(&working->table, filename, &id)){
|
||||
if (id < working->file_max_count){
|
||||
result = working->files + id;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// TODO(allen): Find a way to choose an ordering for these so it picks better first options.
|
||||
internal Editing_File*
|
||||
working_set_lookup_file(Working_Set *working_set, String string){
|
||||
Editing_File *file = working_set_contains(working_set, string);
|
||||
|
||||
if (!file){
|
||||
i32 file_i;
|
||||
i32 end = working_set->file_index_count;
|
||||
file = working_set->files;
|
||||
for (file_i = 0; file_i < end; ++file_i, ++file){
|
||||
if (file->name.live_name.str &&
|
||||
(string.size == 0 || has_substr(file->name.live_name, string))){
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (file_i == end) file = 0;
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
// BOTTOM
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
1322
4ed_gui.cpp
1322
4ed_gui.cpp
File diff suppressed because it is too large
Load Diff
|
@ -1,233 +0,0 @@
|
|||
/*
|
||||
* Mr. 4th Dimention - Allen Webster
|
||||
*
|
||||
* 19.09.2015
|
||||
*
|
||||
* File editing view for 4coder
|
||||
*
|
||||
*/
|
||||
|
||||
// TOP
|
||||
|
||||
enum Interactive_View_Action{
|
||||
INTV_OPEN,
|
||||
INTV_SAVE_AS,
|
||||
INTV_NEW,
|
||||
INTV_SWITCH,
|
||||
INTV_KILL,
|
||||
INTV_SURE_TO_KILL
|
||||
};
|
||||
|
||||
enum Interactive_View_Interaction{
|
||||
INTV_SYS_FILE_LIST,
|
||||
INTV_LIVE_FILE_LIST,
|
||||
INTV_SURE_TO_KILL_INTER
|
||||
};
|
||||
|
||||
struct Interactive_View{
|
||||
View view_base;
|
||||
Hot_Directory *hot_directory;
|
||||
Style *style;
|
||||
Working_Set *working_set;
|
||||
Delay *delay;
|
||||
Font_Set *font_set;
|
||||
UI_State state;
|
||||
Interactive_View_Interaction interaction;
|
||||
Interactive_View_Action action;
|
||||
int finished;
|
||||
|
||||
char query_[256];
|
||||
String query;
|
||||
char dest_[256];
|
||||
String dest;
|
||||
i32 user_action;
|
||||
};
|
||||
|
||||
inline Interactive_View*
|
||||
view_to_interactive_view(View *view){
|
||||
Interactive_View *result = 0;
|
||||
if (view->type == VIEW_TYPE_INTERACTIVE)
|
||||
result = (Interactive_View*)view;
|
||||
return result;
|
||||
}
|
||||
|
||||
internal void
|
||||
interactive_view_complete(Interactive_View *view){
|
||||
Panel *panel = view->view_base.panel;
|
||||
switch (view->action){
|
||||
case INTV_OPEN:
|
||||
delayed_open(view->delay, view->hot_directory->string, panel);
|
||||
break;
|
||||
|
||||
case INTV_SAVE_AS:
|
||||
delayed_save_as(view->delay, view->hot_directory->string, panel);
|
||||
delayed_close_minor(view->delay, panel);
|
||||
break;
|
||||
|
||||
case INTV_NEW:
|
||||
delayed_new(view->delay, view->hot_directory->string, panel);
|
||||
break;
|
||||
|
||||
case INTV_SWITCH:
|
||||
delayed_switch(view->delay, view->dest, panel);
|
||||
break;
|
||||
|
||||
case INTV_KILL:
|
||||
delayed_try_kill(view->delay, view->dest, panel);
|
||||
break;
|
||||
|
||||
case INTV_SURE_TO_KILL:
|
||||
switch (view->user_action){
|
||||
case 0:
|
||||
delayed_kill(view->delay, view->dest, panel);
|
||||
delayed_close_minor(view->delay, {}, panel);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
delayed_close_minor(view->delay, {}, panel);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
delayed_save(view->delay, view->dest, panel);
|
||||
delayed_kill(view->delay, view->dest, panel);
|
||||
delayed_close_minor(view->delay, {}, panel);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
internal i32
|
||||
step_draw_int_view(System_Functions *system, Interactive_View *view,
|
||||
Render_Target *target, i32_Rect rect,
|
||||
Input_Summary *user_input, b32 input_stage){
|
||||
if (view->finished) return 0;
|
||||
i32 result = 0;
|
||||
|
||||
UI_State state =
|
||||
ui_state_init(&view->state, target, user_input,
|
||||
view->style, view->font_set, view->working_set, input_stage);
|
||||
|
||||
UI_Layout layout;
|
||||
begin_layout(&layout, rect);
|
||||
|
||||
b32 new_dir = 0;
|
||||
b32 complete = 0;
|
||||
|
||||
do_label(&state, &layout, view->query, 1.f);
|
||||
|
||||
b32 case_sensitive = 0;
|
||||
|
||||
switch (view->interaction){
|
||||
case INTV_SYS_FILE_LIST:
|
||||
{
|
||||
b32 is_new = (view->action == INTV_NEW);
|
||||
|
||||
if (do_file_list_box(system, &state,
|
||||
&layout, view->hot_directory, 0, !is_new, case_sensitive,
|
||||
&new_dir, &complete, 0)){
|
||||
result = 1;
|
||||
}
|
||||
if (new_dir){
|
||||
hot_directory_reload(system,
|
||||
view->hot_directory, view->working_set);
|
||||
}
|
||||
}break;
|
||||
|
||||
case INTV_LIVE_FILE_LIST:
|
||||
if (do_live_file_list_box(system, &state, &layout, view->working_set, &view->dest, &complete)){
|
||||
result = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case INTV_SURE_TO_KILL_INTER:
|
||||
{
|
||||
i32 action = -1;
|
||||
char s_[256];
|
||||
String s = make_fixed_width_string(s_);
|
||||
append(&s, view->dest);
|
||||
append(&s, " has unsaved changes, kill it?");
|
||||
do_label(&state, &layout, s, 1.f);
|
||||
|
||||
i32 id = 0;
|
||||
if (do_list_option(++id, &state, &layout, make_lit_string("(Y)es"))){
|
||||
action = 0;
|
||||
}
|
||||
|
||||
if (do_list_option(++id, &state, &layout, make_lit_string("(N)o"))){
|
||||
action = 1;
|
||||
}
|
||||
|
||||
if (do_list_option(++id, &state, &layout, make_lit_string("(S)ave and kill"))){
|
||||
action = 2;
|
||||
}
|
||||
|
||||
if (action == -1 && input_stage){
|
||||
i32 key_count = user_input->keys.count;
|
||||
for (i32 i = 0; i < key_count; ++i){
|
||||
Key_Event_Data key = user_input->keys.keys[i];
|
||||
switch (key.character){
|
||||
case 'y': case 'Y': action = 0; break;
|
||||
case 'n': case 'N': action = 1; break;
|
||||
case 's': case 'S': action = 2; break;
|
||||
}
|
||||
if (action == -1 && key.keycode == key_esc) action = 1;
|
||||
if (action != -1) break;
|
||||
}
|
||||
}
|
||||
|
||||
if (action != -1){
|
||||
complete = 1;
|
||||
view->user_action = action;
|
||||
}
|
||||
}break;
|
||||
}
|
||||
|
||||
if (complete){
|
||||
view->finished = 1;
|
||||
interactive_view_complete(view);
|
||||
}
|
||||
|
||||
if (ui_finish_frame(&view->state, &state, &layout, rect, 0, 0)){
|
||||
result = 1;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Do_View_Sig(do_interactive_view){
|
||||
i32 result = 0;
|
||||
|
||||
view->mouse_cursor_type = APP_MOUSE_CURSOR_ARROW;
|
||||
Interactive_View *int_view = (Interactive_View*)view;
|
||||
switch (message){
|
||||
case VMSG_STEP: case VMSG_DRAW:
|
||||
result = step_draw_int_view(system, int_view, target, rect, user_input, (message == VMSG_STEP));
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
internal Interactive_View*
|
||||
interactive_view_init(System_Functions *system, View *view,
|
||||
Hot_Directory *hot_dir, Style *style,
|
||||
Working_Set *working_set, Font_Set *font_set, Delay *delay){
|
||||
Interactive_View *result = (Interactive_View*)view;
|
||||
view->type = VIEW_TYPE_INTERACTIVE;
|
||||
view->do_view = do_interactive_view;
|
||||
result->hot_directory = hot_dir;
|
||||
hot_directory_clean_end(hot_dir);
|
||||
hot_directory_reload(system, hot_dir, working_set);
|
||||
result->query = make_fixed_width_string(result->query_);
|
||||
result->dest = make_fixed_width_string(result->dest_);
|
||||
result->style = style;
|
||||
result->working_set = working_set;
|
||||
result->font_set = font_set;
|
||||
result->delay = delay;
|
||||
result->finished = 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
// BOTTOM
|
||||
|
|
@ -42,32 +42,13 @@ struct View;
|
|||
|
||||
typedef Do_View_Sig(Do_View_Function);
|
||||
|
||||
// TODO(allen): this shouldn't exist
|
||||
enum View_Type{
|
||||
VIEW_TYPE_NONE,
|
||||
VIEW_TYPE_FILE,
|
||||
VIEW_TYPE_COLOR,
|
||||
VIEW_TYPE_INTERACTIVE,
|
||||
VIEW_TYPE_MENU,
|
||||
VIEW_TYPE_CONFIG
|
||||
};
|
||||
|
||||
struct Panel;
|
||||
struct View{
|
||||
union{
|
||||
View *next_free;
|
||||
View *major;
|
||||
View *minor;
|
||||
};
|
||||
Panel *panel;
|
||||
Command_Map *map;
|
||||
Do_View_Function *do_view;
|
||||
Mem_Options *mem;
|
||||
i32 type;
|
||||
i32 block_size;
|
||||
Application_Mouse_Cursor mouse_cursor_type;
|
||||
b32 is_active;
|
||||
b32 is_minor;
|
||||
};
|
||||
|
||||
struct Live_Views{
|
||||
|
@ -168,8 +149,6 @@ live_set_alloc_view(Live_Views *live_set, Mem_Options *mem){
|
|||
live_set->free_view = result->next_free;
|
||||
memset(result, 0, live_set->stride);
|
||||
++live_set->count;
|
||||
result->is_active = 1;
|
||||
result->mem = mem;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -180,13 +159,11 @@ live_set_free_view(System_Functions *system, Exchange *exchange, Live_Views *liv
|
|||
view->next_free = live_set->free_view;
|
||||
live_set->free_view = view;
|
||||
--live_set->count;
|
||||
view->is_active = 0;
|
||||
}
|
||||
|
||||
inline void
|
||||
view_set_first(View *new_view, Panel *panel){
|
||||
new_view->panel = panel;
|
||||
new_view->minor = 0;
|
||||
panel->view = new_view;
|
||||
}
|
||||
|
||||
|
@ -194,47 +171,11 @@ inline void
|
|||
view_replace_major(System_Functions *system, Exchange *exchange,
|
||||
View *new_view, Panel *panel, Live_Views *live_set){
|
||||
View *view = panel->view;
|
||||
if (view->is_minor && view->major){
|
||||
live_set_free_view(system, exchange, live_set, view->major);
|
||||
}
|
||||
live_set_free_view(system, exchange, live_set, view);
|
||||
new_view->panel = panel;
|
||||
new_view->minor = 0;
|
||||
panel->view = new_view;
|
||||
}
|
||||
|
||||
inline void
|
||||
view_replace_minor(System_Functions *system, Exchange *exchange,
|
||||
View *new_view, Panel *panel, Live_Views *live_set){
|
||||
View *view = panel->view;
|
||||
|
||||
new_view->is_minor = 1;
|
||||
if (view->is_minor){
|
||||
new_view->major = view->major;
|
||||
live_set_free_view(system, exchange, live_set, view);
|
||||
}
|
||||
else{
|
||||
new_view->major = view;
|
||||
view->is_active = 0;
|
||||
}
|
||||
new_view->panel = panel;
|
||||
panel->view = new_view;
|
||||
}
|
||||
|
||||
inline void
|
||||
view_remove_minor(System_Functions *system, Exchange *exchange,
|
||||
Panel *panel, Live_Views *live_set){
|
||||
View *view = panel->view;
|
||||
View *major = view;
|
||||
if (view->is_minor){
|
||||
major = view->major;
|
||||
live_set_free_view(system, exchange, live_set, view);
|
||||
}
|
||||
Assert(major);
|
||||
panel->view = major;
|
||||
major->is_active = 1;
|
||||
}
|
||||
|
||||
struct Divider_And_ID{
|
||||
Panel_Divider* divider;
|
||||
i32 id;
|
||||
|
|
|
@ -1,91 +0,0 @@
|
|||
/*
|
||||
* Mr. 4th Dimention - Allen Webster
|
||||
*
|
||||
* 26.09.2015
|
||||
*
|
||||
* File editing view for 4coder
|
||||
*
|
||||
*/
|
||||
|
||||
// TOP
|
||||
|
||||
struct Menu_View{
|
||||
View view_base;
|
||||
Style *style;
|
||||
Working_Set *working_set;
|
||||
Delay *delay;
|
||||
Font_Set *font_set;
|
||||
UI_State state;
|
||||
};
|
||||
|
||||
inline Menu_View*
|
||||
view_to_menu_view(View *view){
|
||||
Menu_View *result = 0;
|
||||
if (view->type == VIEW_TYPE_MENU){
|
||||
result = (Menu_View*)view;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
internal i32
|
||||
step_draw_menu_view(Menu_View *view, Render_Target *target, i32_Rect rect,
|
||||
Input_Summary *user_input, b32 input_stage){
|
||||
i32 result = 0;
|
||||
|
||||
UI_State state =
|
||||
ui_state_init(&view->state, target, user_input,
|
||||
view->style, view->font_set, view->working_set, input_stage);
|
||||
|
||||
UI_Layout layout;
|
||||
begin_layout(&layout, rect);
|
||||
|
||||
i32 id = 0;
|
||||
|
||||
do_label(&state, &layout, literal("Menu"), 2.f);
|
||||
|
||||
if (do_list_option(++id, &state, &layout, make_lit_string("Theme Options"))){
|
||||
delayed_theme_options(view->delay, {}, view->view_base.panel);
|
||||
}
|
||||
|
||||
if (do_list_option(++id, &state, &layout, make_lit_string("Keyboard Layout Options"))){
|
||||
delayed_keyboard_options(view->delay, {}, view->view_base.panel);
|
||||
}
|
||||
|
||||
if (ui_finish_frame(&view->state, &state, &layout, rect, 0, 0)){
|
||||
result = 1;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Do_View_Sig(do_menu_view){
|
||||
i32 result = 0;
|
||||
|
||||
Menu_View *menu_view = (Menu_View*)view;
|
||||
switch (message){
|
||||
case VMSG_STEP: case VMSG_DRAW:
|
||||
result = step_draw_menu_view(menu_view, target, rect, user_input, (message == VMSG_STEP));
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
internal Menu_View*
|
||||
menu_view_init(View *view, Style *style, Working_Set *working_set,
|
||||
Delay *delay, Font_Set *font_set){
|
||||
view->type = VIEW_TYPE_INTERACTIVE;
|
||||
view->do_view = do_menu_view;
|
||||
|
||||
Menu_View *result;
|
||||
result = (Menu_View*)view;
|
||||
result->style = style;
|
||||
result->working_set = working_set;
|
||||
result->delay = delay;
|
||||
result->font_set = font_set;
|
||||
return result;
|
||||
}
|
||||
|
||||
// BOTTOM
|
||||
|
||||
|
|
@ -108,7 +108,6 @@ char* generate_keycode_enum(){
|
|||
return(filename);
|
||||
}
|
||||
|
||||
|
||||
char daction_enum_name[] = "Action_Type";
|
||||
char *daction_enum[] = {
|
||||
"OPEN",
|
||||
|
@ -120,9 +119,6 @@ char *daction_enum[] = {
|
|||
"SWITCH",
|
||||
"TRY_KILL",
|
||||
"KILL",
|
||||
"CLOSE_MINOR",
|
||||
"THEME_OPTIONS",
|
||||
"KEYBOARD_OPTIONS"
|
||||
};
|
||||
|
||||
char str_alloc_copy[] =
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* Mr. 4th Dimention - Allen Webster
|
||||
*
|
||||
* 01.03.2016
|
||||
*
|
||||
* Shared header for version stuff
|
||||
*
|
||||
*/
|
||||
|
||||
#define VERSION_NUMBER "alpha 3.4.4"
|
||||
|
||||
#ifdef FRED_SUPER
|
||||
#define VERSION_TYPE " super!"
|
||||
#else
|
||||
#define VERSION_TYPE ""
|
||||
#endif
|
||||
|
||||
#define VERSION VERSION_NUMBER VERSION_TYPE
|
||||
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
// TOP
|
||||
|
||||
#include "4ed_version.h"
|
||||
#include "4ed_config.h"
|
||||
|
||||
#include "4ed_meta.h"
|
||||
|
@ -1827,7 +1828,7 @@ main(int argc, char **argv){
|
|||
// TODO(allen): non-fatal diagnostics
|
||||
}
|
||||
|
||||
#define WINDOW_NAME "4coder-window"
|
||||
#define WINDOW_NAME "4coder-window: " VERSION
|
||||
|
||||
i32 window_x;
|
||||
i32 window_y;
|
||||
|
|
Loading…
Reference in New Issue