API tweaks

This commit is contained in:
Allen Webster 2016-02-25 07:12:09 -05:00
parent 3a03c6dbb0
commit 9c6fdde85d
8 changed files with 662 additions and 730 deletions

View File

@ -12,6 +12,15 @@
#ifndef FRED_BUFFER_TYPES_H #ifndef FRED_BUFFER_TYPES_H
#define FRED_BUFFER_TYPES_H #define FRED_BUFFER_TYPES_H
typedef union Range{
struct{
int min, max;
};
struct{
int start, end;
};
} Range;
typedef struct Full_Cursor{ typedef struct Full_Cursor{
int pos; int pos;
int line, character; int line, character;
@ -66,12 +75,10 @@ seek_unwrapped_xy(float x, float y, int round_down){
static Buffer_Seek static Buffer_Seek
seek_xy(float x, float y, int round_down, int unwrapped){ seek_xy(float x, float y, int round_down, int unwrapped){
Buffer_Seek result; Buffer_Seek result;
if (unwrapped){ result.type = unwrapped?buffer_seek_unwrapped_xy:buffer_seek_wrapped_xy;
result = seek_unwrapped_xy(x,y,round_down); result.x = x;
} result.y = y;
else{ result.round_down = round_down;
result = seek_wrapped_xy(x,y,round_down);
}
return(result); return(result);
} }

View File

@ -57,7 +57,7 @@ bool str_match(const char *a, int len_a, const char *b, int len_b){
HOOK_SIG(my_file_settings){ HOOK_SIG(my_file_settings){
Buffer_Summary buffer = app->get_active_buffer(cmd_context); Buffer_Summary buffer = app->get_active_buffer(cmd_context);
// NOTE(allen|a3.4.2): Whenever you ask for a buffer, you should first check that // NOTE(allen|a3.4.2): Whenever you ask for a buffer, you can check that
// the exists field is set to true. Reasons why the buffer might not exist: // the exists field is set to true. Reasons why the buffer might not exist:
// -The active panel does not contain a buffer and get_active_buffer was used // -The active panel does not contain a buffer and get_active_buffer was used
// -The index provided to get_buffer was out of range [0,max) or that index is associated to a dummy buffer // -The index provided to get_buffer was out of range [0,max) or that index is associated to a dummy buffer
@ -84,94 +84,72 @@ HOOK_SIG(my_file_settings){
CUSTOM_COMMAND_SIG(write_increment){ CUSTOM_COMMAND_SIG(write_increment){
char text[] = "++"; char text[] = "++";
int size = sizeof(text) - 1; int size = sizeof(text) - 1;
// NOTE(allen|a3.4.2): In addition to checking whether the buffer exists after a query,
// if you're going to read from or write to the buffer, you should check ready. A buffer
// is usually ready, but when a buffer has just been opened it is possible that the contents
// haven't been filled yet. If the buffer is not ready trying to read or write it is invalid.
// (See my_file_settings for comments on the exists field).
Buffer_Summary buffer = app->get_active_buffer(cmd_context); Buffer_Summary buffer = app->get_active_buffer(cmd_context);
if (buffer.exists && buffer.ready){ app->buffer_replace_range(cmd_context, &buffer, buffer.file_cursor_pos, buffer.file_cursor_pos, text, size);
app->buffer_replace_range(cmd_context, &buffer, buffer.file_cursor_pos, buffer.file_cursor_pos, text, size);
}
} }
CUSTOM_COMMAND_SIG(write_decrement){ CUSTOM_COMMAND_SIG(write_decrement){
char text[] = "--"; char text[] = "--";
int size = sizeof(text) - 1; int size = sizeof(text) - 1;
Buffer_Summary buffer = app->get_active_buffer(cmd_context); Buffer_Summary buffer = app->get_active_buffer(cmd_context);
if (buffer.exists && buffer.ready){ app->buffer_replace_range(cmd_context, &buffer, buffer.file_cursor_pos, buffer.file_cursor_pos, text, size);
app->buffer_replace_range(cmd_context, &buffer, buffer.file_cursor_pos, buffer.file_cursor_pos, text, size);
}
} }
CUSTOM_COMMAND_SIG(open_long_braces){ CUSTOM_COMMAND_SIG(open_long_braces){
File_View_Summary view; File_View_Summary view;
Buffer_Summary buffer; Buffer_Summary buffer;
char text[] = "{\n\n}";
int size = sizeof(text) - 1;
int pos;
view = app->get_active_file_view(cmd_context); view = app->get_active_file_view(cmd_context);
if (view.exists){ buffer = app->get_buffer(cmd_context, view.file_id);
buffer = app->get_active_buffer(cmd_context);
char text[] = "{\n\n}"; pos = view.cursor.pos;
int size = sizeof(text) - 1; app->buffer_replace_range(cmd_context, &buffer, pos, pos, text, size);
int pos; app->view_set_cursor(cmd_context, &view, seek_pos(pos + 2), 1);
app->view_set_mark(cmd_context, &view, seek_pos(pos + 4));
if (buffer.exists && buffer.ready){ push_parameter(app, cmd_context, par_range_start, pos);
pos = view.cursor.pos; push_parameter(app, cmd_context, par_range_end, pos + size);
app->buffer_replace_range(cmd_context, &buffer, pos, pos, text, size); push_parameter(app, cmd_context, par_clear_blank_lines, 0);
app->view_set_cursor(cmd_context, &view, seek_pos(pos + 2), 1); exec_command(cmd_context, cmdid_auto_tab_range);
app->view_set_mark(cmd_context, &view, seek_pos(pos + 4));
push_parameter(app, cmd_context, par_range_start, pos);
push_parameter(app, cmd_context, par_range_end, pos + size);
push_parameter(app, cmd_context, par_clear_blank_lines, 0);
exec_command(cmd_context, cmdid_auto_tab_range);
}
}
} }
CUSTOM_COMMAND_SIG(ifdef_off){ CUSTOM_COMMAND_SIG(ifdef_off){
File_View_Summary view; File_View_Summary view;
Buffer_Summary buffer; Buffer_Summary buffer;
char text1[] = "#if 0\n";
int size1 = sizeof(text1) - 1;
char text2[] = "#endif\n";
int size2 = sizeof(text2) - 1;
Range range;
int pos;
view = app->get_active_file_view(cmd_context); view = app->get_active_file_view(cmd_context);
if (view.exists){ buffer = app->get_active_buffer(cmd_context);
buffer = app->get_active_buffer(cmd_context);
char text1[] = "#if 0\n"; range = get_range(&view);
int size1 = sizeof(text1) - 1; pos = range.min;
char text2[] = "#endif\n"; app->buffer_replace_range(cmd_context, &buffer, pos, pos, text1, size1);
int size2 = sizeof(text2) - 1;
int pos, c, m; push_parameter(app, cmd_context, par_range_start, pos);
push_parameter(app, cmd_context, par_range_end, pos);
exec_command(cmd_context, cmdid_auto_tab_range);
if (buffer.exists && buffer.ready){ app->refresh_file_view(cmd_context, &view);
c = view.cursor.pos; range = get_range(&view);
m = view.mark.pos; pos = range.max;
pos = (c<m)?(c):(m);
app->buffer_replace_range(cmd_context, &buffer, pos, pos, text1, size1); app->buffer_replace_range(cmd_context, &buffer, pos, pos, text2, size2);
push_parameter(app, cmd_context, par_range_start, pos); push_parameter(app, cmd_context, par_range_start, pos);
push_parameter(app, cmd_context, par_range_end, pos); push_parameter(app, cmd_context, par_range_end, pos);
exec_command(cmd_context, cmdid_auto_tab_range); exec_command(cmd_context, cmdid_auto_tab_range);
app->refresh_file_view(cmd_context, &view);
c = view.cursor.pos;
m = view.mark.pos;
pos = (c>m)?(c):(m);
app->buffer_replace_range(cmd_context, &buffer, pos, pos, text2, size2);
push_parameter(app, cmd_context, par_range_start, pos);
push_parameter(app, cmd_context, par_range_end, pos);
exec_command(cmd_context, cmdid_auto_tab_range);
}
}
} }
CUSTOM_COMMAND_SIG(backspace_word){ CUSTOM_COMMAND_SIG(backspace_word){
@ -180,17 +158,14 @@ CUSTOM_COMMAND_SIG(backspace_word){
int pos2, pos1; int pos2, pos1;
view = app->get_active_file_view(cmd_context); view = app->get_active_file_view(cmd_context);
if (view.exists){
pos2 = view.cursor.pos;
exec_command(cmd_context, cmdid_seek_alphanumeric_left);
app->refresh_file_view(cmd_context, &view);
pos1 = view.cursor.pos;
if (pos1 < pos2){ pos2 = view.cursor.pos;
buffer = app->get_buffer(cmd_context, view.file_id); exec_command(cmd_context, cmdid_seek_alphanumeric_left);
app->buffer_replace_range(cmd_context, &buffer, pos1, pos2, 0, 0); app->refresh_file_view(cmd_context, &view);
} pos1 = view.cursor.pos;
}
buffer = app->get_buffer(cmd_context, view.file_id);
app->buffer_replace_range(cmd_context, &buffer, pos1, pos2, 0, 0);
} }
CUSTOM_COMMAND_SIG(switch_to_compilation){ CUSTOM_COMMAND_SIG(switch_to_compilation){
@ -205,12 +180,9 @@ CUSTOM_COMMAND_SIG(switch_to_compilation){
// to change the specific type of view and set files even when the view didn't // to change the specific type of view and set files even when the view didn't
// contain a file. // contain a file.
view = app->get_active_file_view(cmd_context); view = app->get_active_file_view(cmd_context);
if (view.exists){ buffer = app->get_buffer_by_name(cmd_context, make_string(name, name_size));
buffer = app->get_buffer_by_name(cmd_context, make_string(name, name_size));
if (buffer.exists){ app->view_set_file(cmd_context, &view, buffer.file_id);
app->view_set_file(cmd_context, &view, buffer.file_id);
}
}
} }
CUSTOM_COMMAND_SIG(move_up_10){ CUSTOM_COMMAND_SIG(move_up_10){
@ -218,20 +190,18 @@ CUSTOM_COMMAND_SIG(move_up_10){
float x, y; float x, y;
view = app->get_active_file_view(cmd_context); view = app->get_active_file_view(cmd_context);
if (view.exists){ x = view.preferred_x;
x = view.preferred_x;
if (view.unwrapped_lines){ if (view.unwrapped_lines){
y = view.cursor.unwrapped_y; y = view.cursor.unwrapped_y;
}
else{
y = view.cursor.wrapped_y;
}
y -= 10*view.line_height;
app->view_set_cursor(cmd_context, &view, seek_xy(x, y, 0, view.unwrapped_lines), 0);
} }
else{
y = view.cursor.wrapped_y;
}
y -= 10*view.line_height;
app->view_set_cursor(cmd_context, &view, seek_xy(x, y, 0, view.unwrapped_lines), 0);
} }
CUSTOM_COMMAND_SIG(move_down_10){ CUSTOM_COMMAND_SIG(move_down_10){
@ -239,20 +209,18 @@ CUSTOM_COMMAND_SIG(move_down_10){
float x, y; float x, y;
view = app->get_active_file_view(cmd_context); view = app->get_active_file_view(cmd_context);
if (view.exists){ x = view.preferred_x;
x = view.preferred_x;
if (view.unwrapped_lines){ if (view.unwrapped_lines){
y = view.cursor.wrapped_y; y = view.cursor.wrapped_y;
}
else{
y = view.cursor.wrapped_y;
}
y += 10*view.line_height;
app->view_set_cursor(cmd_context, &view, seek_xy(x, y, 0, view.unwrapped_lines), 0);
} }
else{
y = view.cursor.wrapped_y;
}
y += 10*view.line_height;
app->view_set_cursor(cmd_context, &view, seek_xy(x, y, 0, view.unwrapped_lines), 0);
} }
CUSTOM_COMMAND_SIG(switch_to_file_in_quotes){ CUSTOM_COMMAND_SIG(switch_to_file_in_quotes){
@ -264,7 +232,7 @@ CUSTOM_COMMAND_SIG(switch_to_file_in_quotes){
view = app->get_active_file_view(cmd_context); view = app->get_active_file_view(cmd_context);
if (view.exists){ if (view.exists){
buffer = app->get_buffer(cmd_context, view.file_id); buffer = app->get_buffer(cmd_context, view.file_id);
if (buffer.exists && buffer.ready){ if (buffer.ready){
pos = view.cursor.pos; pos = view.cursor.pos;
app->buffer_seek_delimiter(cmd_context, &buffer, pos, '"', 1, &end); app->buffer_seek_delimiter(cmd_context, &buffer, pos, '"', 1, &end);
app->buffer_seek_delimiter(cmd_context, &buffer, pos, '"', 0, &start); app->buffer_seek_delimiter(cmd_context, &buffer, pos, '"', 0, &start);
@ -283,6 +251,8 @@ CUSTOM_COMMAND_SIG(switch_to_file_in_quotes){
append(&file_name, make_string(short_file_name, size)); append(&file_name, make_string(short_file_name, size));
buffer = app->get_buffer_by_name(cmd_context, file_name); buffer = app->get_buffer_by_name(cmd_context, file_name);
exec_command(cmd_context, cmdid_change_active_panel);
view = app->get_active_file_view(cmd_context);
if (buffer.exists){ if (buffer.exists){
app->view_set_file(cmd_context, &view, buffer.file_id); app->view_set_file(cmd_context, &view, buffer.file_id);
} }

View File

@ -215,6 +215,21 @@ push_directory(Application_Links *app, void *cmd_context){
#define expand_string(d) ((d).str), ((d).size) #define expand_string(d) ((d).str), ((d).size)
inline Range
get_range(File_View_Summary *view){
Range range;
if (view->cursor.pos < view->mark.pos){
range.min = view->cursor.pos;
range.max = view->mark.pos;
}
else{
range.max = view->cursor.pos;
range.min = view->mark.pos;
}
return(range);
}
#if DisableMacroTranslations == 0 #if DisableMacroTranslations == 0
inline void inline void

View File

@ -273,6 +273,9 @@ tailstr(String str){
#ifdef FCPP_STRING_IMPLEMENTATION #ifdef FCPP_STRING_IMPLEMENTATION
#ifndef FCPP_DID_STRING_IMPLEMENTATION
#define FCPP_DID_STRING_IMPLEMENTATION
FCPP_LINK int FCPP_LINK int
str_size(char *str){ str_size(char *str){
int i = 0; int i = 0;
@ -1171,6 +1174,8 @@ wildcard_match(Absolutes *absolutes, String x, int case_sensitive){
return wildcard_match(absolutes, x.str, case_sensitive); return wildcard_match(absolutes, x.str, case_sensitive);
} }
#endif // #ifndef FCPP_DID_STRING_IMPLEMENTATION
#undef FCPP_STRING_IMPLEMENTATION #undef FCPP_STRING_IMPLEMENTATION
#endif // #ifdef FCPP_STRING_IMPLEMENTATION #endif // #ifdef FCPP_STRING_IMPLEMENTATION

232
4ed.cpp
View File

@ -1086,13 +1086,6 @@ COMMAND_DECL(save){
USE_PANEL(panel); USE_PANEL(panel);
delayed_action(delay, DACT_SAVE, file->name.source_path, panel); delayed_action(delay, DACT_SAVE, file->name.source_path, panel);
#if 0
String *file_path = &file->name.source_path;
if (file_path->size > 0){
i32 sys_id = file_save(system, exchange, mem, file, file_path->str);
app_push_file_binding(vars, sys_id, get_file_id(working_set, file));
}
#endif
} }
COMMAND_DECL(interactive_save_as){ COMMAND_DECL(interactive_save_as){
@ -2533,92 +2526,12 @@ setup_ui_commands(Command_Map *commands, Partition *part, Key_Codes *codes, Comm
internal void internal void
setup_file_commands(Command_Map *commands, Partition *part, Key_Codes *codes, Command_Map *parent){ setup_file_commands(Command_Map *commands, Partition *part, Key_Codes *codes, Command_Map *parent){
map_init(commands, part, 101, parent); map_init(commands, part, 10, parent);
commands->vanilla_keyboard_default.function = command_write_character;
map_add(commands, codes->left, MDFR_NONE, command_move_left);
map_add(commands, codes->right, MDFR_NONE, command_move_right);
map_add(commands, codes->del, MDFR_NONE, command_delete);
map_add(commands, codes->back, MDFR_NONE, command_backspace);
map_add(commands, codes->up, MDFR_NONE, command_move_up);
map_add(commands, codes->down, MDFR_NONE, command_move_down);
map_add(commands, codes->end, MDFR_NONE, command_seek_end_of_line);
map_add(commands, codes->home, MDFR_NONE, command_seek_beginning_of_line);
map_add(commands, codes->page_up, MDFR_NONE, command_page_up);
map_add(commands, codes->page_down, MDFR_NONE, command_page_down);
map_add(commands, codes->right, MDFR_CTRL, command_seek_alphanumeric_or_camel_right);
map_add(commands, codes->left, MDFR_CTRL, command_seek_alphanumeric_or_camel_left);
map_add(commands, codes->up, MDFR_CTRL, command_seek_whitespace_up);
map_add(commands, codes->down, MDFR_CTRL, command_seek_whitespace_down);
map_add(commands, ' ', MDFR_CTRL, command_set_mark);
map_add(commands, 'm', MDFR_CTRL, command_cursor_mark_swap);
map_add(commands, 'c', MDFR_CTRL, command_copy);
map_add(commands, 'x', MDFR_CTRL, command_cut);
map_add(commands, 'v', MDFR_CTRL, command_paste);
map_add(commands, 'V', MDFR_CTRL, command_paste_next);
map_add(commands, 'z', MDFR_CTRL, command_undo);
map_add(commands, 'y', MDFR_CTRL, command_redo);
map_add(commands, 'Z', MDFR_CTRL, command_timeline_scrub);
map_add(commands, codes->left, MDFR_ALT, command_increase_rewind_speed);
map_add(commands, codes->right, MDFR_ALT, command_increase_fastforward_speed);
map_add(commands, codes->down, MDFR_ALT, command_stop_rewind_fastforward);
map_add(commands, 'h', MDFR_CTRL, command_history_backward);
map_add(commands, 'H', MDFR_CTRL, command_history_forward);
map_add(commands, 'd', MDFR_CTRL, command_delete_range);
map_add(commands, 'l', MDFR_CTRL, command_toggle_line_wrap);
map_add(commands, '?', MDFR_CTRL, command_toggle_show_whitespace);
map_add(commands, '|', MDFR_CTRL, command_toggle_tokens);
map_add(commands, 'u', MDFR_CTRL, command_to_uppercase);
map_add(commands, 'j', MDFR_CTRL, command_to_lowercase);
map_add(commands, '~', MDFR_CTRL, command_clean_all_lines);
map_add(commands, 'f', MDFR_CTRL, command_search);
map_add(commands, 'r', MDFR_CTRL, command_reverse_search);
map_add(commands, 'g', MDFR_CTRL, command_goto_line);
map_add(commands, '\n', MDFR_NONE, compose_write_auto_tab_line);
map_add(commands, '}', MDFR_NONE, compose_write_auto_tab_line);
map_add(commands, ')', MDFR_NONE, compose_write_auto_tab_line);
map_add(commands, ']', MDFR_NONE, compose_write_auto_tab_line);
map_add(commands, ';', MDFR_NONE, compose_write_auto_tab_line);
map_add(commands, '#', MDFR_NONE, compose_write_auto_tab_line);
map_add(commands, '\t', MDFR_NONE, command_word_complete);
map_add(commands, '\t', MDFR_CTRL, command_auto_tab_range);
map_add(commands, '\t', MDFR_SHIFT, command_auto_tab_line_at_cursor);
map_add(commands, 'K', MDFR_CTRL, command_kill_buffer);
map_add(commands, 'O', MDFR_CTRL, command_reopen);
map_add(commands, 's', MDFR_CTRL, command_save);
map_add(commands, 'w', MDFR_CTRL, command_interactive_save_as);
#if UseFileHistoryDump
map_add(commands, 'h', MDFR_ALT, command_save_history);
#endif
} }
internal void internal void
setup_top_commands(Command_Map *commands, Partition *part, Key_Codes *codes, Command_Map *parent){ setup_top_commands(Command_Map *commands, Partition *part, Key_Codes *codes, Command_Map *parent){
map_init(commands, part, 51, parent); map_init(commands, part, 5, parent);
#if FRED_INTERNAL
map_add(commands, 'd', MDFR_ALT, command_open_debug_view);
#endif
map_add(commands, 'p', MDFR_CTRL, command_open_panel_vsplit);
map_add(commands, '-', MDFR_CTRL, command_open_panel_hsplit);
map_add(commands, 'P', MDFR_CTRL, command_close_panel);
map_add(commands, 'n', MDFR_CTRL, command_interactive_new);
map_add(commands, 'o', MDFR_CTRL, command_interactive_open);
map_add(commands, ',', MDFR_CTRL, command_change_active_panel);
map_add(commands, 'k', MDFR_CTRL, command_interactive_kill_buffer);
map_add(commands, 'i', MDFR_CTRL, command_interactive_switch_buffer);
map_add(commands, 'c', MDFR_ALT, command_open_color_tweaker);
map_add(commands, 'x', MDFR_ALT, command_open_menu);
map_add(commands, 'm', MDFR_ALT, command_build_here);
} }
internal void internal void
@ -3091,9 +3004,16 @@ app_setup_memory(Application_Memory *memory){
internal i32 internal i32
execute_special_tool(void *memory, i32 size, Command_Line_Parameters clparams){ execute_special_tool(void *memory, i32 size, Command_Line_Parameters clparams){
char message[] = "Hell World!"; i32 result;
i32 result = sizeof(message) - 1; char message[] = "tool was not specified or is invalid";
result = sizeof(message) - 1;
memcpy(memory, message, result); memcpy(memory, message, result);
if (clparams.argc > 2){
if (match(clparams.argv[2], "version")){
result = sizeof(VERSION) - 1;
memcpy(memory, VERSION, result);
}
}
return(result); return(result);
} }
@ -3179,37 +3099,38 @@ App_Init_Sig(app_init){
setup_command_table(); setup_command_table();
Command_Map *global = &vars->map_top; Command_Map *global = &vars->map_top;
if (vars->config_api.get_bindings){ Assert(vars->config_api.get_bindings != 0);
i32 size = partition_remaining(partition);
void *data = partition_current(partition);
// TODO(allen): Use a giant bubble of general memory for this. i32 size = partition_remaining(partition);
void *data = partition_current(partition);
// TODO(allen): Use a giant bubble of general memory for this.
// So that it doesn't interfere with the command maps as they allocate // So that it doesn't interfere with the command maps as they allocate
// their own memory. // their own memory.
i32 wanted_size = vars->config_api.get_bindings(data, size, codes); i32 wanted_size = vars->config_api.get_bindings(data, size, codes);
b32 did_top = 0; b32 did_top = 0;
b32 did_file = 0; b32 did_file = 0;
if (wanted_size <= size){ if (wanted_size <= size){
partition_allocate(partition, wanted_size); partition_allocate(partition, wanted_size);
Binding_Unit *unit = (Binding_Unit*)data; Binding_Unit *unit = (Binding_Unit*)data;
if (unit->type == unit_header && unit->header.error == 0){ if (unit->type == unit_header && unit->header.error == 0){
Binding_Unit *end = unit + unit->header.total_size; Binding_Unit *end = unit + unit->header.total_size;
i32 user_map_count = unit->header.user_map_count; i32 user_map_count = unit->header.user_map_count;
vars->map_id_table = vars->map_id_table =
push_array(&vars->mem.part, i32, user_map_count); push_array(&vars->mem.part, i32, user_map_count);
vars->user_maps = vars->user_maps =
push_array(&vars->mem.part, Command_Map, user_map_count); push_array(&vars->mem.part, Command_Map, user_map_count);
vars->user_map_count = user_map_count; vars->user_map_count = user_map_count;
Command_Map *mapptr = 0; Command_Map *mapptr = 0;
for (++unit; unit < end; ++unit){ for (++unit; unit < end; ++unit){
switch (unit->type){ switch (unit->type){
case unit_map_begin: case unit_map_begin:
{ {
int table_max = unit->map_begin.bind_count * 3 / 2; int table_max = unit->map_begin.bind_count * 3 / 2;
@ -3234,50 +3155,50 @@ App_Init_Sig(app_init){
}break; }break;
case unit_inherit: case unit_inherit:
if (mapptr){ if (mapptr){
Command_Map *parent = 0; Command_Map *parent = 0;
int mapid = unit->map_inherit.mapid; int mapid = unit->map_inherit.mapid;
if (mapid == mapid_global) parent = &vars->map_top; if (mapid == mapid_global) parent = &vars->map_top;
else if (mapid == mapid_file) parent = &vars->map_file; else if (mapid == mapid_file) parent = &vars->map_file;
else if (mapid < mapid_global){ else if (mapid < mapid_global){
i32 index = app_get_or_add_map_index(vars, mapid); i32 index = app_get_or_add_map_index(vars, mapid);
if (index < user_map_count) parent = vars->user_maps + index; if (index < user_map_count) parent = vars->user_maps + index;
else parent = 0; else parent = 0;
} }
mapptr->parent = parent; mapptr->parent = parent;
}break; }break;
case unit_binding: case unit_binding:
if (mapptr){ if (mapptr){
Command_Function func = 0; Command_Function func = 0;
if (unit->binding.command_id >= 0 && unit->binding.command_id < cmdid_count) if (unit->binding.command_id >= 0 && unit->binding.command_id < cmdid_count)
func = command_table [unit->binding.command_id]; func = command_table [unit->binding.command_id];
if (func){ if (func){
if (unit->binding.code == 0 && unit->binding.modifiers == 0){ if (unit->binding.code == 0 && unit->binding.modifiers == 0){
mapptr->vanilla_keyboard_default.function = func; mapptr->vanilla_keyboard_default.function = func;
} }
else{ else{
map_add(mapptr, unit->binding.code, unit->binding.modifiers, func); map_add(mapptr, unit->binding.code, unit->binding.modifiers, func);
}
} }
} }
break; }
break;
case unit_callback: case unit_callback:
if (mapptr){ if (mapptr){
Command_Function func = command_user_callback; Command_Function func = command_user_callback;
Custom_Command_Function *custom = unit->callback.func; Custom_Command_Function *custom = unit->callback.func;
if (func){ if (func){
if (unit->callback.code == 0 && unit->callback.modifiers == 0){ if (unit->callback.code == 0 && unit->callback.modifiers == 0){
mapptr->vanilla_keyboard_default.function = func; mapptr->vanilla_keyboard_default.function = func;
mapptr->vanilla_keyboard_default.custom = custom; mapptr->vanilla_keyboard_default.custom = custom;
} }
else{ else{
map_add(mapptr, unit->callback.code, unit->callback.modifiers, func, custom); map_add(mapptr, unit->callback.code, unit->callback.modifiers, func, custom);
}
} }
} }
break; }
break;
case unit_hook: case unit_hook:
{ {
@ -3286,18 +3207,17 @@ App_Init_Sig(app_init){
vars->hooks[hook_id] = unit->hook.func; vars->hooks[hook_id] = unit->hook.func;
} }
}break; }break;
}
} }
} }
} }
}
if (!did_top) setup_top_commands(&vars->map_top, &vars->mem.part, codes, global); if (!did_top) setup_top_commands(&vars->map_top, &vars->mem.part, codes, global);
if (!did_file) setup_file_commands(&vars->map_file, &vars->mem.part, codes, global); if (!did_file) setup_file_commands(&vars->map_file, &vars->mem.part, codes, global);
}
else{ #if !defined(FRED_SUPER)
setup_top_commands(&vars->map_top, &vars->mem.part, codes, global); vars->hooks[hook_start] = 0;
setup_file_commands(&vars->map_file, &vars->mem.part, codes, global); #endif
}
setup_ui_commands(&vars->map_ui, &vars->mem.part, codes, global); setup_ui_commands(&vars->map_ui, &vars->mem.part, codes, global);
#if FRED_INTERNAL #if FRED_INTERNAL

View File

@ -9,6 +9,16 @@
// TOP // TOP
#define VERSION_NUMBER "alpha 3.4.3"
#ifdef FRED_SUPER
#define VERSION_TYPE " super!"
#else
#define VERSION_TYPE ""
#endif
#define VERSION VERSION_NUMBER VERSION_TYPE
#include "4ed_config.h" #include "4ed_config.h"
#define BUFFER_EXPERIMENT_SCALPEL 0 #define BUFFER_EXPERIMENT_SCALPEL 0

View File

@ -9,10 +9,6 @@
// TOP // TOP
struct Range{
i32 start, end;
};
struct File_View_Mode{ struct File_View_Mode{
b8 rewrite; b8 rewrite;
}; };

View File

@ -24,7 +24,12 @@
#include "4ed_dll_reader.h" #include "4ed_dll_reader.h"
#include "4coder_custom.h" #include "4coder_custom.cpp"
#undef exec_command
#undef exec_command_keep_stack
#undef clear_parameters
#include "4ed_system.h" #include "4ed_system.h"
#include "4ed_rendering.h" #include "4ed_rendering.h"
#include "4ed.h" #include "4ed.h"
@ -1602,6 +1607,10 @@ main(int argc, char **argv){
} }
#endif #endif
if (win32vars.custom_api.get_bindings == 0){
win32vars.custom_api.get_bindings = (Get_Binding_Data_Function*)get_bindings;
}
Thread_Context background[4]; Thread_Context background[4];
memset(background, 0, sizeof(background)); memset(background, 0, sizeof(background));
win32vars.groups[BACKGROUND_THREADS].threads = background; win32vars.groups[BACKGROUND_THREADS].threads = background;