file bar is GUI/scroll rule/etc
parent
d2c21a934a
commit
2ca78a6bf8
|
@ -407,6 +407,66 @@ CUSTOM_COMMAND_SIG(reverse_search){
|
|||
isearch(app, 1);
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(rewrite_as_single_caps){
|
||||
File_View_Summary view;
|
||||
Buffer_Summary buffer;
|
||||
Range range;
|
||||
String string;
|
||||
int is_first, i;
|
||||
|
||||
exec_command(app, cmdid_seek_token_left);
|
||||
view = app->get_active_file_view(app);
|
||||
range.min = view.cursor.pos;
|
||||
|
||||
exec_command(app, cmdid_seek_token_right);
|
||||
app->refresh_file_view(app, &view);
|
||||
range.max = view.cursor.pos;
|
||||
|
||||
string.str = (char*)app->memory;
|
||||
string.size = range.max - range.min;
|
||||
assert(string.size < app->memory_size);
|
||||
|
||||
buffer = app->get_buffer(app, view.buffer_id);
|
||||
app->buffer_read_range(app, &buffer, range.min, range.max, string.str);
|
||||
|
||||
is_first = 1;
|
||||
for (i = 0; i < string.size; ++i){
|
||||
if (char_is_alpha_true(string.str[i])){
|
||||
if (is_first) is_first = 0;
|
||||
else string.str[i] = char_to_lower(string.str[i]);
|
||||
}
|
||||
else{
|
||||
is_first = 1;
|
||||
}
|
||||
}
|
||||
|
||||
app->buffer_replace_range(app, &buffer, range.min, range.max, string.str, string.size);
|
||||
}
|
||||
|
||||
// TODO(allen):
|
||||
// get range by specific "word" type (for example "get token range")
|
||||
// read range by specific "word" type
|
||||
// Dream API: for rewrite_as_single_caps
|
||||
#if 0
|
||||
{
|
||||
rewrite = get_rewrite(app, ByToken);
|
||||
string = get_rewrite_string(app, &rewrite, app->memory, app->memory_size);
|
||||
|
||||
is_first = 1;
|
||||
for (i = 0; i < string.size; ++i){
|
||||
if (char_is_alpha_true(string.str[i])){
|
||||
if (is_first) is_first = 0;
|
||||
else string.str[i] = char_to_lower(string.str[i]);
|
||||
}
|
||||
else{
|
||||
is_first = 1;
|
||||
}
|
||||
}
|
||||
|
||||
do_rewrite(app, &rewrite, string);
|
||||
}
|
||||
#endif
|
||||
|
||||
CUSTOM_COMMAND_SIG(replace_in_range){
|
||||
Query_Bar replace;
|
||||
char replace_space[1024];
|
||||
|
@ -701,6 +761,61 @@ CUSTOM_COMMAND_SIG(write_and_auto_tab){
|
|||
exec_command(app, cmdid_auto_tab_line_at_cursor);
|
||||
}
|
||||
|
||||
struct Scroll_Velocity{
|
||||
float x, y;
|
||||
};
|
||||
|
||||
Scroll_Velocity scroll_velocity[16] = {0};
|
||||
|
||||
static int
|
||||
smooth_camera_step(float target, float *current, float *vel, float S, float T){
|
||||
int result = 0;
|
||||
float curr = *current;
|
||||
float v = *vel;
|
||||
if (curr != target){
|
||||
if (curr > target - .1f && curr < target + .1f){
|
||||
curr = target;
|
||||
v = 1.f;
|
||||
}
|
||||
else{
|
||||
float L = curr + T*(target - curr);
|
||||
|
||||
int sign = (target > curr) - (target < curr);
|
||||
float V = curr + sign*v;
|
||||
|
||||
if (sign > 0) curr = (L<V)?(L):(V);
|
||||
else curr = (L>V)?(L):(V);
|
||||
|
||||
if (curr == V){
|
||||
v *= S;
|
||||
}
|
||||
}
|
||||
|
||||
*current = curr;
|
||||
*vel = v;
|
||||
result = 1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
extern "C" SCROLL_RULE_SIG(scroll_rule){
|
||||
Scroll_Velocity *velocity = scroll_velocity + view_id;
|
||||
int result = 0;
|
||||
if (velocity->x == 0.f){
|
||||
velocity->x = 1.f;
|
||||
velocity->y = 1.f;
|
||||
}
|
||||
|
||||
if (smooth_camera_step(target_y, scroll_y, &velocity->y, 40.f, 1.f/4.f)){
|
||||
result = 1;
|
||||
}
|
||||
if (smooth_camera_step(target_x, scroll_x, &velocity->x, 40.f, 1.f/4.f)){
|
||||
result = 1;
|
||||
}
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
extern "C" GET_BINDING_DATA(get_bindings){
|
||||
Bind_Helper context_actual = begin_bind_helper(data, size);
|
||||
Bind_Helper *context = &context_actual;
|
||||
|
@ -830,14 +945,13 @@ extern "C" GET_BINDING_DATA(get_bindings){
|
|||
bind(context, 'g', MDFR_CTRL, goto_line);
|
||||
bind(context, 'q', MDFR_CTRL, query_replace);
|
||||
bind(context, 'a', MDFR_CTRL, replace_in_range);
|
||||
bind(context, 's', MDFR_ALT, rewrite_as_single_caps);
|
||||
|
||||
bind(context, 'K', MDFR_CTRL, cmdid_kill_buffer);
|
||||
bind(context, 'O', MDFR_CTRL, cmdid_reopen);
|
||||
bind(context, 'w', MDFR_CTRL, cmdid_interactive_save_as);
|
||||
bind(context, 's', MDFR_CTRL, cmdid_save);
|
||||
|
||||
bind(context, ',', MDFR_ALT, switch_to_compilation);
|
||||
|
||||
bind(context, '\n', MDFR_SHIFT, write_and_auto_tab);
|
||||
bind(context, ' ', MDFR_SHIFT, cmdid_write_character);
|
||||
|
||||
|
|
|
@ -157,11 +157,13 @@ struct Query_Bar{
|
|||
#define GET_BINDING_DATA(name) int name(void *data, int size)
|
||||
#define CUSTOM_COMMAND_SIG(name) void name(struct Application_Links *app)
|
||||
#define HOOK_SIG(name) void name(struct Application_Links *app)
|
||||
#define SCROLL_RULE_SIG(name) int name(float target_x, float target_y, float *scroll_x, float *scroll_y, int view_id, int is_new_target)
|
||||
|
||||
extern "C"{
|
||||
typedef CUSTOM_COMMAND_SIG(Custom_Command_Function);
|
||||
typedef GET_BINDING_DATA(Get_Binding_Data_Function);
|
||||
typedef HOOK_SIG(Hook_Function);
|
||||
typedef SCROLL_RULE_SIG(Scroll_Rule_Function);
|
||||
}
|
||||
|
||||
struct Application_Links;
|
||||
|
@ -190,6 +192,7 @@ struct Application_Links;
|
|||
#define BUFFER_SEEK_STRING_SIG(name) int name(Application_Links *context, Buffer_Summary *buffer, int start, char *str, int len, int seek_forward, int *out)
|
||||
#define BUFFER_READ_RANGE_SIG(name) int name(Application_Links *context, Buffer_Summary *buffer, int start, int end, char *out)
|
||||
#define BUFFER_REPLACE_RANGE_SIG(name) int name(Application_Links *context, Buffer_Summary *buffer, int start, int end, char *str, int len)
|
||||
#define BUFFER_SET_POS_SIG(name) int name(Application_Links *context, Buffer_Summary *buffer, int pos)
|
||||
|
||||
// File view manipulation
|
||||
#define GET_VIEW_MAX_INDEX_SIG(name) int name(Application_Links *context)
|
||||
|
@ -245,6 +248,7 @@ extern "C"{
|
|||
typedef BUFFER_SEEK_STRING_SIG(Buffer_Seek_String_Function);
|
||||
typedef BUFFER_READ_RANGE_SIG(Buffer_Read_Range_Function);
|
||||
typedef BUFFER_REPLACE_RANGE_SIG(Buffer_Replace_Range_Function);
|
||||
typedef BUFFER_SET_POS_SIG(Buffer_Set_Pos_Function);
|
||||
|
||||
// View manipulation
|
||||
typedef GET_VIEW_MAX_INDEX_SIG(Get_View_Max_Index_Function);
|
||||
|
@ -294,6 +298,7 @@ struct Application_Links{
|
|||
Buffer_Seek_String_Function *buffer_seek_string;
|
||||
Buffer_Read_Range_Function *buffer_read_range;
|
||||
Buffer_Replace_Range_Function *buffer_replace_range;
|
||||
Buffer_Set_Pos_Function *buffer_set_pos;
|
||||
|
||||
// View manipulation
|
||||
Get_View_Max_Index_Function *get_view_max_index;
|
||||
|
@ -319,6 +324,7 @@ struct Application_Links{
|
|||
|
||||
struct Custom_API{
|
||||
Get_Binding_Data_Function *get_bindings;
|
||||
Scroll_Rule_Function *scroll_rule;
|
||||
};
|
||||
|
||||
// NOTE(allen): definitions for the buffer that communicates to 4ed.exe
|
||||
|
|
125
4ed.cpp
125
4ed.cpp
|
@ -62,6 +62,7 @@ struct Command_Data{
|
|||
Editing_Layout *layout;
|
||||
Live_Views *live_set;
|
||||
Style *style;
|
||||
Style_Font *global_font;
|
||||
Delay *delay;
|
||||
struct App_Vars *vars;
|
||||
Exchange *exchange;
|
||||
|
@ -100,6 +101,7 @@ struct App_Vars{
|
|||
|
||||
Font_Set *font_set;
|
||||
|
||||
Style_Font global_font;
|
||||
Style style;
|
||||
Style_Library styles;
|
||||
u32 *palette;
|
||||
|
@ -181,6 +183,7 @@ globalvar Application_Links app_links;
|
|||
#define USE_LAYOUT(n) Editing_Layout *n = command->layout
|
||||
#define USE_LIVE_SET(n) Live_Views *live_set = command->live_set
|
||||
#define USE_STYLE(n) Style *n = command->style
|
||||
#define USE_FONT(n) Style_Font *n = command->global_font
|
||||
#define USE_DELAY(n) Delay *n = command->delay
|
||||
#define USE_VARS(n) App_Vars *n = command->vars
|
||||
#define USE_EXCHANGE(n) Exchange *n = command->exchange
|
||||
|
@ -241,7 +244,7 @@ param_stack_end(Partition *part){
|
|||
|
||||
internal File_View*
|
||||
panel_make_empty(System_Functions *system, Exchange *exchange,
|
||||
App_Vars *vars, Style *style, Panel *panel){
|
||||
App_Vars *vars, Style *style, Style_Font *global_font, Panel *panel){
|
||||
|
||||
Mem_Options *mem = &vars->mem;
|
||||
Editing_Layout *layout = &vars->layout;
|
||||
|
@ -252,13 +255,13 @@ panel_make_empty(System_Functions *system, Exchange *exchange,
|
|||
View_And_ID new_view;
|
||||
|
||||
Assert(panel->view == 0);
|
||||
new_view = live_set_alloc_view(&vars->live_set, mem);
|
||||
new_view = live_set_alloc_view(&vars->live_set, vars->config_api.scroll_rule);
|
||||
panel->view = new_view.view;
|
||||
panel->view->panel = panel;
|
||||
|
||||
file_view = file_view_init(panel->view, layout, working_set, delay,
|
||||
&vars->settings, &vars->hot_directory, mem, &vars->styles);
|
||||
view_set_file(file_view, 0, vars->font_set, style, 0, 0, 0);
|
||||
view_set_file(file_view, 0, vars->font_set, style, global_font, 0, 0, 0);
|
||||
panel->view->map = app_get_map(vars, mapid_global);
|
||||
|
||||
return(file_view);
|
||||
|
@ -284,7 +287,6 @@ COMMAND_DECL(write_character){
|
|||
next_cursor_pos = view->cursor.pos + 1;
|
||||
view_replace_range(system, mem, view, layout, pos, pos, &character, 1, next_cursor_pos);
|
||||
view_cursor_move(view, next_cursor_pos);
|
||||
file->state.cursor_pos = view->cursor.pos;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -948,6 +950,7 @@ view_file_in_panel(Command_Data *cmd, Panel *panel, Editing_File *file){
|
|||
Editing_Layout *layout = cmd->layout;
|
||||
App_Vars *vars = cmd->vars;
|
||||
Style *style = cmd->style;
|
||||
Style_Font *global_font = cmd->global_font;
|
||||
Working_Set *working_set = &vars->working_set;
|
||||
Delay *delay = &vars->delay1;
|
||||
|
||||
|
@ -966,7 +969,7 @@ view_file_in_panel(Command_Data *cmd, Panel *panel, Editing_File *file){
|
|||
temp = begin_temp_memory(&mem->part);
|
||||
cmd->part = partition_sub_part(&mem->part, Kbytes(16));
|
||||
|
||||
view_set_file(file_view, file, vars->font_set, style,
|
||||
view_set_file(file_view, file, vars->font_set, style, global_font,
|
||||
system, vars->hooks[hook_open_file], &app_links);
|
||||
|
||||
cmd->part = old_part;
|
||||
|
@ -988,6 +991,7 @@ COMMAND_DECL(reopen){
|
|||
USE_WORKING_SET(working_set);
|
||||
USE_VARS(vars);
|
||||
USE_STYLE(style);
|
||||
USE_FONT(global_font);
|
||||
|
||||
i32 file_id = exchange_request_file(exchange, expand_str(file->name.source_path));
|
||||
i32 index = 0;
|
||||
|
@ -996,7 +1000,7 @@ COMMAND_DECL(reopen){
|
|||
index = working_set_get_index(working_set, file);
|
||||
app_push_file_binding(vars, file_id, index);
|
||||
|
||||
view_set_file(view, file, vars->font_set, style,
|
||||
view_set_file(view, file, vars->font_set, style, global_font,
|
||||
system, vars->hooks[hook_open_file], &app_links);
|
||||
}
|
||||
else{
|
||||
|
@ -1310,6 +1314,7 @@ COMMAND_DECL(open_panel_vsplit){
|
|||
USE_EXCHANGE(exchange);
|
||||
USE_VARS(vars);
|
||||
USE_STYLE(style);
|
||||
USE_FONT(global_font);
|
||||
|
||||
if (layout->panel_count < layout->panel_max_count){
|
||||
Split_Result split = layout_split_panel(layout, panel, 1);
|
||||
|
@ -1328,7 +1333,7 @@ COMMAND_DECL(open_panel_vsplit){
|
|||
panel2->prev_inner = panel2->inner;
|
||||
|
||||
layout->active_panel = (i32)(panel2 - layout->panels);
|
||||
panel_make_empty(system, exchange, vars, style, panel2);
|
||||
panel_make_empty(system, exchange, vars, style, global_font, panel2);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1339,6 +1344,7 @@ COMMAND_DECL(open_panel_hsplit){
|
|||
USE_EXCHANGE(exchange);
|
||||
USE_VARS(vars);
|
||||
USE_STYLE(style);
|
||||
USE_FONT(global_font);
|
||||
|
||||
if (layout->panel_count < layout->panel_max_count){
|
||||
Split_Result split = layout_split_panel(layout, panel, 0);
|
||||
|
@ -1357,7 +1363,7 @@ COMMAND_DECL(open_panel_hsplit){
|
|||
panel2->prev_inner = panel2->inner;
|
||||
|
||||
layout->active_panel = (i32)(panel2 - layout->panels);
|
||||
panel_make_empty(system, exchange, vars, style, panel2);
|
||||
panel_make_empty(system, exchange, vars, style, global_font, panel2);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1513,8 +1519,9 @@ COMMAND_DECL(move_up){
|
|||
REQ_FILE_VIEW(view);
|
||||
REQ_FILE(file, view);
|
||||
USE_FONT_SET(font_set);
|
||||
USE_FONT(global_font);
|
||||
|
||||
f32 font_height = (f32)get_font_info(font_set, view->style->font_id)->height;
|
||||
f32 font_height = (f32)get_font_info(font_set, global_font->font_id)->height;
|
||||
f32 cy = view_get_cursor_y(view)-font_height;
|
||||
f32 px = view->preferred_x;
|
||||
if (cy >= 0){
|
||||
|
@ -1528,8 +1535,9 @@ COMMAND_DECL(move_down){
|
|||
REQ_FILE_VIEW(view);
|
||||
REQ_FILE(file, view);
|
||||
USE_FONT_SET(font_set);
|
||||
USE_FONT(global_font);
|
||||
|
||||
f32 font_height = (f32)get_font_info(font_set, view->style->font_id)->height;
|
||||
f32 font_height = (f32)get_font_info(font_set, global_font->font_id)->height;
|
||||
f32 cy = view_get_cursor_y(view)+font_height;
|
||||
f32 px = view->preferred_x;
|
||||
view->cursor = view_compute_cursor_from_xy(view, px, cy);
|
||||
|
@ -1710,7 +1718,7 @@ COMMAND_DECL(set_settings){
|
|||
internal void
|
||||
build(System_Functions *system, Mem_Options *mem,
|
||||
App_Vars *vars, Working_Set *working_set,
|
||||
Font_Set *font_set, Style *style,
|
||||
Font_Set *font_set, Style *style, Style_Font *global_font,
|
||||
Live_Views *live_set, Exchange *exchange,
|
||||
Panel *panel, Command_Data *command,
|
||||
String hot_directory,
|
||||
|
@ -1759,7 +1767,7 @@ build(System_Functions *system, Mem_Options *mem,
|
|||
}
|
||||
|
||||
if (file){
|
||||
file_create_super_locked(system, mem, working_set, file, buffer_name, font_set, style->font_id);
|
||||
file_create_super_locked(system, mem, working_set, file, buffer_name, font_set, global_font->font_id);
|
||||
file->settings.unimportant = 1;
|
||||
table_add(&working_set->table, file->name.source_path, index);
|
||||
|
||||
|
@ -1793,6 +1801,7 @@ COMMAND_DECL(command_line){
|
|||
USE_PANEL(panel);
|
||||
USE_EXCHANGE(exchange);
|
||||
USE_FONT_SET(font_set);
|
||||
USE_FONT(global_font);
|
||||
|
||||
char *buffer_name = 0;
|
||||
char *path = 0;
|
||||
|
@ -1857,7 +1866,7 @@ COMMAND_DECL(command_line){
|
|||
}
|
||||
|
||||
build(system, mem, vars, working_set,
|
||||
font_set, style, live_set, exchange,
|
||||
font_set, style, global_font, live_set, exchange,
|
||||
panel, command,
|
||||
vars->hot_directory.string,
|
||||
buffer_name, buffer_name_len,
|
||||
|
@ -2160,8 +2169,8 @@ extern "C"{
|
|||
|
||||
pos = file->state.cursor_pos;
|
||||
if (pos < start) next_cursor = pos;
|
||||
else if (pos < end) next_cursor = start + len;
|
||||
else next_cursor = pos + end - start + len;
|
||||
else if (pos < end) next_cursor = start;
|
||||
else next_cursor = pos + end - start - len;
|
||||
|
||||
file_replace_range(system, mem, file, layout,
|
||||
start, end, str, len, next_cursor);
|
||||
|
@ -2173,6 +2182,30 @@ extern "C"{
|
|||
return(result);
|
||||
}
|
||||
|
||||
BUFFER_SET_POS_SIG(external_buffer_set_pos){
|
||||
Command_Data *cmd = (Command_Data*)context->cmd_context;
|
||||
Editing_File *file;
|
||||
Working_Set *working_set;
|
||||
|
||||
int result = 0;
|
||||
int size;
|
||||
|
||||
if (buffer->exists){
|
||||
working_set = cmd->working_set;
|
||||
file = working_set->files + buffer->buffer_id;
|
||||
if (!file->state.is_dummy && file_is_ready(file)){
|
||||
result = 1;
|
||||
size = buffer_size(&file->state.buffer);
|
||||
if (pos < 0) pos = 0;
|
||||
if (pos > size) pos = size;
|
||||
file->state.cursor_pos = pos;
|
||||
fill_buffer_summary(buffer, file, working_set);
|
||||
}
|
||||
}
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
GET_VIEW_MAX_INDEX_SIG(external_get_view_max_index){
|
||||
Command_Data *cmd = (Command_Data*)context->cmd_context;
|
||||
Live_Views *live_set = cmd->live_set;
|
||||
|
@ -2316,7 +2349,7 @@ extern "C"{
|
|||
if (buffer_id >= 0 && buffer_id < max){
|
||||
file = working_set->files + buffer_id;
|
||||
if (!file->state.is_dummy){
|
||||
view_set_file(file_view, file, cmd->vars->font_set, cmd->style,
|
||||
view_set_file(file_view, file, cmd->vars->font_set, cmd->style, cmd->global_font,
|
||||
cmd->system, cmd->vars->hooks[hook_open_file], &app_links);
|
||||
}
|
||||
}
|
||||
|
@ -2549,10 +2582,11 @@ app_hardcode_styles(App_Vars *vars){
|
|||
style = styles;
|
||||
|
||||
i16 fonts = 1;
|
||||
vars->global_font.font_id = fonts + 0;
|
||||
vars->global_font.font_changed = 0;
|
||||
|
||||
/////////////////
|
||||
style_set_name(style, make_lit_string("4coder"));
|
||||
style->font_id = fonts + 0;
|
||||
|
||||
style->main.back_color = 0xFF0C0C0C;
|
||||
style->main.margin_color = 0xFF181818;
|
||||
|
@ -2587,18 +2621,10 @@ app_hardcode_styles(App_Vars *vars){
|
|||
file_info_style.pop1_color = 0xFF4444AA;
|
||||
file_info_style.pop2_color = 0xFFFF0000;
|
||||
style->main.file_info_style = file_info_style;
|
||||
style->font_changed = 1;
|
||||
++style;
|
||||
|
||||
/////////////////
|
||||
*style = *(style-1);
|
||||
style_set_name(style, make_lit_string("4coder-mono"));
|
||||
style->font_id = fonts + 1;
|
||||
++style;
|
||||
|
||||
/////////////////
|
||||
style_set_name(style, make_lit_string("Handmade Hero"));
|
||||
style->font_id = fonts + 1;
|
||||
|
||||
style->main.back_color = 0xFF161616;
|
||||
style->main.margin_color = 0xFF262626;
|
||||
|
@ -2634,12 +2660,10 @@ app_hardcode_styles(App_Vars *vars){
|
|||
file_info_style.pop1_color = 0xFF03CF0C;
|
||||
file_info_style.pop2_color = 0xFFFF0000;
|
||||
style->main.file_info_style = file_info_style;
|
||||
style->font_changed = 1;
|
||||
++style;
|
||||
|
||||
/////////////////
|
||||
style_set_name(style, make_lit_string("Twilight"));
|
||||
style->font_id = fonts + 2;
|
||||
|
||||
style->main.back_color = 0xFF090D12;
|
||||
style->main.margin_color = 0xFF1A2634;
|
||||
|
@ -2674,12 +2698,10 @@ app_hardcode_styles(App_Vars *vars){
|
|||
file_info_style.pop1_color = 0xFF1BFF0C;
|
||||
file_info_style.pop2_color = 0xFFFF200D;
|
||||
style->main.file_info_style = file_info_style;
|
||||
style->font_changed = 1;
|
||||
++style;
|
||||
|
||||
/////////////////
|
||||
style_set_name(style, make_lit_string("Wolverine"));
|
||||
style->font_id = fonts + 3;
|
||||
|
||||
style->main.back_color = 0xFF070711;
|
||||
style->main.margin_color = 0xFF111168;
|
||||
|
@ -2714,12 +2736,10 @@ app_hardcode_styles(App_Vars *vars){
|
|||
file_info_style.pop1_color = 0xFFFAFA15;
|
||||
file_info_style.pop2_color = 0xFFD20000;
|
||||
style->main.file_info_style = file_info_style;
|
||||
style->font_changed = 1;
|
||||
++style;
|
||||
|
||||
/////////////////
|
||||
style_set_name(style, make_lit_string("stb"));
|
||||
style->font_id = fonts + 4;
|
||||
|
||||
style->main.back_color = 0xFFD6D6D6;
|
||||
style->main.margin_color = 0xFF9E9E9E;
|
||||
|
@ -2731,7 +2751,7 @@ app_hardcode_styles(App_Vars *vars){
|
|||
style->main.highlight_color = 0xFF0044FF;
|
||||
style->main.at_highlight_color = 0xFFD6D6D6;
|
||||
style->main.default_color = 0xFF000000;
|
||||
style->main.comment_color = 0xFF000000;
|
||||
style->main.comment_color = 0xFF005800;
|
||||
style->main.keyword_color = 0xFF000000;
|
||||
style->main.str_constant_color = 0xFF000000;
|
||||
style->main.char_constant_color = style->main.str_constant_color;
|
||||
|
@ -2754,13 +2774,11 @@ app_hardcode_styles(App_Vars *vars){
|
|||
file_info_style.pop1_color = 0xFF1111DC;
|
||||
file_info_style.pop2_color = 0xFFE80505;
|
||||
style->main.file_info_style = file_info_style;
|
||||
style->font_changed = 1;
|
||||
++style;
|
||||
|
||||
vars->styles.count = (i32)(style - styles);
|
||||
vars->styles.max = ArrayCount(vars->styles.styles);
|
||||
style_copy(&vars->style, vars->styles.styles);
|
||||
vars->style.font_changed = 0;
|
||||
}
|
||||
|
||||
char *_4coder_get_extension(const char *filename, int len, int *extension_len){
|
||||
|
@ -2944,6 +2962,21 @@ App_Read_Command_Line_Sig(app_read_command_line){
|
|||
return(out_size);
|
||||
}
|
||||
|
||||
extern "C" SCROLL_RULE_SIG(fallback_scroll_rule){
|
||||
int result = 0;
|
||||
|
||||
if (target_x != *scroll_x){
|
||||
*scroll_x = target_x;
|
||||
result = 1;
|
||||
}
|
||||
if (target_y != *scroll_y){
|
||||
*scroll_y = target_y;
|
||||
result = 1;
|
||||
}
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
App_Init_Sig(app_init){
|
||||
app_links_init(system, memory->user_memory, memory->user_memory_size);
|
||||
|
||||
|
@ -3011,6 +3044,10 @@ App_Init_Sig(app_init){
|
|||
}
|
||||
}
|
||||
|
||||
if (vars->config_api.scroll_rule == 0){
|
||||
vars->config_api.scroll_rule = fallback_scroll_rule;
|
||||
}
|
||||
|
||||
setup_command_table();
|
||||
|
||||
Command_Map *global = &vars->map_top;
|
||||
|
@ -3225,7 +3262,7 @@ App_Init_Sig(app_init){
|
|||
|
||||
// NOTE(allen): init first panel
|
||||
Panel_And_ID p = layout_alloc_panel(&vars->layout);
|
||||
panel_make_empty(system, exchange, vars, &vars->style, p.panel);
|
||||
panel_make_empty(system, exchange, vars, &vars->style, &vars->global_font, p.panel);
|
||||
vars->layout.active_panel = p.id;
|
||||
|
||||
String hdbase = make_fixed_width_string(vars->hot_dir_base_);
|
||||
|
@ -3508,6 +3545,7 @@ App_Step_Sig(app_step){
|
|||
cmd->layout = &vars->layout;
|
||||
cmd->live_set = &vars->live_set;
|
||||
cmd->style = &vars->style;
|
||||
cmd->global_font = &vars->global_font;
|
||||
cmd->delay = &vars->delay1;
|
||||
cmd->vars = vars;
|
||||
cmd->exchange = exchange;
|
||||
|
@ -3941,7 +3979,7 @@ App_Step_Sig(app_step){
|
|||
if (data){
|
||||
String val = make_string((char*)data, size);
|
||||
file_create_from_string(system, mem, working_set, ed_file, filename,
|
||||
vars->font_set, vars->style.font_id, val);
|
||||
vars->font_set, vars->global_font.font_id, val);
|
||||
|
||||
if (ed_file->settings.tokens_exist){
|
||||
file_first_lex_parallel(system, general, ed_file);
|
||||
|
@ -3956,7 +3994,7 @@ App_Step_Sig(app_step){
|
|||
else{
|
||||
if (binding->fail & SysAppCreateNewBuffer){
|
||||
file_create_empty(system, mem, working_set, ed_file, filename,
|
||||
vars->font_set, vars->style.font_id);
|
||||
vars->font_set, vars->global_font.font_id);
|
||||
if (binding->fail & SysAppCreateView){
|
||||
view_file_in_panel(cmd, binding->panel, ed_file);
|
||||
}
|
||||
|
@ -4013,6 +4051,7 @@ App_Step_Sig(app_step){
|
|||
ProfileStart(delayed_actions);
|
||||
if (vars->delay1.count > 0){
|
||||
Style *style = &vars->style;
|
||||
Style_Font *global_font = &vars->global_font;
|
||||
Working_Set *working_set = &vars->working_set;
|
||||
Live_Views *live_set = &vars->live_set;
|
||||
Mem_Options *mem = &vars->mem;
|
||||
|
@ -4156,13 +4195,13 @@ App_Step_Sig(app_step){
|
|||
{
|
||||
Get_File_Result file = working_set_get_available_file(working_set);
|
||||
file_create_empty(system, mem, working_set, file.file, string.str,
|
||||
vars->font_set, style->font_id);
|
||||
vars->font_set, global_font->font_id);
|
||||
table_add(&working_set->table, file.file->name.source_path, file.index);
|
||||
|
||||
View *view = panel->view;
|
||||
File_View *fview = view_to_file_view(view);
|
||||
|
||||
view_set_file(fview, file.file, vars->font_set, style,
|
||||
view_set_file(fview, file.file, vars->font_set, style, global_font,
|
||||
system, vars->hooks[hook_open_file], &app_links);
|
||||
view->map = app_get_map(vars, file.file->settings.base_map_id);
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 0
|
||||
|
@ -4178,7 +4217,7 @@ App_Step_Sig(app_step){
|
|||
View *view = panel->view;
|
||||
File_View *fview = view_to_file_view(view);
|
||||
|
||||
view_set_file(fview, file, vars->font_set, style,
|
||||
view_set_file(fview, file, vars->font_set, style, global_font,
|
||||
system, vars->hooks[hook_open_file], &app_links);
|
||||
view->map = app_get_map(vars, file->settings.base_map_id);
|
||||
}
|
||||
|
@ -4259,13 +4298,13 @@ App_Step_Sig(app_step){
|
|||
|
||||
ProfileStart(style_change);
|
||||
// NOTE(allen): send style change messages if the style has changed
|
||||
if (vars->style.font_changed){
|
||||
vars->style.font_changed = 0;
|
||||
if (vars->global_font.font_changed){
|
||||
vars->global_font.font_changed = 0;
|
||||
|
||||
Editing_File *file = vars->working_set.files;
|
||||
for (i32 i = vars->working_set.file_index_count; i > 0; --i, ++file){
|
||||
if (buffer_good(&file->state.buffer) && !file->state.is_dummy){
|
||||
Render_Font *font = get_font_info(vars->font_set, vars->style.font_id)->font;
|
||||
Render_Font *font = get_font_info(vars->font_set, vars->global_font.font_id)->font;
|
||||
float *advance_data = 0;
|
||||
if (font) advance_data = font->advance_data;
|
||||
|
||||
|
|
|
@ -40,10 +40,10 @@
|
|||
#include "4ed_font_set.cpp"
|
||||
#include "4ed_rendering_helper.cpp"
|
||||
#include "4ed_command.cpp"
|
||||
#include "4ed_layout.cpp"
|
||||
#include "4ed_style.cpp"
|
||||
#include "4ed_file.cpp"
|
||||
#include "4ed_gui.cpp"
|
||||
#include "4ed_layout.cpp"
|
||||
#include "4ed_delay.cpp"
|
||||
#include "4ed_app_settings.h"
|
||||
#include "4ed_file_view.cpp"
|
||||
|
|
|
@ -76,6 +76,7 @@ struct File_View{
|
|||
|
||||
Editing_Layout *layout;
|
||||
|
||||
Style_Font *global_font;
|
||||
Style *style;
|
||||
Working_Set *working_set;
|
||||
Delay *delay;
|
||||
|
@ -115,8 +116,8 @@ struct File_View{
|
|||
|
||||
Full_Cursor cursor;
|
||||
i32 mark;
|
||||
f32 scroll_y, target_y, vel_y;
|
||||
f32 scroll_x, target_x, vel_x;
|
||||
f32 scroll_y, target_y, prev_target_y;
|
||||
f32 scroll_x, target_x, prev_target_x;
|
||||
f32 preferred_x;
|
||||
i32 scroll_i;
|
||||
|
||||
|
@ -433,7 +434,6 @@ view_wrapped_line_span(f32 line_width, f32 max_width){
|
|||
internal i32
|
||||
view_compute_lowest_line(File_View *view){
|
||||
i32 lowest_line = 0;
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 3
|
||||
i32 last_line = view->line_count - 1;
|
||||
if (last_line > 0){
|
||||
if (view->unwrapped_lines){
|
||||
|
@ -451,14 +451,12 @@ view_compute_lowest_line(File_View *view){
|
|||
lowest_line += line_span - 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return lowest_line;
|
||||
}
|
||||
|
||||
internal void
|
||||
view_measure_wraps(System_Functions *system,
|
||||
General_Memory *general, File_View *view){
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 3
|
||||
ProfileMomentFunction();
|
||||
Buffer_Type *buffer;
|
||||
|
||||
|
@ -482,7 +480,6 @@ view_measure_wraps(System_Functions *system,
|
|||
buffer_measure_wrap_y(buffer, view->line_wrap_y, line_height, max_width);
|
||||
|
||||
view->line_count = line_count;
|
||||
#endif
|
||||
}
|
||||
|
||||
internal void*
|
||||
|
@ -505,7 +502,6 @@ file_create_from_string(System_Functions *system, Mem_Options *mem,
|
|||
|
||||
file->state = {};
|
||||
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 3
|
||||
init = buffer_begin_init(&file->state.buffer, val.str, val.size);
|
||||
for (; buffer_init_need_more(&init); ){
|
||||
page_size = buffer_init_page_size(&init);
|
||||
|
@ -520,7 +516,6 @@ file_create_from_string(System_Functions *system, Mem_Options *mem,
|
|||
init_success = buffer_end_init(&init, part->base + part->pos, scratch_size);
|
||||
AllowLocal(init_success);
|
||||
Assert(init_success);
|
||||
#endif
|
||||
|
||||
file_init_strings(file);
|
||||
file_set_name(working_set, file, (char*)filename);
|
||||
|
@ -964,7 +959,6 @@ struct Edit_Spec{
|
|||
Edit_Step step;
|
||||
};
|
||||
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 3
|
||||
internal Edit_Step*
|
||||
file_post_undo(General_Memory *general, Editing_File *file,
|
||||
Edit_Step step, bool32 do_merge, bool32 can_merge){
|
||||
|
@ -1030,7 +1024,6 @@ file_post_undo(General_Memory *general, Editing_File *file,
|
|||
}
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
inline void
|
||||
undo_stack_pop(Edit_Stack *stack){
|
||||
|
@ -1040,7 +1033,6 @@ undo_stack_pop(Edit_Stack *stack){
|
|||
}
|
||||
}
|
||||
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 3
|
||||
internal void
|
||||
file_post_redo(General_Memory *general, Editing_File *file, Edit_Step step){
|
||||
Edit_Stack *redo = &file->state.undo.redo;
|
||||
|
@ -1077,7 +1069,6 @@ file_post_redo(General_Memory *general, Editing_File *file, Edit_Step step){
|
|||
redo->edits[redo->edit_count++] = inv_step;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
inline void
|
||||
file_post_history_block(Editing_File *file, i32 pos){
|
||||
|
@ -1176,8 +1167,7 @@ file_post_history(General_Memory *general, Editing_File *file,
|
|||
inline Full_Cursor
|
||||
view_compute_cursor_from_pos(File_View *view, i32 pos){
|
||||
Editing_File *file = view->file;
|
||||
Style *style = view->style;
|
||||
Render_Font *font = get_font_info(view->font_set, style->font_id)->font;
|
||||
Render_Font *font = get_font_info(view->font_set, view->global_font->font_id)->font;
|
||||
|
||||
Full_Cursor result = {};
|
||||
if (font){
|
||||
|
@ -1189,11 +1179,9 @@ view_compute_cursor_from_pos(File_View *view, i32 pos){
|
|||
}
|
||||
|
||||
inline Full_Cursor
|
||||
view_compute_cursor_from_unwrapped_xy(File_View *view, f32 seek_x, f32 seek_y,
|
||||
b32 round_down = 0){
|
||||
view_compute_cursor_from_unwrapped_xy(File_View *view, f32 seek_x, f32 seek_y, b32 round_down = 0){
|
||||
Editing_File *file = view->file;
|
||||
Style *style = view->style;
|
||||
Render_Font *font = get_font_info(view->font_set, style->font_id)->font;
|
||||
Render_Font *font = get_font_info(view->font_set, view->global_font->font_id)->font;
|
||||
|
||||
Full_Cursor result = {};
|
||||
if (font){
|
||||
|
@ -1210,8 +1198,7 @@ internal Full_Cursor
|
|||
view_compute_cursor_from_wrapped_xy(File_View *view, f32 seek_x, f32 seek_y,
|
||||
b32 round_down = 0){
|
||||
Editing_File *file = view->file;
|
||||
Style *style = view->style;
|
||||
Render_Font *font = get_font_info(view->font_set, style->font_id)->font;
|
||||
Render_Font *font = get_font_info(view->font_set, view->global_font->font_id)->font;
|
||||
|
||||
Full_Cursor result = {};
|
||||
if (font){
|
||||
|
@ -1227,8 +1214,7 @@ view_compute_cursor_from_wrapped_xy(File_View *view, f32 seek_x, f32 seek_y,
|
|||
internal Full_Cursor
|
||||
view_compute_cursor_from_line_pos(File_View *view, i32 line, i32 pos){
|
||||
Editing_File *file = view->file;
|
||||
Style *style = view->style;
|
||||
Render_Font *font = get_font_info(view->font_set, style->font_id)->font;
|
||||
Render_Font *font = get_font_info(view->font_set, view->global_font->font_id)->font;
|
||||
|
||||
Full_Cursor result = {};
|
||||
if (font){
|
||||
|
@ -1332,6 +1318,7 @@ view_set_file(
|
|||
Editing_File *file,
|
||||
Font_Set *set,
|
||||
Style *style,
|
||||
Style_Font *global_font,
|
||||
|
||||
// NOTE(allen): Necessary when file != 0
|
||||
System_Functions *system,
|
||||
|
@ -1348,7 +1335,8 @@ view_set_file(
|
|||
panel = view->view_base.panel;
|
||||
|
||||
// NOTE(allen): This is actually more like view_set_style right?
|
||||
fnt_info = get_font_info(set, style->font_id);
|
||||
fnt_info = get_font_info(set, global_font->font_id);
|
||||
view->global_font = global_font;
|
||||
view->style = style;
|
||||
view->font_advance = fnt_info->advance;
|
||||
view->font_height = fnt_info->height;
|
||||
|
@ -1358,8 +1346,8 @@ view_set_file(
|
|||
view->file = file;
|
||||
|
||||
view->cursor = {};
|
||||
view->vel_y = 1.f;
|
||||
view->vel_x = 1.f;
|
||||
view->prev_target_x = -1000.f;
|
||||
view->prev_target_y = -1000.f;
|
||||
|
||||
target_x = 0;
|
||||
target_y = 0;
|
||||
|
@ -1410,15 +1398,17 @@ view_set_file(
|
|||
}
|
||||
}
|
||||
|
||||
// TODO(allen): Somehow keep track of the scroll limits through this process.
|
||||
// Maybe scroll limits should be stored in the view at each frame.
|
||||
struct Relative_Scrolling{
|
||||
real32 scroll_x, scroll_y;
|
||||
real32 target_x, target_y;
|
||||
f32 scroll_x, scroll_y;
|
||||
f32 target_x, target_y;
|
||||
};
|
||||
|
||||
internal Relative_Scrolling
|
||||
view_get_relative_scrolling(File_View *view){
|
||||
Relative_Scrolling result;
|
||||
real32 cursor_x, cursor_y;
|
||||
f32 cursor_x, cursor_y;
|
||||
cursor_x = view_get_cursor_x(view);
|
||||
cursor_y = view_get_cursor_y(view);
|
||||
result.scroll_x = cursor_x - view->scroll_x;
|
||||
|
@ -1430,13 +1420,11 @@ view_get_relative_scrolling(File_View *view){
|
|||
|
||||
internal void
|
||||
view_set_relative_scrolling(File_View *view, Relative_Scrolling scrolling){
|
||||
real32 cursor_x, cursor_y;
|
||||
f32 cursor_x, cursor_y;
|
||||
cursor_x = view_get_cursor_x(view);
|
||||
cursor_y = view_get_cursor_y(view);
|
||||
view->scroll_y = cursor_y - scrolling.scroll_y;
|
||||
view->target_y = cursor_y - scrolling.target_y;
|
||||
if (view->scroll_y < 0) view->scroll_y = 0;
|
||||
if (view->target_y < 0) view->target_y = 0;
|
||||
}
|
||||
|
||||
inline void
|
||||
|
@ -1731,23 +1719,26 @@ file_edit_cursor_fix(System_Functions *system,
|
|||
Partition *part, General_Memory *general,
|
||||
Editing_File *file, Editing_Layout *layout,
|
||||
Cursor_Fix_Descriptor desc){
|
||||
|
||||
Full_Cursor temp_cursor;
|
||||
File_View *current_view;
|
||||
Temp_Memory cursor_temp = begin_temp_memory(part);
|
||||
i32 cursor_max = layout->panel_max_count * 2;
|
||||
Cursor_With_Index *cursors = push_array(part, Cursor_With_Index, cursor_max);
|
||||
|
||||
f32 y_offset = 0, y_position = 0;
|
||||
i32 cursor_count = 0;
|
||||
i32 panel_count = layout->panel_count;
|
||||
Panel *current_panel = layout->panels;
|
||||
for (i32 i = 0; i < panel_count; ++i, ++current_panel){
|
||||
current_view = view_to_file_view(current_panel->view);
|
||||
if (current_view && current_view->file == file){
|
||||
view_measure_wraps(system, general, current_view);
|
||||
write_cursor_with_index(cursors, &cursor_count, current_view->cursor.pos);
|
||||
write_cursor_with_index(cursors, &cursor_count, current_view->mark - 1);
|
||||
write_cursor_with_index(cursors, &cursor_count, current_view->scroll_i - 1);
|
||||
|
||||
File_View *view;
|
||||
Panel *panel, *used_panels;
|
||||
used_panels = &layout->used_sentinel;
|
||||
|
||||
for (dll_items(panel, used_panels)){
|
||||
view = view_to_file_view(panel->view);
|
||||
if (view->file == file){
|
||||
view_measure_wraps(system, general, view);
|
||||
write_cursor_with_index(cursors, &cursor_count, view->cursor.pos);
|
||||
write_cursor_with_index(cursors, &cursor_count, view->mark - 1);
|
||||
write_cursor_with_index(cursors, &cursor_count, view->scroll_i - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1761,32 +1752,30 @@ file_edit_cursor_fix(System_Functions *system,
|
|||
buffer_update_cursors(cursors, cursor_count,
|
||||
desc.start, desc.end,
|
||||
desc.shift_amount + (desc.end - desc.start));
|
||||
|
||||
}
|
||||
buffer_unsort_cursors(cursors, cursor_count);
|
||||
|
||||
cursor_count = 0;
|
||||
current_panel = layout->panels;
|
||||
for (i32 i = 0; i < panel_count; ++i, ++current_panel){
|
||||
current_view = view_to_file_view(current_panel->view);
|
||||
if (current_view && current_view->file == file){
|
||||
view_cursor_move(current_view, cursors[cursor_count++].pos);
|
||||
current_view->preferred_x = view_get_cursor_x(current_view);
|
||||
for (dll_items(panel, used_panels)){
|
||||
view = view_to_file_view(panel->view);
|
||||
if (view && view->file == file){
|
||||
view_cursor_move(view, cursors[cursor_count++].pos);
|
||||
view->preferred_x = view_get_cursor_x(view);
|
||||
|
||||
current_view->mark = cursors[cursor_count++].pos + 1;
|
||||
current_view->scroll_i = cursors[cursor_count++].pos + 1;
|
||||
temp_cursor = view_compute_cursor_from_pos(current_view, current_view->scroll_i);
|
||||
y_offset = MOD(current_view->scroll_y, current_view->font_height);
|
||||
view->mark = cursors[cursor_count++].pos + 1;
|
||||
view->scroll_i = cursors[cursor_count++].pos + 1;
|
||||
temp_cursor = view_compute_cursor_from_pos(view, view->scroll_i);
|
||||
y_offset = MOD(view->scroll_y, view->font_height);
|
||||
|
||||
if (current_view->unwrapped_lines){
|
||||
if (view->unwrapped_lines){
|
||||
y_position = temp_cursor.unwrapped_y + y_offset;
|
||||
current_view->target_y += (y_position - current_view->scroll_y);
|
||||
current_view->scroll_y = y_position;
|
||||
view->target_y += (y_position - view->scroll_y);
|
||||
view->scroll_y = y_position;
|
||||
}
|
||||
else{
|
||||
y_position = temp_cursor.wrapped_y + y_offset;
|
||||
current_view->target_y += (y_position - current_view->scroll_y);
|
||||
current_view->scroll_y = y_position;
|
||||
view->target_y += (y_position - view->scroll_y);
|
||||
view->scroll_y = y_position;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1806,7 +1795,6 @@ file_do_single_edit(System_Functions *system,
|
|||
file_pre_edit_maintenance(system, &mem->general, file);
|
||||
|
||||
// NOTE(allen): actual text replacement
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 3
|
||||
i32 shift_amount = 0;
|
||||
General_Memory *general = &mem->general;
|
||||
Partition *part = &mem->part;
|
||||
|
@ -1843,15 +1831,15 @@ file_do_single_edit(System_Functions *system,
|
|||
buffer_remeasure_starts(buffer, line_start, line_end, line_shift, shift_amount);
|
||||
buffer_remeasure_widths(buffer, font->advance_data, line_start, line_end, line_shift);
|
||||
|
||||
i32 panel_count = layout->panel_count;
|
||||
Panel *current_panel = layout->panels;
|
||||
for (i32 i = 0; i < panel_count; ++i, ++current_panel){
|
||||
File_View *current_view = view_to_file_view(current_panel->view);
|
||||
if (current_view && current_view->file == file){
|
||||
view_measure_wraps(system, general, current_view);
|
||||
Panel *panel, *used_panels;
|
||||
used_panels = &layout->used_sentinel;
|
||||
|
||||
for (dll_items(panel, used_panels)){
|
||||
File_View *view = view_to_file_view(panel->view);
|
||||
if (view->file == file){
|
||||
view_measure_wraps(system, general, view);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 0
|
||||
// NOTE(allen): fixing stuff afterwards
|
||||
|
@ -1859,7 +1847,6 @@ file_do_single_edit(System_Functions *system,
|
|||
file_relex_parallel(system, mem, file, start, end, shift_amount);
|
||||
#endif
|
||||
|
||||
#if BUFFER_EXPERIMENT_SCALPEL <= 3
|
||||
Cursor_Fix_Descriptor desc = {};
|
||||
desc.start = start;
|
||||
desc.end = end;
|
||||
|
@ -1867,8 +1854,6 @@ file_do_single_edit(System_Functions *system,
|
|||
|
||||
file_edit_cursor_fix(system, part, general,
|
||||
file, layout, desc);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
internal void
|
||||
|
@ -1951,9 +1936,7 @@ view_do_white_batch_edit(System_Functions *system, Mem_Options *mem, File_View *
|
|||
desc.batch = batch;
|
||||
desc.batch_size = batch_size;
|
||||
|
||||
file_edit_cursor_fix(system, part, general,
|
||||
file, layout, desc);
|
||||
|
||||
file_edit_cursor_fix(system, part, general, file, layout, desc);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -2619,40 +2602,7 @@ style_get_color(Style *style, Cpp_Token token){
|
|||
return result;
|
||||
}
|
||||
|
||||
internal bool32
|
||||
smooth_camera_step(real32 *target, real32 *current, real32 *vel, real32 S, real32 T){
|
||||
bool32 result = 0;
|
||||
real32 targ = *target;
|
||||
real32 curr = *current;
|
||||
real32 v = *vel;
|
||||
if (curr != targ){
|
||||
if (curr > targ - .1f && curr < targ + .1f){
|
||||
curr = targ;
|
||||
v = 1.f;
|
||||
}
|
||||
else{
|
||||
real32 L = lerp(curr, T, targ);
|
||||
|
||||
i32 sign = (targ > curr) - (targ < curr);
|
||||
real32 V = curr + sign*v;
|
||||
|
||||
if (sign > 0) curr = Min(L, V);
|
||||
else curr = Max(L, V);
|
||||
|
||||
if (curr == V){
|
||||
v *= S;
|
||||
}
|
||||
}
|
||||
|
||||
*target = targ;
|
||||
*current = curr;
|
||||
*vel = v;
|
||||
result = 1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
inline real32
|
||||
inline f32
|
||||
view_compute_max_target_y(i32 lowest_line, i32 line_height, real32 view_height){
|
||||
real32 max_target_y = ((lowest_line+.5f)*line_height) - view_height*.5f;
|
||||
return max_target_y;
|
||||
|
@ -2784,6 +2734,7 @@ view_show_interactive(System_Functions *system, File_View *fview, Command_Map *g
|
|||
fview->finished = 0;
|
||||
|
||||
copy(&fview->query, query);
|
||||
fview->dest.size = 0;
|
||||
|
||||
hot_directory_clean_end(fview->hot_directory);
|
||||
hot_directory_reload(system, fview->hot_directory, fview->working_set);
|
||||
|
@ -3199,6 +3150,7 @@ theme_adjusting_shit(File_View *view, UI_State *state, UI_Layout *layout){
|
|||
ui.layout = layout;
|
||||
|
||||
ui.fonts = view->font_set;
|
||||
ui.global_font = view->global_font;
|
||||
ui.highlight = view->highlight;
|
||||
ui.color = view->color;
|
||||
ui.has_hover_color = 0;
|
||||
|
@ -3462,6 +3414,60 @@ config_shit(File_View *view, UI_State *state, UI_Layout *layout){
|
|||
}
|
||||
}
|
||||
|
||||
internal void
|
||||
do_file_bar(File_View *view, Editing_File *file, UI_Layout *layout, Render_Target *target){
|
||||
Interactive_Bar bar;
|
||||
Style_Font *font = view->global_font;
|
||||
i32 line_height = view->font_height;
|
||||
Interactive_Style bar_style = view->style->main.file_info_style;
|
||||
|
||||
u32 back_color = bar_style.bar_color;
|
||||
u32 base_color = bar_style.base_color;
|
||||
u32 pop2_color = bar_style.pop2_color;
|
||||
|
||||
bar.rect = layout_rect(layout, line_height + 2);
|
||||
|
||||
if (target){
|
||||
bar.font_id = font->font_id;
|
||||
bar.pos_x = (f32)bar.rect.x0;
|
||||
bar.pos_y = (f32)bar.rect.y0;
|
||||
bar.text_shift_y = 2;
|
||||
bar.text_shift_x = 0;
|
||||
|
||||
draw_rectangle(target, bar.rect, back_color);
|
||||
intbar_draw_string(target, &bar, file->name.live_name, base_color);
|
||||
intbar_draw_string(target, &bar, make_lit_string(" - "), base_color);
|
||||
|
||||
if (file->state.is_loading){
|
||||
intbar_draw_string(target, &bar, make_lit_string(" loading"), base_color);
|
||||
}
|
||||
else{
|
||||
char line_number_space[30];
|
||||
String line_number = make_string(line_number_space, 0, 30);
|
||||
append(&line_number, "L#");
|
||||
append_int_to_str(view->cursor.line, &line_number);
|
||||
|
||||
intbar_draw_string(target, &bar, line_number, base_color);
|
||||
|
||||
if (!file->settings.unimportant){
|
||||
switch (buffer_get_sync(file)){
|
||||
case SYNC_BEHIND_OS:
|
||||
{
|
||||
persist String out_of_sync = make_lit_string(" !");
|
||||
intbar_draw_string(target, &bar, out_of_sync, pop2_color);
|
||||
}break;
|
||||
|
||||
case SYNC_UNSAVED:
|
||||
{
|
||||
persist String out_of_sync = make_lit_string(" *");
|
||||
intbar_draw_string(target, &bar, out_of_sync, pop2_color);
|
||||
}break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal i32
|
||||
step_file_view(System_Functions *system, Exchange *exchange, View *view_, i32_Rect rect,
|
||||
b32 is_active, Input_Summary *user_input){
|
||||
|
@ -3472,18 +3478,20 @@ step_file_view(System_Functions *system, Exchange *exchange, View *view_, i32_Re
|
|||
|
||||
i32 widget_height = 0;
|
||||
{
|
||||
i32_Rect widg_rect = view_widget_rect(view, view->font_height);
|
||||
|
||||
UI_State state =
|
||||
ui_state_init(&view->widget.state, 0, user_input,
|
||||
view->style, view->font_set, 0, 1);
|
||||
view->style, view->global_font->font_id, view->font_set, 0, 1);
|
||||
|
||||
UI_Layout layout;
|
||||
begin_layout(&layout, widg_rect);
|
||||
begin_layout(&layout, rect);
|
||||
|
||||
switch (view->widget.type){
|
||||
case FWIDG_NONE:
|
||||
{
|
||||
if (file){
|
||||
do_file_bar(view, file, &layout, 0);
|
||||
}
|
||||
|
||||
draw_file_view_queries(view, &state, &layout);
|
||||
}break;
|
||||
|
||||
|
@ -3498,8 +3506,8 @@ step_file_view(System_Functions *system, Exchange *exchange, View *view_, i32_Re
|
|||
}break;
|
||||
}
|
||||
|
||||
widget_height = layout.y - widg_rect.y0;
|
||||
if (ui_finish_frame(&view->widget.state, &state, &layout, widg_rect, 0, 0)){
|
||||
widget_height = layout.y - rect.y0;
|
||||
if (ui_finish_frame(&view->widget.state, &state, &layout, rect, 0, 0)){
|
||||
result = 1;
|
||||
}
|
||||
}
|
||||
|
@ -3524,7 +3532,7 @@ step_file_view(System_Functions *system, Exchange *exchange, View *view_, i32_Re
|
|||
if (target_y < -taken_top_space) target_y = -taken_top_space;
|
||||
if (target_y > max_target_y) target_y = max_target_y;
|
||||
|
||||
real32 old_cursor_y = cursor_y;
|
||||
f32 old_cursor_y = cursor_y;
|
||||
if (cursor_y >= target_y + max_y) cursor_y = target_y + max_y;
|
||||
if (cursor_y < target_y + taken_top_space) cursor_y = target_y + taken_top_space;
|
||||
|
||||
|
@ -3561,21 +3569,29 @@ step_file_view(System_Functions *system, Exchange *exchange, View *view_, i32_Re
|
|||
|
||||
view->target_x = target_x;
|
||||
|
||||
if (smooth_camera_step(&view->target_y, &view->scroll_y, &view->vel_y, 40.f, 1.f/4.f)){
|
||||
result = 1;
|
||||
}
|
||||
if (smooth_camera_step(&view->target_x, &view->scroll_x, &view->vel_x, 40.f, 1.f/4.f)){
|
||||
b32 is_new_target = 0;
|
||||
if (view->target_x != view->prev_target_x) is_new_target = 1;
|
||||
if (view->target_y != view->prev_target_y) is_new_target = 1;
|
||||
|
||||
if (view_->scroll_rule(
|
||||
view->target_x, view->target_y,
|
||||
&view->scroll_x, &view->scroll_y,
|
||||
view_->id, is_new_target)){
|
||||
result = 1;
|
||||
}
|
||||
|
||||
view->prev_target_x = view->target_x;
|
||||
view->prev_target_y = view->target_y;
|
||||
|
||||
if (file->state.paste_effect.tick_down > 0){
|
||||
--file->state.paste_effect.tick_down;
|
||||
result = 1;
|
||||
}
|
||||
|
||||
if (is_active && user_input->mouse.press_l){
|
||||
if (user_input->mouse.press_l && is_active){
|
||||
f32 max_y = view_compute_height(view);
|
||||
f32 rx = (f32)(user_input->mouse.x - rect.x0);
|
||||
f32 ry = (f32)(user_input->mouse.y - rect.y0 - line_height - 2);
|
||||
f32 ry = (f32)(user_input->mouse.y - rect.y0);
|
||||
|
||||
if (ry >= extra_top){
|
||||
view_set_widget(view, FWIDG_NONE);
|
||||
|
@ -3593,7 +3609,7 @@ step_file_view(System_Functions *system, Exchange *exchange, View *view_, i32_Re
|
|||
{
|
||||
UI_State state =
|
||||
ui_state_init(&view->ui_state, 0, user_input,
|
||||
view->style, view->font_set, view->working_set, 1);
|
||||
view->style, view->global_font->font_id, view->font_set, view->working_set, 1);
|
||||
|
||||
UI_Layout layout;
|
||||
begin_layout(&layout, rect);
|
||||
|
@ -3628,60 +3644,6 @@ step_file_view(System_Functions *system, Exchange *exchange, View *view_, i32_Re
|
|||
return(result);
|
||||
}
|
||||
|
||||
internal void
|
||||
draw_file_setup_bar(Style *style, i32 line_height, Interactive_Bar *bar, i32_Rect *rect){
|
||||
bar->style = style->main.file_info_style;
|
||||
bar->font_id = style->font_id;
|
||||
bar->pos_x = (f32)rect->x0;
|
||||
bar->pos_y = (f32)rect->y0;
|
||||
bar->text_shift_y = 2;
|
||||
bar->text_shift_x = 0;
|
||||
bar->rect = *rect;
|
||||
bar->rect.y1 = bar->rect.y0 + line_height + 2;
|
||||
rect->y0 += line_height + 2;
|
||||
}
|
||||
|
||||
internal void
|
||||
draw_file_bar(File_View *view, Interactive_Bar *bar, Render_Target *target){
|
||||
Editing_File *file = view->file;
|
||||
|
||||
u32 back_color = bar->style.bar_color;
|
||||
u32 base_color = bar->style.base_color;
|
||||
u32 pop2_color = bar->style.pop2_color;
|
||||
|
||||
draw_rectangle(target, bar->rect, back_color);
|
||||
intbar_draw_string(target, bar, file->name.live_name, base_color);
|
||||
intbar_draw_string(target, bar, make_lit_string(" - "), base_color);
|
||||
|
||||
if (file->state.is_loading){
|
||||
intbar_draw_string(target, bar, make_lit_string(" loading"), base_color);
|
||||
}
|
||||
else{
|
||||
char line_number_space[30];
|
||||
String line_number = make_string(line_number_space, 0, 30);
|
||||
append(&line_number, "L#");
|
||||
append_int_to_str(view->cursor.line, &line_number);
|
||||
|
||||
intbar_draw_string(target, bar, line_number, base_color);
|
||||
|
||||
if (!file->settings.unimportant){
|
||||
switch (buffer_get_sync(file)){
|
||||
case SYNC_BEHIND_OS:
|
||||
{
|
||||
persist String out_of_sync = make_lit_string(" !");
|
||||
intbar_draw_string(target, bar, out_of_sync, pop2_color);
|
||||
}break;
|
||||
|
||||
case SYNC_UNSAVED:
|
||||
{
|
||||
persist String out_of_sync = make_lit_string(" *");
|
||||
intbar_draw_string(target, bar, out_of_sync, pop2_color);
|
||||
}break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal i32
|
||||
draw_file_loaded(File_View *view, i32_Rect rect, b32 is_active, Render_Target *target){
|
||||
Editing_File *file = view->file;
|
||||
|
@ -3708,7 +3670,7 @@ draw_file_loaded(File_View *view, i32_Rect rect, b32 is_active, Render_Target *t
|
|||
i32 max = partition_remaining(part) / sizeof(Buffer_Render_Item);
|
||||
Buffer_Render_Item *items = push_array(part, Buffer_Render_Item, max);
|
||||
|
||||
i16 font_id = style->font_id;
|
||||
i16 font_id = view->global_font->font_id;
|
||||
Render_Font *font = get_font_info(view->font_set, font_id)->font;
|
||||
float *advance_data = 0;
|
||||
if (font) advance_data = font->advance_data;
|
||||
|
@ -3851,31 +3813,34 @@ draw_file_loaded(File_View *view, i32_Rect rect, b32 is_active, Render_Target *t
|
|||
|
||||
internal i32
|
||||
draw_file_view(System_Functions *system, Exchange *exchange,
|
||||
View *view_, View *active, i32_Rect rect, b32 is_active, Render_Target *target, Input_Summary *user_input){
|
||||
View *view_, View *active, i32_Rect rect, b32 is_active,
|
||||
Render_Target *target, Input_Summary *user_input){
|
||||
File_View *view = (File_View*)view_;
|
||||
Editing_File *file = view->file;
|
||||
i32 result = 0;
|
||||
|
||||
i32 widget_height = 0;
|
||||
{
|
||||
i32_Rect widg_rect = view_widget_rect(view, view->font_height);
|
||||
|
||||
UI_State state =
|
||||
ui_state_init(&view->widget.state, target, 0,
|
||||
view->style, view->font_set, 0, 0);
|
||||
view->style, view->global_font->font_id, view->font_set, 0, 0);
|
||||
|
||||
UI_Layout layout;
|
||||
begin_layout(&layout, widg_rect);
|
||||
begin_layout(&layout, rect);
|
||||
|
||||
switch (view->widget.type){
|
||||
case FWIDG_NONE:
|
||||
{
|
||||
if (file){
|
||||
do_file_bar(view, file, &layout, target);
|
||||
}
|
||||
|
||||
draw_file_view_queries(view, &state, &layout);
|
||||
}break;
|
||||
|
||||
case FWIDG_TIMELINES:
|
||||
{
|
||||
if (view->file){
|
||||
Editing_File *file = view->file;
|
||||
if (file){
|
||||
i32 undo_count = file->state.undo.undo.edit_count;
|
||||
i32 redo_count = file->state.undo.redo.edit_count;
|
||||
i32 total_count = undo_count + redo_count;
|
||||
|
@ -3887,8 +3852,8 @@ draw_file_view(System_Functions *system, Exchange *exchange,
|
|||
}break;
|
||||
}
|
||||
|
||||
widget_height = layout.y - widg_rect.y0;
|
||||
ui_finish_frame(&view->widget.state, &state, &layout, widg_rect, 0, 0);
|
||||
widget_height = layout.y - rect.y0;
|
||||
ui_finish_frame(&view->widget.state, &state, &layout, rect, 0, 0);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -3897,7 +3862,7 @@ draw_file_view(System_Functions *system, Exchange *exchange,
|
|||
|
||||
UI_State state =
|
||||
ui_state_init(&view->ui_state, target, user_input,
|
||||
view->style, view->font_set, view->working_set, 0);
|
||||
view->style, view->global_font->font_id, view->font_set, view->working_set, 0);
|
||||
|
||||
UI_Layout layout;
|
||||
begin_layout(&layout, rect);
|
||||
|
@ -3907,16 +3872,9 @@ draw_file_view(System_Functions *system, Exchange *exchange,
|
|||
switch (view->showing_ui){
|
||||
case VUI_None:
|
||||
{
|
||||
if (view->file){
|
||||
Interactive_Bar bar;
|
||||
draw_file_setup_bar(view->style, view->font_height, &bar, &rect);
|
||||
|
||||
if (file_is_ready(view->file)){
|
||||
if (file && file_is_ready(file)){
|
||||
result = draw_file_loaded(view, rect, is_active, target);
|
||||
}
|
||||
|
||||
draw_file_bar(view, &bar, target);
|
||||
}
|
||||
}break;
|
||||
|
||||
case VUI_Theme:
|
||||
|
@ -3953,22 +3911,19 @@ kill_file(
|
|||
General_Memory *general, Editing_File *file,
|
||||
Live_Views *live_set, Editing_Layout *layout){
|
||||
|
||||
View *view;
|
||||
File_View *fview;
|
||||
Panel *panel;
|
||||
i32 panel_count, i;
|
||||
|
||||
panel_count = layout->panel_count;
|
||||
panel = layout->panels;
|
||||
for (i = 0; i < panel_count; ++i, ++panel){
|
||||
view = panel->view;
|
||||
fview = view_to_file_view(view);
|
||||
Panel *panel, *used_panels;
|
||||
used_panels = &layout->used_sentinel;
|
||||
|
||||
for (dll_items(panel, used_panels)){
|
||||
fview = view_to_file_view(panel->view);
|
||||
Assert(fview);
|
||||
|
||||
if (fview->file == file){
|
||||
fview->file = 0;
|
||||
}
|
||||
}
|
||||
|
||||
file_close(system, general, file);
|
||||
file_get_dummy(file);
|
||||
}
|
||||
|
@ -4038,24 +3993,18 @@ struct File_View_Iter{
|
|||
|
||||
Editing_File *file;
|
||||
File_View *skip;
|
||||
Panel *panels;
|
||||
i32 panel_count;
|
||||
i32 i;
|
||||
Panel *used_panels;
|
||||
Panel *panel;
|
||||
};
|
||||
|
||||
internal File_View_Iter
|
||||
file_view_iter_next(File_View_Iter iter){
|
||||
Panel *panel;
|
||||
View *view;
|
||||
File_View *file_view;
|
||||
|
||||
++iter.i;
|
||||
for (panel = iter.panels + iter.i;
|
||||
iter.i < iter.panel_count;
|
||||
++iter.i, ++panel){
|
||||
view = panel->view;
|
||||
file_view = view_to_file_view(view);
|
||||
if (file_view && file_view != iter.skip && file_view->file == iter.file){
|
||||
for (panel = iter.panel; panel != iter.used_panels; panel = panel->next){
|
||||
file_view = view_to_file_view(panel->view);
|
||||
if (file_view != iter.skip && file_view->file == iter.file){
|
||||
iter.view = file_view;
|
||||
break;
|
||||
}
|
||||
|
@ -4066,22 +4015,19 @@ file_view_iter_next(File_View_Iter iter){
|
|||
|
||||
internal File_View_Iter
|
||||
file_view_iter_init(Editing_Layout *layout, Editing_File *file, File_View *skip){
|
||||
File_View_Iter result = {};
|
||||
result.panels = layout->panels;
|
||||
result.panel_count = layout->panel_count;
|
||||
File_View_Iter result;
|
||||
result.used_panels = &layout->used_sentinel;
|
||||
result.panel = result.used_panels->next;
|
||||
result.file = file;
|
||||
result.skip = skip;
|
||||
|
||||
result.i = -1;
|
||||
result = file_view_iter_next(result);
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
internal b32
|
||||
file_view_iter_good(File_View_Iter iter){
|
||||
b32 result = 1;
|
||||
if (iter.i >= iter.panel_count) result = 0;
|
||||
if (iter.panel != iter.used_panels) result = 0;
|
||||
return(result);
|
||||
}
|
||||
|
||||
|
|
32
4ed_gui.cpp
32
4ed_gui.cpp
|
@ -550,12 +550,13 @@ get_pop_color(UI_State *state, u32 *pop, Widget_ID wid, UI_Style style){
|
|||
|
||||
internal UI_State
|
||||
ui_state_init(UI_State *state_in, Render_Target *target, Input_Summary *user_input,
|
||||
Style *style, Font_Set *font_set, Working_Set *working_set, b32 input_stage){
|
||||
Style *style, i16 font_id, Font_Set *font_set, Working_Set *working_set,
|
||||
b32 input_stage){
|
||||
UI_State state = {};
|
||||
state.target = target;
|
||||
state.style = style;
|
||||
state.font_set = font_set;
|
||||
state.font_id = style->font_id;
|
||||
state.font_id = font_id;
|
||||
state.working_set = working_set;
|
||||
if (user_input){
|
||||
state.mouse = &user_input->mouse;
|
||||
|
@ -821,7 +822,7 @@ internal b32
|
|||
do_button(i32 id, UI_State *state, UI_Layout *layout, char *text, i32 height_mult,
|
||||
b32 is_toggle = 0, b32 on = 0){
|
||||
b32 result = 0;
|
||||
i16 font_id = state->style->font_id;
|
||||
i16 font_id = state->font_id;
|
||||
i32 character_h = get_font_info(state->font_set, font_id)->height;
|
||||
|
||||
i32_Rect btn_rect = layout_rect(layout, character_h * height_mult);
|
||||
|
@ -869,7 +870,7 @@ do_button(i32 id, UI_State *state, UI_Layout *layout, char *text, i32 height_mul
|
|||
internal b32
|
||||
do_undo_slider(Widget_ID wid, UI_State *state, UI_Layout *layout, i32 max, i32 v, Undo_Data *undo, i32 *out){
|
||||
b32 result = 0;
|
||||
i16 font_id = state->style->font_id;
|
||||
i16 font_id = state->font_id;
|
||||
i32 character_h = get_font_info(state->font_set, font_id)->height;
|
||||
|
||||
i32_Rect containing_rect = layout_rect(layout, character_h);
|
||||
|
@ -1013,7 +1014,7 @@ do_undo_slider(Widget_ID wid, UI_State *state, UI_Layout *layout, i32 max, i32 v
|
|||
internal void
|
||||
do_label(UI_State *state, UI_Layout *layout, char *text, int text_size, f32 height = 2.f){
|
||||
Style *style = state->style;
|
||||
i16 font_id = style->font_id;
|
||||
i16 font_id = state->font_id;
|
||||
i32 line_height = get_font_info(state->font_set, font_id)->height;
|
||||
i32_Rect label = layout_rect(layout, FLOOR32(line_height * height));
|
||||
|
||||
|
@ -1178,7 +1179,7 @@ draw_gradient_slider(Render_Target *target, Vec4 base, i32 channel,
|
|||
|
||||
inline void
|
||||
draw_hsl_slider(Render_Target *target, Vec4 base, i32 channel,
|
||||
i32 steps, real32 top, f32_Rect slider){
|
||||
i32 steps, f32 top, f32_Rect slider){
|
||||
draw_gradient_slider(target, base, channel, steps, top, slider, 1);
|
||||
}
|
||||
|
||||
|
@ -1195,7 +1196,7 @@ do_main_file_box(System_Functions *system, UI_State *state, UI_Layout *layout,
|
|||
Style *style = state->style;
|
||||
String *string = &hot_directory->string;
|
||||
|
||||
i16 font_id = style->font_id;
|
||||
i16 font_id = state->font_id;
|
||||
i32 line_height = get_font_info(state->font_set, font_id)->height;
|
||||
i32_Rect box = layout_rect(layout, line_height + 2);
|
||||
|
||||
|
@ -1224,7 +1225,7 @@ do_main_string_box(System_Functions *system, UI_State *state, UI_Layout *layout,
|
|||
b32 result = 0;
|
||||
Style *style = state->style;
|
||||
|
||||
i16 font_id = style->font_id;
|
||||
i16 font_id = state->font_id;
|
||||
i32 line_height = get_font_info(state->font_set, font_id)->height;
|
||||
i32_Rect box = layout_rect(layout, line_height + 2);
|
||||
|
||||
|
@ -1251,7 +1252,7 @@ do_list_option(i32 id, UI_State *state, UI_Layout *layout, String text){
|
|||
b32 result = 0;
|
||||
Style *style = state->style;
|
||||
|
||||
i16 font_id = style->font_id;
|
||||
i16 font_id = state->font_id;
|
||||
i32 character_h = get_font_info(state->font_set, font_id)->height;
|
||||
|
||||
i32_Rect box = layout_rect(layout, character_h*2);
|
||||
|
@ -1287,7 +1288,7 @@ do_checkbox_list_option(i32 id, UI_State *state, UI_Layout *layout, String text,
|
|||
b32 result = 0;
|
||||
Style *style = state->style;
|
||||
|
||||
i16 font_id = style->font_id;
|
||||
i16 font_id = state->font_id;
|
||||
i32 character_h = get_font_info(state->font_set, font_id)->height;
|
||||
|
||||
i32_Rect box = layout_rect(layout, character_h*2);
|
||||
|
@ -1332,7 +1333,7 @@ internal b32
|
|||
do_file_option(i32 id, UI_State *state, UI_Layout *layout, String filename, b32 is_folder, String extra, char slash){
|
||||
b32 result = 0;
|
||||
Style *style = state->style;
|
||||
i16 font_id = style->font_id;
|
||||
i16 font_id = state->font_id;
|
||||
i32 character_h = get_font_info(state->font_set, font_id)->height;
|
||||
char slash_buf[2] = { slash, 0 };
|
||||
|
||||
|
@ -1556,6 +1557,7 @@ struct Color_UI{
|
|||
UI_Layout *layout;
|
||||
|
||||
Font_Set *fonts;
|
||||
Style_Font *global_font;
|
||||
|
||||
f32 hex_advance;
|
||||
u32 *palette;
|
||||
|
@ -1964,7 +1966,7 @@ do_palette(Color_UI *ui, i32_Rect rect){
|
|||
|
||||
if (!ui->state->input_stage){
|
||||
Render_Target *target = ui->state->target;
|
||||
draw_string(target, style->font_id, "Global Palette: right click to save color",
|
||||
draw_string(target, ui->state->font_id, "Global Palette: right click to save color",
|
||||
layout.x, layout.rect.y0, style->main.default_color);
|
||||
}
|
||||
|
||||
|
@ -2233,8 +2235,8 @@ do_font_switch(Color_UI *ui){
|
|||
for (i16 i = 1; i < count; ++i){
|
||||
if (i == font_id) continue;
|
||||
if (do_font_option(ui, i)){
|
||||
ui->state->style->font_id = i;
|
||||
ui->state->style->font_changed = 1;
|
||||
ui->global_font->font_id = i;
|
||||
ui->global_font->font_changed = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2251,7 +2253,7 @@ do_style_preview(Library_UI *ui, Style *style, i32 toggle = -1){
|
|||
if (style == ui->state->style) id = 2;
|
||||
else id = raw_ptr_dif(style, ui->styles->styles) + 100;
|
||||
|
||||
i16 font_id = style->font_id;
|
||||
i16 font_id = ui->state->font_id;
|
||||
Font_Info *info = get_font_info(ui->state->font_set, font_id);
|
||||
|
||||
i32_Rect prect = layout_rect(ui->layout, info->height*3 + 6);
|
||||
|
|
|
@ -332,6 +332,8 @@ struct View{
|
|||
Panel *panel;
|
||||
Command_Map *map;
|
||||
Do_View_Function *do_view;
|
||||
Scroll_Rule_Function *scroll_rule;
|
||||
i32 id;
|
||||
};
|
||||
|
||||
struct Live_Views{
|
||||
|
@ -353,7 +355,7 @@ live_set_get_view(Live_Views *live_set, i32 id){
|
|||
}
|
||||
|
||||
internal View_And_ID
|
||||
live_set_alloc_view(Live_Views *live_set, Mem_Options *mem){
|
||||
live_set_alloc_view(Live_Views *live_set, Scroll_Rule_Function *scroll_rule){
|
||||
View_And_ID result = {};
|
||||
|
||||
Assert(live_set->count < live_set->max);
|
||||
|
@ -361,9 +363,11 @@ live_set_alloc_view(Live_Views *live_set, Mem_Options *mem){
|
|||
|
||||
result.view = live_set->free_sentinel.next;
|
||||
result.id = (i32)((char*)result.view - (char*)live_set->views);
|
||||
result.view->id = result.id;
|
||||
|
||||
dll_remove(result.view);
|
||||
memset(result.view, 0, live_set->stride);
|
||||
result.view->scroll_rule = scroll_rule;
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
@ -397,45 +401,5 @@ view_base_compute_height(View *view){
|
|||
#define view_compute_width(view) (view_base_compute_width(&(view)->view_base))
|
||||
#define view_compute_height(view) (view_base_compute_height(&(view)->view_base))
|
||||
|
||||
struct Interactive_Style{
|
||||
u32 bar_color;
|
||||
u32 bar_active_color;
|
||||
u32 base_color;
|
||||
u32 pop1_color;
|
||||
u32 pop2_color;
|
||||
};
|
||||
|
||||
struct Interactive_Bar{
|
||||
Interactive_Style style;
|
||||
f32 pos_x, pos_y;
|
||||
f32 text_shift_x, text_shift_y;
|
||||
i32_Rect rect;
|
||||
i16 font_id;
|
||||
};
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
internal void
|
||||
intbar_draw_string(Render_Target *target, Interactive_Bar *bar,
|
||||
String str, u32 char_color){
|
||||
i16 font_id = bar->font_id;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
// BOTTOM
|
||||
|
||||
|
|
182
4ed_style.cpp
182
4ed_style.cpp
|
@ -9,6 +9,42 @@
|
|||
|
||||
// TOP
|
||||
|
||||
// TODO(allen):
|
||||
// Font changing UI should be in the library menu now, it's not tied to the fonts any more
|
||||
// Get the import export stuff up and running for styles again
|
||||
|
||||
struct Interactive_Style{
|
||||
u32 bar_color;
|
||||
u32 bar_active_color;
|
||||
u32 base_color;
|
||||
u32 pop1_color;
|
||||
u32 pop2_color;
|
||||
};
|
||||
|
||||
struct Interactive_Bar{
|
||||
f32 pos_x, pos_y;
|
||||
f32 text_shift_x, text_shift_y;
|
||||
i32_Rect rect;
|
||||
i16 font_id;
|
||||
};
|
||||
|
||||
internal void
|
||||
intbar_draw_string(Render_Target *target, Interactive_Bar *bar,
|
||||
String str, u32 char_color){
|
||||
i16 font_id = bar->font_id;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
struct Style_Font{
|
||||
i16 font_id;
|
||||
i16 font_changed;
|
||||
};
|
||||
|
||||
struct Style_Main_Data{
|
||||
u32 back_color;
|
||||
u32 margin_color;
|
||||
|
@ -37,51 +73,39 @@ struct Style_Main_Data{
|
|||
Interactive_Style file_info_style;
|
||||
};
|
||||
|
||||
struct Style_File_Format_v4{
|
||||
i32 name_size;
|
||||
char name[24];
|
||||
i32 font_name_size;
|
||||
char font_name[24];
|
||||
Style_Main_Data main;
|
||||
};
|
||||
|
||||
enum Style_Color_Tag{
|
||||
STAG_BAR_COLOR,
|
||||
STAG_BAR_ACTIVE_COLOR,
|
||||
STAG_BAR_BASE_COLOR,
|
||||
STAG_BAR_POP1_COLOR,
|
||||
STAG_BAR_POP2_COLOR,
|
||||
STAG_BACK_COLOR,
|
||||
STAG_MARGIN_COLOR,
|
||||
STAG_MARGIN_HOVER_COLOR,
|
||||
STAG_MARGIN_ACTIVE_COLOR,
|
||||
STAG_CURSOR_COLOR,
|
||||
STAG_AT_CURSOR_COLOR,
|
||||
STAG_HIGHLIGHT_COLOR,
|
||||
STAG_AT_HIGHLIGHT_COLOR,
|
||||
STAG_MARK_COLOR,
|
||||
STAG_DEFAULT_COLOR,
|
||||
STAG_COMMENT_COLOR,
|
||||
STAG_KEYWORD_COLOR,
|
||||
STAG_STR_CONSTANT_COLOR,
|
||||
STAG_CHAR_CONSTANT_COLOR,
|
||||
STAG_INT_CONSTANT_COLOR,
|
||||
STAG_FLOAT_CONSTANT_COLOR,
|
||||
STAG_BOOL_CONSTANT_COLOR,
|
||||
STAG_PREPROC_COLOR,
|
||||
STAG_INCLUDE_COLOR,
|
||||
STAG_SPECIAL_CHARACTER_COLOR,
|
||||
STAG_HIGHLIGHT_JUNK_COLOR,
|
||||
STAG_HIGHLIGHT_WHITE_COLOR,
|
||||
STAG_PASTE_COLOR,
|
||||
STAG_UNDO_COLOR,
|
||||
STAG_NEXT_UNDO_COLOR,
|
||||
STAG_RESULT_LINK_COLOR,
|
||||
STAG_RELATED_LINK_COLOR,
|
||||
STAG_ERROR_LINK_COLOR,
|
||||
STAG_WARNING_LINK_COLOR,
|
||||
enum Style_Tag{
|
||||
Stag_Bar,
|
||||
Stag_Bar_Active,
|
||||
Stag_Bar_Base,
|
||||
Stag_Bar_Pop1,
|
||||
Stag_Bar_Pop2,
|
||||
Stag_Back,
|
||||
Stag_Margin,
|
||||
Stag_Margin_Hover,
|
||||
Stag_Margin_Active,
|
||||
Stag_Cursor,
|
||||
Stag_At_Cursor,
|
||||
Stag_Highlight,
|
||||
Stag_At_Highlight,
|
||||
Stag_Mark,
|
||||
Stag_Default,
|
||||
Stag_Comment,
|
||||
Stag_Keyword,
|
||||
Stag_Str_Constant,
|
||||
Stag_Char_Constant,
|
||||
Stag_Int_Constant,
|
||||
Stag_Float_Constant,
|
||||
Stag_Bool_Constant,
|
||||
Stag_Preproc,
|
||||
Stag_Include,
|
||||
Stag_Special_Character,
|
||||
Stag_Highlight_Junk,
|
||||
Stag_Highlight_White,
|
||||
Stag_Paste,
|
||||
Stag_Undo,
|
||||
Stag_Next_Undo,
|
||||
// never below this
|
||||
STAG_COUNT
|
||||
Stag_Count
|
||||
};
|
||||
|
||||
struct Style_Color_Specifier{
|
||||
|
@ -92,8 +116,6 @@ struct Style_Color_Specifier{
|
|||
struct Style_File_Format{
|
||||
i32 name_size;
|
||||
char name[24];
|
||||
i32 font_name_size;
|
||||
char font_name[24];
|
||||
|
||||
i32 color_specifier_count;
|
||||
};
|
||||
|
@ -102,8 +124,6 @@ struct Style{
|
|||
char name_[24];
|
||||
String name;
|
||||
Style_Main_Data main;
|
||||
b32 font_changed;
|
||||
i16 font_id;
|
||||
};
|
||||
|
||||
struct Style_Library{
|
||||
|
@ -120,51 +140,51 @@ style_copy(Style *dst, Style *src){
|
|||
internal void
|
||||
style_set_name(Style *style, String name){
|
||||
i32 count = ArrayCount(style->name_);
|
||||
style->name_[count - 1] = 0;
|
||||
style->name = make_string(style->name_, 0, count - 1);
|
||||
copy(&style->name, name);
|
||||
terminate_with_null(&style->name);
|
||||
}
|
||||
|
||||
inline u32*
|
||||
style_index_by_tag(Style *s, u32 tag){
|
||||
u32 *result = 0;
|
||||
switch (tag){
|
||||
case STAG_BAR_COLOR: result = &s->main.file_info_style.bar_color; break;
|
||||
case STAG_BAR_ACTIVE_COLOR: result = &s->main.file_info_style.bar_active_color; break;
|
||||
case STAG_BAR_BASE_COLOR: result = &s->main.file_info_style.base_color; break;
|
||||
case STAG_BAR_POP1_COLOR: result = &s->main.file_info_style.pop1_color; break;
|
||||
case STAG_BAR_POP2_COLOR: result = &s->main.file_info_style.pop2_color; break;
|
||||
case Stag_Bar: result = &s->main.file_info_style.bar_color; break;
|
||||
case Stag_Bar_Active: result = &s->main.file_info_style.bar_active_color; break;
|
||||
case Stag_Bar_Base: result = &s->main.file_info_style.base_color; break;
|
||||
case Stag_Bar_Pop1: result = &s->main.file_info_style.pop1_color; break;
|
||||
case Stag_Bar_Pop2: result = &s->main.file_info_style.pop2_color; break;
|
||||
|
||||
case STAG_BACK_COLOR: result = &s->main.back_color; break;
|
||||
case STAG_MARGIN_COLOR: result = &s->main.margin_color; break;
|
||||
case STAG_MARGIN_HOVER_COLOR: result = &s->main.margin_hover_color; break;
|
||||
case STAG_MARGIN_ACTIVE_COLOR: result = &s->main.margin_active_color; break;
|
||||
case Stag_Back: result = &s->main.back_color; break;
|
||||
case Stag_Margin: result = &s->main.margin_color; break;
|
||||
case Stag_Margin_Hover: result = &s->main.margin_hover_color; break;
|
||||
case Stag_Margin_Active: result = &s->main.margin_active_color; break;
|
||||
|
||||
case STAG_CURSOR_COLOR: result = &s->main.cursor_color; break;
|
||||
case STAG_AT_CURSOR_COLOR: result = &s->main.at_cursor_color; break;
|
||||
case STAG_HIGHLIGHT_COLOR: result = &s->main.highlight_color; break;
|
||||
case STAG_AT_HIGHLIGHT_COLOR: result = &s->main.at_highlight_color; break;
|
||||
case STAG_MARK_COLOR: result = &s->main.mark_color; break;
|
||||
case Stag_Cursor: result = &s->main.cursor_color; break;
|
||||
case Stag_At_Cursor: result = &s->main.at_cursor_color; break;
|
||||
case Stag_Highlight: result = &s->main.highlight_color; break;
|
||||
case Stag_At_Highlight: result = &s->main.at_highlight_color; break;
|
||||
case Stag_Mark: result = &s->main.mark_color; break;
|
||||
|
||||
case STAG_DEFAULT_COLOR: result = &s->main.default_color; break;
|
||||
case STAG_COMMENT_COLOR: result = &s->main.comment_color; break;
|
||||
case STAG_KEYWORD_COLOR: result = &s->main.keyword_color; break;
|
||||
case STAG_STR_CONSTANT_COLOR: result = &s->main.str_constant_color; break;
|
||||
case STAG_CHAR_CONSTANT_COLOR: result = &s->main.char_constant_color; break;
|
||||
case STAG_INT_CONSTANT_COLOR: result = &s->main.int_constant_color; break;
|
||||
case STAG_FLOAT_CONSTANT_COLOR: result = &s->main.float_constant_color; break;
|
||||
case STAG_BOOL_CONSTANT_COLOR: result = &s->main.bool_constant_color; break;
|
||||
case Stag_Default: result = &s->main.default_color; break;
|
||||
case Stag_Comment: result = &s->main.comment_color; break;
|
||||
case Stag_Keyword: result = &s->main.keyword_color; break;
|
||||
case Stag_Str_Constant: result = &s->main.str_constant_color; break;
|
||||
case Stag_Char_Constant: result = &s->main.char_constant_color; break;
|
||||
case Stag_Int_Constant: result = &s->main.int_constant_color; break;
|
||||
case Stag_Float_Constant: result = &s->main.float_constant_color; break;
|
||||
case Stag_Bool_Constant: result = &s->main.bool_constant_color; break;
|
||||
|
||||
case STAG_PREPROC_COLOR: result = &s->main.preproc_color; break;
|
||||
case STAG_INCLUDE_COLOR: result = &s->main.include_color; break;
|
||||
case Stag_Preproc: result = &s->main.preproc_color; break;
|
||||
case Stag_Include: result = &s->main.include_color; break;
|
||||
|
||||
case STAG_SPECIAL_CHARACTER_COLOR: result = &s->main.special_character_color; break;
|
||||
case Stag_Special_Character: result = &s->main.special_character_color; break;
|
||||
|
||||
case STAG_HIGHLIGHT_JUNK_COLOR: result = &s->main.highlight_junk_color; break;
|
||||
case STAG_HIGHLIGHT_WHITE_COLOR: result = &s->main.highlight_white_color; break;
|
||||
case Stag_Highlight_Junk: result = &s->main.highlight_junk_color; break;
|
||||
case Stag_Highlight_White: result = &s->main.highlight_white_color; break;
|
||||
|
||||
case STAG_PASTE_COLOR: result = &s->main.paste_color; break;
|
||||
case STAG_UNDO_COLOR: result = &s->main.undo_color; break;
|
||||
case Stag_Paste: result = &s->main.paste_color; break;
|
||||
case Stag_Undo: result = &s->main.undo_color; break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -198,14 +218,10 @@ style_format_for_file(Font_Set *set, Style *style, Style_File_Format *out){
|
|||
out->name_size = style->name.size;
|
||||
memcpy(out->name, style->name.str, ArrayCount(out->name));
|
||||
|
||||
String font_name = get_font_info(set, style->font_id)->name;
|
||||
out->font_name_size = font_name.size;
|
||||
memcpy(out->font_name, font_name.str, font_name.size);
|
||||
|
||||
Style_Color_Specifier *spec = (Style_Color_Specifier*)(out + 1);
|
||||
i32 count = 0;
|
||||
|
||||
for (u32 i = 0; i < STAG_COUNT; ++i){
|
||||
for (u32 i = 0; i < Stag_Count; ++i){
|
||||
u32 *color = style_index_by_tag(style, i);
|
||||
if (color){
|
||||
spec->tag = i;
|
||||
|
|
|
@ -7,7 +7,7 @@ SET clset=64
|
|||
SET WARNINGS=/W4 /wd4310 /wd4100 /wd4201 /wd4505 /wd4996 /wd4127 /wd4510 /wd4512 /wd4610 /WX
|
||||
SET STUFF=/GR- /nologo
|
||||
SET DEBUG=/Zi
|
||||
SET EXPORTS=/EXPORT:get_bindings
|
||||
SET EXPORTS=/EXPORT:get_bindings /EXPORT:scroll_rule
|
||||
SET SRC=4coder_custom.cpp
|
||||
|
||||
cl %WARNINGS% %STUFF% %DEBUG% %SRC% /Fe4coder_custom /LD /link /INCREMENTAL:NO /OPT:REF %EXPORTS%
|
||||
|
|
|
@ -1754,6 +1754,9 @@ main(int argc, char **argv){
|
|||
if (win32vars.custom){
|
||||
win32vars.custom_api.get_bindings = (Get_Binding_Data_Function*)
|
||||
GetProcAddress(win32vars.custom, "get_bindings");
|
||||
|
||||
win32vars.custom_api.scroll_rule = (Scroll_Rule_Function*)
|
||||
GetProcAddress(win32vars.custom, "scroll_rule");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue