file bar is GUI/scroll rule/etc
This commit is contained in:
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
|
||||
|
|
|
@ -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"
|
||||
|
|
2210
4ed_file_view.cpp
2210
4ed_file_view.cpp
File diff suppressed because it is too large
Load Diff
34
4ed_gui.cpp
34
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,13 +1179,13 @@ 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);
|
||||
}
|
||||
|
||||
inline void
|
||||
draw_rgb_slider(Render_Target *target, Vec4 base, i32 channel,
|
||||
i32 steps, f32 top, f32_Rect slider){
|
||||
i32 steps, f32 top, f32_Rect slider){
|
||||
draw_gradient_slider(target, base, channel, steps, top, slider, 0);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -197,15 +217,11 @@ internal Style_File_Format*
|
|||
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