bug fixing
parent
770c48f95b
commit
c8db4004a6
|
@ -150,8 +150,8 @@ CUSTOM_COMMAND_SIG(build_search){
|
|||
|
||||
if (append(&dir, "build")){
|
||||
app->push_parameter(cmd_context,
|
||||
dynamic_int(par_cli_command),
|
||||
dynamic_string(dir.str, dir.size));
|
||||
dynamic_int(par_cli_command),
|
||||
dynamic_string(dir.str, dir.size));
|
||||
exec_command(cmd_context, cmdid_build);
|
||||
}
|
||||
else{
|
||||
|
@ -238,9 +238,9 @@ extern "C" GET_BINDING_DATA(get_bindings){
|
|||
bind_me(context, ']', MDFR_NONE, write_and_auto_tab);
|
||||
bind_me(context, ';', MDFR_NONE, write_and_auto_tab);
|
||||
|
||||
bind(context, '\t', MDFR_NONE, cmdid_auto_tab_line_at_cursor);
|
||||
bind(context, '\t', MDFR_NONE, cmdid_word_complete);
|
||||
bind(context, '\t', MDFR_CTRL, cmdid_auto_tab_range);
|
||||
bind(context, '\t', MDFR_CTRL | MDFR_SHIFT, cmdid_write_character);
|
||||
bind(context, '\t', MDFR_SHIFT, cmdid_auto_tab_line_at_cursor);
|
||||
|
||||
end_map(context);
|
||||
|
||||
|
|
|
@ -64,6 +64,7 @@ enum Command_ID{
|
|||
cmdid_seek_alphanumeric_or_camel_right,
|
||||
cmdid_search,
|
||||
cmdid_rsearch,
|
||||
cmdid_word_complete,
|
||||
cmdid_goto_line,
|
||||
cmdid_set_mark,
|
||||
cmdid_copy,
|
||||
|
@ -96,7 +97,6 @@ enum Command_ID{
|
|||
cmdid_clean_all_lines,
|
||||
cmdid_eol_dosify,
|
||||
cmdid_eol_nixify,
|
||||
cmdid_auto_tab,
|
||||
cmdid_auto_tab_range,
|
||||
cmdid_auto_tab_line_at_cursor,
|
||||
cmdid_auto_tab_whole_file,
|
||||
|
|
|
@ -173,6 +173,7 @@ FCPP_LINK int reverse_seek_slash(String str);
|
|||
FCPP_LINK int reverse_seek_slash(String str, int start_pos);
|
||||
inline bool get_front_of_directory(String *dest, String dir) { return append_checked(dest, substr(dir, reverse_seek_slash(dir) + 1)); }
|
||||
inline bool get_path_of_directory(String *dest, String dir) { return append_checked(dest, substr(dir, 0, reverse_seek_slash(dir) + 1)); }
|
||||
inline void truncate_to_path_of_directory(String *dir) { dir->size = reverse_seek_slash(*dir) + 1; }
|
||||
FCPP_LINK bool set_last_folder(String *dir, char *folder_name);
|
||||
FCPP_LINK bool set_last_folder(String *dir, String folder_name);
|
||||
FCPP_LINK String file_extension(String str);
|
||||
|
|
110
4ed.cpp
110
4ed.cpp
|
@ -44,6 +44,7 @@ struct Complete_State{
|
|||
Table hits;
|
||||
String_Space str;
|
||||
i32 word_start, word_end;
|
||||
b32 initialized;
|
||||
};
|
||||
|
||||
struct App_Vars{
|
||||
|
@ -488,6 +489,10 @@ COMMAND_DECL(word_complete){
|
|||
do_init = 1;
|
||||
}
|
||||
|
||||
if (complete_state->initialized == 0){
|
||||
do_init = 1;
|
||||
}
|
||||
|
||||
if (do_init){
|
||||
word_end = view->cursor.pos;
|
||||
word_start = word_end;
|
||||
|
@ -514,6 +519,12 @@ COMMAND_DECL(word_complete){
|
|||
|
||||
size = word_end - word_start;
|
||||
|
||||
if (size == 0){
|
||||
complete_state->initialized = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
complete_state->initialized = 1;
|
||||
search_iter_init(general, &complete_state->iter, size);
|
||||
buffer_stringify(buffer, word_start, word_end, complete_state->iter.word.str);
|
||||
complete_state->iter.word.size = size;
|
||||
|
@ -863,65 +874,6 @@ COMMAND_DECL(interactive_new){
|
|||
copy(&int_view->query, "New: ");
|
||||
}
|
||||
|
||||
#if 0
|
||||
internal File_View*
|
||||
app_open_file(System_Functions *system, Exchange *exchange,
|
||||
App_Vars *vars, Mem_Options *mem, Panel *panel,
|
||||
Working_Set *working_set, String *string, Style *style,
|
||||
Live_Views *live_set, Command_Data *command_data){
|
||||
File_View *result = 0;
|
||||
Editing_File *target_file = 0;
|
||||
b32 created_file = 0;
|
||||
|
||||
target_file = working_set_contains(working_set, *string);
|
||||
if (!target_file){
|
||||
Get_File_Result file = working_set_get_available_file(working_set);
|
||||
if (file.file){
|
||||
file_get_dummy(file.file);
|
||||
created_file = file_create(system, mem, file.file, string->str, style->font);
|
||||
table_add(&working_set->table, file.file->source_path, file.index);
|
||||
if (created_file){
|
||||
target_file = file.file;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (target_file){
|
||||
View *new_view = live_set_alloc_view(live_set, &vars->mem);
|
||||
|
||||
view_replace_major(system, exchange, new_view, panel, live_set);
|
||||
|
||||
File_View *file_view = file_view_init(new_view, &vars->layout);
|
||||
result = file_view;
|
||||
|
||||
View *old_view = command_data->view;
|
||||
command_data->view = new_view;
|
||||
|
||||
Partition old_part = command_data->part;
|
||||
Temp_Memory temp = begin_temp_memory(&vars->mem.part);
|
||||
command_data->part = partition_sub_part(&vars->mem.part, 16 << 10);
|
||||
|
||||
view_set_file(system, file_view, target_file, style,
|
||||
vars->hooks[hook_open_file], command_data, &app_links);
|
||||
|
||||
command_data->part = old_part;
|
||||
end_temp_memory(temp);
|
||||
command_data->view = old_view;
|
||||
|
||||
new_view->map = app_get_map(vars, target_file->base_map_id);
|
||||
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 0
|
||||
if (created_file && target_file->tokens_exist &&
|
||||
target_file->token_stack.tokens == 0){
|
||||
file_first_lex_parallel(system, &mem->general, target_file);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
internal void
|
||||
app_push_file_binding(App_Vars *vars, int sys_id, int app_id){
|
||||
Sys_App_Binding binding;
|
||||
|
@ -951,7 +903,7 @@ app_open_file_background(App_Vars *vars, Exchange *exchange, Working_Set *workin
|
|||
result.is_new = 1;
|
||||
result.file = file.file;
|
||||
file_init_strings(result.file);
|
||||
file_set_name(result.file, filename.str);
|
||||
file_set_name(working_set, result.file, filename.str);
|
||||
file_set_to_loading(result.file);
|
||||
table_add(&working_set->table, result.file->name.source_path, file.index);
|
||||
|
||||
|
@ -1311,21 +1263,6 @@ COMMAND_DECL(eol_nixify){
|
|||
file->state.last_4ed_edit_time = system->time();
|
||||
}
|
||||
|
||||
COMMAND_DECL(auto_tab){
|
||||
#if 0
|
||||
ProfileMomentFunction();
|
||||
REQ_FILE_VIEW(view);
|
||||
REQ_FILE(file, view);
|
||||
USE_LAYOUT(layout);
|
||||
USE_MEM(mem);
|
||||
|
||||
if (file->token_stack.tokens && file->tokens_complete){
|
||||
Range range = get_range(view->cursor.pos, view->mark);
|
||||
view_auto_tab_tokens(mem, view, layout, range.start, range.end);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
COMMAND_DECL(auto_tab_range){
|
||||
ProfileMomentFunction();
|
||||
REQ_FILE_VIEW(view);
|
||||
|
@ -1887,7 +1824,7 @@ build(System_Functions *system, Mem_Options *mem,
|
|||
}
|
||||
|
||||
if (file){
|
||||
file_create_super_locked(system, mem, file, buffer_name, font_set, style->font_id);
|
||||
file_create_super_locked(system, mem, working_set, file, buffer_name, font_set, style->font_id);
|
||||
file->settings.unimportant = 1;
|
||||
table_add(&working_set->table, file->name.source_path, index);
|
||||
|
||||
|
@ -2246,7 +2183,6 @@ setup_file_commands(Command_Map *commands, Partition *part, Key_Codes *codes, Co
|
|||
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, 't', MDFR_CTRL, command_word_complete);
|
||||
|
||||
map_add(commands, 'r', MDFR_CTRL, command_rsearch);
|
||||
map_add(commands, 'g', MDFR_CTRL, command_goto_line);
|
||||
|
@ -2257,9 +2193,9 @@ setup_file_commands(Command_Map *commands, Partition *part, Key_Codes *codes, Co
|
|||
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_auto_tab_line_at_cursor);
|
||||
map_add(commands, '\t', MDFR_NONE, command_word_complete);
|
||||
map_add(commands, '\t', MDFR_CTRL, command_auto_tab_range);
|
||||
map_add(commands, '\t', MDFR_CTRL | MDFR_SHIFT, command_write_character);
|
||||
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);
|
||||
|
@ -2312,6 +2248,7 @@ setup_command_table(){
|
|||
SET(seek_alphanumeric_or_camel_left);
|
||||
SET(search);
|
||||
SET(rsearch);
|
||||
SET(word_complete);
|
||||
SET(goto_line);
|
||||
SET(set_mark);
|
||||
SET(copy);
|
||||
|
@ -2343,7 +2280,6 @@ setup_command_table(){
|
|||
SET(clean_all_lines);
|
||||
SET(eol_dosify);
|
||||
SET(eol_nixify);
|
||||
SET(auto_tab);
|
||||
SET(auto_tab_range);
|
||||
SET(auto_tab_line_at_cursor);
|
||||
SET(auto_tab_whole_file);
|
||||
|
@ -3629,7 +3565,7 @@ App_Step_Sig(app_step){
|
|||
if (fview){
|
||||
Editing_File *file = fview->file;
|
||||
if (file && !file->state.is_dummy){
|
||||
i32 sys_id = file_save_and_set_names(system, exchange, mem, file, string->str);
|
||||
i32 sys_id = file_save_and_set_names(system, exchange, mem, working_set, file, string->str);
|
||||
app_push_file_binding(vars, sys_id, get_file_id(working_set, file));
|
||||
}
|
||||
}
|
||||
|
@ -3647,7 +3583,7 @@ App_Step_Sig(app_step){
|
|||
case DACT_NEW:
|
||||
{
|
||||
Get_File_Result file = working_set_get_available_file(working_set);
|
||||
file_create_empty(system, mem, file.file, string->str,
|
||||
file_create_empty(system, mem, working_set, file.file, string->str,
|
||||
vars->font_set, style->font_id);
|
||||
table_add(&working_set->table, file.file->name.source_path, file.index);
|
||||
|
||||
|
@ -3818,20 +3754,22 @@ App_Step_Sig(app_step){
|
|||
Editing_File_Preload preload_settings;
|
||||
char *filename;
|
||||
|
||||
Working_Set *working_set = &vars->working_set;
|
||||
|
||||
if (exchange_file_ready(exchange, binding->sys_id, &data, &size, &max)){
|
||||
ed_file = vars->working_set.files + binding->app_id;
|
||||
ed_file = working_set->files + binding->app_id;
|
||||
filename = exchange_file_filename(exchange, binding->sys_id);
|
||||
preload_settings = ed_file->preload;
|
||||
if (data){
|
||||
String val = make_string((char*)data, size);
|
||||
file_create_from_string(system, &vars->mem, ed_file, filename,
|
||||
file_create_from_string(system, &vars->mem, working_set, ed_file, filename,
|
||||
vars->font_set, vars->style.font_id, val);
|
||||
|
||||
if (ed_file->settings.tokens_exist)
|
||||
file_first_lex_parallel(system, &vars->mem.general, ed_file);
|
||||
}
|
||||
else{
|
||||
file_create_empty(system, &vars->mem, ed_file, filename,
|
||||
file_create_empty(system, &vars->mem, working_set, ed_file, filename,
|
||||
vars->font_set, vars->style.font_id);
|
||||
}
|
||||
|
||||
|
@ -3854,7 +3792,7 @@ App_Step_Sig(app_step){
|
|||
exchange_clear_file(exchange, binding->sys_id);
|
||||
}
|
||||
|
||||
Editing_File *file = get_file(&vars->working_set, binding->app_id);
|
||||
Editing_File *file = get_file(working_set, binding->app_id);
|
||||
if (file){
|
||||
file_synchronize_times(system, file, file->name.source_path.str);
|
||||
}
|
||||
|
|
|
@ -135,8 +135,8 @@ map_extract(Command_Map *map, Key_Event_Data key){
|
|||
u16 code;
|
||||
u8 command = MDFR_NONE;
|
||||
|
||||
if (key.character_no_caps_lock != 0 &&
|
||||
key.character_no_caps_lock != ' ') shift = 0;
|
||||
//if (key.character_no_caps_lock != 0 &&
|
||||
// key.character_no_caps_lock != ' ') shift = 0;
|
||||
|
||||
if (shift) command |= MDFR_SHIFT;
|
||||
if (ctrl) command |= MDFR_CTRL;
|
||||
|
@ -148,7 +148,9 @@ map_extract(Command_Map *map, Key_Event_Data key){
|
|||
map_find(map, code, command, &bind);
|
||||
}
|
||||
else{
|
||||
command &= ~(MDFR_SHIFT);
|
||||
if (code != '\n' && code != '\t' && code != ' '){
|
||||
command &= ~(MDFR_SHIFT);
|
||||
}
|
||||
|
||||
map_find(map, code, command, &bind);
|
||||
if (bind.function == 0){
|
||||
|
|
|
@ -1203,16 +1203,30 @@ file_init_strings(Editing_File *file){
|
|||
file->name.extension = make_fixed_width_string(file->name.extension_);
|
||||
}
|
||||
|
||||
inline b32
|
||||
file_is_ready(Editing_File *file){
|
||||
b32 result = 0;
|
||||
if (file && file->state.is_loading == 0){
|
||||
result = 1;
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
inline void
|
||||
file_set_name(Editing_File *file, char *filename){
|
||||
file_set_name(Working_Set *working_set, Editing_File *file, char *filename){
|
||||
String f, ext;
|
||||
Editing_File *file_ptr;
|
||||
i32 i, count, file_x, original_len;
|
||||
b32 hit_conflict;
|
||||
|
||||
Assert(file->name.live_name.str != 0);
|
||||
|
||||
f = make_string_slowly(filename);
|
||||
copy_checked(&file->name.source_path, f);
|
||||
|
||||
file->name.live_name.size = 0;
|
||||
get_front_of_directory(&file->name.live_name, f);
|
||||
|
||||
if (file->name.source_path.size == file->name.live_name.size){
|
||||
file->name.extension.size = 0;
|
||||
}
|
||||
|
@ -1220,6 +1234,31 @@ file_set_name(Editing_File *file, char *filename){
|
|||
ext = file_extension(f);
|
||||
copy(&file->name.extension, ext);
|
||||
}
|
||||
|
||||
original_len = file->name.live_name.size;
|
||||
count = working_set->file_index_count;
|
||||
hit_conflict = 1;
|
||||
file_x = 0;
|
||||
while (hit_conflict){
|
||||
hit_conflict = 0;
|
||||
file_ptr = working_set->files;
|
||||
for (i = 0; i < count; ++i, ++file_ptr){
|
||||
if (file_ptr != file && !file_ptr->state.is_dummy && file_is_ready(file_ptr)){
|
||||
if (match(file->name.live_name, file_ptr->name.live_name)){
|
||||
++file_x;
|
||||
hit_conflict = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hit_conflict){
|
||||
file->name.live_name.size = original_len;
|
||||
append(&file->name.live_name, " <");
|
||||
append_int_to_str(file_x, &file->name.live_name);
|
||||
append(&file->name.live_name, ">");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline void
|
||||
|
@ -1271,11 +1310,12 @@ file_save(System_Functions *system, Exchange *exchange, Mem_Options *mem,
|
|||
|
||||
inline b32
|
||||
file_save_and_set_names(System_Functions *system, Exchange *exchange,
|
||||
Mem_Options *mem, Editing_File *file, char *filename){
|
||||
Mem_Options *mem, Working_Set *working_set, Editing_File *file,
|
||||
char *filename){
|
||||
b32 result = 0;
|
||||
result = file_save(system, exchange, mem, file, filename);
|
||||
if (result){
|
||||
file_set_name(file, filename);
|
||||
file_set_name(working_set, file, filename);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -1501,9 +1541,10 @@ alloc_for_buffer(void *context, int *size){
|
|||
|
||||
internal void
|
||||
file_create_from_string(System_Functions *system, Mem_Options *mem,
|
||||
Editing_File *file, char *filename,
|
||||
Font_Set *set, i16 font_id,
|
||||
String val, b8 super_locked = 0){
|
||||
Working_Set *working_set, Editing_File *file, char *filename,
|
||||
Font_Set *set, i16 font_id,
|
||||
String val, b8 super_locked = 0){
|
||||
|
||||
General_Memory *general = &mem->general;
|
||||
Partition *part = &mem->part;
|
||||
Buffer_Init_Type init;
|
||||
|
@ -1529,7 +1570,7 @@ file_create_from_string(System_Functions *system, Mem_Options *mem,
|
|||
#endif
|
||||
|
||||
file_init_strings(file);
|
||||
file_set_name(file, (char*)filename);
|
||||
file_set_name(working_set, file, (char*)filename);
|
||||
|
||||
file->state.font_id = font_id;
|
||||
|
||||
|
@ -1570,20 +1611,25 @@ file_create_from_string(System_Functions *system, Mem_Options *mem,
|
|||
}
|
||||
|
||||
internal b32
|
||||
file_create_empty(System_Functions *system, Mem_Options *mem, Editing_File *file,
|
||||
char *filename, Font_Set *set, i16 font_id){
|
||||
file_create_empty(
|
||||
System_Functions *system, Mem_Options *mem,
|
||||
Working_Set *working_set, Editing_File *file,
|
||||
char *filename, Font_Set *set, i16 font_id){
|
||||
|
||||
b32 result = 1;
|
||||
String empty_str = {};
|
||||
file_create_from_string(system, mem, file, filename, set, font_id, empty_str);
|
||||
file_create_from_string(system, mem, working_set, file, filename, set, font_id, empty_str);
|
||||
return result;
|
||||
}
|
||||
|
||||
internal b32
|
||||
file_create_super_locked(System_Functions *system, Mem_Options *mem, Editing_File *file,
|
||||
char *filename, Font_Set *set, i16 font_id){
|
||||
file_create_super_locked(
|
||||
System_Functions *system, Mem_Options *mem,
|
||||
Working_Set *working_set, Editing_File *file,
|
||||
char *filename, Font_Set *set, i16 font_id){
|
||||
b32 result = 1;
|
||||
String empty_str = {};
|
||||
file_create_from_string(system, mem, file, filename, set, font_id, empty_str, 1);
|
||||
file_create_from_string(system, mem, working_set, file, filename, set, font_id, empty_str, 1);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1671,15 +1717,6 @@ file_set_to_loading(Editing_File *file){
|
|||
file->state.is_loading = 1;
|
||||
}
|
||||
|
||||
inline b32
|
||||
file_is_ready(Editing_File *file){
|
||||
b32 result = 0;
|
||||
if (file && file->state.is_loading == 0){
|
||||
result = 1;
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
struct Shift_Information{
|
||||
i32 start, end, amount;
|
||||
};
|
||||
|
@ -2827,14 +2864,6 @@ file_do_single_edit(System_Functions *system,
|
|||
if (old_data) general_memory_free(general, old_data);
|
||||
}
|
||||
|
||||
#if BUFFER_EXPERIMENT_SCALPEL == 3
|
||||
buffer_rope_check(&file->buffer, part->base + part->pos, scratch_size);
|
||||
#endif
|
||||
|
||||
#if BUFFER_EXPERIMENT_SCALPEL == 2
|
||||
buffer_mugab_check(&file->buffer);
|
||||
#endif
|
||||
|
||||
i32 line_start = buffer_get_line_index(&file->state.buffer, start);
|
||||
i32 line_end = buffer_get_line_index(&file->state.buffer, end);
|
||||
i32 replaced_line_count = line_end - line_start;
|
||||
|
@ -3544,8 +3573,8 @@ view_auto_tab_tokens(System_Functions *system,
|
|||
i32 start = file->state.buffer.line_starts[line_i];
|
||||
i32 preferred_indentation;
|
||||
i32 correct_indentation;
|
||||
bool32 all_whitespace = 0;
|
||||
bool32 all_space = 0;
|
||||
b32 all_whitespace = 0;
|
||||
b32 all_space = 0;
|
||||
i32 hard_start =
|
||||
buffer_find_hard_start(&file->state.buffer, start, &all_whitespace, &all_space,
|
||||
&preferred_indentation, 4);
|
||||
|
@ -3565,6 +3594,7 @@ view_auto_tab_tokens(System_Functions *system,
|
|||
new_edit.end = hard_start;
|
||||
edits[edit_count++] = new_edit;
|
||||
}
|
||||
|
||||
Assert(edit_count <= edit_max);
|
||||
}
|
||||
|
||||
|
@ -3583,6 +3613,18 @@ view_auto_tab_tokens(System_Functions *system,
|
|||
view_do_white_batch_edit(system, mem, view, file, layout, spec, hist_normal);
|
||||
}
|
||||
|
||||
{
|
||||
b32 all_whitespace = 0;
|
||||
b32 all_space = 0;
|
||||
i32 preferred_indentation;
|
||||
i32 start = view->cursor.pos;
|
||||
i32 hard_start = buffer_find_hard_start(
|
||||
&file->state.buffer, start, &all_whitespace, &all_space,
|
||||
&preferred_indentation, 4);
|
||||
|
||||
view_cursor_move(view, hard_start);
|
||||
}
|
||||
|
||||
end_temp_memory(temp);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -14,16 +14,16 @@
|
|||
//
|
||||
|
||||
struct Interactive_Style{
|
||||
u32 bar_color;
|
||||
u32 bar_active_color;
|
||||
u32 base_color;
|
||||
u32 pop1_color;
|
||||
u32 pop2_color;
|
||||
u32 bar_color;
|
||||
u32 bar_active_color;
|
||||
u32 base_color;
|
||||
u32 pop1_color;
|
||||
u32 pop2_color;
|
||||
};
|
||||
|
||||
struct Interactive_Bar{
|
||||
Interactive_Style style;
|
||||
real32 pos_x, pos_y;
|
||||
Interactive_Style style;
|
||||
real32 pos_x, pos_y;
|
||||
real32 text_shift_x, text_shift_y;
|
||||
i32_Rect rect;
|
||||
i16 font_id;
|
||||
|
@ -137,6 +137,14 @@ internal void
|
|||
intbar_draw_string(Render_Target *target,
|
||||
Interactive_Bar *bar, u8 *str, u32 char_color){
|
||||
i16 font_id = bar->font_id;
|
||||
|
||||
draw_string(target, font_id, (char*)str,
|
||||
(i32)(bar->pos_x + bar->text_shift_x),
|
||||
(i32)(bar->pos_y + bar->text_shift_y),
|
||||
char_color);
|
||||
bar->pos_x += font_string_width(target, font_id, (char*)str);
|
||||
|
||||
#if 0
|
||||
for (i32 i = 0; str[i]; ++i){
|
||||
char c = str[i];
|
||||
font_draw_glyph(target, font_id, c,
|
||||
|
@ -145,20 +153,30 @@ intbar_draw_string(Render_Target *target,
|
|||
char_color);
|
||||
bar->pos_x += font_get_glyph_width(target, font_id, c);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
internal void
|
||||
intbar_draw_string(Render_Target *target, Interactive_Bar *bar,
|
||||
String str, u32 char_color){
|
||||
i16 font_id = bar->font_id;
|
||||
for (i32 i = 0; i < str.size; ++i){
|
||||
|
||||
draw_string(target, font_id, str,
|
||||
(i32)(bar->pos_x + bar->text_shift_x),
|
||||
(i32)(bar->pos_y + bar->text_shift_y),
|
||||
char_color);
|
||||
bar->pos_x += font_string_width(target, font_id, str);
|
||||
|
||||
#if 0
|
||||
for (i32 i = 0; i < str.size; ++i){
|
||||
char c = str.str[i];
|
||||
font_draw_glyph(target, font_id, c,
|
||||
font_draw_glyph(target, font_id, c,
|
||||
bar->pos_x + bar->text_shift_x,
|
||||
bar->pos_y + bar->text_shift_y,
|
||||
char_color);
|
||||
bar->pos_x += font_get_glyph_width(target, font_id, c);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
internal void
|
||||
|
@ -308,7 +326,7 @@ layout_alloc_divider(Editing_Layout *layout){
|
|||
if (layout->panel_count == 1){
|
||||
layout->root = result.id;
|
||||
}
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
internal Divider_And_ID
|
||||
|
@ -326,7 +344,7 @@ layout_alloc_panel(Editing_Layout *layout){
|
|||
Panel *result = layout->panels + layout->panel_count;
|
||||
*result = {};
|
||||
++layout->panel_count;
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
internal void
|
||||
|
@ -354,7 +372,7 @@ layout_calc_divider_id(Editing_Layout *layout, Panel_Divider *divider){
|
|||
Divider_And_ID result;
|
||||
result.divider = divider;
|
||||
result.id = (i32)(divider - layout->dividers);
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
struct Split_Result{
|
||||
|
@ -485,9 +503,9 @@ layout_fix_all_panels(Editing_Layout *layout){
|
|||
internal void
|
||||
layout_refit(Editing_Layout *layout,
|
||||
i32 prev_x_off, i32 prev_y_off,
|
||||
i32 prev_width, i32 prev_height){
|
||||
i32 prev_width, i32 prev_height){
|
||||
Panel_Divider *dividers = layout->dividers;
|
||||
i32 divider_max_count = layout->panel_max_count - 1;
|
||||
i32 divider_max_count = layout->panel_max_count - 1;
|
||||
|
||||
i32 x_off = 0;
|
||||
i32 y_off = 0;
|
||||
|
|
|
@ -295,13 +295,17 @@ launch_rendering(Render_Target *target){
|
|||
|
||||
internal i32
|
||||
draw_font_info_load(Partition *partition,
|
||||
char *filename,
|
||||
i32 pt_size,
|
||||
i32 *height,
|
||||
i32 *advance){
|
||||
char *filename_untranslated,
|
||||
i32 pt_size, i32 *height, i32 *advance){
|
||||
|
||||
char space_[1024];
|
||||
String filename = make_fixed_width_string(space_);
|
||||
b32 translate_success = system_to_binary_path(&filename, filename_untranslated);
|
||||
if (!translate_success) return 0;
|
||||
|
||||
i32 result = 1;
|
||||
Data file;
|
||||
file = system_load_file(filename);
|
||||
file = system_load_file(filename.str);
|
||||
|
||||
Temp_Memory temp = begin_temp_memory(partition);
|
||||
stbtt_packedchar *chardata = push_array(partition, stbtt_packedchar, 256);
|
||||
|
@ -379,13 +383,19 @@ draw_font_info_load(Partition *partition,
|
|||
|
||||
internal i32
|
||||
draw_font_load(void *base_block, i32 size,
|
||||
Render_Font *font_out,
|
||||
char *filename,
|
||||
i32 pt_size,
|
||||
i32 tab_width){
|
||||
Render_Font *font_out,
|
||||
char *filename_untranslated,
|
||||
i32 pt_size,
|
||||
i32 tab_width){
|
||||
|
||||
char space_[1024];
|
||||
String filename = make_fixed_width_string(space_);
|
||||
b32 translate_success = system_to_binary_path(&filename, filename_untranslated);
|
||||
if (!translate_success) return 0;
|
||||
|
||||
i32 result = 1;
|
||||
Data file;
|
||||
file = system_load_file(filename);
|
||||
file = system_load_file(filename.str);
|
||||
|
||||
Partition partition_ = partition_open(base_block, size);
|
||||
Partition *partition = &partition_;
|
||||
|
|
|
@ -162,7 +162,22 @@ internal f32
|
|||
font_string_width(Render_Target *target, i16 font_id, char *str){
|
||||
f32 x = 0;
|
||||
for (i32 i = 0; str[i]; ++i){
|
||||
x += font_get_glyph_width(target, font_id, str[i]);
|
||||
u8 c = str[i];
|
||||
// TODO(allen): Someday let's not punt on the the unicode rendering
|
||||
c = c % 128;
|
||||
x += font_get_glyph_width(target, font_id, c);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
internal f32
|
||||
font_string_width(Render_Target *target, i16 font_id, String str){
|
||||
f32 x = 0;
|
||||
for (i32 i = 0; i < str.size; ++i){
|
||||
u8 c = str.str[i];
|
||||
// TODO(allen): Someday let's not punt on the the unicode rendering
|
||||
c = c % 128;
|
||||
x += font_get_glyph_width(target, font_id, c);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
@ -172,7 +187,9 @@ draw_string(Render_Target *target, i16 font_id,
|
|||
char *str, i32 x_, i32 y, u32 color){
|
||||
real32 x = (real32)x_;
|
||||
for (i32 i = 0; str[i]; ++i){
|
||||
char c = str[i];
|
||||
u8 c = str[i];
|
||||
// TODO(allen): Someday let's not punt on the the unicode rendering
|
||||
c = c % 128;
|
||||
font_draw_glyph(target, font_id, c, x, (f32)y, color);
|
||||
x += font_get_glyph_width(target, font_id, c);
|
||||
}
|
||||
|
@ -183,8 +200,10 @@ internal f32
|
|||
draw_string_mono(Render_Target *target, i16 font_id,
|
||||
char *str, f32 x, f32 y, f32 advance, u32 color){
|
||||
for (i32 i = 0; str[i]; ++i){
|
||||
font_draw_glyph_mono(target, font_id, str[i],
|
||||
x, y, advance, color);
|
||||
u8 c = str[i];
|
||||
// TODO(allen): Someday let's not punt on the the unicode rendering
|
||||
c = c % 128;
|
||||
font_draw_glyph_mono(target, font_id, c, x, y, advance, color);
|
||||
x += advance;
|
||||
}
|
||||
return x;
|
||||
|
@ -195,7 +214,9 @@ draw_string(Render_Target *target, i16 font_id,
|
|||
String str, i32 x_, i32 y, u32 color){
|
||||
f32 x = (f32)x_;
|
||||
for (i32 i = 0; i < str.size; ++i){
|
||||
char c = str.str[i];
|
||||
u8 c = str.str[i];
|
||||
// TODO(allen): Someday let's not punt on the the unicode rendering
|
||||
c = c % 128;
|
||||
font_draw_glyph(target, font_id, c,
|
||||
x, (f32)y, color);
|
||||
x += font_get_glyph_width(target, font_id, c);
|
||||
|
@ -207,8 +228,10 @@ internal f32
|
|||
draw_string_mono(Render_Target *target, i16 font_id,
|
||||
String str, f32 x, f32 y, f32 advance, u32 color){
|
||||
for (i32 i = 0; i < str.size; ++i){
|
||||
font_draw_glyph_mono(target, font_id,
|
||||
str.str[i], x, y, advance, color);
|
||||
u8 c = str.str[i];
|
||||
// TODO(allen): Someday let's not punt on the the unicode rendering
|
||||
c = c % 128;
|
||||
font_draw_glyph_mono(target, font_id, c, x, y, advance, color);
|
||||
x += advance;
|
||||
}
|
||||
return x;
|
||||
|
@ -232,7 +255,10 @@ internal f32
|
|||
font_get_string_width(Render_Target *target, i16 font_id, String string){
|
||||
f32 result = 0;
|
||||
for (i32 i = 0; i < string.size; ++i){
|
||||
font_get_glyph_width(target, font_id, string.str[i]);
|
||||
u8 c = string.str[i];
|
||||
// TODO(allen): Someday let's not punt on the the unicode rendering
|
||||
c = c % 128;
|
||||
font_get_glyph_width(target, font_id, c);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -1061,100 +1061,6 @@ main(int argc, char **argv)
|
|||
}break;
|
||||
|
||||
}
|
||||
|
||||
#if 0
|
||||
if((Event.xcookie.type == GenericEvent) &&
|
||||
(Event.xcookie.extension == XInput2OpCode) &&
|
||||
XGetEventData(linuxvars.XDisplay, &Event.xcookie))
|
||||
{
|
||||
switch(Event.xcookie.evtype)
|
||||
{
|
||||
case XI_Motion:
|
||||
{
|
||||
Window root_return, child_return;
|
||||
int root_x_return, root_y_return;
|
||||
int MouseX, MouseY;
|
||||
unsigned int mask_return;
|
||||
XQueryPointer(linuxvars.XDisplay,
|
||||
linuxvars.XWindow,
|
||||
&root_return, &child_return,
|
||||
&root_x_return, &root_y_return,
|
||||
&MouseX, &MouseY,
|
||||
&mask_return);
|
||||
} break;
|
||||
|
||||
case XI_ButtonPress:
|
||||
case XI_ButtonRelease:
|
||||
{
|
||||
b32 Down = (Event.xcookie.evtype == XI_ButtonPress);
|
||||
XIDeviceEvent *DevEvent = (XIDeviceEvent *)Event.xcookie.data;
|
||||
int Button = DevEvent->detail;
|
||||
} break;
|
||||
|
||||
case XI_KeyPress:
|
||||
case XI_KeyRelease:
|
||||
{
|
||||
b32 Down = (Event.xcookie.evtype == XI_KeyPress);
|
||||
XIDeviceEvent *DevEvent = (XIDeviceEvent *)Event.xcookie.data;
|
||||
int keycode = DevEvent->detail;
|
||||
|
||||
if (Down){
|
||||
printf("Keycode %d\n", keycode);
|
||||
|
||||
// NOTE(allen): Thanks to eisbehr for providing the code
|
||||
// for initializing an XKeyPressedEvent struct for use in
|
||||
// Xmb8LookupString
|
||||
XKeyPressedEvent eventBase = {};
|
||||
eventBase.type = KeyPress;
|
||||
eventBase.serial = 0xF00D;
|
||||
eventBase.send_event = 1; // at least admit that this isn't a genuine event
|
||||
eventBase.display = DevEvent->display;
|
||||
eventBase.window = DevEvent->event;
|
||||
eventBase.root = DevEvent->root;
|
||||
eventBase.subwindow = 0;
|
||||
eventBase.time = {}; // Let's hope we don't need a real time.
|
||||
eventBase.x = 0;
|
||||
eventBase.y = 0;
|
||||
eventBase.x_root = 0;
|
||||
eventBase.y_root = 0;
|
||||
eventBase.state = 0; // state of modifiers
|
||||
// Button1Mask, Button2Mask, Button3Mask, Button4Mask, Button5Mask,
|
||||
// ShiftMask, LockMask, ControlMask,
|
||||
// Mod1Mask, Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask.
|
||||
//eventBase.keycode = 10;//minKeyCode;
|
||||
eventBase.same_screen = 1;
|
||||
|
||||
eventBase.keycode = keycode;
|
||||
|
||||
char lookup_buffer[32];
|
||||
Status status;
|
||||
i32 size;
|
||||
KeySym keysym;
|
||||
|
||||
size = XmbLookupString(linuxvars.xic, &eventBase,
|
||||
lookup_buffer, sizeof(lookup_buffer),
|
||||
&keysym, &status);
|
||||
|
||||
if (status == XBufferOverflow){
|
||||
printf("Buffer overflow %d\n", size);
|
||||
}
|
||||
else if (status == XLookupNone){
|
||||
printf("nothing branch\n");
|
||||
}
|
||||
else if (status == XLookupChars || status == XLookupBoth){
|
||||
printf("keysym %lu translation: %.*s\n", keysym, size, lookup_buffer);
|
||||
}
|
||||
else{
|
||||
printf("unknown branch %d\n", status);
|
||||
}
|
||||
break;
|
||||
}
|
||||
} break;
|
||||
}
|
||||
|
||||
XFreeEventData(linuxvars.XDisplay, &Event.xcookie);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
b32 redraw = 1;
|
||||
|
|
|
@ -37,12 +37,14 @@ struct Font_Load_System{
|
|||
#define Sys_File_Can_Be_Made(name) b32 name(char *filename)
|
||||
#define Sys_Load_File_Sig(name) Data name(char *filename)
|
||||
#define Sys_Save_File_Sig(name) b32 name(char *filename, char *data, i32 size)
|
||||
#define Sys_To_Binary_Path(name) b32 name(String *out_filename, char *filename)
|
||||
|
||||
internal Sys_Get_Memory_Sig(system_get_memory_);
|
||||
internal Sys_Free_Memory_Sig(system_free_memory);
|
||||
internal Sys_File_Can_Be_Made(system_file_can_be_made);
|
||||
internal Sys_Load_File_Sig(system_load_file);
|
||||
internal Sys_Save_File_Sig(system_save_file);
|
||||
internal Sys_To_Binary_Path(system_to_binary_path);
|
||||
|
||||
#define system_get_memory(size) system_get_memory_((size), __LINE__, __FILE__)
|
||||
|
||||
|
|
|
@ -847,6 +847,21 @@ Sys_CLI_End_Update_Sig(system_cli_end_update){
|
|||
return close_me;
|
||||
}
|
||||
|
||||
internal
|
||||
Sys_To_Binary_Path(system_to_binary_path){
|
||||
b32 translate_success = 0;
|
||||
i32 max = out_filename->memory_size;
|
||||
i32 size = GetModuleFileName(0, out_filename->str, max);
|
||||
if (size > 0 && size < max-1){
|
||||
out_filename->size = size;
|
||||
truncate_to_path_of_directory(out_filename);
|
||||
if (append(out_filename, filename) && terminate_with_null(out_filename)){
|
||||
translate_success = 1;
|
||||
}
|
||||
}
|
||||
return (translate_success);
|
||||
}
|
||||
|
||||
internal b32
|
||||
Win32LoadAppCode(){
|
||||
b32 result = 0;
|
||||
|
@ -1249,13 +1264,12 @@ Win32Callback(HWND hwnd, UINT uMsg,
|
|||
Font_Load_Parameters *params = win32vars.fnt.params + lParam;
|
||||
|
||||
for (b32 success = 0; success == 0;){
|
||||
|
||||
success = draw_font_load(win32vars.fnt.part.base,
|
||||
win32vars.fnt.part.max,
|
||||
params->font_out,
|
||||
params->filename,
|
||||
params->pt_size,
|
||||
params->tab_width);
|
||||
win32vars.fnt.part.max,
|
||||
params->font_out,
|
||||
params->filename,
|
||||
params->pt_size,
|
||||
params->tab_width);
|
||||
|
||||
if (!success){
|
||||
Win32ScratchPartitionDouble(&win32vars.fnt.part);
|
||||
|
|
Loading…
Reference in New Issue