whitespace batch bug fixed, some indent bugs fixed, keyboard input improved, removed old keyboard files

This commit is contained in:
Allen Webster 2016-05-14 16:08:11 -04:00
parent 4f4bc15e8a
commit e6d27c2bd8
12 changed files with 234 additions and 230 deletions

View File

@ -256,6 +256,11 @@ HOOK_SIG(my_file_settings){
wrap_lines = 0;
}
// NOTE(allen|a4.0.5): Unlike previous versions the command cmdid_set_settings
// no longer automatically effects the active buffer. This command will actually be
// phased out in favor of an app call soon.
push_parameter(app, par_buffer_id, buffer.buffer_id);
push_parameter(app, par_lex_as_cpp_file, treat_as_code);
push_parameter(app, par_wrap_lines, wrap_lines);
push_parameter(app, par_key_mapid, (treat_as_code)?((int)my_code_map):((int)mapid_file));

198
4ed.cpp
View File

@ -158,7 +158,8 @@ do_feedback_message(System_Functions *system, Models *models, String value){
// Commands
globalvar Application_Links app_links;
// TODO(allen): MOVE THIS TO models
//globalvar Application_Links app_links;
#define USE_MODELS(n) Models *n = command->models
#define USE_VARS(n) App_Vars *n = command->vars
@ -223,7 +224,7 @@ panel_make_empty(System_Functions *system, Exchange *exchange, App_Vars *vars, P
Assert(panel->view == 0);
new_view = live_set_alloc_view(&vars->live_set, panel, models);
view_set_file(new_view.view, 0, models, 0, 0, 0);
view_set_file(new_view.view, 0, models, 0);
new_view.view->map = app_get_map(models, mapid_global);
return(new_view.view);
@ -877,7 +878,7 @@ view_file_in_panel(Command_Data *cmd, Panel *panel, Editing_File *file){
cmd->part = partition_sub_part(part, Kbytes(16));
View *view = panel->view;
view_set_file(view, file, models, system, models->hooks[hook_open_file], &app_links);
view_set_file(view, file, models, system);
view_show_file(view, 0);
cmd->part = old_part;
@ -908,8 +909,7 @@ COMMAND_DECL(reopen){
index = file->id.id;
app_push_file_binding(vars, file_id, index);
view_set_file(view, file, models, system,
models->hooks[hook_open_file], &app_links);
view_set_file(view, file, models, system);
view_show_file(view, 0);
}
else{
@ -1521,14 +1521,14 @@ COMMAND_DECL(cursor_mark_swap){
}
COMMAND_DECL(user_callback){
if (binding.custom) binding.custom(&app_links);
USE_MODELS(models);
if (binding.custom) binding.custom(&models->app_links);
}
COMMAND_DECL(set_settings){
REQ_READABLE_VIEW(view);
REQ_FILE(file, view);
USE_MODELS(models);
Editing_File *file = 0;
b32 set_mapid = 0;
i32 new_mapid = 0;
@ -1537,61 +1537,47 @@ COMMAND_DECL(set_settings){
for (; param < end; param = param_next(param, end)){
int p = dynamic_to_int(&param->param.param);
switch (p){
case par_buffer_id:
{
int v = dynamic_to_int(&param->param.value);
file = working_set_get_active_file(&models->working_set, v);
}break;
case par_lex_as_cpp_file:
{
#if BUFFER_EXPERIMENT_SCALPEL <= 0
int v = dynamic_to_bool(&param->param.value);
if (file->settings.tokens_exist){
if (!v) file_kill_tokens(system, &models->mem.general, file);
}
else{
if (v) file_first_lex_parallel(system, &models->mem.general, file);
if (file){
int v = dynamic_to_bool(&param->param.value);
if (file->settings.tokens_exist){
if (!v) file_kill_tokens(system, &models->mem.general, file);
}
else{
if (v) file_first_lex_parallel(system, &models->mem.general, file);
}
}
#endif
}break;
case par_wrap_lines:
{
int v = dynamic_to_bool(&param->param.value);
if (view->file_data.unwrapped_lines){
if (v){
view->file_data.unwrapped_lines = 0;
file->settings.unwrapped_lines = 0;
if (!file->state.is_loading){
Relative_Scrolling scrolling = view_get_relative_scrolling(view);
view->file_scroll.target_x = 0;
view->file_data.cursor =
view_compute_cursor_from_pos(view, view->file_data.cursor.pos);
view_set_relative_scrolling(view, scrolling);
}
}
}
else{
if (!v){
view->file_data.unwrapped_lines = 1;
file->settings.unwrapped_lines = 1;
if (!file->state.is_loading){
Relative_Scrolling scrolling = view_get_relative_scrolling(view);
view->file_data.cursor =
view_compute_cursor_from_pos(view, view->file_data.cursor.pos);
view_set_relative_scrolling(view, scrolling);
}
}
if (file){
file->settings.unwrapped_lines = !v;
}
}break;
case par_key_mapid:
{
set_mapid = 1;
int v = dynamic_to_int(&param->param.value);
if (v == mapid_global) file->settings.base_map_id = mapid_global;
else if (v == mapid_file) file->settings.base_map_id = mapid_file;
else if (v < mapid_global){
new_mapid = app_get_map_index(models, v);
if (new_mapid < models->user_map_count) file->settings.base_map_id = v;
else file->settings.base_map_id = mapid_file;
if (file){
set_mapid = 1;
int v = dynamic_to_int(&param->param.value);
if (v == mapid_global) file->settings.base_map_id = mapid_global;
else if (v == mapid_file) file->settings.base_map_id = mapid_file;
else if (v < mapid_global){
new_mapid = app_get_map_index(models, v);
if (new_mapid < models->user_map_count) file->settings.base_map_id = v;
else file->settings.base_map_id = mapid_file;
}
}
}break;
}
@ -2405,8 +2391,7 @@ extern "C"{
if (file){
result = 1;
if (file != vptr->file_data.file){
view_set_file(vptr, file, models, cmd->system,
models->hooks[hook_open_file], &app_links);
view_set_file(vptr, file, models, cmd->system);
view_show_file(vptr, 0);
}
}
@ -2535,58 +2520,58 @@ command_caller(Coroutine *coroutine){
}
internal void
app_links_init(System_Functions *system, void *data, int size){
app_links.memory = data;
app_links.memory_size = size;
app_links_init(System_Functions *system, Application_Links *app_links, void *data, int size){
app_links->memory = data;
app_links->memory_size = size;
app_links.exec_command_keep_stack = external_exec_command_keep_stack;
app_links.push_parameter = external_push_parameter;
app_links.push_memory = external_push_memory;
app_links.clear_parameters = external_clear_parameters;
app_links->exec_command_keep_stack = external_exec_command_keep_stack;
app_links->push_parameter = external_push_parameter;
app_links->push_memory = external_push_memory;
app_links->clear_parameters = external_clear_parameters;
app_links.directory_get_hot = external_directory_get_hot;
app_links.file_exists = system->file_exists;
app_links.directory_cd = system->directory_cd;
app_links.get_file_list = external_get_file_list;
app_links.free_file_list = external_free_file_list;
app_links->directory_get_hot = external_directory_get_hot;
app_links->file_exists = system->file_exists;
app_links->directory_cd = system->directory_cd;
app_links->get_file_list = external_get_file_list;
app_links->free_file_list = external_free_file_list;
app_links.get_buffer_first = external_get_buffer_first;
app_links.get_buffer_next = external_get_buffer_next;
app_links->get_buffer_first = external_get_buffer_first;
app_links->get_buffer_next = external_get_buffer_next;
app_links.get_buffer = external_get_buffer;
app_links.get_active_buffer = external_get_active_buffer;
app_links.get_parameter_buffer = external_get_parameter_buffer;
app_links.get_buffer_by_name = external_get_buffer_by_name;
app_links->get_buffer = external_get_buffer;
app_links->get_active_buffer = external_get_active_buffer;
app_links->get_parameter_buffer = external_get_parameter_buffer;
app_links->get_buffer_by_name = external_get_buffer_by_name;
app_links.refresh_buffer = external_refresh_buffer;
app_links.buffer_seek_delimiter = external_buffer_seek_delimiter;
app_links.buffer_seek_string = external_buffer_seek_string;
app_links.buffer_seek_string_insensitive = external_buffer_seek_string_insensitive;
app_links.buffer_read_range = external_buffer_read_range;
app_links.buffer_replace_range = external_buffer_replace_range;
app_links->refresh_buffer = external_refresh_buffer;
app_links->buffer_seek_delimiter = external_buffer_seek_delimiter;
app_links->buffer_seek_string = external_buffer_seek_string;
app_links->buffer_seek_string_insensitive = external_buffer_seek_string_insensitive;
app_links->buffer_read_range = external_buffer_read_range;
app_links->buffer_replace_range = external_buffer_replace_range;
app_links.get_view_first = external_get_view_first;
app_links.get_view_next = external_get_view_next;
app_links->get_view_first = external_get_view_first;
app_links->get_view_next = external_get_view_next;
app_links.get_view = external_get_view;
app_links.get_active_view = external_get_active_view;
app_links->get_view = external_get_view;
app_links->get_active_view = external_get_active_view;
app_links.refresh_view = external_refresh_view;
app_links.view_set_cursor = external_view_set_cursor;
app_links.view_set_mark = external_view_set_mark;
app_links.view_set_highlight = external_view_set_highlight;
app_links.view_set_buffer = external_view_set_buffer;
app_links->refresh_view = external_refresh_view;
app_links->view_set_cursor = external_view_set_cursor;
app_links->view_set_mark = external_view_set_mark;
app_links->view_set_highlight = external_view_set_highlight;
app_links->view_set_buffer = external_view_set_buffer;
app_links.get_user_input = external_get_user_input;
app_links.get_command_input = external_get_command_input;
app_links->get_user_input = external_get_user_input;
app_links->get_command_input = external_get_command_input;
app_links.start_query_bar = external_start_query_bar;
app_links.end_query_bar = external_end_query_bar;
app_links.print_message = external_print_message;
app_links->start_query_bar = external_start_query_bar;
app_links->end_query_bar = external_end_query_bar;
app_links->print_message = external_print_message;
app_links.change_theme = external_change_theme;
app_links.change_font = external_change_font;
app_links.set_theme_colors = external_set_theme_colors;
app_links->change_theme = external_change_theme;
app_links->change_font = external_change_font;
app_links->set_theme_colors = external_set_theme_colors;
}
internal void
@ -3123,13 +3108,13 @@ App_Init_Sig(app_init){
i32 panel_max_count;
i32 divider_max_count;
app_links_init(system, memory->user_memory, memory->user_memory_size);
vars = (App_Vars*)memory->vars_memory;
models = &vars->models;
app_links_init(system, &models->app_links, memory->user_memory, memory->user_memory_size);
models->config_api = api;
app_links.cmd_context = &vars->command_data;
models->app_links.cmd_context = &vars->command_data;
partition = &models->mem.part;
target->partition = partition;
@ -3195,14 +3180,14 @@ App_Init_Sig(app_init){
global = &models->map_top;
Assert(models->config_api.get_bindings != 0);
wanted_size = models->config_api.get_bindings(app_links.memory, app_links.memory_size);
wanted_size = models->config_api.get_bindings(models->app_links.memory, models->app_links.memory_size);
if (wanted_size <= app_links.memory_size){
if (wanted_size <= models->app_links.memory_size){
Command_Map *map_ptr = 0;
Binding_Unit *unit, *end;
i32 user_map_count;
unit = (Binding_Unit*)app_links.memory;
unit = (Binding_Unit*)models->app_links.memory;
if (unit->type == unit_header && unit->header.error == 0){
end = unit + unit->header.total_size;
@ -3306,7 +3291,7 @@ App_Init_Sig(app_init){
}
}
memset(app_links.memory, 0, wanted_size);
memset(models->app_links.memory, 0, wanted_size);
if (!did_top) setup_top_commands(&models->map_top, &models->mem.part, global);
if (!did_file) setup_file_commands(&models->map_file, &models->mem.part, global);
@ -3667,7 +3652,7 @@ App_Step_Sig(app_step){
models->message_buffer = file;
if (models->hooks[hook_start]){
models->hooks[hook_start](&app_links);
models->hooks[hook_start](&models->app_links);
cmd->part.pos = 0;
}
@ -4374,14 +4359,14 @@ App_Step_Sig(app_step){
View *view = panel->view;
view_set_file(view, file, models, system, models->hooks[hook_open_file], &app_links);
view_set_file(view, file, models, system);
view_show_file(view, 0);
view->map = app_get_map(models, file->settings.base_map_id);
Hook_Function *new_file_fnc = models->hooks[hook_new_file];
if (new_file_fnc){
models->buffer_param_indices[models->buffer_param_count++] = file->id.id;
new_file_fnc(&app_links);
new_file_fnc(&models->app_links);
models->buffer_param_count = 0;
file->settings.is_initialized = 1;
}
@ -4404,8 +4389,7 @@ App_Step_Sig(app_step){
if (file){
View *view = panel->view;
view_set_file(view, file, models, system,
models->hooks[hook_open_file], &app_links);
view_set_file(view, file, models, system);
view_show_file(view, 0);
view->map = app_get_map(models, file->settings.base_map_id);
}
@ -4422,8 +4406,7 @@ App_Step_Sig(app_step){
if (file && !file->settings.never_kill){
working_set_remove(system, working_set, file->name.source_path);
kill_file(system, exchange, models, file,
models->hooks[hook_open_file], &app_links);
kill_file(system, exchange, models, file);
}
}break;
@ -4452,8 +4435,7 @@ App_Step_Sig(app_step){
}
else{
working_set_remove(system, working_set, file->name.source_path);
kill_file(system, exchange, models, file,
models->hooks[hook_open_file], &app_links);
kill_file(system, exchange, models, file);
}
}
}break;

View File

@ -40,7 +40,7 @@ struct Models{
u32 command_coroutine_flags[2];
Hook_Function *hooks[hook_type_count];
Application_Links *app;
Application_Links app_links;
i32 *buffer_param_indices;
i32 buffer_param_count, buffer_param_max;

Binary file not shown.

View File

@ -35,14 +35,7 @@ str_alloc_copy(General_Memory *general, String str){
result.str = (char*)general_memory_allocate(general, result.memory_size, 0);
memcpy(result.str, str.str, str.size);
result.str[result.size] = 0;
return(result);
}
inline Delayed_Action
delayed_action_zero(){
Delayed_Action action={(Action_Type)0};
return(action);
}
return(result);}
inline Delayed_Action*
delayed_action_(Delay *delay, Action_Type type){
@ -52,8 +45,7 @@ delayed_action_(Delay *delay, Action_Type type){
delay->acts = (Delayed_Action*)general_memory_reallocate(delay->general, delay->acts, delay->count*sizeof(Delayed_Action), delay->max*sizeof(Delayed_Action), 0);
}
result = delay->acts + delay->count++;
*result = delayed_action_zero();
*result = {};
result->type = type;
return(result);
}

View File

@ -588,7 +588,21 @@ file_create_from_string(System_Functions *system, Models *models,
}
Hook_Function *open_hook = models->hooks[hook_open_file];
open_hook(models->app);
models->buffer_param_indices[models->buffer_param_count++] = file->id.id;
open_hook(&models->app_links);
models->buffer_param_count = 0;
file->settings.is_initialized = 1;
#if 0
if (file){
if (open_hook && file->settings.is_initialized == 0){
models->buffer_param_indices[models->buffer_param_count++] = file->id.id;
open_hook(app);
models->buffer_param_count = 0;
file->settings.is_initialized = 1;
}
}
#endif
}
internal b32
@ -1267,10 +1281,7 @@ view_set_file(
View *view, Editing_File *file, Models *models,
// NOTE(allen): Necessary when file != 0
System_Functions *system, Hook_Function *open_hook, Application_Links *app,
// other
b32 set_vui = 1){
System_Functions *system){
Font_Info *fnt_info;
@ -1796,6 +1807,7 @@ file_do_white_batch_edit(System_Functions *system, Models *models, Editing_File
for (; token->start < edit->start && edit->start < token->start + token->size &&
token < end_token; ++token){
token->size += local_shift;
token->start += shift_amount;
}
for (; token->start < edit->start && token < end_token; ++token){
token->start += shift_amount;
@ -2222,9 +2234,8 @@ view_clean_whitespace(System_Functions *system, Models *models, View *view){
}
internal void
view_auto_tab_tokens(System_Functions *system,
Models *models, View *view,
i32 start, i32 end, b32 empty_blank_lines, b32 use_tabs){
view_auto_tab_tokens(System_Functions *system, Models *models,
View *view, i32 start, i32 end, b32 empty_blank_lines, b32 use_tabs){
#if BUFFER_EXPERIMENT_SCALPEL <= 0
Editing_File *file = view->file_data.file;
Mem_Options *mem = &models->mem;
@ -2251,90 +2262,131 @@ view_auto_tab_tokens(System_Functions *system,
Cpp_Token *token, *self_token;
{
i32 start_pos = file->state.buffer.line_starts[line_start];
i32 start_pos = buffer->line_starts[line_start];
Cpp_Get_Token_Result result = cpp_get_token(&tokens, start_pos);
token_i = result.token_index;
if (result.in_whitespace) token_i += 1;
self_token = tokens.tokens + token_i;
}
i32 line = line_start - 1;
for (; line >= 0; --line){
i32 start = file->state.buffer.line_starts[line];
b32 all_whitespace = 0;
b32 all_space = 0;
buffer_find_hard_start(&file->state.buffer, start,
&all_whitespace, &all_space, &current_indent, 4);
if (!all_whitespace) break;
// NOTE(allen): This part looks at code before the current code to figure out
// how much to indent the current code.
for (token = self_token; token_i > 0; --token_i, --token){
switch(token->type){
case CPP_TOKEN_BRACKET_OPEN:
case CPP_TOKEN_BRACKET_CLOSE:
token_i = 0;
break;
}
}
i32 line = 0;
{
i32 start = 0;
b32 all_whitespace = 0, all_space = 0;
line = buffer_get_line_index(buffer, token->start);
start = buffer->line_starts[line];
buffer_find_hard_start(buffer, start, &all_whitespace, &all_space, &current_indent, 4);
}
// NOTE(allen): It is not clear what this part does...
// it looks like it figures out the current token from the line, but
// the system now figures out the line from the current token...
// All we really need here is to make sure we start on the first
// token of the line we want to start at I think.
if (line < 0){
token_i = 0;
token = tokens.tokens + token_i;
}
else{
i32 start_pos = file->state.buffer.line_starts[line];
i32 start_pos = buffer->line_starts[line];
Cpp_Get_Token_Result result = cpp_get_token(&tokens, start_pos);
token_i = result.token_index;
if (result.in_whitespace) token_i += 1;
token = tokens.tokens + token_i;
while (token >= tokens.tokens &&
token->flags & CPP_TFLAG_PP_DIRECTIVE ||
token->flags & CPP_TFLAG_PP_BODY){
--token;
}
if (token < tokens.tokens){
++token;
current_indent = 0;
}
else if (token->start < start_pos){
line = buffer_get_line_index(&file->state.buffer, token->start);
i32 start = file->state.buffer.line_starts[line];
line = buffer_get_line_index(buffer, token->start);
i32 start = buffer->line_starts[line];
b32 all_whitespace = 0;
b32 all_space = 0;
buffer_find_hard_start(&file->state.buffer, start,
&all_whitespace, &all_space, &current_indent, 4);
buffer_find_hard_start(buffer, start, &all_whitespace, &all_space, &current_indent, 4);
Assert(!all_whitespace);
}
}
indent_marks -= line_start;
i32 line_i = line_start;
i32 next_line_start = file->state.buffer.line_starts[line_i];
i32 next_line_start = buffer->line_starts[line_i];
switch (token->type){
case CPP_TOKEN_BRACKET_OPEN: current_indent += 4; break;
case CPP_TOKEN_PARENTHESE_OPEN: current_indent += 4; break;
case CPP_TOKEN_BRACE_OPEN: current_indent += 4; break;
}
Cpp_Token *prev_token = token;
Cpp_Token T;
Cpp_Token prev_token = *token;
++token;
for (; line_i < line_end; ++token_i, ++token){
for (; token->start >= next_line_start && line_i < line_end;){
for (; line_i < line_end; ++token){
if (token < tokens.tokens + tokens.count){
T = *token;
}
else{
T.type = CPP_TOKEN_EOF;
T.start = buffer_size(buffer);
T.flags = 0;
}
for (; T.start >= next_line_start && line_i < line_end;){
i32 this_line_start = next_line_start;
next_line_start = file->state.buffer.line_starts[line_i+1];
if (line_i+1 < buffer->line_count){
next_line_start = buffer->line_starts[line_i+1];
}
else{
next_line_start = buffer_size(buffer);
}
i32 this_indent;
if (prev_token && prev_token->type == CPP_TOKEN_COMMENT &&
prev_token->start <= this_line_start && prev_token->start + prev_token->size > this_line_start){
this_indent = -1;
if (prev_token.type == CPP_TOKEN_COMMENT &&
prev_token.start <= this_line_start && prev_token.start + prev_token.size > this_line_start){
if (line_i > 0){
this_indent = indent_marks[line_i-1];
}
else{
this_indent = 0;
}
}
else{
this_indent = current_indent;
if (token->start < next_line_start){
if (token->flags & CPP_TFLAG_PP_DIRECTIVE) this_indent = 0;
if (T.start < next_line_start){
if (T.flags & CPP_TFLAG_PP_DIRECTIVE){
this_indent = 0;
}
else{
switch (token->type){
switch (T.type){
case CPP_TOKEN_BRACKET_CLOSE: this_indent -= 4; break;
case CPP_TOKEN_PARENTHESE_CLOSE: this_indent -= 4; break;
case CPP_TOKEN_BRACE_CLOSE: this_indent -= 4; break;
case CPP_TOKEN_BRACE_OPEN: break;
default:
if (current_indent > 0 && prev_token){
if (!(prev_token->flags & CPP_TFLAG_PP_BODY ||
prev_token->flags & CPP_TFLAG_PP_DIRECTIVE)){
switch (prev_token->type){
if (current_indent > 0){
if (!(prev_token.flags & CPP_TFLAG_PP_BODY ||
prev_token.flags & CPP_TFLAG_PP_DIRECTIVE)){
switch (prev_token.type){
case CPP_TOKEN_BRACKET_OPEN: case CPP_TOKEN_PARENTHESE_OPEN:
case CPP_TOKEN_BRACE_OPEN: case CPP_TOKEN_BRACE_CLOSE:
case CPP_TOKEN_SEMICOLON: case CPP_TOKEN_COLON: break;
@ -2352,7 +2404,7 @@ view_auto_tab_tokens(System_Functions *system,
++line_i;
}
switch (token->type){
switch (T.type){
case CPP_TOKEN_BRACKET_OPEN: current_indent += 4; break;
case CPP_TOKEN_BRACKET_CLOSE: current_indent -= 4; break;
case CPP_TOKEN_PARENTHESE_OPEN: current_indent += 4; break;
@ -2360,7 +2412,7 @@ view_auto_tab_tokens(System_Functions *system,
case CPP_TOKEN_BRACE_OPEN: current_indent += 4; break;
case CPP_TOKEN_BRACE_CLOSE: current_indent -= 4; break;
}
prev_token = token;
prev_token = T;
}
}
@ -2369,14 +2421,14 @@ view_auto_tab_tokens(System_Functions *system,
char *str_base = (char*)part->base + part->pos;
i32 str_size = 0;
for (i32 line_i = line_start; line_i < line_end; ++line_i){
i32 start = file->state.buffer.line_starts[line_i];
i32 start = buffer->line_starts[line_i];
i32 preferred_indentation;
i32 correct_indentation;
b32 all_whitespace = 0;
b32 all_space = 0;
i32 tab_width = 4;
i32 hard_start =
buffer_find_hard_start(&file->state.buffer, start, &all_whitespace, &all_space,
buffer_find_hard_start(buffer, start, &all_whitespace, &all_space,
&preferred_indentation, tab_width);
correct_indentation = indent_marks[line_i];
@ -2427,7 +2479,7 @@ view_auto_tab_tokens(System_Functions *system,
i32 preferred_indentation;
i32 start = view->file_data.cursor.pos;
i32 hard_start = buffer_find_hard_start(
&file->state.buffer, start, &all_whitespace, &all_space,
buffer, start, &all_whitespace, &all_space,
&preferred_indentation, 4);
view_cursor_move(view, hard_start);
@ -4650,11 +4702,8 @@ do_render_file_view(System_Functions *system, Exchange *exchange,
return(result);
}
// TODO(allen): Passing this hook and app pointer is a hack. It can go as soon as we start
// initializing files independently of setting them to views.
internal void
kill_file(System_Functions *system, Exchange *exchange, Models *models, Editing_File *file,
Hook_Function *open_hook, Application_Links *app){
kill_file(System_Functions *system, Exchange *exchange, Models *models, Editing_File *file){
File_Node *node, *used;
file_close(system, &models->mem.general, file);
@ -4668,12 +4717,12 @@ kill_file(System_Functions *system, Exchange *exchange, Models *models, Editing_
iter = file_view_iter_next(iter)){
if (node != used){
iter.view->file_data.file = 0;
view_set_file(iter.view, (Editing_File*)node, models, system, open_hook, app, 0);
view_set_file(iter.view, (Editing_File*)node, models, system);
node = node->next;
}
else{
iter.view->file_data.file = 0;
view_set_file(iter.view, 0, models, system, open_hook, app, 0);
view_set_file(iter.view, 0, models, system);
}
}
}

View File

@ -1,20 +0,0 @@
/*
* Mr. 4th Dimention - Allen Webster
*
* 16.11.2014
*
* Keyboard layer for 4coder
*
*/
// TOP
globalvar u8 keycode_lookup_table[255];
inline u8
keycode_lookup(u8 system_code){
return keycode_lookup_table[system_code];
}
// BOTTOM

View File

@ -1,31 +0,0 @@
/*
* Mr. 4th Dimention - Allen Webster
*
* 12.17.2014
*
* Win32-US Keyboard layer for 4coder
*
*/
// TOP
#include "4ed_keyboard.cpp"
internal void
keycode_init(){
keycode_lookup_table[VK_BACK] = key_back;
keycode_lookup_table[VK_DELETE] = key_del;
keycode_lookup_table[VK_UP] = key_up;
keycode_lookup_table[VK_DOWN] = key_down;
keycode_lookup_table[VK_LEFT] = key_left;
keycode_lookup_table[VK_RIGHT] = key_right;
keycode_lookup_table[VK_INSERT] = key_insert;
keycode_lookup_table[VK_HOME] = key_home;
keycode_lookup_table[VK_END] = key_end;
keycode_lookup_table[VK_PRIOR] = key_page_up;
keycode_lookup_table[VK_NEXT] = key_page_down;
keycode_lookup_table[VK_ESCAPE] = key_esc;
}
// BOTTOM

View File

@ -1,4 +1,4 @@
Distribution Date: 13.5.2016 (dd.mm.yyyy)
Distribution Date: 14.5.2016 (dd.mm.yyyy)
Thank you for contributing to the 4coder project!

View File

@ -1,4 +1,4 @@
Distribution Date: 13.5.2016 (dd.mm.yyyy)
Distribution Date: 14.5.2016 (dd.mm.yyyy)
Thank you for contributing to the 4coder project!

View File

@ -192,18 +192,18 @@ buffer_replace_range(Buffer *buffer, int start, int end, char *str, int len, int
internal_4tech int
buffer_batch_edit_step(Buffer_Batch_State *state, Buffer *buffer, Buffer_Edit *sorted_edits,
char *strings, int edit_count, void *scratch, int scratch_size, int *request_amount){
char *strings, int edit_count, void *scratch, int scratch_size, int *request_amount){
Buffer_Edit *edit;
int i, result;
int shift_total, shift_amount;
result = 0;
shift_total = state->shift_total;
i = state->i;
edit = sorted_edits + i;
for (; i < edit_count; ++i, ++edit){
assert(edit->end + shift_total < buffer_size(buffer));
assert(edit->end + shift_total <= buffer_size(buffer));
result = buffer_replace_range(buffer, edit->start + shift_total, edit->end + shift_total,
strings + edit->str_start, edit->len, &shift_amount,
scratch, scratch_size, request_amount);

View File

@ -1198,6 +1198,31 @@ Win32RedrawScreen(HDC hdc){
SwapBuffers(hdc);
}
// NOTE(allen): Old contents of 4ed_keyboard.cpp
globalvar u8 keycode_lookup_table[255];
inline u8
keycode_lookup(u8 system_code){
return keycode_lookup_table[system_code];
}
// NOTE(allen): Old contents of 4ed_win32_keyboard.cpp
internal void
keycode_init(){
keycode_lookup_table[VK_BACK] = key_back;
keycode_lookup_table[VK_DELETE] = key_del;
keycode_lookup_table[VK_UP] = key_up;
keycode_lookup_table[VK_DOWN] = key_down;
keycode_lookup_table[VK_LEFT] = key_left;
keycode_lookup_table[VK_RIGHT] = key_right;
keycode_lookup_table[VK_INSERT] = key_insert;
keycode_lookup_table[VK_HOME] = key_home;
keycode_lookup_table[VK_END] = key_end;
keycode_lookup_table[VK_PRIOR] = key_page_up;
keycode_lookup_table[VK_NEXT] = key_page_down;
keycode_lookup_table[VK_ESCAPE] = key_esc;
}
internal LRESULT
Win32Callback(HWND hwnd, UINT uMsg,
WPARAM wParam, LPARAM lParam){
@ -1325,10 +1350,12 @@ Win32Callback(HWND hwnd, UINT uMsg,
// control+alt is used to signal AltGr for important keys.
if (result1 && result2){
char c1 = char_to_upper((char)x1);
char c2 = char_to_upper((char)x2);
char cParam = char_to_upper((char)wParam);
if (c1 != cParam && c2 == cParam){
if ((c1 == '\n' || c1 == '\r') && cParam != VK_RETURN){
result1 = 0;
}
if (c1 == '\t' && cParam != VK_TAB){
result1 = 0;
}
}