right alt

This commit is contained in:
Allen Webster 2016-01-16 20:34:48 -05:00
parent 0aa1df3da0
commit 7009115967
21 changed files with 4490 additions and 4215 deletions

View File

@ -17,7 +17,9 @@
clear_parameters(cmd_context) clear_parameters(cmd_context)
#define push_memory(cmd_context, len) app->push_memory(cmd_context, len) #define push_memory(cmd_context, len) app->push_memory(cmd_context, len)
#ifndef literal
#define literal(s) s, (sizeof(s)-1) #define literal(s) s, (sizeof(s)-1)
#endif
// NOTE(allen|a3.1): All of your custom ids should be >= mapid_user_custom. // NOTE(allen|a3.1): All of your custom ids should be >= mapid_user_custom.
// I recommend enumerating your own map ids as shown here. // I recommend enumerating your own map ids as shown here.

View File

@ -132,6 +132,7 @@ enum Param_ID{
par_cli_path, par_cli_path,
par_cli_command, par_cli_command,
par_cli_overlap_with_conflict, par_cli_overlap_with_conflict,
par_cli_always_bind_to_view,
// never below this // never below this
par_type_count par_type_count
}; };
@ -284,7 +285,7 @@ struct Application_Links{
Directory_CD *directory_cd; Directory_CD *directory_cd;
}; };
struct Config_API{ struct Custom_API{
Get_Binding_Data_Function *get_bindings; Get_Binding_Data_Function *get_bindings;
Set_Extra_Font_Function *set_extra_font; Set_Extra_Font_Function *set_extra_font;
}; };

View File

@ -1537,7 +1537,8 @@ cpp_get_token(Cpp_Token_Stack *token_stack, int pos){
last = token_stack->count; last = token_stack->count;
Cpp_Get_Token_Result result = {}; Cpp_Get_Token_Result result = {};
while (1){ if (token_stack->count > 0){
for (;;){
result.token_index = (first + last)/2; result.token_index = (first + last)/2;
int this_start = token_stack->tokens[result.token_index].start; int this_start = token_stack->tokens[result.token_index].start;
@ -1573,6 +1574,11 @@ cpp_get_token(Cpp_Token_Stack *token_stack, int pos){
result.in_whitespace = 1; result.in_whitespace = 1;
} }
} }
}
else{
result.token_index = -1;
result.in_whitespace = 1;
}
return result; return result;
} }

99
4ed.cpp
View File

@ -83,7 +83,7 @@ struct App_Vars{
App_State_Resizing resizing; App_State_Resizing resizing;
Panel *prev_mouse_panel; Panel *prev_mouse_panel;
Config_API config_api; Custom_API config_api;
}; };
internal i32 internal i32
@ -166,7 +166,7 @@ struct Command_Data{
Exchange *exchange; Exchange *exchange;
i32 screen_width, screen_height; i32 screen_width, screen_height;
Key_Single key; Key_Event_Data key;
Partition part; Partition part;
System_Functions *system; System_Functions *system;
@ -224,7 +224,7 @@ COMMAND_DECL(write_character){
USE_LAYOUT(layout); USE_LAYOUT(layout);
USE_MEM(mem); USE_MEM(mem);
u8 character = (u8)command->key.key.character; u8 character = (u8)command->key.character;
char str_space[2]; char str_space[2];
String string = make_string(str_space, 2); String string = make_string(str_space, 2);
str_space[0] = character; str_space[0] = character;
@ -794,7 +794,7 @@ app_open_file(System_Functions *system, App_Vars *vars, Exchange *exchange,
created_file = 1; created_file = 1;
target_file = file.file; target_file = file.file;
file_get_loading(target_file); file_get_loading(target_file);
table_add(&working_set->table, target_file->state.source_path, file.index); table_add(&working_set->table, filename_str, file.index);
file_init_strings(target_file); file_init_strings(target_file);
file_set_name(target_file, filename); file_set_name(target_file, filename);
@ -1535,7 +1535,8 @@ COMMAND_DECL(open_menu){
view_replace_minor(system, exchange, new_view, panel, live_set); view_replace_minor(system, exchange, new_view, panel, live_set);
new_view->map = &vars->map_ui; new_view->map = &vars->map_ui;
Menu_View *menu_view = menu_view_init(new_view, style, working_set, &vars->delay); Menu_View *menu_view = menu_view_init(new_view, style, working_set,
&vars->delay, vars->font_set);
AllowLocal(menu_view); AllowLocal(menu_view);
} }
@ -1666,6 +1667,9 @@ COMMAND_DECL(set_settings){
} }
} }
#define CLI_OverlapWithConflict (1<<0)
#define CLI_AlwaysBindToView (2<<0)
internal void internal void
build(System_Functions *system, Mem_Options *mem, build(System_Functions *system, Mem_Options *mem,
App_Vars *vars, Working_Set *working_set, App_Vars *vars, Working_Set *working_set,
@ -1675,14 +1679,16 @@ build(System_Functions *system, Mem_Options *mem,
char *buffer_name, i32 buffer_name_len, char *buffer_name, i32 buffer_name_len,
char *path, i32 path_len, char *path, i32 path_len,
char *script, i32 script_len, char *script, i32 script_len,
b32 overlap_with_conflict){ u32 flags){
if (buffer_name == 0 || path == 0 || script == 0){ if (buffer_name == 0 || path == 0 || script == 0){
return; return;
} }
if (vars->cli_processes.count < vars->cli_processes.max){ if (vars->cli_processes.count < vars->cli_processes.max){
Editing_Layout *layout = &vars->layout;
Editing_File *file = working_set_contains(working_set, make_string_slowly(buffer_name)); Editing_File *file = working_set_contains(working_set, make_string_slowly(buffer_name));
i32 index; i32 index;
b32 bind_to_new_view = 1;
if (!file){ if (!file){
Get_File_Result get_file = working_set_get_available_file(working_set); Get_File_Result get_file = working_set_get_available_file(working_set);
@ -1693,27 +1699,42 @@ build(System_Functions *system, Mem_Options *mem,
i32 proc_count = vars->cli_processes.count; i32 proc_count = vars->cli_processes.count;
for (i32 i = 0; i < proc_count; ++i){ for (i32 i = 0; i < proc_count; ++i){
if (vars->cli_processes.procs[i].out_file == file){ if (vars->cli_processes.procs[i].out_file == file){
if (overlap_with_conflict) if (flags & CLI_OverlapWithConflict)
vars->cli_processes.procs[i].out_file = 0; vars->cli_processes.procs[i].out_file = 0;
else file = 0; else file = 0;
break; break;
} }
} }
index = (i32)(file - vars->working_set.files); index = (i32)(file - vars->working_set.files);
if (file){
if (!(flags & CLI_AlwaysBindToView)){
Panel *panel = layout->panels;
for (i32 i = 0; i < layout->panel_count; ++i, ++panel){
File_View *fview = view_to_file_view(panel->view);
if (fview && fview->file == file){
bind_to_new_view = 0;
break;
}
}
}
}
} }
if (file){ if (file){
file_create_super_locked(system, mem, file, buffer_name, font_set, style->font_id); file_create_super_locked(system, mem, file, buffer_name, font_set, style->font_id);
table_add(&working_set->table, file->state.live_name, index); table_add(&working_set->table, file->state.live_name, index);
if (bind_to_new_view){
View *new_view = live_set_alloc_view(live_set, mem); View *new_view = live_set_alloc_view(live_set, mem);
view_replace_major(system, exchange, new_view, panel, live_set); view_replace_major(system, exchange, new_view, panel, live_set);
File_View *file_view = file_view_init(new_view, &vars->layout); File_View *file_view = file_view_init(new_view, layout);
view_set_file(system, file_view, file, font_set, style, view_set_file(system, file_view, file, font_set, style,
vars->hooks[hook_open_file], command, &app_links); vars->hooks[hook_open_file], command, &app_links);
new_view->map = app_get_map(vars, file->settings.base_map_id); new_view->map = app_get_map(vars, file->settings.base_map_id);
}
i32 i = vars->cli_processes.count++; i32 i = vars->cli_processes.count++;
CLI_Process *proc = vars->cli_processes.procs + i; CLI_Process *proc = vars->cli_processes.procs + i;
if (!system->cli_call(path, script, &proc->cli)){ if (!system->cli_call(path, script, &proc->cli)){
@ -1748,7 +1769,7 @@ COMMAND_DECL(build){
int buffer_name_len = 0; int buffer_name_len = 0;
int path_len = 0; int path_len = 0;
int script_len = 0; int script_len = 0;
b32 overlap_with_conflict = 1; u32 flags = CLI_OverlapWithConflict;
Command_Parameter *end = param_stack_end(&command->part); Command_Parameter *end = param_stack_end(&command->part);
Command_Parameter *param = param_stack_first(&command->part, end); Command_Parameter *param = param_stack_first(&command->part, end);
@ -1787,7 +1808,18 @@ COMMAND_DECL(build){
case par_cli_overlap_with_conflict: case par_cli_overlap_with_conflict:
{ {
overlap_with_conflict = dynamic_to_int(&param->param.value); if (dynamic_to_int(&param->param.value))
flags |= CLI_OverlapWithConflict;
else
flags &= (~CLI_OverlapWithConflict);
}break;
case par_cli_always_bind_to_view:
{
if (dynamic_to_int(&param->param.value))
flags |= CLI_OverlapWithConflict;
else
flags &= (~CLI_OverlapWithConflict);
}break; }break;
} }
} }
@ -1798,7 +1830,7 @@ COMMAND_DECL(build){
buffer_name, buffer_name_len, buffer_name, buffer_name_len,
path, path_len, path, path_len,
script, script_len, script, script_len,
overlap_with_conflict); flags);
} }
COMMAND_DECL(build_here){ COMMAND_DECL(build_here){
@ -1812,7 +1844,7 @@ COMMAND_DECL(build_here){
USE_EXCHANGE(exchange); USE_EXCHANGE(exchange);
USE_FONT_SET(font_set); USE_FONT_SET(font_set);
b32 overlap_with_conflict = 0; u32 flags = 0;
char *buffer_name = "*compilation*"; char *buffer_name = "*compilation*";
int buffer_name_len = sizeof("*compilation*")-1; int buffer_name_len = sizeof("*compilation*")-1;
@ -1845,7 +1877,7 @@ COMMAND_DECL(build_here){
buffer_name, buffer_name_len, buffer_name, buffer_name_len,
path.str, path.size, path.str, path.size,
dir.str, dir.size, dir.str, dir.size,
overlap_with_conflict); flags);
} }
internal void internal void
@ -2251,7 +2283,7 @@ app_hardcode_styles(App_Vars *vars){
///////////////// /////////////////
style_set_name(style, make_lit_string("4coder")); style_set_name(style, make_lit_string("4coder"));
style->font_id = fonts + 4; style->font_id = fonts + 0;
style->main.back_color = 0xFF0C0C0C; style->main.back_color = 0xFF0C0C0C;
style->main.margin_color = 0xFF181818; style->main.margin_color = 0xFF181818;
@ -2292,12 +2324,12 @@ app_hardcode_styles(App_Vars *vars){
///////////////// /////////////////
*style = *(style-1); *style = *(style-1);
style_set_name(style, make_lit_string("4coder-mono")); style_set_name(style, make_lit_string("4coder-mono"));
style->font_id = fonts; style->font_id = fonts + 1;
++style; ++style;
///////////////// /////////////////
style_set_name(style, make_lit_string("Handmade Hero")); style_set_name(style, make_lit_string("Handmade Hero"));
style->font_id = fonts; style->font_id = fonts + 1;
style->main.back_color = 0xFF161616; style->main.back_color = 0xFF161616;
style->main.margin_color = 0xFF262626; style->main.margin_color = 0xFF262626;
@ -2378,7 +2410,7 @@ app_hardcode_styles(App_Vars *vars){
///////////////// /////////////////
style_set_name(style, make_lit_string("Wolverine")); style_set_name(style, make_lit_string("Wolverine"));
style->font_id = fonts + 1; style->font_id = fonts + 3;
style->main.back_color = 0xFF070711; style->main.back_color = 0xFF070711;
style->main.margin_color = 0xFF111168; style->main.margin_color = 0xFF111168;
@ -2418,7 +2450,7 @@ app_hardcode_styles(App_Vars *vars){
///////////////// /////////////////
style_set_name(style, make_lit_string("stb")); style_set_name(style, make_lit_string("stb"));
style->font_id = fonts + 3; style->font_id = fonts + 4;
style->main.back_color = 0xFFD6D6D6; style->main.back_color = 0xFFD6D6D6;
style->main.margin_color = 0xFF9E9E9E; style->main.margin_color = 0xFF9E9E9E;
@ -2482,8 +2514,6 @@ bool _4coder_str_match(const char *a, int len_a, const char *b, int len_b){
return result; return result;
} }
#define literal(s) s, (sizeof(s) - 1)
HOOK_SIG(default_open_file_hook){ HOOK_SIG(default_open_file_hook){
Buffer_Summary buffer = app->get_active_buffer(cmd_context); Buffer_Summary buffer = app->get_active_buffer(cmd_context);
@ -2715,6 +2745,10 @@ App_Init_Sig(app_init){
#define LitStr(n) n, sizeof(n)-1 #define LitStr(n) n, sizeof(n)-1
Font_Setup font_setup[] = { Font_Setup font_setup[] = {
{LitStr("LiberationSans-Regular.ttf"),
LitStr("liberation sans"),
16},
{LitStr("liberation-mono.ttf"), {LitStr("liberation-mono.ttf"),
LitStr("liberation mono"), LitStr("liberation mono"),
16}, 16},
@ -2731,10 +2765,6 @@ App_Init_Sig(app_init){
LitStr("inconsolata"), LitStr("inconsolata"),
16}, 16},
{LitStr("LiberationSans-Regular.ttf"),
LitStr("liberation sans"),
16},
}; };
i32 font_count = ArrayCount(font_setup); i32 font_count = ArrayCount(font_setup);
@ -2954,20 +2984,16 @@ App_Step_Sig(app_step){
key_data.keys[key_data.count++] = input->hold[i]; key_data.keys[key_data.count++] = input->hold[i];
} }
for (i32 i = 0; i < CONTROL_KEY_COUNT; ++i){
key_data.modifiers[i] = input->control_keys[i];
}
Mouse_Summary mouse_data; Mouse_Summary mouse_data;
mouse_data.mx = mouse->x; mouse_data.mx = mouse->x;
mouse_data.my = mouse->y; mouse_data.my = mouse->y;
mouse_data.l = mouse->left_button; mouse_data.l = mouse->left_button;
mouse_data.r = mouse->right_button; mouse_data.r = mouse->right_button;
mouse_data.press_l = mouse_data.l && !mouse->left_button_prev; mouse_data.press_l = mouse->left_button_pressed;
mouse_data.press_r = mouse_data.r && !mouse->right_button_prev; mouse_data.press_r = mouse->right_button_pressed;
mouse_data.release_l = !mouse_data.l && mouse->left_button_prev; mouse_data.release_l = mouse->left_button_released;
mouse_data.release_r = !mouse_data.r && mouse->right_button_prev; mouse_data.release_r = mouse->right_button_released;
mouse_data.out_of_window = mouse->out_of_window; mouse_data.out_of_window = mouse->out_of_window;
mouse_data.wheel_used = (mouse->wheel != 0); mouse_data.wheel_used = (mouse->wheel != 0);
@ -3205,7 +3231,7 @@ App_Step_Sig(app_step){
Command_Map *map = 0; Command_Map *map = 0;
View *view = active_panel->view; View *view = active_panel->view;
Key_Single key = get_single_key(&key_data, key_i); Key_Event_Data key = get_single_key(&key_data, key_i);
command_data.key = key; command_data.key = key;
Command_Map *visited_maps[16] = {}; Command_Map *visited_maps[16] = {};
@ -3267,9 +3293,6 @@ App_Step_Sig(app_step){
dead_input.mouse.mx = mouse_data.mx; dead_input.mouse.mx = mouse_data.mx;
dead_input.mouse.my = mouse_data.my; dead_input.mouse.my = mouse_data.my;
dead_input.codes = codes; dead_input.codes = codes;
dead_input.keys.modifiers[0] = key_data.modifiers[0];
dead_input.keys.modifiers[1] = key_data.modifiers[1];
dead_input.keys.modifiers[2] = key_data.modifiers[2];
Input_Summary active_input = {}; Input_Summary active_input = {};
dead_input.mouse.mx = mouse_data.mx; dead_input.mouse.mx = mouse_data.mx;
@ -3571,7 +3594,7 @@ App_Step_Sig(app_step){
ProfileStart(redraw); ProfileStart(redraw);
if (mouse_panel != vars->prev_mouse_panel) app_result.redraw = 1; if (mouse_panel != vars->prev_mouse_panel) app_result.redraw = 1;
if (app_result.redraw){ if (app_result.redraw){
begin_render_section(target); begin_render_section(target, system);
target->clip_top = -1; target->clip_top = -1;
draw_push_clip(target, rect_from_target(target)); draw_push_clip(target, rect_from_target(target));
@ -3614,7 +3637,7 @@ App_Step_Sig(app_step){
draw_rectangle(target, i32R(inner.x1, inner.y0, full.x1, inner.y1), margin_color); draw_rectangle(target, i32R(inner.x1, inner.y0, full.x1, inner.y1), margin_color);
} }
end_render_section(target); end_render_section(target, system);
} }
ProfileEnd(redraw); ProfileEnd(redraw);

29
4ed.h
View File

@ -26,15 +26,17 @@ enum Key_Control{
CONTROL_KEY_SHIFT, CONTROL_KEY_SHIFT,
CONTROL_KEY_CONTROL, CONTROL_KEY_CONTROL,
CONTROL_KEY_ALT, CONTROL_KEY_ALT,
CONTROL_KEY_CAPS,
// always last // always last
CONTROL_KEY_COUNT CONTROL_KEY_COUNT
}; };
struct Key_Event_Data{ struct Key_Event_Data{
u8 keycode; u8 keycode;
//u8 apply_shift;
u8 character; u8 character;
u8 character_no_caps_lock; u8 character_no_caps_lock;
b8 modifiers[CONTROL_KEY_COUNT];
}; };
struct Key_Input_Data{ struct Key_Input_Data{
@ -42,37 +44,28 @@ struct Key_Input_Data{
Key_Event_Data hold[KEY_INPUT_BUFFER_SIZE]; Key_Event_Data hold[KEY_INPUT_BUFFER_SIZE];
i32 press_count; i32 press_count;
i32 hold_count; i32 hold_count;
b8 control_keys[CONTROL_KEY_COUNT];
b8 caps_lock;
}; };
struct Key_Summary{ struct Key_Summary{
i32 count; i32 count;
Key_Event_Data keys[KEY_INPUT_BUFFER_DSIZE]; Key_Event_Data keys[KEY_INPUT_BUFFER_DSIZE];
bool8 modifiers[CONTROL_KEY_COUNT];
}; };
struct Key_Single{ inline Key_Event_Data
Key_Event_Data key;
b8 *modifiers;
};
inline Key_Single
get_single_key(Key_Summary *summary, i32 index){ get_single_key(Key_Summary *summary, i32 index){
Assert(index >= 0 && index < summary->count); Assert(index >= 0 && index < summary->count);
Key_Single key; Key_Event_Data key;
key.key = summary->keys[index]; key = summary->keys[index];
key.modifiers = summary->modifiers;
return key; return key;
} }
struct Mouse_State{ struct Mouse_State{
b32 out_of_window; b32 out_of_window;
b32 left_button, right_button; b8 left_button, right_button;
b32 left_button_prev, right_button_prev; b8 left_button_pressed, right_button_pressed;
i32 x, y; b8 left_button_released, right_button_released;
i16 wheel; i16 wheel;
i32 x, y;
}; };
struct Mouse_Summary{ struct Mouse_Summary{
@ -135,7 +128,7 @@ struct Exchange{
Key_Codes *loose_codes, \ Key_Codes *loose_codes, \
Clipboard_Contents clipboard, \ Clipboard_Contents clipboard, \
String current_directory, \ String current_directory, \
Config_API api) Custom_API api)
typedef App_Init_Sig(App_Init); typedef App_Init_Sig(App_Init);

View File

@ -190,7 +190,7 @@ draw_rgb_slider(Render_Target *target, Vec4 base, i32 channel,
} }
internal void internal void
do_label(UI_State *state, UI_Layout *layout, char *text, f32 height = 2.f){ do_label(UI_State *state, UI_Layout *layout, char *text, int text_size, f32 height = 2.f){
Style *style = state->style; Style *style = state->style;
i16 font_id = style->font_id; i16 font_id = style->font_id;
i32 line_height = get_font_info(state->font_set, font_id)->height; i32 line_height = get_font_info(state->font_set, font_id)->height;
@ -202,11 +202,18 @@ do_label(UI_State *state, UI_Layout *layout, char *text, f32 height = 2.f){
u32 fore = style->main.default_color; u32 fore = style->main.default_color;
draw_rectangle(target, label, back); draw_rectangle(target, label, back);
i32 height = label.y1 - label.y0; i32 height = label.y1 - label.y0;
draw_string(target, font_id, text, label.x0,
String textstr = make_string(text, text_size);
draw_string(target, font_id, textstr, label.x0,
label.y0 + (height - line_height)/2, fore); label.y0 + (height - line_height)/2, fore);
} }
} }
inline void
do_label(UI_State *state, UI_Layout *layout, String text, f32 height = 2.f){
do_label(state, layout, text.str, text.size, height);
}
internal void internal void
do_scroll_bar(UI_State *state, i32_Rect rect){ do_scroll_bar(UI_State *state, i32_Rect rect){
i32 id = 1; i32 id = 1;
@ -447,19 +454,19 @@ do_channel_field(i32 sub_id, Color_UI *ui, u8 *channel, Channel_Field_Type ftype
Key_Summary *keys = ui->state.keys; Key_Summary *keys = ui->state.keys;
Key_Codes *codes = ui->state.codes; Key_Codes *codes = ui->state.codes;
for (i32 key_i = 0; key_i < keys->count; ++key_i){ for (i32 key_i = 0; key_i < keys->count; ++key_i){
Key_Single key = get_single_key(keys, key_i); Key_Event_Data key = get_single_key(keys, key_i);
if (key.key.keycode == codes->right){ if (key.keycode == codes->right){
++indx; ++indx;
if (indx > digit_count-1) indx = 0; if (indx > digit_count-1) indx = 0;
} }
if (key.key.keycode == codes->left){ if (key.keycode == codes->left){
--indx; --indx;
if (indx < 0) indx = digit_count-1; if (indx < 0) indx = digit_count-1;
} }
i32 new_value = *channel; i32 new_value = *channel;
if (key.key.keycode == codes->up || key.key.keycode == codes->down){ if (key.keycode == codes->up || key.keycode == codes->down){
i32 place = digit_count-1-indx; i32 place = digit_count-1-indx;
i32 base = (ftype == CF_DEC)?10:0x10; i32 base = (ftype == CF_DEC)?10:0x10;
i32 step_amount = 1; i32 step_amount = 1;
@ -467,13 +474,13 @@ do_channel_field(i32 sub_id, Color_UI *ui, u8 *channel, Channel_Field_Type ftype
step_amount *= base; step_amount *= base;
--place; --place;
} }
if (key.key.keycode == codes->down){ if (key.keycode == codes->down){
step_amount = 0 - step_amount; step_amount = 0 - step_amount;
} }
new_value += step_amount; new_value += step_amount;
} }
u8 c = (u8)key.key.character; u8 c = (u8)key.character;
bool32 is_good = (ftype == CF_DEC)?char_is_numeric(c):char_is_hex(c); bool32 is_good = (ftype == CF_DEC)?char_is_numeric(c):char_is_hex(c);
if (is_good){ if (is_good){
string_buffer[indx] = c; string_buffer[indx] = c;
@ -1563,7 +1570,7 @@ step_draw_library(System_Functions *system, Exchange *exchange, Mem_Options *mem
switch (mode){ switch (mode){
case CV_MODE_LIBRARY: case CV_MODE_LIBRARY:
{ {
do_label(&ui.state, &ui.layout, "Current Theme - Click to Edit"); do_label(&ui.state, &ui.layout, literal("Current Theme - Click to Edit"));
if (do_style_preview(&ui, color_view->main_style)){ if (do_style_preview(&ui, color_view->main_style)){
color_view->mode = CV_MODE_ADJUSTING; color_view->mode = CV_MODE_ADJUSTING;
color_view->state.selected = {}; color_view->state.selected = {};
@ -1592,7 +1599,7 @@ step_draw_library(System_Functions *system, Exchange *exchange, Mem_Options *mem
memset(color_view->import_export_check, 0, sizeof(color_view->import_export_check)); memset(color_view->import_export_check, 0, sizeof(color_view->import_export_check));
} }
do_label(&ui.state, &ui.layout, "Theme Library - Click to Select"); do_label(&ui.state, &ui.layout, literal("Theme Library - Click to Select"));
i32 style_count = color_view->styles->count; i32 style_count = color_view->styles->count;
Style *style = color_view->styles->styles; Style *style = color_view->styles->styles;
@ -1606,12 +1613,12 @@ step_draw_library(System_Functions *system, Exchange *exchange, Mem_Options *mem
case CV_MODE_IMPORT_FILE: case CV_MODE_IMPORT_FILE:
{ {
do_label(&ui.state, &ui.layout, "Current Theme"); do_label(&ui.state, &ui.layout, literal("Current Theme"));
do_style_preview(&ui, color_view->main_style); do_style_preview(&ui, color_view->main_style);
b32 file_selected = 0; b32 file_selected = 0;
do_label(&ui.state, &ui.layout, "Import Which File?"); do_label(&ui.state, &ui.layout, literal("Import Which File?"));
begin_row(&ui.layout, 2); begin_row(&ui.layout, 2);
if (do_button(-2, &ui.state, &ui.layout, "*.p4c only", 2, 1, color_view->p4c_only)){ if (do_button(-2, &ui.state, &ui.layout, "*.p4c only", 2, 1, color_view->p4c_only)){
color_view->p4c_only = !color_view->p4c_only; color_view->p4c_only = !color_view->p4c_only;
@ -1671,12 +1678,12 @@ step_draw_library(System_Functions *system, Exchange *exchange, Mem_Options *mem
case CV_MODE_EXPORT_FILE: case CV_MODE_EXPORT_FILE:
{ {
do_label(&ui.state, &ui.layout, "Current Theme"); do_label(&ui.state, &ui.layout, literal("Current Theme"));
do_style_preview(&ui, color_view->main_style); do_style_preview(&ui, color_view->main_style);
b32 file_selected = 0; b32 file_selected = 0;
do_label(&ui.state, &ui.layout, "Export File Name?"); do_label(&ui.state, &ui.layout, literal("Export File Name?"));
begin_row(&ui.layout, 2); begin_row(&ui.layout, 2);
if (do_button(-2, &ui.state, &ui.layout, "Finish Export", 2)){ if (do_button(-2, &ui.state, &ui.layout, "Finish Export", 2)){
file_selected = 1; file_selected = 1;
@ -1722,14 +1729,14 @@ step_draw_library(System_Functions *system, Exchange *exchange, Mem_Options *mem
case CV_MODE_IMPORT: case CV_MODE_IMPORT:
{ {
do_label(&ui.state, &ui.layout, "Current Theme"); do_label(&ui.state, &ui.layout, literal("Current Theme"));
do_style_preview(&ui, color_view->main_style); do_style_preview(&ui, color_view->main_style);
i32 style_count = color_view->inspecting_styles.count; i32 style_count = color_view->inspecting_styles.count;
Style *styles = color_view->inspecting_styles.styles; Style *styles = color_view->inspecting_styles.styles;
bool8 *import_check = color_view->import_export_check; bool8 *import_check = color_view->import_export_check;
do_label(&ui.state, &ui.layout, "Pack"); do_label(&ui.state, &ui.layout, literal("Pack"));
begin_row(&ui.layout, 2); begin_row(&ui.layout, 2);
if (do_button(-2, &ui.state, &ui.layout, "Finish Import", 2)){ if (do_button(-2, &ui.state, &ui.layout, "Finish Import", 2)){
Style *style = styles; Style *style = styles;
@ -1753,10 +1760,10 @@ step_draw_library(System_Functions *system, Exchange *exchange, Mem_Options *mem
case CV_MODE_EXPORT: case CV_MODE_EXPORT:
{ {
do_label(&ui.state, &ui.layout, "Current Theme"); do_label(&ui.state, &ui.layout, literal("Current Theme"));
do_style_preview(&ui, color_view->main_style); do_style_preview(&ui, color_view->main_style);
do_label(&ui.state, &ui.layout, "Export Which Themes?"); do_label(&ui.state, &ui.layout, literal("Export Which Themes?"));
begin_row(&ui.layout, 2); begin_row(&ui.layout, 2);
if (do_button(-2, &ui.state, &ui.layout, "Export", 2)){ if (do_button(-2, &ui.state, &ui.layout, "Export", 2)){
color_view->mode = CV_MODE_EXPORT_FILE; color_view->mode = CV_MODE_EXPORT_FILE;

View File

@ -126,7 +126,7 @@ apply_shift_to_code(u8 keycode){
} }
internal Command_Binding internal Command_Binding
map_extract(Command_Map *map, Key_Single key){ map_extract(Command_Map *map, Key_Event_Data key){
Command_Binding bind = {}; Command_Binding bind = {};
b32 ctrl = key.modifiers[CONTROL_KEY_CONTROL]; b32 ctrl = key.modifiers[CONTROL_KEY_CONTROL];
@ -135,16 +135,16 @@ map_extract(Command_Map *map, Key_Single key){
u16 code; u16 code;
u8 command = MDFR_NONE; u8 command = MDFR_NONE;
if (key.key.character_no_caps_lock != 0 && if (key.character_no_caps_lock != 0 &&
key.key.character_no_caps_lock != ' ') shift = 0; key.character_no_caps_lock != ' ') shift = 0;
if (shift) command |= MDFR_SHIFT; if (shift) command |= MDFR_SHIFT;
if (ctrl) command |= MDFR_CTRL; if (ctrl) command |= MDFR_CTRL;
if (alt) command |= MDFR_ALT; if (alt) command |= MDFR_ALT;
code = key.key.character_no_caps_lock; code = key.character_no_caps_lock;
if (code == 0){ if (code == 0){
code = key.key.keycode; code = key.keycode;
map_find(map, code, command, &bind); map_find(map, code, command, &bind);
} }
else{ else{

View File

@ -219,8 +219,11 @@ draw_os_events(Debug_View *view, i32_Rect rect, Render_Target *target,
i16 font_id = view->font_id; i16 font_id = view->font_id;
i32 line_height = get_font_info(&target->font_set, font_id)->height; i32 line_height = get_font_info(&target->font_set, font_id)->height;
#if 0
draw_modifiers(view, target, active_input->keys.modifiers, draw_modifiers(view, target, active_input->keys.modifiers,
0xFFFFFFFF, 0xFF444444, &x, y); 0xFFFFFFFF, 0xFF444444, &x, y);
#endif
max_x = x; max_x = x;
x = rect.x0; x = rect.x0;
y += line_height; y += line_height;
@ -325,7 +328,8 @@ step_debug_view(Debug_View *view, i32_Rect rect, Render_Target *target,
Input_Summary *active_input){ Input_Summary *active_input){
persist i32 max_past = ArrayCount(view->past_keys); persist i32 max_past = ArrayCount(view->past_keys);
bool8 *modifiers = active_input->keys.modifiers; #if 0
b8 *modifiers = active_input->keys.modifiers;
for (i32 i = 0; i < active_input->keys.count; ++i){ for (i32 i = 0; i < active_input->keys.count; ++i){
Dbg_Past_Key *past_key = view->past_keys + view->past_key_pos; Dbg_Past_Key *past_key = view->past_keys + view->past_key_pos;
++view->past_key_pos; ++view->past_key_pos;
@ -350,6 +354,7 @@ step_debug_view(Debug_View *view, i32_Rect rect, Render_Target *target,
if (active_input->mouse.wheel_used) if (active_input->mouse.wheel_used)
view->prev_mouse_wheel = active_input->mouse.wheel_amount; view->prev_mouse_wheel = active_input->mouse.wheel_amount;
#endif
} }
internal internal

View File

@ -95,6 +95,7 @@ struct Editing_File_Settings{
i32 dos_write_mode; i32 dos_write_mode;
b32 tokens_exist; b32 tokens_exist;
b32 super_locked; b32 super_locked;
b32 is_initialized;
}; };
// NOTE(allen): This part of the Editing_File is cleared whenever // NOTE(allen): This part of the Editing_File is cleared whenever
@ -425,10 +426,10 @@ struct Single_Line_Mode{
internal Single_Line_Input_Step internal Single_Line_Input_Step
app_single_line_input_core(System_Functions *system, app_single_line_input_core(System_Functions *system,
Key_Codes *codes, Working_Set *working_set, Key_Codes *codes, Working_Set *working_set,
Key_Single key, Single_Line_Mode mode){ Key_Event_Data key, Single_Line_Mode mode){
Single_Line_Input_Step result = {}; Single_Line_Input_Step result = {};
if (key.key.keycode == codes->back){ if (key.keycode == codes->back){
result.hit_backspace = 1; result.hit_backspace = 1;
if (mode.string->size > 0){ if (mode.string->size > 0){
result.made_a_change = 1; result.made_a_change = 1;
@ -453,7 +454,7 @@ app_single_line_input_core(System_Functions *system,
} }
} }
else if (key.key.character == '\n' || key.key.character == '\t'){ else if (key.character == '\n' || key.character == '\t'){
result.made_a_change = 1; result.made_a_change = 1;
if (key.modifiers[CONTROL_KEY_CONTROL] || if (key.modifiers[CONTROL_KEY_CONTROL] ||
key.modifiers[CONTROL_KEY_ALT]){ key.modifiers[CONTROL_KEY_ALT]){
@ -490,17 +491,17 @@ app_single_line_input_core(System_Functions *system,
} }
} }
else if (key.key.keycode == codes->esc){ else if (key.keycode == codes->esc){
result.hit_esc = 1; result.hit_esc = 1;
result.made_a_change = 1; result.made_a_change = 1;
} }
else if (key.key.character){ else if (key.character){
result.hit_a_character = 1; result.hit_a_character = 1;
if (!key.modifiers[CONTROL_KEY_CONTROL] && if (!key.modifiers[CONTROL_KEY_CONTROL] &&
!key.modifiers[CONTROL_KEY_ALT]){ !key.modifiers[CONTROL_KEY_ALT]){
if (mode.string->size+1 < mode.string->memory_size){ if (mode.string->size+1 < mode.string->memory_size){
u8 new_character = (u8)key.key.character; u8 new_character = (u8)key.character;
mode.string->str[mode.string->size] = new_character; mode.string->str[mode.string->size] = new_character;
mode.string->size++; mode.string->size++;
mode.string->str[mode.string->size] = 0; mode.string->str[mode.string->size] = 0;
@ -521,7 +522,7 @@ app_single_line_input_core(System_Functions *system,
inline Single_Line_Input_Step inline Single_Line_Input_Step
app_single_line_input_step(System_Functions *system, app_single_line_input_step(System_Functions *system,
Key_Codes *codes, Key_Single key, String *string){ Key_Codes *codes, Key_Event_Data key, String *string){
Single_Line_Mode mode = {}; Single_Line_Mode mode = {};
mode.type = SINGLE_LINE_STRING; mode.type = SINGLE_LINE_STRING;
mode.string = string; mode.string = string;
@ -530,7 +531,7 @@ app_single_line_input_step(System_Functions *system,
inline Single_Line_Input_Step inline Single_Line_Input_Step
app_single_file_input_step(System_Functions *system, app_single_file_input_step(System_Functions *system,
Key_Codes *codes, Working_Set *working_set, Key_Single key, Key_Codes *codes, Working_Set *working_set, Key_Event_Data key,
String *string, Hot_Directory *hot_directory, String *string, Hot_Directory *hot_directory,
bool32 fast_folder_select){ bool32 fast_folder_select){
Single_Line_Mode mode = {}; Single_Line_Mode mode = {};
@ -543,13 +544,13 @@ app_single_file_input_step(System_Functions *system,
inline Single_Line_Input_Step inline Single_Line_Input_Step
app_single_number_input_step(System_Functions *system, app_single_number_input_step(System_Functions *system,
Key_Codes *codes, Key_Single key, String *string){ Key_Codes *codes, Key_Event_Data key, String *string){
Single_Line_Input_Step result = {}; Single_Line_Input_Step result = {};
Single_Line_Mode mode = {}; Single_Line_Mode mode = {};
mode.type = SINGLE_LINE_STRING; mode.type = SINGLE_LINE_STRING;
mode.string = string; mode.string = string;
char c = (char)key.key.character; char c = (char)key.character;
if (c == 0 || c == '\n' || char_is_numeric(c)) if (c == 0 || c == '\n' || char_is_numeric(c))
result = app_single_line_input_core(system, codes, 0, key, mode); result = app_single_line_input_core(system, codes, 0, key, mode);
return result; return result;
@ -936,8 +937,8 @@ ui_do_text_field_input(UI_State *state, String *str){
bool32 result = 0; bool32 result = 0;
Key_Summary *keys = state->keys; Key_Summary *keys = state->keys;
for (i32 key_i = 0; key_i < keys->count; ++key_i){ for (i32 key_i = 0; key_i < keys->count; ++key_i){
Key_Single key = get_single_key(keys, key_i); Key_Event_Data key = get_single_key(keys, key_i);
char c = (char)key.key.character; char c = (char)key.character;
if (char_is_basic(c) && str->size < str->memory_size-1){ if (char_is_basic(c) && str->size < str->memory_size-1){
str->str[str->size++] = c; str->str[str->size++] = c;
str->str[str->size] = 0; str->str[str->size] = 0;
@ -945,7 +946,7 @@ ui_do_text_field_input(UI_State *state, String *str){
else if (c == '\n'){ else if (c == '\n'){
result = 1; result = 1;
} }
else if (key.key.keycode == state->codes->back && str->size > 0){ else if (key.keycode == state->codes->back && str->size > 0){
str->str[--str->size] = 0; str->str[--str->size] = 0;
} }
} }
@ -958,7 +959,7 @@ ui_do_file_field_input(System_Functions *system,
bool32 result = 0; bool32 result = 0;
Key_Summary *keys = state->keys; Key_Summary *keys = state->keys;
for (i32 key_i = 0; key_i < keys->count; ++key_i){ for (i32 key_i = 0; key_i < keys->count; ++key_i){
Key_Single key = get_single_key(keys, key_i); Key_Event_Data key = get_single_key(keys, key_i);
String *str = &hot_dir->string; String *str = &hot_dir->string;
terminate_with_null(str); terminate_with_null(str);
Single_Line_Input_Step step = Single_Line_Input_Step step =
@ -974,7 +975,7 @@ ui_do_line_field_input(System_Functions *system,
bool32 result = 0; bool32 result = 0;
Key_Summary *keys = state->keys; Key_Summary *keys = state->keys;
for (i32 key_i = 0; key_i < keys->count; ++key_i){ for (i32 key_i = 0; key_i < keys->count; ++key_i){
Key_Single key = get_single_key(keys, key_i); Key_Event_Data key = get_single_key(keys, key_i);
terminate_with_null(string); terminate_with_null(string);
Single_Line_Input_Step step = Single_Line_Input_Step step =
app_single_line_input_step(system, state->codes, key, string); app_single_line_input_step(system, state->codes, key, string);
@ -1553,9 +1554,7 @@ working_set_get_available_file(Working_Set *working_set){
} }
} }
if (result.file){ if (result.file) *result.file = {};
*result.file = {};
}
return result; return result;
} }
@ -1639,7 +1638,7 @@ Job_Callback_Sig(job_full_lex){
status = cpp_lex_file_nonalloc(cpp_file, &tokens, status); status = cpp_lex_file_nonalloc(cpp_file, &tokens, status);
} }
i32 new_max = LargeRoundUp(tokens.count, Kbytes(1)); i32 new_max = LargeRoundUp(tokens.count+1, Kbytes(1));
system->acquire_lock(FRAME_LOCK); system->acquire_lock(FRAME_LOCK);
{ {
@ -2247,9 +2246,9 @@ view_file_loaded_init(System_Functions *system, File_View *view, i32 cursor_pos)
} }
internal void internal void
view_set_file(System_Functions *system, File_View *view, Editing_File *file, view_set_file(System_Functions *system, File_View *view,
Font_Set *set, Style *style, Custom_Command_Function *open_hook, Editing_File *file, Font_Set *set, Style *style,
void *cmd_context, Application_Links *app){ Hook_Function *open_hook, void *cmd_context, Application_Links *app){
Panel *panel = view->view_base.panel; Panel *panel = view->view_base.panel;
view->file = file; view->file = file;
view->locked = file->settings.super_locked; view->locked = file->settings.super_locked;
@ -2296,7 +2295,10 @@ view_set_file(System_Functions *system, File_View *view, Editing_File *file,
view->vel_y = 1.f; view->vel_y = 1.f;
view->vel_x = 1.f; view->vel_x = 1.f;
if (open_hook) open_hook(cmd_context, app); if (open_hook && file->settings.is_initialized == 0){
open_hook(cmd_context, app);
file->settings.is_initialized = 1;
}
} }
struct Relative_Scrolling{ struct Relative_Scrolling{
@ -2723,8 +2725,7 @@ file_do_single_edit(System_Functions *system,
} }
internal void internal void
view_do_white_batch_edit(System_Functions *system, view_do_white_batch_edit(System_Functions *system, Mem_Options *mem, File_View *view, Editing_File *file,
Mem_Options *mem, File_View *view, Editing_File *file,
Editing_Layout *layout, Edit_Spec spec, History_Mode history_mode){ Editing_Layout *layout, Edit_Spec spec, History_Mode history_mode){
if (view->locked) return; if (view->locked) return;
#if BUFFER_EXPERIMENT_SCALPEL <= 3 #if BUFFER_EXPERIMENT_SCALPEL <= 3
@ -2871,7 +2872,7 @@ view_undo_redo(System_Functions *system,
Assert(step.type == expected_type); Assert(step.type == expected_type);
Edit_Spec spec; Edit_Spec spec = {};
spec.step = step; spec.step = step;
if (step.child_count == 0){ if (step.child_count == 0){
@ -4341,7 +4342,7 @@ HANDLE_COMMAND_SIG(handle_command_file_view){
if (binding.function) binding.function(system, command, binding); if (binding.function) binding.function(system, command, binding);
file_view->mode = file_view->next_mode; file_view->mode = file_view->next_mode;
if (key.key.keycode == codes->esc) if (key.keycode == codes->esc)
view_set_widget(file_view, FWIDG_NONE); view_set_widget(file_view, FWIDG_NONE);
}break; }break;

View File

@ -115,7 +115,7 @@ font_set_load(Partition *partition, Font_Set *set, i16 font_id){
font__insert(&set->used_slots, slot); font__insert(&set->used_slots, slot);
Render_Font *font = (Render_Font*)(slot + 1); Render_Font *font = (Render_Font*)(slot + 1);
set->font_load(partition, font, info->filename.str, info->pt_size, 4); set->font_load(font, info->filename.str, info->pt_size, 4);
info->font = font; info->font = font;
slot->font_id = font_id; slot->font_id = font_id;
} }

View File

@ -113,8 +113,7 @@ step_draw_int_view(System_Functions *system, Interactive_View *view,
b32 new_dir = 0; b32 new_dir = 0;
b32 complete = 0; b32 complete = 0;
terminate_with_null(&view->query); do_label(&state, &layout, view->query, 1.f);
do_label(&state, &layout, view->query.str, 1.f);
switch (view->interaction){ switch (view->interaction){
case INTV_SYS_FILE_LIST: case INTV_SYS_FILE_LIST:
@ -142,7 +141,7 @@ step_draw_int_view(System_Functions *system, Interactive_View *view,
String s = make_fixed_width_string(s_); String s = make_fixed_width_string(s_);
append(&s, view->dest); append(&s, view->dest);
append(&s, " has unsaved changes, kill it?"); append(&s, " has unsaved changes, kill it?");
do_label(&state, &layout, s.str, 1.f); do_label(&state, &layout, s, 1.f);
i32 id = 0; i32 id = 0;
if (do_list_option(++id, &state, &layout, make_lit_string("(Y)es"))){ if (do_list_option(++id, &state, &layout, make_lit_string("(Y)es"))){

View File

@ -49,7 +49,7 @@ typedef Do_View_Sig(Do_View_Function);
#define HANDLE_COMMAND_SIG(name) \ #define HANDLE_COMMAND_SIG(name) \
void (name)(System_Functions *system, View *view, \ void (name)(System_Functions *system, View *view, \
Command_Data *command, Command_Binding binding, \ Command_Data *command, Command_Binding binding, \
Key_Single key, Key_Codes *codes) Key_Event_Data key, Key_Codes *codes)
typedef HANDLE_COMMAND_SIG(Handle_Command_Function); typedef HANDLE_COMMAND_SIG(Handle_Command_Function);

View File

@ -47,7 +47,7 @@ struct Mem_Options{
inline Partition inline Partition
partition_open(void *memory, i32 size){ partition_open(void *memory, i32 size){
Partition partition; Partition partition;
partition.base = (u8*)memory;; partition.base = (u8*)memory;
partition.pos = 0; partition.pos = 0;
partition.max = size; partition.max = size;
return partition; return partition;

View File

@ -14,6 +14,7 @@ struct Menu_View{
Style *style; Style *style;
Working_Set *working_set; Working_Set *working_set;
Delay *delay; Delay *delay;
Font_Set *font_set;
UI_State state; UI_State state;
}; };
@ -33,14 +34,14 @@ step_draw_menu_view(Menu_View *view, Render_Target *target, i32_Rect rect,
UI_State state = UI_State state =
ui_state_init(&view->state, target, user_input, ui_state_init(&view->state, target, user_input,
view->style, &target->font_set, view->working_set, input_stage); view->style, view->font_set, view->working_set, input_stage);
UI_Layout layout; UI_Layout layout;
begin_layout(&layout, rect); begin_layout(&layout, rect);
i32 id = 0; i32 id = 0;
do_label(&state, &layout, "Menu", 2.f); do_label(&state, &layout, literal("Menu"), 2.f);
if (do_list_option_lit(++id, &state, &layout, "Theme Options")){ if (do_list_option_lit(++id, &state, &layout, "Theme Options")){
delayed_action(view->delay, DACT_THEME_OPTIONS, {}, view->view_base.panel); delayed_action(view->delay, DACT_THEME_OPTIONS, {}, view->view_base.panel);
@ -67,7 +68,8 @@ Do_View_Sig(do_menu_view){
} }
internal Menu_View* internal Menu_View*
menu_view_init(View *view, Style *style, Working_Set *working_set, Delay *delay){ menu_view_init(View *view, Style *style, Working_Set *working_set,
Delay *delay, Font_Set *font_set){
view->type = VIEW_TYPE_INTERACTIVE; view->type = VIEW_TYPE_INTERACTIVE;
view->do_view = do_menu_view; view->do_view = do_menu_view;
@ -76,6 +78,7 @@ menu_view_init(View *view, Style *style, Working_Set *working_set, Delay *delay)
result->style = style; result->style = style;
result->working_set = working_set; result->working_set = working_set;
result->delay = delay; result->delay = delay;
result->font_set = font_set;
return result; return result;
} }

View File

@ -101,6 +101,10 @@ _OutDbgStr(u8*);
#define Swap(a,b) {auto t = a; a = b; b = t;} #define Swap(a,b) {auto t = a; a = b; b = t;}
#ifndef literal
#define literal(s) s, (sizeof(s)-1)
#endif
#define Min(a,b) (((a)<(b))?(a):(b)) #define Min(a,b) (((a)<(b))?(a):(b))
#define Max(a,b) (((a)>(b))?(a):(b)) #define Max(a,b) (((a)>(b))?(a):(b))

View File

@ -269,11 +269,16 @@ launch_rendering(Render_Target *target){
#undef ExtractStruct #undef ExtractStruct
internal internal i32
Font_Info_Load_Sig(draw_font_info_load){ draw_font_info_load(Partition *partition,
char *filename,
i32 pt_size,
i32 *height,
i32 *advance){
i32 result = 1; i32 result = 1;
Data file; Data file;
file = system_load_file(filename); file = system_load_file(filename);
Temp_Memory temp = begin_temp_memory(partition); Temp_Memory temp = begin_temp_memory(partition);
stbtt_packedchar *chardata = push_array(partition, stbtt_packedchar, 256); stbtt_packedchar *chardata = push_array(partition, stbtt_packedchar, 256);
@ -348,12 +353,19 @@ Font_Info_Load_Sig(draw_font_info_load){
return(result); return(result);
} }
internal internal i32
Font_Load_Sig(draw_font_load){ draw_font_load(void *base_block, i32 size,
Render_Font *font_out,
char *filename,
i32 pt_size,
i32 tab_width){
i32 result = 1; i32 result = 1;
Data file; Data file;
file = system_load_file(filename); file = system_load_file(filename);
Temp_Memory temp = begin_temp_memory(partition);
Partition partition_ = partition_open(base_block, size);
Partition *partition = &partition_;
stbtt_packedchar *chardata = font_out->chardata; stbtt_packedchar *chardata = font_out->chardata;
i32 oversample = 2; i32 oversample = 2;
@ -395,14 +407,6 @@ Font_Load_Sig(draw_font_load){
stbtt_pack_context spc; stbtt_pack_context spc;
#if 0
if (stbtt_BakeFontBitmap((u8*)file.data, 0, (f32)pt_size,
memory_cursor, tex_width, tex_height, 0, 128,
font_out->chardata, partition) <= 0){
result = 0;
}
#endif
if (stbtt_PackBegin(&spc, (u8*)block, tex_width, tex_height, tex_width, 1, partition)){ if (stbtt_PackBegin(&spc, (u8*)block, tex_width, tex_height, tex_width, 1, partition)){
stbtt_PackSetOversampling(&spc, oversample, oversample); stbtt_PackSetOversampling(&spc, oversample, oversample);
if (stbtt_PackFontRange(&spc, (u8*)file.data, 0, if (stbtt_PackFontRange(&spc, (u8*)file.data, 0,
@ -457,8 +461,6 @@ Font_Load_Sig(draw_font_load){
system_free_memory(file.data); system_free_memory(file.data);
} }
end_temp_memory(temp);
return result; return result;
} }

View File

@ -107,7 +107,6 @@ struct Render_Piece_Combined{
typedef Draw_Push_Piece_Sig(Draw_Push_Piece); typedef Draw_Push_Piece_Sig(Draw_Push_Piece);
#define Font_Load_Sig(name) i32 name( \ #define Font_Load_Sig(name) i32 name( \
Partition *partition, \
Render_Font *font_out, \ Render_Font *font_out, \
char *filename, \ char *filename, \
i32 pt_size, \ i32 pt_size, \

View File

@ -20,15 +20,18 @@ draw_pop_clip(Render_Target *target){
} }
internal void internal void
begin_render_section(Render_Target *target){ begin_render_section(Render_Target *target, System_Functions *system){
Font_Set *font_set = &target->font_set; Font_Set *font_set = &target->font_set;
font_set->used_this_frame = 0; font_set->used_this_frame = 0;
memset(font_set->font_used_flags, 0, font_set->max); memset(font_set->font_used_flags, 0, font_set->max);
target->size = 0;
system->acquire_lock(RENDER_LOCK);
} }
internal void internal void
end_render_section(Render_Target *target){ end_render_section(Render_Target *target, System_Functions *system){
//Font_Set *font_set = &target->font_set; //Font_Set *font_set = &target->font_set;
system->release_lock(RENDER_LOCK);
} }
internal void internal void

View File

@ -61,6 +61,9 @@ struct Thread_Context;
enum Lock_ID{ enum Lock_ID{
FRAME_LOCK, FRAME_LOCK,
INPUT_LOCK,
FONT_LOCK,
RENDER_LOCK,
CANCEL_LOCK0, CANCEL_LOCK0,
CANCEL_LOCK1, CANCEL_LOCK1,
CANCEL_LOCK2, CANCEL_LOCK2,

BIN
vc120.pdb

Binary file not shown.

File diff suppressed because it is too large Load Diff