4coder_handmade_hero.cpp ready to go
This commit is contained in:
parent
6e1abb4237
commit
d71d10434a
|
@ -1,11 +1,8 @@
|
||||||
/*
|
// Alternative customizations, set Custom_Current to select which to apply.
|
||||||
* Example use of customization API
|
#define Custom_Default 0
|
||||||
*/
|
#define Custom_HandmadeHero 1
|
||||||
|
|
||||||
// NOTE(allen): See exec_command and surrounding code in 4coder_helper.h
|
#define Custom_Current Custom_Default
|
||||||
// to decide whether you want macro translations, without them you will
|
|
||||||
// have to manipulate the command and parameter stack through
|
|
||||||
// "app->" which may be more or less clear depending on your use.
|
|
||||||
|
|
||||||
#include "4coder_custom.h"
|
#include "4coder_custom.h"
|
||||||
|
|
||||||
|
@ -30,6 +27,23 @@ enum My_Maps{
|
||||||
HOOK_SIG(my_start){
|
HOOK_SIG(my_start){
|
||||||
exec_command(app, cmdid_open_panel_vsplit);
|
exec_command(app, cmdid_open_panel_vsplit);
|
||||||
exec_command(app, cmdid_change_active_panel);
|
exec_command(app, cmdid_change_active_panel);
|
||||||
|
|
||||||
|
app->change_theme(app, literal("4coder"));
|
||||||
|
app->change_font(app, literal("liberation mono"));
|
||||||
|
|
||||||
|
// Theme options:
|
||||||
|
// "4coder"
|
||||||
|
// "Handmade Hero"
|
||||||
|
// "Twilight"
|
||||||
|
// "Woverine"
|
||||||
|
// "stb"
|
||||||
|
|
||||||
|
// Font options:
|
||||||
|
// "liberation sans"
|
||||||
|
// "liberation mono"
|
||||||
|
// "hack"
|
||||||
|
// "cutive mono"
|
||||||
|
// "inconsolata"
|
||||||
}
|
}
|
||||||
|
|
||||||
HOOK_SIG(my_file_settings){
|
HOOK_SIG(my_file_settings){
|
||||||
|
@ -367,8 +381,10 @@ isearch(Application_Links *app, int start_reversed){
|
||||||
int step_forward = 0;
|
int step_forward = 0;
|
||||||
int step_backward = 0;
|
int step_backward = 0;
|
||||||
|
|
||||||
if (CommandEqual(in.command, search)) step_forward = 1;
|
if (CommandEqual(in.command, search) ||
|
||||||
if (CommandEqual(in.command, reverse_search)) step_backward = 1;
|
in.key.keycode == key_page_down || in.key.keycode == key_down) step_forward = 1;
|
||||||
|
if (CommandEqual(in.command, reverse_search) ||
|
||||||
|
in.key.keycode == key_page_down || in.key.keycode == key_up) step_backward = 1;
|
||||||
|
|
||||||
int start_pos = pos;
|
int start_pos = pos;
|
||||||
if (step_forward && reverse){
|
if (step_forward && reverse){
|
||||||
|
@ -682,7 +698,7 @@ CUSTOM_COMMAND_SIG(execute_arbitrary_command){
|
||||||
// as an example you have everything you need to make it work already. You could
|
// as an example you have everything you need to make it work already. You could
|
||||||
// even use app->memory to create a hash table in the start hook.
|
// even use app->memory to create a hash table in the start hook.
|
||||||
Query_Bar bar;
|
Query_Bar bar;
|
||||||
char space[1024], more_space[1024];
|
char space[1024];
|
||||||
bar.prompt = make_lit_string("Command: ");
|
bar.prompt = make_lit_string("Command: ");
|
||||||
bar.string = make_fixed_width_string(space);
|
bar.string = make_fixed_width_string(space);
|
||||||
|
|
||||||
|
@ -700,20 +716,11 @@ CUSTOM_COMMAND_SIG(execute_arbitrary_command){
|
||||||
else if(match(bar.string, make_lit_string("close all code"))){
|
else if(match(bar.string, make_lit_string("close all code"))){
|
||||||
exec_command(app, close_all_code);
|
exec_command(app, close_all_code);
|
||||||
}
|
}
|
||||||
else if (match(bar.string, make_lit_string("open in quotes"))){
|
|
||||||
exec_command(app, open_file_in_quotes);
|
|
||||||
}
|
|
||||||
else if (match(bar.string, make_lit_string("open menu"))){
|
else if (match(bar.string, make_lit_string("open menu"))){
|
||||||
exec_command(app, cmdid_open_menu);
|
exec_command(app, cmdid_open_menu);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
bar.prompt = make_fixed_width_string(more_space);
|
// TODO(allen): feedback message
|
||||||
append(&bar.prompt, make_lit_string("Unrecognized: "));
|
|
||||||
append(&bar.prompt, bar.string);
|
|
||||||
bar.string.size = 0;
|
|
||||||
|
|
||||||
app->start_query_bar(app, &bar, 0);
|
|
||||||
app->get_user_input(app, EventOnAnyKey | EventOnButton, 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -840,6 +847,8 @@ CUSTOM_COMMAND_SIG(write_and_auto_tab){
|
||||||
exec_command(app, cmdid_auto_tab_line_at_cursor);
|
exec_command(app, cmdid_auto_tab_line_at_cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE(allen|a4) See 4coder_styles.h for a list of available style tags.
|
||||||
|
// There are style tags corresponding to every color in the theme editor.
|
||||||
CUSTOM_COMMAND_SIG(improve_theme){
|
CUSTOM_COMMAND_SIG(improve_theme){
|
||||||
Theme_Color colors[] = {
|
Theme_Color colors[] = {
|
||||||
{Stag_Bar, 0xFF0088},
|
{Stag_Bar, 0xFF0088},
|
||||||
|
@ -868,7 +877,7 @@ CUSTOM_COMMAND_SIG(ruin_theme){
|
||||||
app->set_theme_colors(app, colors, count);
|
app->set_theme_colors(app, colors, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE(allen|a4.0.0): scroll rule information
|
// NOTE(allen|a4): scroll rule information
|
||||||
//
|
//
|
||||||
// The parameters:
|
// The parameters:
|
||||||
// target_x, target_y
|
// target_x, target_y
|
||||||
|
@ -955,10 +964,17 @@ SCROLL_RULE_SIG(smooth_scroll_rule){
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if Custom_Current == Custom_HandmadeHero
|
||||||
|
# include "4coder_handmade_hero.cpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
extern "C" GET_BINDING_DATA(get_bindings){
|
extern "C" GET_BINDING_DATA(get_bindings){
|
||||||
Bind_Helper context_actual = begin_bind_helper(data, size);
|
Bind_Helper context_actual = begin_bind_helper(data, size);
|
||||||
Bind_Helper *context = &context_actual;
|
Bind_Helper *context = &context_actual;
|
||||||
|
|
||||||
|
#if Custom_Current == Custom_HandmadeHero
|
||||||
|
casey_get_bindings(context);
|
||||||
|
#else
|
||||||
|
|
||||||
// NOTE(allen|a3.1): Right now hooks have no loyalties to maps, all hooks are
|
// NOTE(allen|a3.1): Right now hooks have no loyalties to maps, all hooks are
|
||||||
// global and once set they always apply, regardless of what map is active.
|
// global and once set they always apply, regardless of what map is active.
|
||||||
|
@ -1037,10 +1053,10 @@ extern "C" GET_BINDING_DATA(get_bindings){
|
||||||
|
|
||||||
begin_map(context, mapid_file);
|
begin_map(context, mapid_file);
|
||||||
|
|
||||||
// NOTE(allen|a3.4.4): Binding this essentially binds all key combos that
|
// NOTE(allen|a3.4.4): Binding this essentially binds
|
||||||
// would normally insert a character into a buffer.
|
// all key combos that would normally insert a character
|
||||||
// Or apply this rule: if the code for the key is not an enum value
|
// into a buffer. If the code for the key is not an enum
|
||||||
// such as key_left or key_back then it is a vanilla key.
|
// value such as key_left or key_back then it is a vanilla key.
|
||||||
// It is possible to override this binding for individual keys.
|
// It is possible to override this binding for individual keys.
|
||||||
bind_vanilla_keys(context, cmdid_write_character);
|
bind_vanilla_keys(context, cmdid_write_character);
|
||||||
|
|
||||||
|
@ -1104,6 +1120,7 @@ extern "C" GET_BINDING_DATA(get_bindings){
|
||||||
bind(context, ' ', MDFR_SHIFT, cmdid_write_character);
|
bind(context, ' ', MDFR_SHIFT, cmdid_write_character);
|
||||||
|
|
||||||
end_map(context);
|
end_map(context);
|
||||||
|
#endif
|
||||||
|
|
||||||
end_bind_helper(context);
|
end_bind_helper(context);
|
||||||
|
|
||||||
|
|
|
@ -341,57 +341,59 @@ extern "C"{
|
||||||
struct Application_Links;
|
struct Application_Links;
|
||||||
|
|
||||||
// Command exectuion
|
// Command exectuion
|
||||||
#define PUSH_PARAMETER_SIG(name) void name(Application_Links *app, Dynamic param, Dynamic value)
|
#define PUSH_PARAMETER_SIG(n) void n(Application_Links *app, Dynamic param, Dynamic value)
|
||||||
#define PUSH_MEMORY_SIG(name) char* name(Application_Links *app, int len)
|
#define PUSH_MEMORY_SIG(n) char* n(Application_Links *app, int len)
|
||||||
#define EXECUTE_COMMAND_SIG(name) void name(Application_Links *app, int command_id)
|
#define EXECUTE_COMMAND_SIG(n) void n(Application_Links *app, int command_id)
|
||||||
#define CLEAR_PARAMETERS_SIG(name) void name(Application_Links *app)
|
#define CLEAR_PARAMETERS_SIG(n) void n(Application_Links *app)
|
||||||
|
|
||||||
// File system navigation
|
// File system navigation
|
||||||
#define DIRECTORY_GET_HOT_SIG(name) int name(Application_Links *app, char *out, int capacity)
|
#define DIRECTORY_GET_HOT_SIG(n) int n(Application_Links *app, char *out, int capacity)
|
||||||
#define FILE_EXISTS_SIG(name) int name(Application_Links *app, char *filename, int len)
|
#define FILE_EXISTS_SIG(n) int n(Application_Links *app, char *filename, int len)
|
||||||
#define DIRECTORY_CD_SIG(name) int name(Application_Links *app, char *dir, int *len, int capacity, char *rel_path, int rel_len)
|
#define DIRECTORY_CD_SIG(n) int n(Application_Links *app, char *dir, int *len, int capacity, char *rel_path, int rel_len)
|
||||||
#define GET_FILE_LIST_SIG(name) File_List name(Application_Links *app, char *dir, int len)
|
#define GET_FILE_LIST_SIG(n) File_List n(Application_Links *app, char *dir, int len)
|
||||||
#define FREE_FILE_LIST_SIG(name) void name(Application_Links *app, File_List list)
|
#define FREE_FILE_LIST_SIG(n) void n(Application_Links *app, File_List list)
|
||||||
|
|
||||||
// Direct buffer manipulation
|
// Direct buffer manipulation
|
||||||
#define GET_BUFFER_FIRST_SIG(name) Buffer_Summary name(Application_Links *app)
|
#define GET_BUFFER_FIRST_SIG(n) Buffer_Summary n(Application_Links *app)
|
||||||
#define GET_BUFFER_NEXT_SIG(name) void name(Application_Links *app, Buffer_Summary *buffer)
|
#define GET_BUFFER_NEXT_SIG(n) void n(Application_Links *app, Buffer_Summary *buffer)
|
||||||
|
|
||||||
#define GET_BUFFER_SIG(name) Buffer_Summary name(Application_Links *app, int index)
|
#define GET_BUFFER_SIG(n) Buffer_Summary n(Application_Links *app, int index)
|
||||||
#define GET_ACTIVE_BUFFER_SIG(name) Buffer_Summary name(Application_Links *app)
|
#define GET_ACTIVE_BUFFER_SIG(n) Buffer_Summary n(Application_Links *app)
|
||||||
#define GET_PARAMETER_BUFFER_SIG(name) Buffer_Summary name(Application_Links *app, int param_index)
|
#define GET_PARAMETER_BUFFER_SIG(n) Buffer_Summary n(Application_Links *app, int param_index)
|
||||||
#define GET_BUFFER_BY_NAME(name) Buffer_Summary name(Application_Links *app, char *filename, int len)
|
#define GET_BUFFER_BY_NAME(n) Buffer_Summary n(Application_Links *app, char *filename, int len)
|
||||||
|
|
||||||
#define BUFFER_SEEK_DELIMITER_SIG(name) int name(Application_Links *app, Buffer_Summary *buffer, int start, char delim, int seek_forward, int *out)
|
#define BUFFER_SEEK_DELIMITER_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int start, char delim, int seek_forward, int *out)
|
||||||
#define BUFFER_SEEK_STRING_SIG(name) int name(Application_Links *app, Buffer_Summary *buffer, int start, char *str, int len, int seek_forward, int *out)
|
#define BUFFER_SEEK_STRING_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int start, char *str, int len, int seek_forward, int *out)
|
||||||
|
|
||||||
#define REFRESH_BUFFER_SIG(name) int name(Application_Links *app, Buffer_Summary *buffer)
|
#define REFRESH_BUFFER_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer)
|
||||||
#define BUFFER_READ_RANGE_SIG(name) int name(Application_Links *app, Buffer_Summary *buffer, int start, int end, char *out)
|
#define BUFFER_READ_RANGE_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int start, int end, char *out)
|
||||||
#define BUFFER_REPLACE_RANGE_SIG(name) int name(Application_Links *app, Buffer_Summary *buffer, int start, int end, char *str, int len)
|
#define BUFFER_REPLACE_RANGE_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int start, int end, char *str, int len)
|
||||||
#define BUFFER_SET_POS_SIG(name) int name(Application_Links *app, Buffer_Summary *buffer, int pos)
|
#define BUFFER_SET_POS_SIG(n) int n(Application_Links *app, Buffer_Summary *buffer, int pos)
|
||||||
|
|
||||||
// File view manipulation
|
// File view manipulation
|
||||||
#define GET_VIEW_FIRST_SIG(name) View_Summary name(Application_Links *app)
|
#define GET_VIEW_FIRST_SIG(n) View_Summary n(Application_Links *app)
|
||||||
#define GET_VIEW_NEXT_SIG(name) void name(Application_Links *app, View_Summary *view)
|
#define GET_VIEW_NEXT_SIG(n) void n(Application_Links *app, View_Summary *view)
|
||||||
|
|
||||||
#define GET_VIEW_SIG(name) View_Summary name(Application_Links *app, int index)
|
#define GET_VIEW_SIG(n) View_Summary n(Application_Links *app, int index)
|
||||||
#define GET_ACTIVE_VIEW_SIG(name) View_Summary name(Application_Links *app)
|
#define GET_ACTIVE_VIEW_SIG(n) View_Summary n(Application_Links *app)
|
||||||
|
|
||||||
#define REFRESH_VIEW_SIG(name) int name(Application_Links *app, View_Summary *view)
|
#define REFRESH_VIEW_SIG(n) int n(Application_Links *app, View_Summary *view)
|
||||||
#define VIEW_SET_CURSOR_SIG(name) int name(Application_Links *app, View_Summary *view, Buffer_Seek seek, int set_preferred_x)
|
#define VIEW_SET_CURSOR_SIG(n) int n(Application_Links *app, View_Summary *view, Buffer_Seek seek, int set_preferred_x)
|
||||||
#define VIEW_SET_MARK_SIG(name) int name(Application_Links *app, View_Summary *view, Buffer_Seek seek)
|
#define VIEW_SET_MARK_SIG(n) int n(Application_Links *app, View_Summary *view, Buffer_Seek seek)
|
||||||
#define VIEW_SET_HIGHLIGHT_SIG(name) int name(Application_Links *app, View_Summary *view, int start, int end, int turn_on)
|
#define VIEW_SET_HIGHLIGHT_SIG(n) int n(Application_Links *app, View_Summary *view, int start, int end, int turn_on)
|
||||||
#define VIEW_SET_BUFFER_SIG(name) int name(Application_Links *app, View_Summary *view, int buffer_id)
|
#define VIEW_SET_BUFFER_SIG(n) int n(Application_Links *app, View_Summary *view, int buffer_id)
|
||||||
|
|
||||||
// Directly get user input
|
// Directly get user input
|
||||||
#define GET_USER_INPUT_SIG(name) User_Input name(Application_Links *context, unsigned int get_type, unsigned int abort_type)
|
#define GET_USER_INPUT_SIG(n) User_Input n(Application_Links *app, unsigned int get_type, unsigned int abort_type)
|
||||||
|
|
||||||
// Queries
|
// Queries
|
||||||
#define START_QUERY_BAR_SIG(name) int name(Application_Links *context, Query_Bar *bar, unsigned int flags)
|
#define START_QUERY_BAR_SIG(n) int n(Application_Links *app, Query_Bar *bar, unsigned int flags)
|
||||||
#define END_QUERY_BAR_SIG(name) void name(Application_Links *context, Query_Bar *bar, unsigned int flags)
|
#define END_QUERY_BAR_SIG(n) void n(Application_Links *app, Query_Bar *bar, unsigned int flags)
|
||||||
|
|
||||||
// Setting colors
|
// Color settings
|
||||||
#define SET_THEME_COLORS_SIG(name) void name(Application_Links *context, Theme_Color *colors, int count)
|
#define CHANGE_THEME_SIG(n) void n(Application_Links *app, char *name, int len)
|
||||||
|
#define CHANGE_FONT_SIG(n) void n(Application_Links *app, char *name, int len)
|
||||||
|
#define SET_THEME_COLORS_SIG(n) void n(Application_Links *app, Theme_Color *colors, int count)
|
||||||
|
|
||||||
|
|
||||||
// Boundry type flags
|
// Boundry type flags
|
||||||
|
@ -467,7 +469,9 @@ extern "C"{
|
||||||
typedef START_QUERY_BAR_SIG(Start_Query_Bar_Function);
|
typedef START_QUERY_BAR_SIG(Start_Query_Bar_Function);
|
||||||
typedef END_QUERY_BAR_SIG(End_Query_Bar_Function);
|
typedef END_QUERY_BAR_SIG(End_Query_Bar_Function);
|
||||||
|
|
||||||
// Set theme colors
|
// Color settings
|
||||||
|
typedef CHANGE_THEME_SIG(Change_Theme_Function);
|
||||||
|
typedef CHANGE_FONT_SIG(Change_Font_Function);
|
||||||
typedef SET_THEME_COLORS_SIG(Set_Theme_Colors_Function);
|
typedef SET_THEME_COLORS_SIG(Set_Theme_Colors_Function);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -527,6 +531,8 @@ struct Application_Links{
|
||||||
End_Query_Bar_Function *end_query_bar;
|
End_Query_Bar_Function *end_query_bar;
|
||||||
|
|
||||||
// Theme
|
// Theme
|
||||||
|
Change_Theme_Function *change_theme;
|
||||||
|
Change_Font_Function *change_font;
|
||||||
Set_Theme_Colors_Function *set_theme_colors;
|
Set_Theme_Colors_Function *set_theme_colors;
|
||||||
|
|
||||||
// Internal
|
// Internal
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -244,6 +244,23 @@ active_view_to_line(Application_Links *app, int line_number){
|
||||||
app->view_set_cursor(app, &view, seek_line_char(line_number, 0), 1);
|
app->view_set_cursor(app, &view, seek_line_char(line_number, 0), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline View_Summary
|
||||||
|
get_first_view_with_buffer(Application_Links *app, int buffer_id){
|
||||||
|
View_Summary result = {};
|
||||||
|
View_Summary test = {};
|
||||||
|
|
||||||
|
for(test = app->get_view_first(app);
|
||||||
|
test.exists;
|
||||||
|
app->get_view_next(app, &test)){
|
||||||
|
if(test.buffer_id == buffer_id){
|
||||||
|
result = test;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
inline int
|
inline int
|
||||||
key_is_unmodified(Key_Event_Data *key){
|
key_is_unmodified(Key_Event_Data *key){
|
||||||
char *mods = key->modifiers;
|
char *mods = key->modifiers;
|
||||||
|
@ -322,3 +339,5 @@ query_user_number(Application_Links *app, Query_Bar *bar){
|
||||||
int success = query_user_general(app, bar, 1);
|
int success = query_user_general(app, bar, 1);
|
||||||
return(success);
|
return(success);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline String empty_string() {String Result = {}; return(Result);}
|
||||||
|
|
46
4ed.cpp
46
4ed.cpp
|
@ -948,6 +948,10 @@ COMMAND_DECL(interactive_open){
|
||||||
delayed_open_background(delay, string);
|
delayed_open_background(delay, string);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
// TODO(allen): Change the behavior of all delayed_open/background
|
||||||
|
// calls so that they still allocate the buffer right away. This way
|
||||||
|
// it's still possible to get at the buffer if so wished in the API.
|
||||||
|
// The switch for this view doesn't need to happen until the file is ready.
|
||||||
delayed_open(delay, string, panel);
|
delayed_open(delay, string, panel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2454,7 +2458,7 @@ extern "C"{
|
||||||
}
|
}
|
||||||
|
|
||||||
GET_USER_INPUT_SIG(external_get_user_input){
|
GET_USER_INPUT_SIG(external_get_user_input){
|
||||||
Command_Data *cmd = (Command_Data*)context->cmd_context;
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||||
System_Functions *system = cmd->system;
|
System_Functions *system = cmd->system;
|
||||||
Coroutine *coroutine = cmd->models->command_coroutine;
|
Coroutine *coroutine = cmd->models->command_coroutine;
|
||||||
User_Input result;
|
User_Input result;
|
||||||
|
@ -2469,7 +2473,7 @@ extern "C"{
|
||||||
}
|
}
|
||||||
|
|
||||||
START_QUERY_BAR_SIG(external_start_query_bar){
|
START_QUERY_BAR_SIG(external_start_query_bar){
|
||||||
Command_Data *cmd = (Command_Data*)context->cmd_context;
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||||
Query_Slot *slot = 0;
|
Query_Slot *slot = 0;
|
||||||
View *vptr;
|
View *vptr;
|
||||||
|
|
||||||
|
@ -2482,19 +2486,49 @@ extern "C"{
|
||||||
}
|
}
|
||||||
|
|
||||||
END_QUERY_BAR_SIG(external_end_query_bar){
|
END_QUERY_BAR_SIG(external_end_query_bar){
|
||||||
Command_Data *cmd = (Command_Data*)context->cmd_context;
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||||
View *vptr;
|
View *vptr;
|
||||||
|
|
||||||
vptr = cmd->view;
|
vptr = cmd->view;
|
||||||
free_query_slot(&vptr->query_set, bar);
|
free_query_slot(&vptr->query_set, bar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CHANGE_THEME_SIG(external_change_theme){
|
||||||
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||||
|
Style_Library *styles = &cmd->models->styles;
|
||||||
|
String theme_name = make_string(name, len);
|
||||||
|
Style *s;
|
||||||
|
i32 i, count;
|
||||||
|
|
||||||
|
count = styles->count;
|
||||||
|
s = styles->styles;
|
||||||
|
for (i = 0; i < count; ++i, ++s){
|
||||||
|
if (match(s->name, theme_name)){
|
||||||
|
style_copy(&cmd->models->style, s);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CHANGE_FONT_SIG(external_change_font){
|
||||||
|
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;
|
||||||
|
|
||||||
|
if (font_set_extract(set, font_name, &font_id)){
|
||||||
|
global_font->font_id = font_id;
|
||||||
|
global_font->font_changed = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SET_THEME_COLORS_SIG(external_set_theme_colors){
|
SET_THEME_COLORS_SIG(external_set_theme_colors){
|
||||||
Command_Data *cmd = (Command_Data*)context->cmd_context;
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||||
Style *style = &cmd->models->style;
|
Style *style = &cmd->models->style;
|
||||||
Theme_Color *theme_color;
|
Theme_Color *theme_color;
|
||||||
i32 i;
|
|
||||||
u32 *color;
|
u32 *color;
|
||||||
|
i32 i;
|
||||||
|
|
||||||
theme_color = colors;
|
theme_color = colors;
|
||||||
for (i = 0; i < count; ++i, ++theme_color){
|
for (i = 0; i < count; ++i, ++theme_color){
|
||||||
|
@ -2569,6 +2603,8 @@ app_links_init(System_Functions *system, void *data, int size){
|
||||||
app_links.start_query_bar = external_start_query_bar;
|
app_links.start_query_bar = external_start_query_bar;
|
||||||
app_links.end_query_bar = external_end_query_bar;
|
app_links.end_query_bar = external_end_query_bar;
|
||||||
|
|
||||||
|
app_links.change_theme = external_change_theme;
|
||||||
|
app_links.change_font = external_change_font;
|
||||||
app_links.set_theme_colors = external_set_theme_colors;
|
app_links.set_theme_colors = external_set_theme_colors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,12 +35,13 @@
|
||||||
#define FCPP_LEXER_IMPLEMENTATION
|
#define FCPP_LEXER_IMPLEMENTATION
|
||||||
#include "4cpp_lexer.h"
|
#include "4cpp_lexer.h"
|
||||||
|
|
||||||
|
#include "4ed_template.cpp"
|
||||||
|
|
||||||
#include "4ed_font_set.cpp"
|
#include "4ed_font_set.cpp"
|
||||||
#include "4ed_rendering_helper.cpp"
|
#include "4ed_rendering_helper.cpp"
|
||||||
|
|
||||||
#include "4ed_style.h"
|
#include "4ed_style.h"
|
||||||
#include "4ed_style.cpp"
|
#include "4ed_style.cpp"
|
||||||
#include "4ed_template.cpp"
|
|
||||||
#include "4ed_exchange.cpp"
|
#include "4ed_exchange.cpp"
|
||||||
#include "4ed_command.cpp"
|
#include "4ed_command.cpp"
|
||||||
#include "4ed_file.cpp"
|
#include "4ed_file.cpp"
|
||||||
|
|
|
@ -1724,6 +1724,11 @@ file_do_white_batch_edit(System_Functions *system, App_Models *models, Editing_F
|
||||||
Mem_Options *mem = &models->mem;
|
Mem_Options *mem = &models->mem;
|
||||||
Editing_Layout *layout = &models->layout;
|
Editing_Layout *layout = &models->layout;
|
||||||
|
|
||||||
|
// NOTE(allen): fixing stuff "beforewards"???
|
||||||
|
Assert(spec.str == 0);
|
||||||
|
file_update_history_before_edit(mem, file, spec.step, 0, history_mode);
|
||||||
|
file_pre_edit_maintenance(system, &mem->general, file);
|
||||||
|
|
||||||
// NOTE(allen): actual text replacement
|
// NOTE(allen): actual text replacement
|
||||||
General_Memory *general = &mem->general;
|
General_Memory *general = &mem->general;
|
||||||
Partition *part = &mem->part;
|
Partition *part = &mem->part;
|
||||||
|
@ -3383,7 +3388,7 @@ step_file_view(System_Functions *system, Exchange *exchange, View *view, i32_Rec
|
||||||
switch (view->widget.type){
|
switch (view->widget.type){
|
||||||
case FWIDG_NONE:
|
case FWIDG_NONE:
|
||||||
{
|
{
|
||||||
if (file){
|
if (file && view->showing_ui == VUI_None){
|
||||||
do_file_bar(view, file, &layout, 0);
|
do_file_bar(view, file, &layout, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3733,7 +3738,7 @@ draw_file_view(System_Functions *system, Exchange *exchange,
|
||||||
switch (view->widget.type){
|
switch (view->widget.type){
|
||||||
case FWIDG_NONE:
|
case FWIDG_NONE:
|
||||||
{
|
{
|
||||||
if (file){
|
if (file && view->showing_ui == VUI_None){
|
||||||
do_file_bar(view, file, &layout, target);
|
do_file_bar(view, file, &layout, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,14 +55,12 @@ font_set_init(Font_Set *set, Partition *partition, i32 max, i16 live_max){
|
||||||
set->free_slots = {};
|
set->free_slots = {};
|
||||||
set->used_slots = {};
|
set->used_slots = {};
|
||||||
|
|
||||||
set->free_slots.next = &set->free_slots;
|
dll_init_sentinel(&set->free_slots);
|
||||||
set->free_slots.prev = &set->free_slots;
|
dll_init_sentinel(&set->used_slots);
|
||||||
set->used_slots.next = &set->used_slots;
|
|
||||||
set->used_slots.prev = &set->used_slots;
|
|
||||||
|
|
||||||
char *ptr = (char*)set->font_block;
|
char *ptr = (char*)set->font_block;
|
||||||
for (i32 i = 0; i < live_max; ++i){
|
for (i32 i = 0; i < live_max; ++i){
|
||||||
font__insert(&set->free_slots, (Font_Slot*)ptr);
|
dll_insert(&set->free_slots, (Font_Slot*)ptr);
|
||||||
ptr += sizeof(Font_Slot) + sizeof(Render_Font);
|
ptr += sizeof(Font_Slot) + sizeof(Render_Font);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,11 +44,6 @@ struct Style_Library{
|
||||||
};
|
};
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
struct Style_Color_Specifier{
|
|
||||||
u32 tag;
|
|
||||||
u32 color;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Style_File_Format{
|
struct Style_File_Format{
|
||||||
i32 name_size;
|
i32 name_size;
|
||||||
char name[24];
|
char name[24];
|
||||||
|
|
|
@ -1056,15 +1056,19 @@ buffer_cursor_seek(Buffer_Type *buffer, Buffer_Seek seek, float max_width,
|
||||||
switch(seek.type){
|
switch(seek.type){
|
||||||
case buffer_seek_pos:
|
case buffer_seek_pos:
|
||||||
if (cursor.pos >= seek.pos) goto buffer_cursor_seek_end;
|
if (cursor.pos >= seek.pos) goto buffer_cursor_seek_end;
|
||||||
|
break;
|
||||||
|
|
||||||
case buffer_seek_wrapped_xy:
|
case buffer_seek_wrapped_xy:
|
||||||
if (seek.x == 0 && cursor.wrapped_y >= seek.y) goto buffer_cursor_seek_end;
|
if (seek.x == 0 && cursor.wrapped_y >= seek.y) goto buffer_cursor_seek_end;
|
||||||
|
break;
|
||||||
|
|
||||||
case buffer_seek_unwrapped_xy:
|
case buffer_seek_unwrapped_xy:
|
||||||
if (seek.x == 0 && cursor.unwrapped_y >= seek.y) goto buffer_cursor_seek_end;
|
if (seek.x == 0 && cursor.unwrapped_y >= seek.y) goto buffer_cursor_seek_end;
|
||||||
|
break;
|
||||||
|
|
||||||
case buffer_seek_line_char:
|
case buffer_seek_line_char:
|
||||||
if (cursor.line >= seek.line && cursor.character >= seek.character) goto buffer_cursor_seek_end;
|
if (cursor.line >= seek.line && cursor.character >= seek.character) goto buffer_cursor_seek_end;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (advance_data){
|
if (advance_data){
|
||||||
|
|
|
@ -9,8 +9,8 @@ SET STUFF=/GR- /nologo
|
||||||
SET DEBUG=/Zi
|
SET DEBUG=/Zi
|
||||||
SET EXPORTS=/EXPORT:get_bindings
|
SET EXPORTS=/EXPORT:get_bindings
|
||||||
SET SRC=4coder_custom.cpp
|
SET SRC=4coder_custom.cpp
|
||||||
REM SET LINKS=user32.lib gdi32.lib
|
SET LINKS=user32.lib gdi32.lib
|
||||||
SET LINKS=
|
REM SET LINKS=
|
||||||
|
|
||||||
cl %WARNINGS% %STUFF% %DEBUG% %SRC% %LINKS% /Fe4coder_custom /LD /link /INCREMENTAL:NO /OPT:REF %EXPORTS%
|
cl %WARNINGS% %STUFF% %DEBUG% %SRC% %LINKS% /Fe4coder_custom /LD /link /INCREMENTAL:NO /OPT:REF %EXPORTS%
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue