Fixed theme config
parent
74b8759c67
commit
d28a1d6aba
|
@ -1555,11 +1555,9 @@ load_config_and_apply(Application_Links *app, Arena *out_arena, Config_Data *con
|
||||||
change_mode(app, config->mode);
|
change_mode(app, config->mode);
|
||||||
global_set_setting(app, GlobalSetting_LAltLCtrlIsAltGr, config->lalt_lctrl_is_altgr);
|
global_set_setting(app, GlobalSetting_LAltLCtrlIsAltGr, config->lalt_lctrl_is_altgr);
|
||||||
|
|
||||||
// TODO(allen):
|
Color_Table *colors = get_color_table_by_name(config->default_theme_name);
|
||||||
#if 0
|
set_active_color(colors);
|
||||||
change_theme(app, config->default_theme_name.str, config->default_theme_name.size);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Face_Description description = {};
|
Face_Description description = {};
|
||||||
if (override_font_size != 0){
|
if (override_font_size != 0){
|
||||||
description.parameters.pt_size = override_font_size;
|
description.parameters.pt_size = override_font_size;
|
||||||
|
|
|
@ -156,6 +156,13 @@ set_default_color_scheme(Application_Links *app){
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
|
function void
|
||||||
|
set_active_color(Color_Table *table){
|
||||||
|
if (table != 0){
|
||||||
|
active_color_table = *table;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function void
|
function void
|
||||||
save_theme(Color_Table table, String_Const_u8 name){
|
save_theme(Color_Table table, String_Const_u8 name){
|
||||||
Color_Table_Node *node = push_array(&global_theme_arena, Color_Table_Node, 1);
|
Color_Table_Node *node = push_array(&global_theme_arena, Color_Table_Node, 1);
|
||||||
|
@ -165,4 +172,20 @@ save_theme(Color_Table table, String_Const_u8 name){
|
||||||
node->table = table;
|
node->table = table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
|
||||||
|
function Color_Table*
|
||||||
|
get_color_table_by_name(String_Const_u8 name){
|
||||||
|
Color_Table *result = 0;
|
||||||
|
for (Color_Table_Node *node = global_theme_list.first;
|
||||||
|
node != 0;
|
||||||
|
node = node->next){
|
||||||
|
if (string_match(node->name, name)){
|
||||||
|
result = &node->table;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
// BOTTOM
|
// BOTTOM
|
||||||
|
|
|
@ -11,12 +11,12 @@ CUSTOM_DOC("Default command for responding to a startup event")
|
||||||
User_Input input = get_current_input(app);
|
User_Input input = get_current_input(app);
|
||||||
if (match_core_code(&input, CoreCode_Startup)){
|
if (match_core_code(&input, CoreCode_Startup)){
|
||||||
String_Const_u8_Array file_names = input.event.core.file_names;
|
String_Const_u8_Array file_names = input.event.core.file_names;
|
||||||
|
load_themes_default_folder(app);
|
||||||
default_4coder_initialize(app, file_names);
|
default_4coder_initialize(app, file_names);
|
||||||
default_4coder_side_by_side_panels(app, file_names);
|
default_4coder_side_by_side_panels(app, file_names);
|
||||||
if (global_config.automatically_load_project){
|
if (global_config.automatically_load_project){
|
||||||
load_project(app);
|
load_project(app);
|
||||||
}
|
}
|
||||||
load_themes_default_folder(app);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -932,8 +932,44 @@ BUFFER_HOOK_SIG(default_begin_buffer){
|
||||||
}
|
}
|
||||||
|
|
||||||
BUFFER_HOOK_SIG(default_new_file){
|
BUFFER_HOOK_SIG(default_new_file){
|
||||||
// buffer_id
|
Scratch_Block scratch(app);
|
||||||
// no meaning for return
|
String_Const_u8 file_name = push_buffer_base_name(app, scratch, buffer_id);
|
||||||
|
if (!string_match(string_postfix(file_name, 2), string_u8_litexpr(".h"))) {
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
List_String_Const_u8 guard_list = {};
|
||||||
|
for (u64 i = 0; i < file_name.size; ++i){
|
||||||
|
u8 c[2] = {};
|
||||||
|
u64 c_size = 1;
|
||||||
|
u8 ch = file_name.str[i];
|
||||||
|
if (ch == '.'){
|
||||||
|
c[0] = '_';
|
||||||
|
}
|
||||||
|
else if (ch >= 'A' && ch <= 'Z'){
|
||||||
|
c_size = 2;
|
||||||
|
c[0] = '_';
|
||||||
|
c[1] = ch;
|
||||||
|
}
|
||||||
|
else if (ch >= 'a' && ch <= 'z'){
|
||||||
|
c[0] = ch - ('a' - 'A');
|
||||||
|
}
|
||||||
|
String_Const_u8 part = push_string_copy(scratch, SCu8(c, c_size));
|
||||||
|
string_list_push(scratch, &guard_list, part);
|
||||||
|
}
|
||||||
|
String_Const_u8 guard = string_list_flatten(scratch, guard_list);
|
||||||
|
|
||||||
|
Buffer_Insertion insert = begin_buffer_insertion_at_buffered(app, buffer_id, 0, scratch, KB(16));
|
||||||
|
insertf(&insert,
|
||||||
|
"#ifndef %.*s\n"
|
||||||
|
"#define %.*s\n"
|
||||||
|
"\n"
|
||||||
|
"#endif //%.*s\n",
|
||||||
|
string_expand(guard),
|
||||||
|
string_expand(guard),
|
||||||
|
string_expand(guard));
|
||||||
|
end_buffer_insertion(&insert);
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ insert_string__no_buffering(Buffer_Insertion *insertion, String_Const_u8 string)
|
||||||
insertion->at += string.size;
|
insertion->at += string.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
function void
|
||||||
insert__flush(Buffer_Insertion *insertion){
|
insert__flush(Buffer_Insertion *insertion){
|
||||||
Cursor *cursor = insertion->cursor;
|
Cursor *cursor = insertion->cursor;
|
||||||
u64 pos = insertion->temp.temp_memory_cursor.pos;
|
u64 pos = insertion->temp.temp_memory_cursor.pos;
|
||||||
|
@ -53,7 +53,7 @@ insert__flush(Buffer_Insertion *insertion){
|
||||||
end_temp(insertion->temp);
|
end_temp(insertion->temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char*
|
function char*
|
||||||
insert__reserve(Buffer_Insertion *insertion, u64 size){
|
insert__reserve(Buffer_Insertion *insertion, u64 size){
|
||||||
char *space = push_array(insertion->cursor, char, size);
|
char *space = push_array(insertion->cursor, char, size);
|
||||||
if (space == 0){
|
if (space == 0){
|
||||||
|
@ -63,14 +63,14 @@ insert__reserve(Buffer_Insertion *insertion, u64 size){
|
||||||
return(space);
|
return(space);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
function void
|
||||||
end_buffer_insertion(Buffer_Insertion *insertion){
|
end_buffer_insertion(Buffer_Insertion *insertion){
|
||||||
if (insertion->buffering){
|
if (insertion->buffering){
|
||||||
insert__flush(insertion);
|
insert__flush(insertion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
function void
|
||||||
insert_string(Buffer_Insertion *insertion, String_Const_u8 string){
|
insert_string(Buffer_Insertion *insertion, String_Const_u8 string){
|
||||||
if (!insertion->buffering){
|
if (!insertion->buffering){
|
||||||
insert_string__no_buffering(insertion, string);
|
insert_string__no_buffering(insertion, string);
|
||||||
|
@ -86,7 +86,7 @@ insert_string(Buffer_Insertion *insertion, String_Const_u8 string){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static u64
|
function u64
|
||||||
insertf(Buffer_Insertion *insertion, char *format, ...){
|
insertf(Buffer_Insertion *insertion, char *format, ...){
|
||||||
Scratch_Block scratch(insertion->app);
|
Scratch_Block scratch(insertion->app);
|
||||||
va_list args;
|
va_list args;
|
||||||
|
@ -97,12 +97,12 @@ insertf(Buffer_Insertion *insertion, char *format, ...){
|
||||||
return(string.size);
|
return(string.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
function void
|
||||||
insertc(Buffer_Insertion *insertion, char C){
|
insertc(Buffer_Insertion *insertion, char C){
|
||||||
insert_string(insertion, SCu8(&C, 1));
|
insert_string(insertion, SCu8(&C, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
static b32
|
function b32
|
||||||
insert_line_from_buffer(Buffer_Insertion *insertion, Buffer_ID buffer_id, i32 line, i32 truncate_at){
|
insert_line_from_buffer(Buffer_Insertion *insertion, Buffer_ID buffer_id, i32 line, i32 truncate_at){
|
||||||
b32 success = is_valid_line(insertion->app, buffer_id, line);
|
b32 success = is_valid_line(insertion->app, buffer_id, line);
|
||||||
if (success){
|
if (success){
|
||||||
|
@ -112,7 +112,7 @@ insert_line_from_buffer(Buffer_Insertion *insertion, Buffer_ID buffer_id, i32 li
|
||||||
return(success);
|
return(success);
|
||||||
}
|
}
|
||||||
|
|
||||||
static b32
|
function b32
|
||||||
insert_line_from_buffer(Buffer_Insertion *insertion, Buffer_ID buffer_id, i32 line){
|
insert_line_from_buffer(Buffer_Insertion *insertion, Buffer_ID buffer_id, i32 line){
|
||||||
return(insert_line_from_buffer(insertion, buffer_id, line, 0));
|
return(insert_line_from_buffer(insertion, buffer_id, line, 0));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue