API tweaks
parent
3a03c6dbb0
commit
9c6fdde85d
|
@ -12,6 +12,15 @@
|
|||
#ifndef 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{
|
||||
int pos;
|
||||
int line, character;
|
||||
|
@ -66,12 +75,10 @@ seek_unwrapped_xy(float x, float y, int round_down){
|
|||
static Buffer_Seek
|
||||
seek_xy(float x, float y, int round_down, int unwrapped){
|
||||
Buffer_Seek result;
|
||||
if (unwrapped){
|
||||
result = seek_unwrapped_xy(x,y,round_down);
|
||||
}
|
||||
else{
|
||||
result = seek_wrapped_xy(x,y,round_down);
|
||||
}
|
||||
result.type = unwrapped?buffer_seek_unwrapped_xy:buffer_seek_wrapped_xy;
|
||||
result.x = x;
|
||||
result.y = y;
|
||||
result.round_down = round_down;
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ bool str_match(const char *a, int len_a, const char *b, int len_b){
|
|||
HOOK_SIG(my_file_settings){
|
||||
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 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
|
||||
|
@ -84,94 +84,72 @@ HOOK_SIG(my_file_settings){
|
|||
CUSTOM_COMMAND_SIG(write_increment){
|
||||
char text[] = "++";
|
||||
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);
|
||||
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){
|
||||
char text[] = "--";
|
||||
int size = sizeof(text) - 1;
|
||||
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){
|
||||
File_View_Summary view;
|
||||
Buffer_Summary buffer;
|
||||
char text[] = "{\n\n}";
|
||||
int size = sizeof(text) - 1;
|
||||
int pos;
|
||||
|
||||
view = app->get_active_file_view(cmd_context);
|
||||
if (view.exists){
|
||||
buffer = app->get_active_buffer(cmd_context);
|
||||
buffer = app->get_buffer(cmd_context, view.file_id);
|
||||
|
||||
char text[] = "{\n\n}";
|
||||
int size = sizeof(text) - 1;
|
||||
int pos;
|
||||
pos = view.cursor.pos;
|
||||
app->buffer_replace_range(cmd_context, &buffer, pos, pos, text, size);
|
||||
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){
|
||||
pos = view.cursor.pos;
|
||||
app->buffer_replace_range(cmd_context, &buffer, pos, pos, text, size);
|
||||
app->view_set_cursor(cmd_context, &view, seek_pos(pos + 2), 1);
|
||||
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);
|
||||
}
|
||||
}
|
||||
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){
|
||||
File_View_Summary view;
|
||||
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);
|
||||
if (view.exists){
|
||||
buffer = app->get_active_buffer(cmd_context);
|
||||
buffer = app->get_active_buffer(cmd_context);
|
||||
|
||||
char text1[] = "#if 0\n";
|
||||
int size1 = sizeof(text1) - 1;
|
||||
range = get_range(&view);
|
||||
pos = range.min;
|
||||
|
||||
char text2[] = "#endif\n";
|
||||
int size2 = sizeof(text2) - 1;
|
||||
app->buffer_replace_range(cmd_context, &buffer, pos, pos, text1, size1);
|
||||
|
||||
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){
|
||||
c = view.cursor.pos;
|
||||
m = view.mark.pos;
|
||||
pos = (c<m)?(c):(m);
|
||||
app->refresh_file_view(cmd_context, &view);
|
||||
range = get_range(&view);
|
||||
pos = range.max;
|
||||
|
||||
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_end, pos);
|
||||
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);
|
||||
}
|
||||
}
|
||||
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){
|
||||
|
@ -180,17 +158,14 @@ CUSTOM_COMMAND_SIG(backspace_word){
|
|||
int pos2, pos1;
|
||||
|
||||
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){
|
||||
buffer = app->get_buffer(cmd_context, view.file_id);
|
||||
app->buffer_replace_range(cmd_context, &buffer, pos1, pos2, 0, 0);
|
||||
}
|
||||
}
|
||||
pos2 = view.cursor.pos;
|
||||
exec_command(cmd_context, cmdid_seek_alphanumeric_left);
|
||||
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){
|
||||
|
@ -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
|
||||
// contain a file.
|
||||
view = app->get_active_file_view(cmd_context);
|
||||
if (view.exists){
|
||||
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);
|
||||
}
|
||||
}
|
||||
buffer = app->get_buffer_by_name(cmd_context, make_string(name, name_size));
|
||||
|
||||
app->view_set_file(cmd_context, &view, buffer.file_id);
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(move_up_10){
|
||||
|
@ -218,20 +190,18 @@ CUSTOM_COMMAND_SIG(move_up_10){
|
|||
float x, y;
|
||||
|
||||
view = app->get_active_file_view(cmd_context);
|
||||
if (view.exists){
|
||||
x = view.preferred_x;
|
||||
x = view.preferred_x;
|
||||
|
||||
if (view.unwrapped_lines){
|
||||
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);
|
||||
if (view.unwrapped_lines){
|
||||
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);
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(move_down_10){
|
||||
|
@ -239,20 +209,18 @@ CUSTOM_COMMAND_SIG(move_down_10){
|
|||
float x, y;
|
||||
|
||||
view = app->get_active_file_view(cmd_context);
|
||||
if (view.exists){
|
||||
x = view.preferred_x;
|
||||
x = view.preferred_x;
|
||||
|
||||
if (view.unwrapped_lines){
|
||||
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);
|
||||
if (view.unwrapped_lines){
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
if (view.exists){
|
||||
buffer = app->get_buffer(cmd_context, view.file_id);
|
||||
if (buffer.exists && buffer.ready){
|
||||
if (buffer.ready){
|
||||
pos = view.cursor.pos;
|
||||
app->buffer_seek_delimiter(cmd_context, &buffer, pos, '"', 1, &end);
|
||||
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));
|
||||
|
||||
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){
|
||||
app->view_set_file(cmd_context, &view, buffer.file_id);
|
||||
}
|
||||
|
|
|
@ -215,6 +215,21 @@ push_directory(Application_Links *app, void *cmd_context){
|
|||
|
||||
#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
|
||||
|
||||
inline void
|
||||
|
|
|
@ -273,6 +273,9 @@ tailstr(String str){
|
|||
|
||||
#ifdef FCPP_STRING_IMPLEMENTATION
|
||||
|
||||
#ifndef FCPP_DID_STRING_IMPLEMENTATION
|
||||
#define FCPP_DID_STRING_IMPLEMENTATION
|
||||
|
||||
FCPP_LINK int
|
||||
str_size(char *str){
|
||||
int i = 0;
|
||||
|
@ -1171,6 +1174,8 @@ wildcard_match(Absolutes *absolutes, String x, int case_sensitive){
|
|||
return wildcard_match(absolutes, x.str, case_sensitive);
|
||||
}
|
||||
|
||||
#endif // #ifndef FCPP_DID_STRING_IMPLEMENTATION
|
||||
|
||||
#undef FCPP_STRING_IMPLEMENTATION
|
||||
#endif // #ifdef FCPP_STRING_IMPLEMENTATION
|
||||
|
||||
|
|
232
4ed.cpp
232
4ed.cpp
|
@ -1086,13 +1086,6 @@ COMMAND_DECL(save){
|
|||
USE_PANEL(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){
|
||||
|
@ -2533,92 +2526,12 @@ setup_ui_commands(Command_Map *commands, Partition *part, Key_Codes *codes, Comm
|
|||
|
||||
internal void
|
||||
setup_file_commands(Command_Map *commands, Partition *part, Key_Codes *codes, Command_Map *parent){
|
||||
map_init(commands, part, 101, 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
|
||||
map_init(commands, part, 10, parent);
|
||||
}
|
||||
|
||||
internal void
|
||||
setup_top_commands(Command_Map *commands, Partition *part, Key_Codes *codes, Command_Map *parent){
|
||||
map_init(commands, part, 51, 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);
|
||||
map_init(commands, part, 5, parent);
|
||||
}
|
||||
|
||||
internal void
|
||||
|
@ -3091,9 +3004,16 @@ app_setup_memory(Application_Memory *memory){
|
|||
|
||||
internal i32
|
||||
execute_special_tool(void *memory, i32 size, Command_Line_Parameters clparams){
|
||||
char message[] = "Hell World!";
|
||||
i32 result = sizeof(message) - 1;
|
||||
i32 result;
|
||||
char message[] = "tool was not specified or is invalid";
|
||||
result = sizeof(message) - 1;
|
||||
memcpy(memory, message, result);
|
||||
if (clparams.argc > 2){
|
||||
if (match(clparams.argv[2], "version")){
|
||||
result = sizeof(VERSION) - 1;
|
||||
memcpy(memory, VERSION, result);
|
||||
}
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
@ -3179,37 +3099,38 @@ App_Init_Sig(app_init){
|
|||
setup_command_table();
|
||||
|
||||
Command_Map *global = &vars->map_top;
|
||||
if (vars->config_api.get_bindings){
|
||||
i32 size = partition_remaining(partition);
|
||||
void *data = partition_current(partition);
|
||||
Assert(vars->config_api.get_bindings != 0);
|
||||
|
||||
// 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
|
||||
// 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_file = 0;
|
||||
if (wanted_size <= size){
|
||||
partition_allocate(partition, wanted_size);
|
||||
b32 did_top = 0;
|
||||
b32 did_file = 0;
|
||||
if (wanted_size <= size){
|
||||
partition_allocate(partition, wanted_size);
|
||||
|
||||
Binding_Unit *unit = (Binding_Unit*)data;
|
||||
if (unit->type == unit_header && unit->header.error == 0){
|
||||
Binding_Unit *end = unit + unit->header.total_size;
|
||||
Binding_Unit *unit = (Binding_Unit*)data;
|
||||
if (unit->type == unit_header && unit->header.error == 0){
|
||||
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 =
|
||||
push_array(&vars->mem.part, i32, user_map_count);
|
||||
vars->map_id_table =
|
||||
push_array(&vars->mem.part, i32, user_map_count);
|
||||
|
||||
vars->user_maps =
|
||||
push_array(&vars->mem.part, Command_Map, user_map_count);
|
||||
vars->user_maps =
|
||||
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;
|
||||
for (++unit; unit < end; ++unit){
|
||||
switch (unit->type){
|
||||
Command_Map *mapptr = 0;
|
||||
for (++unit; unit < end; ++unit){
|
||||
switch (unit->type){
|
||||
case unit_map_begin:
|
||||
{
|
||||
int table_max = unit->map_begin.bind_count * 3 / 2;
|
||||
|
@ -3234,50 +3155,50 @@ App_Init_Sig(app_init){
|
|||
}break;
|
||||
|
||||
case unit_inherit:
|
||||
if (mapptr){
|
||||
Command_Map *parent = 0;
|
||||
int mapid = unit->map_inherit.mapid;
|
||||
if (mapid == mapid_global) parent = &vars->map_top;
|
||||
else if (mapid == mapid_file) parent = &vars->map_file;
|
||||
else if (mapid < mapid_global){
|
||||
i32 index = app_get_or_add_map_index(vars, mapid);
|
||||
if (index < user_map_count) parent = vars->user_maps + index;
|
||||
else parent = 0;
|
||||
}
|
||||
mapptr->parent = parent;
|
||||
}break;
|
||||
if (mapptr){
|
||||
Command_Map *parent = 0;
|
||||
int mapid = unit->map_inherit.mapid;
|
||||
if (mapid == mapid_global) parent = &vars->map_top;
|
||||
else if (mapid == mapid_file) parent = &vars->map_file;
|
||||
else if (mapid < mapid_global){
|
||||
i32 index = app_get_or_add_map_index(vars, mapid);
|
||||
if (index < user_map_count) parent = vars->user_maps + index;
|
||||
else parent = 0;
|
||||
}
|
||||
mapptr->parent = parent;
|
||||
}break;
|
||||
|
||||
case unit_binding:
|
||||
if (mapptr){
|
||||
Command_Function func = 0;
|
||||
if (unit->binding.command_id >= 0 && unit->binding.command_id < cmdid_count)
|
||||
func = command_table [unit->binding.command_id];
|
||||
if (func){
|
||||
if (unit->binding.code == 0 && unit->binding.modifiers == 0){
|
||||
mapptr->vanilla_keyboard_default.function = func;
|
||||
}
|
||||
else{
|
||||
map_add(mapptr, unit->binding.code, unit->binding.modifiers, func);
|
||||
}
|
||||
if (mapptr){
|
||||
Command_Function func = 0;
|
||||
if (unit->binding.command_id >= 0 && unit->binding.command_id < cmdid_count)
|
||||
func = command_table [unit->binding.command_id];
|
||||
if (func){
|
||||
if (unit->binding.code == 0 && unit->binding.modifiers == 0){
|
||||
mapptr->vanilla_keyboard_default.function = func;
|
||||
}
|
||||
else{
|
||||
map_add(mapptr, unit->binding.code, unit->binding.modifiers, func);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case unit_callback:
|
||||
if (mapptr){
|
||||
Command_Function func = command_user_callback;
|
||||
Custom_Command_Function *custom = unit->callback.func;
|
||||
if (func){
|
||||
if (unit->callback.code == 0 && unit->callback.modifiers == 0){
|
||||
mapptr->vanilla_keyboard_default.function = func;
|
||||
mapptr->vanilla_keyboard_default.custom = custom;
|
||||
}
|
||||
else{
|
||||
map_add(mapptr, unit->callback.code, unit->callback.modifiers, func, custom);
|
||||
}
|
||||
if (mapptr){
|
||||
Command_Function func = command_user_callback;
|
||||
Custom_Command_Function *custom = unit->callback.func;
|
||||
if (func){
|
||||
if (unit->callback.code == 0 && unit->callback.modifiers == 0){
|
||||
mapptr->vanilla_keyboard_default.function = func;
|
||||
mapptr->vanilla_keyboard_default.custom = custom;
|
||||
}
|
||||
else{
|
||||
map_add(mapptr, unit->callback.code, unit->callback.modifiers, func, custom);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case unit_hook:
|
||||
{
|
||||
|
@ -3286,18 +3207,17 @@ App_Init_Sig(app_init){
|
|||
vars->hooks[hook_id] = unit->hook.func;
|
||||
}
|
||||
}break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
else{
|
||||
setup_top_commands(&vars->map_top, &vars->mem.part, codes, global);
|
||||
setup_file_commands(&vars->map_file, &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 !defined(FRED_SUPER)
|
||||
vars->hooks[hook_start] = 0;
|
||||
#endif
|
||||
|
||||
setup_ui_commands(&vars->map_ui, &vars->mem.part, codes, global);
|
||||
#if FRED_INTERNAL
|
||||
|
|
|
@ -9,6 +9,16 @@
|
|||
|
||||
// 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"
|
||||
|
||||
#define BUFFER_EXPERIMENT_SCALPEL 0
|
||||
|
|
|
@ -9,10 +9,6 @@
|
|||
|
||||
// TOP
|
||||
|
||||
struct Range{
|
||||
i32 start, end;
|
||||
};
|
||||
|
||||
struct File_View_Mode{
|
||||
b8 rewrite;
|
||||
};
|
||||
|
|
|
@ -24,7 +24,12 @@
|
|||
|
||||
#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_rendering.h"
|
||||
#include "4ed.h"
|
||||
|
@ -1602,6 +1607,10 @@ main(int argc, char **argv){
|
|||
}
|
||||
#endif
|
||||
|
||||
if (win32vars.custom_api.get_bindings == 0){
|
||||
win32vars.custom_api.get_bindings = (Get_Binding_Data_Function*)get_bindings;
|
||||
}
|
||||
|
||||
Thread_Context background[4];
|
||||
memset(background, 0, sizeof(background));
|
||||
win32vars.groups[BACKGROUND_THREADS].threads = background;
|
||||
|
|
Loading…
Reference in New Issue