fstr_bool string_set_match(
String *str_set,
int32_t count,
String str,
int32_t *match_index
)
diff --git a/4coder_custom_api.h b/4coder_custom_api.h
index 07ac0fe0..bb6da8ff 100644
--- a/4coder_custom_api.h
+++ b/4coder_custom_api.h
@@ -41,7 +41,8 @@
#define END_QUERY_BAR_SIG(n) void n(Application_Links *app, Query_Bar *bar, uint32_t flags)
#define PRINT_MESSAGE_SIG(n) void n(Application_Links *app, char *str, int32_t len)
#define CHANGE_THEME_SIG(n) void n(Application_Links *app, char *name, int32_t len)
-#define CHANGE_FONT_SIG(n) void n(Application_Links *app, char *name, int32_t len)
+#define CHANGE_FONT_SIG(n) void n(Application_Links *app, char *name, int32_t len, bool32 apply_to_all_files)
+#define BUFFER_SET_FONT_SIG(n) void n(Application_Links *app, Buffer_Summary *buffer, char *name, int32_t len)
#define SET_THEME_COLORS_SIG(n) void n(Application_Links *app, Theme_Color *colors, int32_t count)
#define GET_THEME_COLORS_SIG(n) void n(Application_Links *app, Theme_Color *colors, int32_t count)
#define DIRECTORY_GET_HOT_SIG(n) int32_t n(Application_Links *app, char *out, int32_t capacity)
@@ -99,6 +100,7 @@ extern "C"{
typedef PRINT_MESSAGE_SIG(Print_Message_Function);
typedef CHANGE_THEME_SIG(Change_Theme_Function);
typedef CHANGE_FONT_SIG(Change_Font_Function);
+ typedef BUFFER_SET_FONT_SIG(Buffer_Set_Font_Function);
typedef SET_THEME_COLORS_SIG(Set_Theme_Colors_Function);
typedef GET_THEME_COLORS_SIG(Get_Theme_Colors_Function);
typedef DIRECTORY_GET_HOT_SIG(Directory_Get_Hot_Function);
@@ -159,6 +161,7 @@ struct Application_Links{
Print_Message_Function *print_message;
Change_Theme_Function *change_theme;
Change_Font_Function *change_font;
+ Buffer_Set_Font_Function *buffer_set_font;
Set_Theme_Colors_Function *set_theme_colors;
Get_Theme_Colors_Function *get_theme_colors;
Directory_Get_Hot_Function *directory_get_hot;
@@ -221,6 +224,7 @@ app_links->end_query_bar = End_Query_Bar;\
app_links->print_message = Print_Message;\
app_links->change_theme = Change_Theme;\
app_links->change_font = Change_Font;\
+app_links->buffer_set_font = Buffer_Set_Font;\
app_links->set_theme_colors = Set_Theme_Colors;\
app_links->get_theme_colors = Get_Theme_Colors;\
app_links->directory_get_hot = Directory_Get_Hot;\
diff --git a/4coder_default_bindings.cpp b/4coder_default_bindings.cpp
index 9d52437e..5bc129b1 100644
--- a/4coder_default_bindings.cpp
+++ b/4coder_default_bindings.cpp
@@ -126,16 +126,16 @@ CUSTOM_COMMAND_SIG(seek_whitespace_down_end_line){
}
HOOK_SIG(my_start){
+ init_memory(app);
+
+ app->change_theme(app, literal("4coder"));
+ app->change_font(app, literal("Liberation Sans"), true);
+
exec_command(app, open_panel_vsplit);
exec_command(app, hide_scrollbar);
exec_command(app, change_active_panel);
exec_command(app, hide_scrollbar);
- app->change_theme(app, literal("4coder"));
- app->change_font(app, literal("Liberation Sans"));
-
- init_memory(app);
-
// Theme options:
// "4coder"
// "Handmade Hero"
diff --git a/4coder_default_building.cpp b/4coder_default_building.cpp
index 6e702347..e61c468d 100644
--- a/4coder_default_building.cpp
+++ b/4coder_default_building.cpp
@@ -37,6 +37,9 @@ CUSTOM_COMMAND_SIG(build_in_build_panel){
execute_standard_build(app, &build_view, &original_buffer);
+ buffer = app->get_buffer_by_name(app, literal("*compilation*"), AccessAll);
+ app->buffer_set_font(app, &buffer, literal("Inconsolata"));
+
prev_location = null_location;
}
diff --git a/4coder_jump_parsing.cpp b/4coder_jump_parsing.cpp
index 213797ea..fe280333 100644
--- a/4coder_jump_parsing.cpp
+++ b/4coder_jump_parsing.cpp
@@ -119,15 +119,19 @@ parse_error(String line, Jump_Location *location,
int colon_pos1 = find(line, 0, ':');
int colon_pos2 = find(line, colon_pos1+1, ':');
- String filename = substr(line, 0, colon_pos1);
- String line_number = substr(line, colon_pos1+1, colon_pos2 - colon_pos1 - 1);
-
- if (filename.size > 0 && line_number.size > 0){
- location->file = filename;
- location->line = str_to_int(line_number);
- location->column = 0;
- *colon_char = colon_pos2;
- result = true;
+ if (colon_pos2 < line.size){
+ String filename = substr(line, 0, colon_pos1);
+ String line_number = substr(line, colon_pos1+1, colon_pos2 - colon_pos1 - 1);
+
+ if (str_is_int(line_number)){
+ if (filename.size > 0 && line_number.size > 0){
+ location->file = filename;
+ location->line = str_to_int(line_number);
+ location->column = 0;
+ *colon_char = colon_pos2;
+ result = true;
+ }
+ }
}
}
}
diff --git a/4coder_string.h b/4coder_string.h
index 21c8ad42..0a8e2f09 100644
--- a/4coder_string.h
+++ b/4coder_string.h
@@ -133,6 +133,7 @@ FSTRING_LINK fstr_bool append_u64_to_str(String *dest, uint64_t x);
FSTRING_LINK int32_t float_to_str_size(float x);
FSTRING_LINK fstr_bool append_float_to_str(String *dest, float x);
FSTRING_LINK fstr_bool float_to_str(String *dest, float x);
+FSTRING_LINK fstr_bool str_is_int(String str);
FSTRING_LINK int32_t str_to_int(char *str);
FSTRING_LINK int32_t str_to_int(String str);
FSTRING_LINK int32_t hexchar_to_int(char c);
@@ -1332,6 +1333,20 @@ float_to_str(String *dest, float x){
}
#endif
+#ifdef FSTRING_IMPLEMENTATION
+FSTRING_LINK fstr_bool
+str_is_int(String str){
+ fstr_bool result = true;
+ for (int32_t i = 0; i < str.size; ++i){
+ if (!char_is_numeric(str.str[i])){
+ result = false;
+ break;
+ }
+ }
+ return(result);
+}
+#endif
+
#ifdef FSTRING_IMPLEMENTATION
FSTRING_LINK int32_t
str_to_int(char *str){
diff --git a/4coder_types.h b/4coder_types.h
index d3864931..49c34180 100644
--- a/4coder_types.h
+++ b/4coder_types.h
@@ -1,6 +1,5 @@
-
/* DOC(bool32 is an alias name to signal that an integer parameter or field is for
true/false vales.) */
typedef int32_t bool32;
@@ -18,7 +17,7 @@ when a buffer is closed it's id may be recycled by future, different buffers.) *
typedef int32_t Buffer_ID;
/* DOC(View_ID is used to name a 4coder view. Each view has a unique id in
-the range [1,16].) */
+the interval [1,16].) */
typedef int32_t View_ID;
#define ENUM(type,name) typedef type name; enum name##_
diff --git a/4ed.cpp b/4ed.cpp
index 3d5e5079..f2e0603c 100644
--- a/4ed.cpp
+++ b/4ed.cpp
@@ -833,7 +833,6 @@ app_hardcode_styles(Models *models){
i16 fonts = 1;
models->global_font.font_id = fonts + 0;
- models->global_font.font_changed = 0;
/////////////////
style_set_name(style, make_lit_string("4coder"));
@@ -1697,17 +1696,6 @@ App_Step_Sig(app_step){
}
}
- // NOTE(allen): begin allowing the cursors and scroll locations
- // to move around.
- {
- Panel *panel = 0, *used_panels = 0;
- used_panels = &models->layout.used_sentinel;
- for (dll_items(panel, used_panels)){
- Assert(panel->view);
- view_begin_cursor_scroll_updates(panel->view);
- }
- }
-
// NOTE(allen): reorganizing panels on screen
{
i32 prev_width = models->layout.full_width;
@@ -2319,17 +2307,6 @@ App_Step_Sig(app_step){
update_command_data(vars, cmd);
- // NOTE(allen): post scroll vars back to the view's gui targets
- {
- Panel *panel = 0, *used_panels = 0;
-
- used_panels = &models->layout.used_sentinel;
- for (dll_items(panel, used_panels)){
- Assert(panel->view);
- view_end_cursor_scroll_updates(panel->view);
- }
- }
-
// NOTE(allen): command execution
{
Key_Summary key_data = get_key_data(&vars->available_input);
@@ -2631,39 +2608,6 @@ App_Step_Sig(app_step){
}
}
- // NOTE(allen): send style change messages if the style has changed
- if (models->global_font.font_changed){
- models->global_font.font_changed = 0;
-
- File_Node *node, *used_nodes;
- Editing_File *file;
- Render_Font *font = get_font_info(models->font_set, models->global_font.font_id)->font;
- float *advance_data = 0;
- if (font) advance_data = font->advance_data;
-
- used_nodes = &models->working_set.used_sentinel;
- for (dll_items(node, used_nodes)){
- file = (Editing_File*)node;
- file_measure_starts_widths(system, &models->mem.general, &file->state.buffer, advance_data);
- }
-
- Panel *panel, *used_panels;
- used_panels = &models->layout.used_sentinel;
- for (dll_items(panel, used_panels)){
- update_view_line_height(models, panel->view);
- remeasure_file_view(system, panel->view);
- }
- }
-
- // NOTE(allen): post scroll vars back to the view's gui targets
- {
- Panel *panel = 0, *used_panels = &models->layout.used_sentinel;
- for (dll_items(panel, used_panels)){
- Assert(panel->view);
- view_end_cursor_scroll_updates(panel->view);
- }
- }
-
// NOTE(allen): on the first frame there should be no scrolling
if (input->first_step){
Panel *panel = 0, *used_panels = &models->layout.used_sentinel;
diff --git a/4ed_api_implementation.cpp b/4ed_api_implementation.cpp
index 31625710..39568e74 100644
--- a/4ed_api_implementation.cpp
+++ b/4ed_api_implementation.cpp
@@ -791,16 +791,6 @@ DOC_SEE(Buffer_Batch_Edit_Type)
bool32 result = false;
- app->print_message(app, literal("Buffer_Batch_Edit:\n"));
- {
- char space[512];
- String str = make_fixed_width_string(space);
- append(&str, "edit_count: ");
- append_int_to_str(&str, edit_count);
- append(&str, '\n');
- app->print_message(app, str.str, str.size);
- }
-
if (file){
Temp_Memory temp = begin_temp_memory(part);
Buffer_Edit *inverse_edits = push_array(part, Buffer_Edit, edit_count);
@@ -832,7 +822,6 @@ DOC_SEE(Buffer_Setting_ID)
Command_Data *cmd = (Command_Data*)app->cmd_context;
System_Functions *system = cmd->system;
Models *models = cmd->models;
-
Editing_File *file = imp_get_file(cmd, buffer);
bool32 result = false;
@@ -1738,28 +1727,6 @@ DOC_SEE(int_color)
return(result);
}
-/*
-API_EXPORT void
-View_Set_Paste_Rewrite_(Application_Links *app, View_Summary *view){
- Command_Data *cmd = (Command_Data*)app->cmd_context;
- View *vptr = imp_get_view(cmd, view);
- if (vptr){
- vptr->next_mode.rewrite = true;
- }
-}
-
-API_EXPORT int
-View_Get_Paste_Rewrite_(Application_Links *app, View_Summary *view){
- Command_Data *cmd = (Command_Data*)app->cmd_context;
- View *vptr = imp_get_view(cmd, view);
- int result = false;
- if (vptr){
- result = vptr->mode.rewrite;
- }
- return(result);
-}
-*/
-
API_EXPORT User_Input
Get_User_Input(Application_Links *app, Input_Type_Flag get_type, Input_Type_Flag abort_type)/*
DOC_PARAM(get_type, The get_type parameter specifies the set of input types that should be returned.)
@@ -1895,7 +1862,7 @@ API_EXPORT void
Change_Theme(Application_Links *app, char *name, int32_t len)/*
DOC_PARAM(name, The name parameter specifies the name of the theme to begin using; it need not be null terminated.)
DOC_PARAM(len, The len parameter specifies the length of the name string.)
-DOC(This call changes 4coder's theme to one of the built in themes.)
+DOC(This call changes 4coder's color pallet to one of the built in themes.)
*/{
Command_Data *cmd = (Command_Data*)app->cmd_context;
Style_Library *styles = &cmd->models->styles;
@@ -1914,20 +1881,55 @@ DOC(This call changes 4coder's theme to one of the built in themes.)
}
API_EXPORT void
-Change_Font(Application_Links *app, char *name, int32_t len)/*
+Change_Font(Application_Links *app, char *name, int32_t len, bool32 apply_to_all_files)/*
DOC_PARAM(name, The name parameter specifies the name of the font to begin using; it need not be null terminated.)
DOC_PARAM(len, The len parameter specifies the length of the name string.)
-DOC(This call changes 4coder's font to one of the built in fonts.)
+DOC_PARAM(apply_to_all_files, If this is set all open files change to this font. Usually this should be true
+durring the start hook because several files already exist at that time.)
+DOC(This call changes 4coder's default font to one of the built in fonts.)
*/{
Command_Data *cmd = (Command_Data*)app->cmd_context;
Font_Set *set = cmd->models->font_set;
+
Style_Font *global_font = &cmd->models->global_font;
String font_name = make_string(name, len);
i16 font_id = 0;
if (font_set_extract(set, font_name, &font_id)){
global_font->font_id = font_id;
- global_font->font_changed = 1;
+
+ if (apply_to_all_files){
+ System_Functions *system = cmd->system;
+ Models *models = cmd->models;
+
+ File_Node *node = 0;
+ File_Node *sentinel = &models->working_set.used_sentinel;
+ for (dll_items(node, sentinel)){
+ Editing_File *file = (Editing_File*)node;
+ file_set_font(system, models, file, font_id);
+ }
+ }
+ }
+}
+
+API_EXPORT void
+Buffer_Set_Font(Application_Links *app, Buffer_Summary *buffer, char *name, int32_t len)/*
+DOC_PARAM(buffer, This parameter the buffer that shall have it's font changed)
+DOC_PARAM(name, The name parameter specifies the name of the font to begin using; it need not be null terminated.)
+DOC_PARAM(len, The len parameter specifies the length of the name string.)
+DOC(This call sets the display font of a particular buffer.)
+*/{
+ Command_Data *cmd = (Command_Data*)app->cmd_context;
+ System_Functions *system = cmd->system;
+ Models *models = cmd->models;
+ Editing_File *file = imp_get_file(cmd, buffer);
+
+ Font_Set *set = models->font_set;
+ String font_name = make_string(name, len);
+ i16 font_id = 0;
+
+ if (font_set_extract(set, font_name, &font_id)){
+ file_set_font(system, models, file, font_id);
}
}
diff --git a/4ed_file.cpp b/4ed_file.cpp
index 53ba3864..1dbe3d45 100644
--- a/4ed_file.cpp
+++ b/4ed_file.cpp
@@ -119,6 +119,7 @@ struct Text_Effect{
struct Editing_File_Settings{
i32 base_map_id;
i32 dos_write_mode;
+ i16 font_id;
b8 unwrapped_lines;
b8 tokens_exist;
b8 is_initialized;
diff --git a/4ed_file_view.cpp b/4ed_file_view.cpp
index c08b812f..6d426ff9 100644
--- a/4ed_file_view.cpp
+++ b/4ed_file_view.cpp
@@ -414,7 +414,7 @@ inline Full_Cursor
view_compute_cursor_from_pos(View *view, i32 pos){
Editing_File *file = view->file_data.file;
Models *models = view->persistent.models;
- Render_Font *font = get_font_info(models->font_set, models->global_font.font_id)->font;
+ Render_Font *font = get_font_info(models->font_set, file->settings.font_id)->font;
Full_Cursor result = {};
if (font){
@@ -429,7 +429,7 @@ inline Full_Cursor
view_compute_cursor_from_unwrapped_xy(View *view, f32 seek_x, f32 seek_y, b32 round_down = 0){
Editing_File *file = view->file_data.file;
Models *models = view->persistent.models;
- Render_Font *font = get_font_info(models->font_set, models->global_font.font_id)->font;
+ Render_Font *font = get_font_info(models->font_set, file->settings.font_id)->font;
Full_Cursor result = {};
if (font){
@@ -445,7 +445,7 @@ internal Full_Cursor
view_compute_cursor_from_wrapped_xy(View *view, f32 seek_x, f32 seek_y, b32 round_down = 0){
Editing_File *file = view->file_data.file;
Models *models = view->persistent.models;
- Render_Font *font = get_font_info(models->font_set, models->global_font.font_id)->font;
+ Render_Font *font = get_font_info(models->font_set, file->settings.font_id)->font;
Full_Cursor result = {};
if (font){
@@ -462,7 +462,7 @@ internal Full_Cursor
view_compute_cursor_from_line_pos(View *view, i32 line, i32 pos){
Editing_File *file = view->file_data.file;
Models *models = view->persistent.models;
- Render_Font *font = get_font_info(models->font_set, models->global_font.font_id)->font;
+ Render_Font *font = get_font_info(models->font_set, file->settings.font_id)->font;
Full_Cursor result = {};
if (font){
@@ -1046,22 +1046,22 @@ file_create_from_string(System_Functions *system, Models *models,
General_Memory *general = &models->mem.general;
Partition *part = &models->mem.part;
Buffer_Init_Type init;
- i32 page_size, scratch_size, init_success;
file->state = editing_file_state_zero();
init = buffer_begin_init(&file->state.buffer, val.str, val.size);
for (; buffer_init_need_more(&init); ){
- page_size = buffer_init_page_size(&init);
+ i32 page_size = buffer_init_page_size(&init);
page_size = LargeRoundUp(page_size, Kbytes(4));
if (page_size < Kbytes(4)) page_size = Kbytes(4);
void *data = general_memory_allocate(general, page_size);
buffer_init_provide_page(&init, data, page_size);
}
- scratch_size = partition_remaining(part);
+ i32 scratch_size = partition_remaining(part);
Assert(scratch_size > 0);
- init_success = buffer_end_init(&init, part->base + part->pos, scratch_size);
+
+ b32 init_success = buffer_end_init(&init, part->base + part->pos, scratch_size);
AllowLocal(init_success);
Assert(init_success);
@@ -1076,6 +1076,7 @@ file_create_from_string(System_Functions *system, Models *models,
file_synchronize_times(system, file, name);
i16 font_id = models->global_font.font_id;
+ file->settings.font_id = font_id;
Render_Font *font = get_font_info(font_set, font_id)->font;
float *advance_data = 0;
if (font) advance_data = font->advance_data;
@@ -1735,6 +1736,12 @@ file_view_nullify_file(View *view){
view->file_data = file_viewing_data_zero();
}
+internal void
+update_view_line_height(Models *models, View *view, i16 font_id){
+ Render_Font *font = get_font_info(models->font_set, font_id)->font;
+ view->line_height = font->height;
+}
+
internal void
view_set_file(View *view, Editing_File *file, Models *models){
if (view->file_data.file != 0){
@@ -1760,6 +1767,11 @@ view_set_file(View *view, Editing_File *file, Models *models){
if (file_is_ready(file)){
view_measure_wraps(&models->mem.general, view);
}
+
+ update_view_line_height(models, view, file->settings.font_id);
+ }
+ else{
+ update_view_line_height(models, view, models->global_font.font_id);
}
}
@@ -2150,7 +2162,7 @@ file_do_single_edit(System_Functions *system,
i32 new_line_count = buffer_count_newlines(&file->state.buffer, start, start+str_len);
i32 line_shift = new_line_count - replaced_line_count;
- i16 font_id = models->global_font.font_id;
+ i16 font_id = file->settings.font_id;
Render_Font *font = get_font_info(models->font_set, font_id)->font;
file_grow_starts_widths_as_needed(general, buffer, line_shift);
@@ -2224,7 +2236,7 @@ file_do_batch_edit(System_Functions *system, Models *models, Editing_File *file,
// NOTE(allen): meta data
{
Buffer_Measure_Starts state = {};
- i16 font_id = models->global_font.font_id;
+ i16 font_id = file->settings.font_id;
Render_Font *font = get_font_info(models->font_set, font_id)->font;
float *advance_data = 0;
if (font) advance_data = font->advance_data;
@@ -3078,12 +3090,6 @@ style_get_color(Style *style, Cpp_Token token){
return result;
}
-internal void
-update_view_line_height(Models *models, View *view){
- Font_Info *fnt_info = get_font_info(models->font_set, models->global_font.font_id);
- view->line_height = fnt_info->height;
-}
-
internal void
remeasure_file_view(System_Functions *system, View *view){
if (file_is_ready(view->file_data.file)){
@@ -3099,6 +3105,22 @@ remeasure_file_view(System_Functions *system, View *view){
}
}
+internal void
+file_set_font(System_Functions *system, Models *models, Editing_File *file, i16 font_id){
+ Render_Font *font = get_font_info(models->font_set, font_id)->font;
+ f32 *advance_data = font->advance_data;
+ file->settings.font_id = font_id;
+ file_measure_starts_widths(system, &models->mem.general, &file->state.buffer, advance_data);
+
+ Editing_Layout *layout = &models->layout;
+ for (View_Iter iter = file_view_iter_init(layout, file, 0);
+ file_view_iter_good(iter);
+ iter = file_view_iter_next(iter)){
+ update_view_line_height(models, iter.view, font_id);
+ remeasure_file_view(system, iter.view);
+ }
+}
+
inline void
view_show_GUI(View *view, View_UI ui){
view->map = &view->persistent.models->map_ui;
@@ -3586,48 +3608,6 @@ view_reinit_scrolling(View *view){
return(scroll);
}
-// TODO(allen): GTFO!
-internal void
-view_begin_cursor_scroll_updates(View *view){
-
-#if 0
- if (view->file_data.file && view->file_data.file == view->prev_context.file){
- Assert(view->prev_cursor_pos == view_get_cursor_pos(view));
- }
-#endif
-
-}
-
-internal void
-view_end_cursor_scroll_updates(View *view){
-
-#if 0
- if (view->edit_pos){
- i32 set_type = view->edit_pos->last_set_type;
-
- switch (set_type){
- case EditPos_None: break;
-
- case EditPos_CursorSet:
- {
- if (view->gui_target.did_file){
- view->edit_pos->scroll.max_y = view_compute_max_target_y(view);
- }
- view_move_view_to_cursor(view, &view->edit_pos->scroll, false);
- gui_post_scroll_vars(&view->gui_target, &view->edit_pos->scroll, view->scroll_region);
- }break;
-
- case EditPos_ScrollSet:
- {
- view_move_cursor_to_view(view, view->edit_pos->scroll);
- gui_post_scroll_vars(&view->gui_target, &view->edit_pos->scroll, view->scroll_region);
- }break;
- }
- }
-#endif
-
-}
-
internal b32
file_step(View *view, i32_Rect region, Input_Summary *user_input, b32 is_active, b32 *consumed_l){
i32 is_animating = 0;
@@ -4079,12 +4059,6 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
scroll_context.id[1] = view->showing_ui;
scroll_context.id[0] = (u64)(view->file_data.file);
- // TODO(allen): ????
-
-#if 0
- gui_get_scroll_vars(target, scroll_context, &view->scroll_region);
-#endif
-
GUI_Scroll_Vars scroll_zero = {0};
GUI_Scroll_Vars *scroll = &scroll_zero;
@@ -4168,9 +4142,12 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
}
message = make_lit_string("Set Font");
- id.id[0] = (u64)(&models->global_font);
- if (gui_do_button(target, id, message)){
- view->color_mode = CV_Mode_Font;
+ if (view->file_data.file){
+ id.id[0] = (u64)(&view->file_data.file->settings.font_id);
+
+ if (gui_do_button(target, id, message)){
+ view->color_mode = CV_Mode_Font;
+ }
}
message = make_lit_string("Theme Library - Click to Select");
@@ -4198,11 +4175,12 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
case CV_Mode_Font:
{
+ Assert(view->file_data.file);
+
Font_Set *font_set = models->font_set;
Font_Info *info = 0;
i16 i = 1, count = (i16)models->font_set->count + 1;
- i16 font_id = 0, new_font_id = 0;
String message = make_lit_string("Back");
@@ -4211,8 +4189,8 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
view->color_mode = CV_Mode_Library;
}
- font_id = models->global_font.font_id;
- new_font_id = font_id;
+ i16 font_id = view->file_data.file->settings.font_id;
+ i16 new_font_id = font_id;
for (i = 1; i < count; ++i){
info = get_font_info(font_set, i);
@@ -4231,7 +4209,7 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
}
}
- models->global_font.font_id = (i16)(new_font_id);
+ file_set_font(system, models, view->file_data.file, new_font_id);
}break;
case CV_Mode_Adjusting:
@@ -5341,7 +5319,7 @@ draw_file_loaded(View *view, i32_Rect rect, b32 is_active, Render_Target *target
i32 max = partition_remaining(part) / sizeof(Buffer_Render_Item);
Buffer_Render_Item *items = push_array(part, Buffer_Render_Item, max);
- i16 font_id = models->global_font.font_id;
+ i16 font_id = file->settings.font_id;
Render_Font *font = get_font_info(models->font_set, font_id)->font;
float *advance_data = 0;
if (font) advance_data = font->advance_data;
@@ -5496,7 +5474,8 @@ draw_file_loaded(View *view, i32_Rect rect, b32 is_active, Render_Target *target
}
internal void
-draw_text_field(Render_Target *target, View *view, i32_Rect rect, String p, String t){
+draw_text_field(Render_Target *target, View *view, i16 font_id,
+ i32_Rect rect, String p, String t){
Models *models = view->persistent.models;
Style *style = main_style(models);
@@ -5507,8 +5486,6 @@ draw_text_field(Render_Target *target, View *view, i32_Rect rect, String p, Stri
i32 x = rect.x0;
i32 y = rect.y0 + 2;
- i16 font_id = models->global_font.font_id;
-
if (target){
draw_rectangle(target, rect, back_color);
x = CEIL32(draw_string(target, font_id, p, x, y, text2_color));
@@ -5517,7 +5494,8 @@ draw_text_field(Render_Target *target, View *view, i32_Rect rect, String p, Stri
}
internal void
-draw_text_with_cursor(Render_Target *target, View *view, i32_Rect rect, String s, i32 pos){
+draw_text_with_cursor(Render_Target *target, View *view, i16 font_id,
+ i32_Rect rect, String s, i32 pos){
Models *models = view->persistent.models;
Style *style = main_style(models);
@@ -5529,8 +5507,6 @@ draw_text_with_cursor(Render_Target *target, View *view, i32_Rect rect, String s
f32 x = (f32)rect.x0;
i32 y = rect.y0 + 2;
- i16 font_id = models->global_font.font_id;
-
if (target){
draw_rectangle(target, rect, back_color);
@@ -5565,7 +5541,6 @@ internal void
draw_file_bar(Render_Target *target, View *view, Editing_File *file, i32_Rect rect){
File_Bar bar;
Models *models = view->persistent.models;
- Style_Font *font = &models->global_font;
Style *style = main_style(models);
Interactive_Style bar_style = style->main.file_info_style;
@@ -5577,7 +5552,7 @@ draw_file_bar(Render_Target *target, View *view, Editing_File *file, i32_Rect re
bar.rect = rect;
if (target){
- bar.font_id = font->font_id;
+ bar.font_id = file->settings.font_id;
bar.pos_x = (f32)bar.rect.x0;
bar.pos_y = (f32)bar.rect.y0;
bar.text_shift_y = 2;
@@ -5660,11 +5635,8 @@ get_margin_color(i32 active_level, Style *style){
internal void
draw_color_button(GUI_Target *gui_target, Render_Target *target, View *view,
- i32_Rect rect, GUI_id id, u32 fore, u32 back, String text){
- Models *models = view->persistent.models;
-
+ i16 font_id, i32_Rect rect, GUI_id id, u32 fore, u32 back, String text){
i32 active_level = gui_active_level(gui_target, id);
- i16 font_id = models->global_font.font_id;
if (active_level > 0){
Swap(u32, back, fore);
@@ -5692,13 +5664,13 @@ draw_font_button(GUI_Target *gui_target, Render_Target *target, View *view,
}
internal void
-draw_fat_option_block(GUI_Target *gui_target, Render_Target *target, View *view, i32_Rect rect, GUI_id id,
+draw_fat_option_block(GUI_Target *gui_target, Render_Target *target, View *view,
+ i16 font_id, i32_Rect rect, GUI_id id,
String text, String pop, i8 checkbox = -1){
Models *models = view->persistent.models;
Style *style = main_style(models);
i32 active_level = gui_active_level(gui_target, id);
- i16 font_id = models->global_font.font_id;
i32_Rect inner = get_inner_rect(rect, 3);
@@ -5734,12 +5706,12 @@ draw_fat_option_block(GUI_Target *gui_target, Render_Target *target, View *view,
}
internal void
-draw_button(GUI_Target *gui_target, Render_Target *target, View *view, i32_Rect rect, GUI_id id, String text){
+draw_button(GUI_Target *gui_target, Render_Target *target, View *view,
+ i16 font_id, i32_Rect rect, GUI_id id, String text){
Models *models = view->persistent.models;
Style *style = main_style(models);
i32 active_level = gui_active_level(gui_target, id);
- i16 font_id = models->global_font.font_id;
i32_Rect inner = get_inner_rect(rect, 3);
@@ -5760,11 +5732,11 @@ draw_button(GUI_Target *gui_target, Render_Target *target, View *view, i32_Rect
}
internal void
-draw_style_preview(GUI_Target *gui_target, Render_Target *target, View *view, i32_Rect rect, GUI_id id, Style *style){
+draw_style_preview(GUI_Target *gui_target, Render_Target *target, View *view,
+ i16 font_id, i32_Rect rect, GUI_id id, Style *style){
Models *models = view->persistent.models;
i32 active_level = gui_active_level(gui_target, id);
- i16 font_id = models->global_font.font_id;
Font_Info *info = get_font_info(models->font_set, font_id);
i32_Rect inner = get_inner_rect(rect, 3);
@@ -5819,6 +5791,11 @@ do_render_file_view(System_Functions *system, View *view, GUI_Scroll_Vars *scrol
i32 max_y = view_compute_max_target_y(view);
+ i16 font_id = 0;
+ if (file){
+ font_id = file->settings.font_id;
+ }
+
if (gui_target->push.pos > 0){
gui_session_init(&gui_session, gui_target, rect, view->line_height);
@@ -5857,7 +5834,7 @@ do_render_file_view(System_Functions *system, View *view, GUI_Scroll_Vars *scrol
void *ptr = (h+1);
String p = gui_read_string(&ptr);
String t = gui_read_string(&ptr);
- draw_text_field(target, view, gui_session.rect, p, t);
+ draw_text_field(target, view, font_id, gui_session.rect, p, t);
}break;
case guicom_text_with_cursor:
@@ -5866,7 +5843,7 @@ do_render_file_view(System_Functions *system, View *view, GUI_Scroll_Vars *scrol
String s = gui_read_string(&ptr);
i32 pos = gui_read_integer(&ptr);
- draw_text_with_cursor(target, view, gui_session.rect, s, pos);
+ draw_text_with_cursor(target, view, font_id, gui_session.rect, s, pos);
}break;
case guicom_color_button:
@@ -5877,7 +5854,7 @@ do_render_file_view(System_Functions *system, View *view, GUI_Scroll_Vars *scrol
u32 back = (u32)gui_read_integer(&ptr);
String t = gui_read_string(&ptr);
- draw_color_button(gui_target, target, view, gui_session.rect, b->id, fore, back, t);
+ draw_color_button(gui_target, target, view, font_id, gui_session.rect, b->id, fore, back, t);
}break;
case guicom_font_button:
@@ -5902,7 +5879,7 @@ do_render_file_view(System_Functions *system, View *view, GUI_Scroll_Vars *scrol
append(&f, system->slash);
}
- draw_fat_option_block(gui_target, target, view, gui_session.rect, b->id, f, m);
+ draw_fat_option_block(gui_target, target, view, font_id, gui_session.rect, b->id, f, m);
}break;
case guicom_style_preview:
@@ -5911,7 +5888,7 @@ do_render_file_view(System_Functions *system, View *view, GUI_Scroll_Vars *scrol
i32 style_index = *(i32*)(b + 1);
Style *style = get_style(view->persistent.models, style_index);
- draw_style_preview(gui_target, target, view, gui_session.rect, b->id, style);
+ draw_style_preview(gui_target, target, view, font_id, gui_session.rect, b->id, style);
}break;
case guicom_fixed_option:
@@ -5927,7 +5904,7 @@ do_render_file_view(System_Functions *system, View *view, GUI_Scroll_Vars *scrol
status = (i8)gui_read_byte(&ptr);
}
- draw_fat_option_block(gui_target, target, view, gui_session.rect, b->id, f, m, status);
+ draw_fat_option_block(gui_target, target, view, font_id, gui_session.rect, b->id, f, m, status);
}break;
case guicom_button:
@@ -5936,7 +5913,7 @@ do_render_file_view(System_Functions *system, View *view, GUI_Scroll_Vars *scrol
void *ptr = (b + 1);
String t = gui_read_string(&ptr);
- draw_button(gui_target, target, view, gui_session.rect, b->id, t);
+ draw_button(gui_target, target, view, font_id, gui_session.rect, b->id, t);
}break;
case guicom_scrollable_bar:
@@ -6061,8 +6038,6 @@ live_set_alloc_view(Live_Views *live_set, Panel *panel, Models *models){
result.view->persistent.models = models;
- update_view_line_height(models, result.view);
-
init_query_set(&result.view->query_set);
{
diff --git a/4ed_style.cpp b/4ed_style.cpp
index 99f629ee..d0413575 100644
--- a/4ed_style.cpp
+++ b/4ed_style.cpp
@@ -11,7 +11,6 @@
struct Style_Font{
i16 font_id;
- i16 font_changed;
};
struct Style{
diff --git a/README.txt b/README.txt
index 9168ed98..84b3d518 100644
--- a/README.txt
+++ b/README.txt
@@ -1,4 +1,4 @@
-Distribution Date: 12.7.2016 (dd.mm.yyyy)
+Distribution Date: 14.7.2016 (dd.mm.yyyy)
Thank you for contributing to the 4coder project!
diff --git a/internal_4coder_string.cpp b/internal_4coder_string.cpp
index ff8c319b..52db6bd0 100644
--- a/internal_4coder_string.cpp
+++ b/internal_4coder_string.cpp
@@ -1250,9 +1250,22 @@ space in dest this call returns non-zero.) */{
return(result);
}
+FSTRING_LINK fstr_bool
+str_is_int(String str)/*
+DOC(If str is a valid string representation of an integer, this call returns non-zero.) */{
+ fstr_bool result = true;
+ for (int32_t i = 0; i < str.size; ++i){
+ if (!char_is_numeric(str.str[i])){
+ result = false;
+ break;
+ }
+ }
+ return(result);
+}
+
FSTRING_LINK int32_t
str_to_int(char *str)/*
-DOC(If str represents a valid string representation of an integer, this call will return
+DOC(If str is a valid string representation of an integer, this call will return
the integer represented by the string. Otherwise this call returns zero.) */{
int32_t x = 0;
for (; *str; ++str){
diff --git a/power/4coder_experiments.cpp b/power/4coder_experiments.cpp
index 5286852f..86949d36 100644
--- a/power/4coder_experiments.cpp
+++ b/power/4coder_experiments.cpp
@@ -190,8 +190,8 @@ CUSTOM_COMMAND_SIG(save_theme_settings){
#include
#define SETTINGS_FILE ".4coder_settings"
-HOOK_SIG(experimental_start_hook){
- my_start(app);
+HOOK_SIG(experimental_start){
+ init_memory(app);
char theme_name[128];
char font_name[128];
@@ -217,8 +217,16 @@ HOOK_SIG(experimental_start_hook){
fclose(file);
- app->change_theme(app, theme_name, (int)strlen(theme_name));
- app->change_font(app, font_name, (int)strlen(font_name));
+ int theme_len = (int)strlen(theme_name);
+ int font_len = (int)strlen(font_name);
+
+ app->change_theme(app, theme_name, theme_len);
+ app->change_font(app, font_name, font_len, true);
+
+ exec_command(app, open_panel_vsplit);
+ exec_command(app, hide_scrollbar);
+ exec_command(app, change_active_panel);
+ exec_command(app, hide_scrollbar);
}
return(0);
@@ -229,7 +237,7 @@ get_bindings(void *data, int size){
Bind_Helper context_ = begin_bind_helper(data, size);
Bind_Helper *context = &context_;
- set_hook(context, hook_start, experimental_start_hook);
+ set_hook(context, hook_start, experimental_start);
set_open_file_hook(context, my_file_settings);
set_input_filter(context, my_suppress_mouse_filter);
set_command_caller(context, default_command_caller);