Generic lifetime buckets for core variables

master
Allen Webster 2018-08-10 17:42:15 -07:00
parent fc5df0c118
commit f0b9b76d9f
14 changed files with 227 additions and 154 deletions

View File

@ -689,10 +689,17 @@ STRUCT Query_Bar{
String string;
};
/* DOC(This feature is not implemented.) */
STRUCT Event_Message{
/* DOC(This feature is not implemented.) */
int32_t type;
static int32_t CoreVariableIndex_ERROR = -1;
ENUM(int32_t, Lifetime_Type){
LifetimeType_View = 0,
LifetimeType_Buffer = 1,
};
STRUCT Lifetime_Handle{
Lifetime_Type type;
View_ID view_id;
Buffer_ID buffer_id;
};
ENUM(int16_t, UI_Item_Type){

View File

@ -50,10 +50,10 @@ CUSTOM_DOC("At the cursor, insert the text at the top of the clipboard.")
int32_t count = clipboard_count(app, 0);
if (count > 0){
View_Summary view = get_active_view(app, access);
view_set_variable(app, &view, view_next_rewrite_loc, RewritePaste);
Lifetime_Handle view_life = view_get_lifetime_handle(app, view.view_id);
core_variable_set(app, view_life, view_next_rewrite_loc, RewritePaste);
int32_t paste_index = 0;
view_set_variable(app, &view, view_paste_index_loc, paste_index);
core_variable_set(app, view_life, view_paste_index_loc, paste_index);
int32_t len = clipboard_index(app, 0, paste_index, 0, 0);
char *str = 0;
@ -87,15 +87,16 @@ CUSTOM_DOC("If the previous command was paste or paste_next, replaces the paste
int32_t count = clipboard_count(app, 0);
if (count > 0){
View_Summary view = get_active_view(app, access);
Lifetime_Handle view_life = view_get_lifetime_handle(app, view.view_id);
uint64_t rewrite = 0;
view_get_variable(app, &view, view_rewrite_loc, &rewrite);
core_variable_get(app, view_life, view_rewrite_loc, &rewrite);
if (rewrite == RewritePaste){
view_set_variable(app, &view, view_next_rewrite_loc, RewritePaste);
core_variable_set(app, view_life, view_next_rewrite_loc, RewritePaste);
uint64_t prev_paste_index = 0;
view_get_variable(app, &view, view_paste_index_loc, &prev_paste_index);
core_variable_get(app, view_life, view_paste_index_loc, &prev_paste_index);
int32_t paste_index = (int32_t)prev_paste_index + 1;
view_set_variable(app, &view, view_paste_index_loc, paste_index);
core_variable_set(app, view_life, view_paste_index_loc, paste_index);
int32_t len = clipboard_index(app, 0, paste_index, 0, 0);
char *str = 0;

View File

@ -56,13 +56,15 @@ new_view_settings(Application_Links *app, View_Summary *view){
static void
view_set_passive(Application_Links *app, View_Summary *view, bool32 value){
view_set_variable(app, view, view_is_passive_loc, (uint64_t)value);
Lifetime_Handle view_life = view_get_lifetime_handle(app, view->view_id);
core_variable_set(app, view_life, view_is_passive_loc, (uint64_t)value);
}
static bool32
view_get_is_passive(Application_Links *app, View_Summary *view){
Lifetime_Handle view_life = view_get_lifetime_handle(app, view->view_id);
uint64_t is_passive = 0;
view_get_variable(app, view, view_is_passive_loc, &is_passive);
core_variable_get(app, view_life, view_is_passive_loc, &is_passive);
return(is_passive != 0);
}
@ -245,10 +247,10 @@ default_4coder_initialize(Application_Links *app, int32_t override_font_size, bo
load_folder_of_themes_into_live_set(app, &global_part, "themes");
load_config_and_apply(app, &global_part, &global_config, override_font_size, override_hinting);
view_rewrite_loc = create_view_variable(app, "DEFAULT.rewrite" , (uint64_t)0);
view_next_rewrite_loc = create_view_variable(app, "DEFAULT.next_rewrite", (uint64_t)0);
view_paste_index_loc = create_view_variable(app, "DEFAULT.paste_index" , (uint64_t)0);
view_is_passive_loc = create_view_variable(app, "DEFAULT.is_passive" , (uint64_t)false);
view_rewrite_loc = create_core_variable(app, LifetimeType_View, "DEFAULT.rewrite" , (uint64_t)0);
view_next_rewrite_loc = create_core_variable(app, LifetimeType_View, "DEFAULT.next_rewrite", (uint64_t)0);
view_paste_index_loc = create_core_variable(app, LifetimeType_View, "DEFAULT.paste_index" , (uint64_t)0);
view_is_passive_loc = create_core_variable(app, LifetimeType_View, "DEFAULT.is_passive" , (uint64_t)false);
}
static void

View File

@ -42,12 +42,13 @@ START_HOOK_SIG(default_start){
// also relies on this particular command caller hook.
COMMAND_CALLER_HOOK(default_command_caller){
View_Summary view = get_active_view(app, AccessAll);
Lifetime_Handle view_life = view_get_lifetime_handle(app, view.view_id);
view_set_variable(app, &view, view_next_rewrite_loc, 0);
core_variable_set(app, view_life, view_next_rewrite_loc, 0);
exec_command(app, cmd);
uint64_t next_rewrite = 0;
view_get_variable(app, &view, view_next_rewrite_loc, &next_rewrite);
view_set_variable(app, &view, view_rewrite_loc, next_rewrite);
core_variable_get(app, view_life, view_next_rewrite_loc, &next_rewrite);
core_variable_set(app, view_life, view_rewrite_loc, next_rewrite);
return(0);
}

View File

@ -25,6 +25,7 @@ struct Application_Links;
#define BUFFER_REMOVE_MARKERS_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, Marker_Handle marker)
#define BUFFER_GET_SETTING_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting, int32_t *value_out)
#define BUFFER_SET_SETTING_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting, int32_t value)
#define BUFFER_GET_LIFETIME_HANDLE_SIG(n) Lifetime_Handle n(Application_Links *app, Buffer_ID buffer_id)
#define BUFFER_TOKEN_COUNT_SIG(n) int32_t n(Application_Links *app, Buffer_Summary *buffer)
#define BUFFER_READ_TOKENS_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, int32_t start_token, int32_t end_token, Cpp_Token *tokens_out)
#define BUFFER_GET_TOKEN_INDEX_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, int32_t pos, Cpp_Get_Token_Result *get_result)
@ -41,6 +42,7 @@ struct Application_Links;
#define SET_ACTIVE_VIEW_SIG(n) bool32 n(Application_Links *app, View_Summary *view)
#define VIEW_GET_SETTING_SIG(n) bool32 n(Application_Links *app, View_Summary *view, View_Setting_ID setting, int32_t *value_out)
#define VIEW_SET_SETTING_SIG(n) bool32 n(Application_Links *app, View_Summary *view, View_Setting_ID setting, int32_t value)
#define VIEW_GET_LIFETIME_HANDLE_SIG(n) Lifetime_Handle n(Application_Links *app, View_ID view_id)
#define VIEW_SET_SPLIT_PROPORTION_SIG(n) bool32 n(Application_Links *app, View_Summary *view, float t)
#define VIEW_COMPUTE_CURSOR_SIG(n) bool32 n(Application_Links *app, View_Summary *view, Buffer_Seek seek, Full_Cursor *cursor_out)
#define VIEW_SET_CURSOR_SIG(n) bool32 n(Application_Links *app, View_Summary *view, Buffer_Seek seek, bool32 set_preferred_x)
@ -49,13 +51,13 @@ struct Application_Links;
#define VIEW_SET_HIGHLIGHT_SIG(n) bool32 n(Application_Links *app, View_Summary *view, int32_t start, int32_t end, bool32 turn_on)
#define VIEW_SET_BUFFER_SIG(n) bool32 n(Application_Links *app, View_Summary *view, Buffer_ID buffer_id, Set_Buffer_Flag flags)
#define VIEW_POST_FADE_SIG(n) bool32 n(Application_Links *app, View_Summary *view, float seconds, int32_t start, int32_t end, int_color color)
#define CREATE_VIEW_VARIABLE_SIG(n) int32_t n(Application_Links *app, char *null_terminated_name, uint64_t default_value)
#define VIEW_SET_VARIABLE_SIG(n) bool32 n(Application_Links *app, View_Summary *view, int32_t location, uint64_t value)
#define VIEW_GET_VARIABLE_SIG(n) bool32 n(Application_Links *app, View_Summary *view, int32_t location, uint64_t *value_out)
#define VIEW_START_UI_MODE_SIG(n) int32_t n(Application_Links *app, View_Summary *view)
#define VIEW_END_UI_MODE_SIG(n) int32_t n(Application_Links *app, View_Summary *view)
#define VIEW_SET_UI_SIG(n) bool32 n(Application_Links *app, View_Summary *view, UI_Control *control)
#define VIEW_GET_UI_COPY_SIG(n) UI_Control n(Application_Links *app, View_Summary *view, struct Partition *part)
#define CREATE_CORE_VARIABLE_SIG(n) int32_t n(Application_Links *app, Lifetime_Type type, char *null_terminated_name, uint64_t default_value)
#define CORE_VARIABLE_SET_SIG(n) bool32 n(Application_Links *app, Lifetime_Handle handle, int32_t location, uint64_t value)
#define CORE_VARIABLE_GET_SIG(n) bool32 n(Application_Links *app, Lifetime_Handle handle, int32_t location, uint64_t *value_out)
#define GET_USER_INPUT_SIG(n) User_Input n(Application_Links *app, Input_Type_Flag get_type, Input_Type_Flag abort_type)
#define GET_COMMAND_INPUT_SIG(n) User_Input n(Application_Links *app)
#define GET_MOUSE_STATE_SIG(n) Mouse_State n(Application_Links *app)
@ -121,6 +123,7 @@ typedef BUFFER_GET_MARKERS_SIG(Buffer_Get_Markers_Function);
typedef BUFFER_REMOVE_MARKERS_SIG(Buffer_Remove_Markers_Function);
typedef BUFFER_GET_SETTING_SIG(Buffer_Get_Setting_Function);
typedef BUFFER_SET_SETTING_SIG(Buffer_Set_Setting_Function);
typedef BUFFER_GET_LIFETIME_HANDLE_SIG(Buffer_Get_Lifetime_Handle_Function);
typedef BUFFER_TOKEN_COUNT_SIG(Buffer_Token_Count_Function);
typedef BUFFER_READ_TOKENS_SIG(Buffer_Read_Tokens_Function);
typedef BUFFER_GET_TOKEN_INDEX_SIG(Buffer_Get_Token_Index_Function);
@ -137,6 +140,7 @@ typedef CLOSE_VIEW_SIG(Close_View_Function);
typedef SET_ACTIVE_VIEW_SIG(Set_Active_View_Function);
typedef VIEW_GET_SETTING_SIG(View_Get_Setting_Function);
typedef VIEW_SET_SETTING_SIG(View_Set_Setting_Function);
typedef VIEW_GET_LIFETIME_HANDLE_SIG(View_Get_Lifetime_Handle_Function);
typedef VIEW_SET_SPLIT_PROPORTION_SIG(View_Set_Split_Proportion_Function);
typedef VIEW_COMPUTE_CURSOR_SIG(View_Compute_Cursor_Function);
typedef VIEW_SET_CURSOR_SIG(View_Set_Cursor_Function);
@ -145,13 +149,13 @@ typedef VIEW_SET_MARK_SIG(View_Set_Mark_Function);
typedef VIEW_SET_HIGHLIGHT_SIG(View_Set_Highlight_Function);
typedef VIEW_SET_BUFFER_SIG(View_Set_Buffer_Function);
typedef VIEW_POST_FADE_SIG(View_Post_Fade_Function);
typedef CREATE_VIEW_VARIABLE_SIG(Create_View_Variable_Function);
typedef VIEW_SET_VARIABLE_SIG(View_Set_Variable_Function);
typedef VIEW_GET_VARIABLE_SIG(View_Get_Variable_Function);
typedef VIEW_START_UI_MODE_SIG(View_Start_UI_Mode_Function);
typedef VIEW_END_UI_MODE_SIG(View_End_UI_Mode_Function);
typedef VIEW_SET_UI_SIG(View_Set_UI_Function);
typedef VIEW_GET_UI_COPY_SIG(View_Get_UI_Copy_Function);
typedef CREATE_CORE_VARIABLE_SIG(Create_Core_Variable_Function);
typedef CORE_VARIABLE_SET_SIG(Core_Variable_Set_Function);
typedef CORE_VARIABLE_GET_SIG(Core_Variable_Get_Function);
typedef GET_USER_INPUT_SIG(Get_User_Input_Function);
typedef GET_COMMAND_INPUT_SIG(Get_Command_Input_Function);
typedef GET_MOUSE_STATE_SIG(Get_Mouse_State_Function);
@ -219,6 +223,7 @@ Buffer_Get_Markers_Function *buffer_get_markers;
Buffer_Remove_Markers_Function *buffer_remove_markers;
Buffer_Get_Setting_Function *buffer_get_setting;
Buffer_Set_Setting_Function *buffer_set_setting;
Buffer_Get_Lifetime_Handle_Function *buffer_get_lifetime_handle;
Buffer_Token_Count_Function *buffer_token_count;
Buffer_Read_Tokens_Function *buffer_read_tokens;
Buffer_Get_Token_Index_Function *buffer_get_token_index;
@ -235,6 +240,7 @@ Close_View_Function *close_view;
Set_Active_View_Function *set_active_view;
View_Get_Setting_Function *view_get_setting;
View_Set_Setting_Function *view_set_setting;
View_Get_Lifetime_Handle_Function *view_get_lifetime_handle;
View_Set_Split_Proportion_Function *view_set_split_proportion;
View_Compute_Cursor_Function *view_compute_cursor;
View_Set_Cursor_Function *view_set_cursor;
@ -243,13 +249,13 @@ View_Set_Mark_Function *view_set_mark;
View_Set_Highlight_Function *view_set_highlight;
View_Set_Buffer_Function *view_set_buffer;
View_Post_Fade_Function *view_post_fade;
Create_View_Variable_Function *create_view_variable;
View_Set_Variable_Function *view_set_variable;
View_Get_Variable_Function *view_get_variable;
View_Start_UI_Mode_Function *view_start_ui_mode;
View_End_UI_Mode_Function *view_end_ui_mode;
View_Set_UI_Function *view_set_ui;
View_Get_UI_Copy_Function *view_get_ui_copy;
Create_Core_Variable_Function *create_core_variable;
Core_Variable_Set_Function *core_variable_set;
Core_Variable_Get_Function *core_variable_get;
Get_User_Input_Function *get_user_input;
Get_Command_Input_Function *get_command_input;
Get_Mouse_State_Function *get_mouse_state;
@ -316,6 +322,7 @@ Buffer_Get_Markers_Function *buffer_get_markers_;
Buffer_Remove_Markers_Function *buffer_remove_markers_;
Buffer_Get_Setting_Function *buffer_get_setting_;
Buffer_Set_Setting_Function *buffer_set_setting_;
Buffer_Get_Lifetime_Handle_Function *buffer_get_lifetime_handle_;
Buffer_Token_Count_Function *buffer_token_count_;
Buffer_Read_Tokens_Function *buffer_read_tokens_;
Buffer_Get_Token_Index_Function *buffer_get_token_index_;
@ -332,6 +339,7 @@ Close_View_Function *close_view_;
Set_Active_View_Function *set_active_view_;
View_Get_Setting_Function *view_get_setting_;
View_Set_Setting_Function *view_set_setting_;
View_Get_Lifetime_Handle_Function *view_get_lifetime_handle_;
View_Set_Split_Proportion_Function *view_set_split_proportion_;
View_Compute_Cursor_Function *view_compute_cursor_;
View_Set_Cursor_Function *view_set_cursor_;
@ -340,13 +348,13 @@ View_Set_Mark_Function *view_set_mark_;
View_Set_Highlight_Function *view_set_highlight_;
View_Set_Buffer_Function *view_set_buffer_;
View_Post_Fade_Function *view_post_fade_;
Create_View_Variable_Function *create_view_variable_;
View_Set_Variable_Function *view_set_variable_;
View_Get_Variable_Function *view_get_variable_;
View_Start_UI_Mode_Function *view_start_ui_mode_;
View_End_UI_Mode_Function *view_end_ui_mode_;
View_Set_UI_Function *view_set_ui_;
View_Get_UI_Copy_Function *view_get_ui_copy_;
Create_Core_Variable_Function *create_core_variable_;
Core_Variable_Set_Function *core_variable_set_;
Core_Variable_Get_Function *core_variable_get_;
Get_User_Input_Function *get_user_input_;
Get_Command_Input_Function *get_command_input_;
Get_Mouse_State_Function *get_mouse_state_;
@ -421,6 +429,7 @@ app_links->buffer_get_markers_ = Buffer_Get_Markers;\
app_links->buffer_remove_markers_ = Buffer_Remove_Markers;\
app_links->buffer_get_setting_ = Buffer_Get_Setting;\
app_links->buffer_set_setting_ = Buffer_Set_Setting;\
app_links->buffer_get_lifetime_handle_ = Buffer_Get_Lifetime_Handle;\
app_links->buffer_token_count_ = Buffer_Token_Count;\
app_links->buffer_read_tokens_ = Buffer_Read_Tokens;\
app_links->buffer_get_token_index_ = Buffer_Get_Token_Index;\
@ -437,6 +446,7 @@ app_links->close_view_ = Close_View;\
app_links->set_active_view_ = Set_Active_View;\
app_links->view_get_setting_ = View_Get_Setting;\
app_links->view_set_setting_ = View_Set_Setting;\
app_links->view_get_lifetime_handle_ = View_Get_Lifetime_Handle;\
app_links->view_set_split_proportion_ = View_Set_Split_Proportion;\
app_links->view_compute_cursor_ = View_Compute_Cursor;\
app_links->view_set_cursor_ = View_Set_Cursor;\
@ -445,13 +455,13 @@ app_links->view_set_mark_ = View_Set_Mark;\
app_links->view_set_highlight_ = View_Set_Highlight;\
app_links->view_set_buffer_ = View_Set_Buffer;\
app_links->view_post_fade_ = View_Post_Fade;\
app_links->create_view_variable_ = Create_View_Variable;\
app_links->view_set_variable_ = View_Set_Variable;\
app_links->view_get_variable_ = View_Get_Variable;\
app_links->view_start_ui_mode_ = View_Start_UI_Mode;\
app_links->view_end_ui_mode_ = View_End_UI_Mode;\
app_links->view_set_ui_ = View_Set_UI;\
app_links->view_get_ui_copy_ = View_Get_UI_Copy;\
app_links->create_core_variable_ = Create_Core_Variable;\
app_links->core_variable_set_ = Core_Variable_Set;\
app_links->core_variable_get_ = Core_Variable_Get;\
app_links->get_user_input_ = Get_User_Input;\
app_links->get_command_input_ = Get_Command_Input;\
app_links->get_mouse_state_ = Get_Mouse_State;\
@ -518,6 +528,7 @@ static inline bool32 buffer_get_markers(Application_Links *app, Buffer_Summary *
static inline bool32 buffer_remove_markers(Application_Links *app, Buffer_Summary *buffer, Marker_Handle marker){return(app->buffer_remove_markers(app, buffer, marker));}
static inline bool32 buffer_get_setting(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting, int32_t *value_out){return(app->buffer_get_setting(app, buffer, setting, value_out));}
static inline bool32 buffer_set_setting(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting, int32_t value){return(app->buffer_set_setting(app, buffer, setting, value));}
static inline Lifetime_Handle buffer_get_lifetime_handle(Application_Links *app, Buffer_ID buffer_id){return(app->buffer_get_lifetime_handle(app, buffer_id));}
static inline int32_t buffer_token_count(Application_Links *app, Buffer_Summary *buffer){return(app->buffer_token_count(app, buffer));}
static inline bool32 buffer_read_tokens(Application_Links *app, Buffer_Summary *buffer, int32_t start_token, int32_t end_token, Cpp_Token *tokens_out){return(app->buffer_read_tokens(app, buffer, start_token, end_token, tokens_out));}
static inline bool32 buffer_get_token_index(Application_Links *app, Buffer_Summary *buffer, int32_t pos, Cpp_Get_Token_Result *get_result){return(app->buffer_get_token_index(app, buffer, pos, get_result));}
@ -534,6 +545,7 @@ static inline bool32 close_view(Application_Links *app, View_Summary *view){retu
static inline bool32 set_active_view(Application_Links *app, View_Summary *view){return(app->set_active_view(app, view));}
static inline bool32 view_get_setting(Application_Links *app, View_Summary *view, View_Setting_ID setting, int32_t *value_out){return(app->view_get_setting(app, view, setting, value_out));}
static inline bool32 view_set_setting(Application_Links *app, View_Summary *view, View_Setting_ID setting, int32_t value){return(app->view_set_setting(app, view, setting, value));}
static inline Lifetime_Handle view_get_lifetime_handle(Application_Links *app, View_ID view_id){return(app->view_get_lifetime_handle(app, view_id));}
static inline bool32 view_set_split_proportion(Application_Links *app, View_Summary *view, float t){return(app->view_set_split_proportion(app, view, t));}
static inline bool32 view_compute_cursor(Application_Links *app, View_Summary *view, Buffer_Seek seek, Full_Cursor *cursor_out){return(app->view_compute_cursor(app, view, seek, cursor_out));}
static inline bool32 view_set_cursor(Application_Links *app, View_Summary *view, Buffer_Seek seek, bool32 set_preferred_x){return(app->view_set_cursor(app, view, seek, set_preferred_x));}
@ -542,13 +554,13 @@ static inline bool32 view_set_mark(Application_Links *app, View_Summary *view, B
static inline bool32 view_set_highlight(Application_Links *app, View_Summary *view, int32_t start, int32_t end, bool32 turn_on){return(app->view_set_highlight(app, view, start, end, turn_on));}
static inline bool32 view_set_buffer(Application_Links *app, View_Summary *view, Buffer_ID buffer_id, Set_Buffer_Flag flags){return(app->view_set_buffer(app, view, buffer_id, flags));}
static inline bool32 view_post_fade(Application_Links *app, View_Summary *view, float seconds, int32_t start, int32_t end, int_color color){return(app->view_post_fade(app, view, seconds, start, end, color));}
static inline int32_t create_view_variable(Application_Links *app, char *null_terminated_name, uint64_t default_value){return(app->create_view_variable(app, null_terminated_name, default_value));}
static inline bool32 view_set_variable(Application_Links *app, View_Summary *view, int32_t location, uint64_t value){return(app->view_set_variable(app, view, location, value));}
static inline bool32 view_get_variable(Application_Links *app, View_Summary *view, int32_t location, uint64_t *value_out){return(app->view_get_variable(app, view, location, value_out));}
static inline int32_t view_start_ui_mode(Application_Links *app, View_Summary *view){return(app->view_start_ui_mode(app, view));}
static inline int32_t view_end_ui_mode(Application_Links *app, View_Summary *view){return(app->view_end_ui_mode(app, view));}
static inline bool32 view_set_ui(Application_Links *app, View_Summary *view, UI_Control *control){return(app->view_set_ui(app, view, control));}
static inline UI_Control view_get_ui_copy(Application_Links *app, View_Summary *view, struct Partition *part){return(app->view_get_ui_copy(app, view, part));}
static inline int32_t create_core_variable(Application_Links *app, Lifetime_Type type, char *null_terminated_name, uint64_t default_value){return(app->create_core_variable(app, type, null_terminated_name, default_value));}
static inline bool32 core_variable_set(Application_Links *app, Lifetime_Handle handle, int32_t location, uint64_t value){return(app->core_variable_set(app, handle, location, value));}
static inline bool32 core_variable_get(Application_Links *app, Lifetime_Handle handle, int32_t location, uint64_t *value_out){return(app->core_variable_get(app, handle, location, value_out));}
static inline User_Input get_user_input(Application_Links *app, Input_Type_Flag get_type, Input_Type_Flag abort_type){return(app->get_user_input(app, get_type, abort_type));}
static inline User_Input get_command_input(Application_Links *app){return(app->get_command_input(app));}
static inline Mouse_State get_mouse_state(Application_Links *app){return(app->get_mouse_state(app));}
@ -615,6 +627,7 @@ static inline bool32 buffer_get_markers(Application_Links *app, Buffer_Summary *
static inline bool32 buffer_remove_markers(Application_Links *app, Buffer_Summary *buffer, Marker_Handle marker){return(app->buffer_remove_markers_(app, buffer, marker));}
static inline bool32 buffer_get_setting(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting, int32_t *value_out){return(app->buffer_get_setting_(app, buffer, setting, value_out));}
static inline bool32 buffer_set_setting(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting, int32_t value){return(app->buffer_set_setting_(app, buffer, setting, value));}
static inline Lifetime_Handle buffer_get_lifetime_handle(Application_Links *app, Buffer_ID buffer_id){return(app->buffer_get_lifetime_handle_(app, buffer_id));}
static inline int32_t buffer_token_count(Application_Links *app, Buffer_Summary *buffer){return(app->buffer_token_count_(app, buffer));}
static inline bool32 buffer_read_tokens(Application_Links *app, Buffer_Summary *buffer, int32_t start_token, int32_t end_token, Cpp_Token *tokens_out){return(app->buffer_read_tokens_(app, buffer, start_token, end_token, tokens_out));}
static inline bool32 buffer_get_token_index(Application_Links *app, Buffer_Summary *buffer, int32_t pos, Cpp_Get_Token_Result *get_result){return(app->buffer_get_token_index_(app, buffer, pos, get_result));}
@ -631,6 +644,7 @@ static inline bool32 close_view(Application_Links *app, View_Summary *view){retu
static inline bool32 set_active_view(Application_Links *app, View_Summary *view){return(app->set_active_view_(app, view));}
static inline bool32 view_get_setting(Application_Links *app, View_Summary *view, View_Setting_ID setting, int32_t *value_out){return(app->view_get_setting_(app, view, setting, value_out));}
static inline bool32 view_set_setting(Application_Links *app, View_Summary *view, View_Setting_ID setting, int32_t value){return(app->view_set_setting_(app, view, setting, value));}
static inline Lifetime_Handle view_get_lifetime_handle(Application_Links *app, View_ID view_id){return(app->view_get_lifetime_handle_(app, view_id));}
static inline bool32 view_set_split_proportion(Application_Links *app, View_Summary *view, float t){return(app->view_set_split_proportion_(app, view, t));}
static inline bool32 view_compute_cursor(Application_Links *app, View_Summary *view, Buffer_Seek seek, Full_Cursor *cursor_out){return(app->view_compute_cursor_(app, view, seek, cursor_out));}
static inline bool32 view_set_cursor(Application_Links *app, View_Summary *view, Buffer_Seek seek, bool32 set_preferred_x){return(app->view_set_cursor_(app, view, seek, set_preferred_x));}
@ -639,13 +653,13 @@ static inline bool32 view_set_mark(Application_Links *app, View_Summary *view, B
static inline bool32 view_set_highlight(Application_Links *app, View_Summary *view, int32_t start, int32_t end, bool32 turn_on){return(app->view_set_highlight_(app, view, start, end, turn_on));}
static inline bool32 view_set_buffer(Application_Links *app, View_Summary *view, Buffer_ID buffer_id, Set_Buffer_Flag flags){return(app->view_set_buffer_(app, view, buffer_id, flags));}
static inline bool32 view_post_fade(Application_Links *app, View_Summary *view, float seconds, int32_t start, int32_t end, int_color color){return(app->view_post_fade_(app, view, seconds, start, end, color));}
static inline int32_t create_view_variable(Application_Links *app, char *null_terminated_name, uint64_t default_value){return(app->create_view_variable_(app, null_terminated_name, default_value));}
static inline bool32 view_set_variable(Application_Links *app, View_Summary *view, int32_t location, uint64_t value){return(app->view_set_variable_(app, view, location, value));}
static inline bool32 view_get_variable(Application_Links *app, View_Summary *view, int32_t location, uint64_t *value_out){return(app->view_get_variable_(app, view, location, value_out));}
static inline int32_t view_start_ui_mode(Application_Links *app, View_Summary *view){return(app->view_start_ui_mode_(app, view));}
static inline int32_t view_end_ui_mode(Application_Links *app, View_Summary *view){return(app->view_end_ui_mode_(app, view));}
static inline bool32 view_set_ui(Application_Links *app, View_Summary *view, UI_Control *control){return(app->view_set_ui_(app, view, control));}
static inline UI_Control view_get_ui_copy(Application_Links *app, View_Summary *view, struct Partition *part){return(app->view_get_ui_copy_(app, view, part));}
static inline int32_t create_core_variable(Application_Links *app, Lifetime_Type type, char *null_terminated_name, uint64_t default_value){return(app->create_core_variable_(app, type, null_terminated_name, default_value));}
static inline bool32 core_variable_set(Application_Links *app, Lifetime_Handle handle, int32_t location, uint64_t value){return(app->core_variable_set_(app, handle, location, value));}
static inline bool32 core_variable_get(Application_Links *app, Lifetime_Handle handle, int32_t location, uint64_t *value_out){return(app->core_variable_get_(app, handle, location, value_out));}
static inline User_Input get_user_input(Application_Links *app, Input_Type_Flag get_type, Input_Type_Flag abort_type){return(app->get_user_input_(app, get_type, abort_type));}
static inline User_Input get_command_input(Application_Links *app){return(app->get_command_input_(app));}
static inline Mouse_State get_mouse_state(Application_Links *app){return(app->get_mouse_state_(app));}

View File

@ -223,7 +223,7 @@ int32_t source_name_len;
int32_t line_number;
};
static Command_Metadata fcoder_metacmd_table[202] = {
{ PROC_LINKS(allow_mouse, 0), "allow_mouse", 11, "Shows the mouse and causes all mouse input to be processed normally.", 68, "/home/allen/4ed/code/4coder_default_framework.cpp", 49, 191 },
{ PROC_LINKS(allow_mouse, 0), "allow_mouse", 11, "Shows the mouse and causes all mouse input to be processed normally.", 68, "/home/allen/4ed/code/4coder_default_framework.cpp", 49, 193 },
{ PROC_LINKS(auto_tab_line_at_cursor, 0), "auto_tab_line_at_cursor", 23, "Auto-indents the line on which the cursor sits.", 47, "/home/allen/4ed/code/4coder_auto_indent.cpp", 43, 722 },
{ PROC_LINKS(auto_tab_range, 0), "auto_tab_range", 14, "Auto-indents the range between the cursor and the mark.", 55, "/home/allen/4ed/code/4coder_auto_indent.cpp", 43, 733 },
{ PROC_LINKS(auto_tab_whole_file, 0), "auto_tab_whole_file", 19, "Audo-indents the entire current buffer.", 39, "/home/allen/4ed/code/4coder_auto_indent.cpp", 43, 712 },
@ -233,8 +233,8 @@ static Command_Metadata fcoder_metacmd_table[202] = {
{ PROC_LINKS(build_in_build_panel, 0), "build_in_build_panel", 20, "Looks for a build.bat, build.sh, or makefile in the current and parent directories. Runs the first that it finds and prints the output to *compilation*. Puts the *compilation* buffer in a panel at the footer of the current view.", 230, "/home/allen/4ed/code/4coder_build_commands.cpp", 46, 187 },
{ PROC_LINKS(build_search, 0), "build_search", 12, "Looks for a build.bat, build.sh, or makefile in the current and parent directories. Runs the first that it finds and prints the output to *compilation*.", 153, "/home/allen/4ed/code/4coder_build_commands.cpp", 46, 155 },
{ PROC_LINKS(center_view, 0), "center_view", 11, "Centers the view vertically on the line on which the cursor sits.", 65, "/home/allen/4ed/code/4coder_base_commands.cpp", 45, 120 },
{ PROC_LINKS(change_active_panel, 0), "change_active_panel", 19, "Change the currently active panel, moving to the panel with the next highest view_id.", 85, "/home/allen/4ed/code/4coder_default_framework.cpp", 49, 133 },
{ PROC_LINKS(change_active_panel_backwards, 0), "change_active_panel_backwards", 29, "Change the currently active panel, moving to the panel with the next lowest view_id.", 84, "/home/allen/4ed/code/4coder_default_framework.cpp", 49, 143 },
{ PROC_LINKS(change_active_panel, 0), "change_active_panel", 19, "Change the currently active panel, moving to the panel with the next highest view_id.", 85, "/home/allen/4ed/code/4coder_default_framework.cpp", 49, 135 },
{ PROC_LINKS(change_active_panel_backwards, 0), "change_active_panel_backwards", 29, "Change the currently active panel, moving to the panel with the next lowest view_id.", 84, "/home/allen/4ed/code/4coder_default_framework.cpp", 49, 145 },
{ PROC_LINKS(change_to_build_panel, 0), "change_to_build_panel", 21, "If the special build panel is open, makes the build panel the active panel.", 75, "/home/allen/4ed/code/4coder_build_commands.cpp", 46, 209 },
{ PROC_LINKS(clean_all_lines, 0), "clean_all_lines", 15, "Removes trailing whitespace from all lines in the current buffer.", 65, "/home/allen/4ed/code/4coder_base_commands.cpp", 45, 368 },
{ PROC_LINKS(click_set_cursor, 0), "click_set_cursor", 16, "Sets the cursor position to the mouse position.", 47, "/home/allen/4ed/code/4coder_base_commands.cpp", 45, 174 },
@ -345,14 +345,14 @@ static Command_Metadata fcoder_metacmd_table[202] = {
{ PROC_LINKS(open_long_braces_break, 0), "open_long_braces_break", 22, "At the cursor, insert a '{' and '}break;' separated by a blank line.", 68, "/home/allen/4ed/code/4coder_combined_write_commands.cpp", 55, 74 },
{ PROC_LINKS(open_long_braces_semicolon, 0), "open_long_braces_semicolon", 26, "At the cursor, insert a '{' and '};' separated by a blank line.", 63, "/home/allen/4ed/code/4coder_combined_write_commands.cpp", 55, 66 },
{ PROC_LINKS(open_matching_file_cpp, 0), "open_matching_file_cpp", 22, "If the current file is a *.cpp or *.h, attempts to open the corresponding *.h or *.cpp file in the other view.", 110, "/home/allen/4ed/code/4coder_base_commands.cpp", 45, 1387 },
{ PROC_LINKS(open_panel_hsplit, 0), "open_panel_hsplit", 17, "Create a new panel by horizontally splitting the active panel.", 62, "/home/allen/4ed/code/4coder_default_framework.cpp", 49, 162 },
{ PROC_LINKS(open_panel_vsplit, 0), "open_panel_vsplit", 17, "Create a new panel by vertically splitting the active panel.", 60, "/home/allen/4ed/code/4coder_default_framework.cpp", 49, 153 },
{ PROC_LINKS(open_panel_hsplit, 0), "open_panel_hsplit", 17, "Create a new panel by horizontally splitting the active panel.", 62, "/home/allen/4ed/code/4coder_default_framework.cpp", 49, 164 },
{ PROC_LINKS(open_panel_vsplit, 0), "open_panel_vsplit", 17, "Create a new panel by vertically splitting the active panel.", 60, "/home/allen/4ed/code/4coder_default_framework.cpp", 49, 155 },
{ PROC_LINKS(page_down, 0), "page_down", 9, "Scrolls the view down one view height and moves the cursor down one view height.", 80, "/home/allen/4ed/code/4coder_base_commands.cpp", 45, 288 },
{ PROC_LINKS(page_up, 0), "page_up", 7, "Scrolls the view up one view height and moves the cursor up one view height.", 76, "/home/allen/4ed/code/4coder_base_commands.cpp", 45, 279 },
{ PROC_LINKS(paste, 0), "paste", 5, "At the cursor, insert the text at the top of the clipboard.", 59, "/home/allen/4ed/code/4coder_clipboard.cpp", 41, 46 },
{ PROC_LINKS(paste_and_indent, 0), "paste_and_indent", 16, "Paste from the top of clipboard and run auto-indent on the newly pasted text.", 77, "/home/allen/4ed/code/4coder_clipboard.cpp", 41, 130 },
{ PROC_LINKS(paste_and_indent, 0), "paste_and_indent", 16, "Paste from the top of clipboard and run auto-indent on the newly pasted text.", 77, "/home/allen/4ed/code/4coder_clipboard.cpp", 41, 131 },
{ PROC_LINKS(paste_next, 0), "paste_next", 10, "If the previous command was paste or paste_next, replaces the paste range with the next text down on the clipboard, otherwise operates as the paste command.", 156, "/home/allen/4ed/code/4coder_clipboard.cpp", 41, 83 },
{ PROC_LINKS(paste_next_and_indent, 0), "paste_next_and_indent", 21, "Paste the next item on the clipboard and run auto-indent on the newly pasted text.", 82, "/home/allen/4ed/code/4coder_clipboard.cpp", 41, 137 },
{ PROC_LINKS(paste_next_and_indent, 0), "paste_next_and_indent", 21, "Paste the next item on the clipboard and run auto-indent on the newly pasted text.", 82, "/home/allen/4ed/code/4coder_clipboard.cpp", 41, 138 },
{ PROC_LINKS(place_in_scope, 0), "place_in_scope", 14, "Wraps the code contained in the range between cursor and mark with a new curly brace scope.", 91, "/home/allen/4ed/code/4coder_scope_commands.cpp", 46, 481 },
{ PROC_LINKS(project_fkey_command, 0), "project_fkey_command", 20, "Run an 'fkey command' configured in a project.4coder file. Determines the index of the 'fkey command' by which function key or numeric key was pressed to trigger the command.", 175, "/home/allen/4ed/code/4coder_project_commands.cpp", 48, 1078 },
{ PROC_LINKS(project_go_to_root_directory, 0), "project_go_to_root_directory", 28, "Changes 4coder's hot directory to the root directory of the currently loaded project. With no loaded project nothing hapepns.", 125, "/home/allen/4ed/code/4coder_project_commands.cpp", 48, 1103 },
@ -361,7 +361,7 @@ static Command_Metadata fcoder_metacmd_table[202] = {
{ PROC_LINKS(query_replace_selection, 0), "query_replace_selection", 23, "Queries the user for a string, and incrementally replace every occurence of the string found in the selected range with the specified string.", 141, "/home/allen/4ed/code/4coder_base_commands.cpp", 45, 950 },
{ PROC_LINKS(redo, 0), "redo", 4, "Advances forewards through the undo history.", 44, "/home/allen/4ed/code/4coder_base_commands.cpp", 45, 1459 },
{ PROC_LINKS(reload_themes, 0), "reload_themes", 13, "Loads all the theme files in the theme folder, replacing duplicates with the new theme data.", 92, "/home/allen/4ed/code/4coder_base_commands.cpp", 45, 1479 },
{ PROC_LINKS(remap_interactive, 0), "remap_interactive", 17, "Switch to a named key binding map.", 34, "/home/allen/4ed/code/4coder_default_framework.cpp", 49, 211 },
{ PROC_LINKS(remap_interactive, 0), "remap_interactive", 17, "Switch to a named key binding map.", 34, "/home/allen/4ed/code/4coder_default_framework.cpp", 49, 213 },
{ PROC_LINKS(rename_file_query, 0), "rename_file_query", 17, "Queries the user for a new name and renames the file of the current buffer, altering the buffer's name too.", 107, "/home/allen/4ed/code/4coder_base_commands.cpp", 45, 1090 },
{ PROC_LINKS(reopen, 0), "reopen", 6, "Reopen the current buffer from the hard drive.", 46, "/home/allen/4ed/code/4coder_base_commands.cpp", 45, 1465 },
{ PROC_LINKS(replace_in_range, 0), "replace_in_range", 16, "Queries the user for two strings, and replaces all occurences of the first string in the range between the cursor and the mark with the second string.", 150, "/home/allen/4ed/code/4coder_base_commands.cpp", 45, 810 },
@ -404,14 +404,14 @@ static Command_Metadata fcoder_metacmd_table[202] = {
{ PROC_LINKS(show_scrollbar, 0), "show_scrollbar", 14, "Sets the current view to show it's scrollbar.", 45, "/home/allen/4ed/code/4coder_base_commands.cpp", 45, 450 },
{ PROC_LINKS(snipe_token_or_word, 0), "snipe_token_or_word", 19, "Delete a single, whole token on or to the left of the cursor and post it to the clipboard.", 90, "/home/allen/4ed/code/4coder_seek.cpp", 36, 1259 },
{ PROC_LINKS(snipe_token_or_word_right, 0), "snipe_token_or_word_right", 25, "Delete a single, whole token on or to the right of the cursor and post it to the clipboard.", 91, "/home/allen/4ed/code/4coder_seek.cpp", 36, 1265 },
{ PROC_LINKS(suppress_mouse, 0), "suppress_mouse", 14, "Hides the mouse and causes all mosue input (clicks, position, wheel) to be ignored.", 83, "/home/allen/4ed/code/4coder_default_framework.cpp", 49, 185 },
{ PROC_LINKS(suppress_mouse, 0), "suppress_mouse", 14, "Hides the mouse and causes all mosue input (clicks, position, wheel) to be ignored.", 83, "/home/allen/4ed/code/4coder_default_framework.cpp", 49, 187 },
{ PROC_LINKS(swap_buffers_between_panels, 0), "swap_buffers_between_panels", 27, "Set the other non-active panel to view the buffer that the active panel views, and switch to that panel.", 104, "/home/allen/4ed/code/4coder_base_commands.cpp", 45, 1411 },
{ PROC_LINKS(to_lowercase, 0), "to_lowercase", 12, "Converts all ascii text in the range between the cursor and the mark to lowercase.", 82, "/home/allen/4ed/code/4coder_base_commands.cpp", 45, 348 },
{ PROC_LINKS(to_uppercase, 0), "to_uppercase", 12, "Converts all ascii text in the range between the cursor and the mark to uppercase.", 82, "/home/allen/4ed/code/4coder_base_commands.cpp", 45, 328 },
{ PROC_LINKS(toggle_filebar, 0), "toggle_filebar", 14, "Toggles the visibility status of the current view's filebar.", 60, "/home/allen/4ed/code/4coder_base_commands.cpp", 45, 478 },
{ PROC_LINKS(toggle_fullscreen, 0), "toggle_fullscreen", 17, "Toggle fullscreen mode on or off. The change(s) do not take effect until the next frame.", 89, "/home/allen/4ed/code/4coder_default_framework.cpp", 49, 203 },
{ PROC_LINKS(toggle_fullscreen, 0), "toggle_fullscreen", 17, "Toggle fullscreen mode on or off. The change(s) do not take effect until the next frame.", 89, "/home/allen/4ed/code/4coder_default_framework.cpp", 49, 205 },
{ PROC_LINKS(toggle_line_wrap, 0), "toggle_line_wrap", 16, "Toggles the current buffer's line wrapping status.", 50, "/home/allen/4ed/code/4coder_base_commands.cpp", 45, 487 },
{ PROC_LINKS(toggle_mouse, 0), "toggle_mouse", 12, "Toggles the mouse suppression mode, see suppress_mouse and allow_mouse.", 71, "/home/allen/4ed/code/4coder_default_framework.cpp", 49, 197 },
{ PROC_LINKS(toggle_mouse, 0), "toggle_mouse", 12, "Toggles the mouse suppression mode, see suppress_mouse and allow_mouse.", 71, "/home/allen/4ed/code/4coder_default_framework.cpp", 49, 199 },
{ PROC_LINKS(toggle_show_whitespace, 0), "toggle_show_whitespace", 22, "Toggles the current buffer's whitespace visibility status.", 58, "/home/allen/4ed/code/4coder_base_commands.cpp", 45, 554 },
{ PROC_LINKS(toggle_virtual_whitespace, 0), "toggle_virtual_whitespace", 25, "Toggles the current buffer's virtual whitespace status.", 55, "/home/allen/4ed/code/4coder_base_commands.cpp", 45, 543 },
{ PROC_LINKS(undo, 0), "undo", 4, "Advances backwards through the undo history.", 44, "/home/allen/4ed/code/4coder_base_commands.cpp", 45, 1453 },

View File

@ -828,12 +828,14 @@ CUSTOM_DOC("Iteratively tries completing the word to the left of the cursor with
if (buffer.exists){
int32_t do_init = false;
Lifetime_Handle view_life = view_get_lifetime_handle(app, view.view_id);
uint64_t rewrite = 0;
view_get_variable(app, &view, view_rewrite_loc, &rewrite);
core_variable_get(app, view_life, view_rewrite_loc, &rewrite);
if (rewrite != RewriteWordComplete){
do_init = true;
}
view_set_variable(app, &view, view_next_rewrite_loc, RewriteWordComplete);
core_variable_set(app, view_life, view_next_rewrite_loc, RewriteWordComplete);
if (!complete_state.initialized){
do_init = true;
}

View File

@ -103,7 +103,6 @@ fill_view_summary(System_Functions *system, View_Summary *view, View *vptr, Comm
internal Editing_File*
get_file_from_identifier(System_Functions *system, Working_Set *working_set, Buffer_Identifier buffer){
Editing_File *file = 0;
if (buffer.id){
file = working_set_get_active_file(working_set, buffer.id);
}
@ -111,22 +110,25 @@ get_file_from_identifier(System_Functions *system, Working_Set *working_set, Buf
String name = make_string(buffer.name, buffer.name_len);
file = working_set_contains_name(working_set, name);
}
return(file);
}
internal Editing_File*
imp_get_file(Command_Data *cmd, Buffer_ID buffer_id){
Working_Set *working_set = &cmd->models->working_set;
Editing_File *file = working_set_get_active_file(working_set, buffer_id);
if (file != 0 && !file_is_ready(file)){
file = 0;
}
return(file);
}
internal Editing_File*
imp_get_file(Command_Data *cmd, Buffer_Summary *buffer){
Editing_File *file = 0;
Working_Set *working_set = &cmd->models->working_set;;
if (buffer && buffer->exists){
file = working_set_get_active_file(working_set, buffer->buffer_id);
if (file != 0 && !file_is_ready(file)){
file = 0;
}
file = imp_get_file(cmd, buffer->buffer_id);
}
return(file);
}
@ -134,7 +136,6 @@ internal View*
imp_get_view(Command_Data *cmd, View_ID view_id){
Live_Views *live_set = cmd->live_set;
View *vptr = 0;
view_id = view_id - 1;
if (view_id >= 0 && view_id < live_set->max){
vptr = live_set->views + view_id;
@ -142,18 +143,15 @@ imp_get_view(Command_Data *cmd, View_ID view_id){
vptr = 0;
}
}
return(vptr);
}
internal View*
imp_get_view(Command_Data *cmd, View_Summary *view){
View *vptr = 0;
if (view && view->exists){
if (view != 0 && view->exists){
vptr = imp_get_view(cmd, view->view_id);
}
return(vptr);
}
@ -927,10 +925,10 @@ DOC_RETURN(returns non-zero on success)
*/{
Command_Data *cmd = (Command_Data*)app->cmd_context;
Editing_File *file = imp_get_file(cmd, buffer);
bool32 result = 0;
bool32 result = false;
if (file){
result = 1;
if (file != 0){
result = true;
switch (setting){
case BufferSetting_Lex:
{
@ -1197,6 +1195,19 @@ DOC_SEE(Buffer_Setting_ID)
return(result);
}
API_EXPORT Lifetime_Handle
Buffer_Get_Lifetime_Handle(Application_Links *app, Buffer_ID buffer_id)
{
Command_Data *cmd = (Command_Data*)app->cmd_context;
Editing_File *file = imp_get_file(cmd, buffer_id);
Lifetime_Handle lifetime = {0};
if (file != 0){
lifetime.type = LifetimeType_Buffer;
lifetime.buffer_id = buffer_id;
}
return(lifetime);
}
API_EXPORT int32_t
Buffer_Token_Count(Application_Links *app, Buffer_Summary *buffer)
/*
@ -1206,13 +1217,12 @@ If the buffer does not exist or if it is not a lexed buffer, the return is zero.
*/{
Command_Data *cmd = (Command_Data*)app->cmd_context;
Editing_File *file = imp_get_file(cmd, buffer);
int32_t count = 0;
if (file && file->state.token_array.tokens && file->state.tokens_complete){
if (file != 0 &&
file->state.token_array.tokens &&
file->state.tokens_complete){
count = file->state.token_array.count;
}
return(count);
}
@ -1808,7 +1818,6 @@ in the system, the call will fail.)
layout_fix_all_panels(&models->layout);
}
return(result);
}
@ -1817,11 +1826,9 @@ Set_Active_View(Application_Links *app, View_Summary *view)
/*
DOC_PARAM(view, The view parameter specifies which view to make active.)
DOC_RETURN(This call returns non-zero on success.)
DOC(If the given view is open, it is set as the
active view, and takes subsequent commands and is returned
from get_active_view.)
DOC_SEE(get_active_view)
*/{
Command_Data *cmd = (Command_Data*)app->cmd_context;
@ -1932,6 +1939,19 @@ DOC_SEE(View_Setting_ID)
return(result);
}
API_EXPORT Lifetime_Handle
View_Get_Lifetime_Handle(Application_Links *app, View_ID view_id)
{
Command_Data *cmd = (Command_Data*)app->cmd_context;
View *view = imp_get_view(cmd, view_id);
Lifetime_Handle lifetime = {0};
if (view != 0){
lifetime.type = LifetimeType_View;
lifetime.view_id = view_id;
}
return(lifetime);
}
API_EXPORT bool32
View_Set_Split_Proportion(Application_Links *app, View_Summary *view, float t)
/*
@ -2185,54 +2205,8 @@ DOC_SEE(int_color)
}
API_EXPORT int32_t
Create_View_Variable(Application_Links *app, char *null_terminated_name, uint64_t default_value){
Command_Data *cmd = (Command_Data*)app->cmd_context;
Models *models = cmd->models;
String name = make_string_slowly(null_terminated_name);
return(dynamic_variables_lookup_or_create(&models->mem.general,
&models->view_variable_layout, name, default_value));
}
API_EXPORT bool32
View_Set_Variable(Application_Links *app, View_Summary *view, int32_t location, uint64_t value){
Command_Data *cmd = (Command_Data*)app->cmd_context;
View *vptr = imp_get_view(cmd, view);
bool32 result = false;
if (vptr != 0){
Models *models = cmd->models;
u64 *ptr = 0;
if (dynamic_variables_get_ptr(&models->mem.general,
&models->view_variable_layout,
&vptr->transient.dynamic_vars,
location, &ptr)){
result = true;
*ptr = value;
}
}
return(result);
}
API_EXPORT bool32
View_Get_Variable(Application_Links *app, View_Summary *view, int32_t location, uint64_t *value_out){
Command_Data *cmd = (Command_Data*)app->cmd_context;
View *vptr = imp_get_view(cmd, view);
bool32 result = false;
if (vptr != 0){
Models *models = cmd->models;
u64 *ptr = 0;
if (dynamic_variables_get_ptr(&models->mem.general,
&models->view_variable_layout,
&vptr->transient.dynamic_vars,
location, &ptr)){
result = true;
*value_out = *ptr;
}
}
return(result);
}
API_EXPORT int32_t
View_Start_UI_Mode(Application_Links *app, View_Summary *view){
View_Start_UI_Mode(Application_Links *app, View_Summary *view)
{
Command_Data *cmd = (Command_Data*)app->cmd_context;
View *vptr = imp_get_view(cmd, view);
if (vptr != 0){
@ -2246,7 +2220,8 @@ View_Start_UI_Mode(Application_Links *app, View_Summary *view){
}
API_EXPORT int32_t
View_End_UI_Mode(Application_Links *app, View_Summary *view){
View_End_UI_Mode(Application_Links *app, View_Summary *view)
{
Command_Data *cmd = (Command_Data*)app->cmd_context;
View *vptr = imp_get_view(cmd, view);
if (vptr != 0){
@ -2265,7 +2240,8 @@ View_End_UI_Mode(Application_Links *app, View_Summary *view){
}
API_EXPORT bool32
View_Set_UI(Application_Links *app, View_Summary *view, UI_Control *control){
View_Set_UI(Application_Links *app, View_Summary *view, UI_Control *control)
{
Command_Data *cmd = (Command_Data*)app->cmd_context;
View *vptr = imp_get_view(cmd, view);
Models *models = cmd->models;
@ -2358,7 +2334,8 @@ View_Set_UI(Application_Links *app, View_Summary *view, UI_Control *control){
}
API_EXPORT UI_Control
View_Get_UI_Copy(Application_Links *app, View_Summary *view, struct Partition *part){
View_Get_UI_Copy(Application_Links *app, View_Summary *view, struct Partition *part)
{
Command_Data *cmd = (Command_Data*)app->cmd_context;
View *vptr = imp_get_view(cmd, view);
UI_Control result = {0};
@ -2378,6 +2355,89 @@ View_Get_UI_Copy(Application_Links *app, View_Summary *view, struct Partition *p
return(result);
}
API_EXPORT int32_t
Create_Core_Variable(Application_Links *app, Lifetime_Type type, char *null_terminated_name, uint64_t default_value)
{
Command_Data *cmd = (Command_Data*)app->cmd_context;
Models *models = cmd->models;
String name = make_string_slowly(null_terminated_name);
General_Memory *general = &models->mem.general;
switch (type){
case LifetimeType_View:
{
Dynamic_Variable_Layout *layout = &models->view_variable_layout;
return(dynamic_variables_lookup_or_create(general, layout, name, default_value));
}break;
case LifetimeType_Buffer:
{
Dynamic_Variable_Layout *layout = &models->buffer_variable_layout;
return(dynamic_variables_lookup_or_create(general, layout, name, default_value));
}break;
}
return(CoreVariableIndex_ERROR);
}
internal bool32
get_dynamic_variable(Command_Data *cmd, Lifetime_Handle handle,
int32_t location, uint64_t **ptr_out){
Models *models = cmd->models;
General_Memory *general = &models->mem.general;
Dynamic_Variable_Layout *layout = 0;
Dynamic_Variable_Block *block = 0;
switch (handle.type){
case LifetimeType_View:
{
View *vptr = imp_get_view(cmd, handle.view_id);
if (vptr != 0){
layout = &models->view_variable_layout;
block = &vptr->transient.dynamic_vars;
}
}break;
case LifetimeType_Buffer:
{
Editing_File *file = imp_get_file(cmd, handle.buffer_id);
if (file != 0){
layout = &models->buffer_variable_layout;
block = &file->dynamic_vars;
}
}break;
}
bool32 result = false;
if (layout != 0 && block != 0){
if (dynamic_variables_get_ptr(general, layout, block, location, ptr_out)){
result = true;
}
}
return(result);
}
API_EXPORT bool32
Core_Variable_Set(Application_Links *app, Lifetime_Handle handle, int32_t location, uint64_t value)
{
Command_Data *cmd = (Command_Data*)app->cmd_context;
u64 *ptr = 0;
if (get_dynamic_variable(cmd, handle, location, &ptr)){
*ptr = value;
return(true);
}
return(false);
}
API_EXPORT bool32
Core_Variable_Get(Application_Links *app, Lifetime_Handle handle, int32_t location, uint64_t *value_out)
{
Command_Data *cmd = (Command_Data*)app->cmd_context;
u64 *ptr = 0;
if (get_dynamic_variable(cmd, handle, location, &ptr)){
*value_out = *ptr;
return(true);
}
return(false);
}
API_EXPORT User_Input
Get_User_Input(Application_Links *app, Input_Type_Flag get_type, Input_Type_Flag abort_type)
/*
@ -2439,23 +2499,6 @@ DOC_SEE(Mouse_State)
return(mouse);
}
/*
API_EXPORT Event_Message
Get_Event_Message (Application_Links *app){
Event_Message message = {0};
System_Functions *system = (System_Functions*)app->system_links;
Coroutine *coroutine = (Coroutine*)app->current_coroutine;
if (app->type_coroutine == Co_View){
Assert(coroutine);
system->yield_coroutine(coroutine);
message = *(Event_Message*)coroutine->in;
}
return(message);
}
*/
API_EXPORT bool32
Start_Query_Bar(Application_Links *app, Query_Bar *bar, uint32_t flags)
/*
@ -2516,7 +2559,8 @@ Get_Theme_Count(Application_Links *app)
}
API_EXPORT String
Get_Theme_Name(Application_Links *app, Partition *arena, int32_t index){
Get_Theme_Name(Application_Links *app, Partition *arena, int32_t index)
{
Command_Data *cmd = (Command_Data*)app->cmd_context;
Style_Library *library = &cmd->models->styles;

View File

@ -67,6 +67,7 @@ struct Models{
Live_Views live_set;
Parse_Context_Memory parse_context_memory;
Dynamic_Variable_Layout buffer_variable_layout;
Dynamic_Variable_Layout view_variable_layout;
Editing_File *message_buffer;

View File

@ -43,6 +43,7 @@
#include "4ed_linked_node_macros.h"
#include "4ed_log.h"
#include "4ed_dynamic_variables.h"
#include "4ed_buffer_model.h"
#include "4ed_translation.h"
@ -59,10 +60,10 @@
#include "4ed_cli.h"
#include "4ed_gui.h"
#include "4ed_layout.h"
#include "4ed_dynamic_variables.h"
#include "4ed_view.h"
#include "4ed_app_models.h"
#include "4ed_dynamic_variables.cpp"
#include "4ed_parse_context.cpp"
#include "4ed_font.cpp"
#include "4ed_translation.cpp"
@ -79,7 +80,6 @@
#include "4ed_hot_directory.cpp"
#include "4ed_cli.cpp"
#include "4ed_gui.cpp"
#include "4ed_dynamic_variables.cpp"
#include "4ed_layout.cpp"
#include "4coder_buffer_seek_constructors.cpp"
#include "4ed_view.cpp"

View File

@ -131,6 +131,7 @@ struct Editing_File{
b32 is_loading;
b32 is_dummy;
Editing_File_State state;
Dynamic_Variable_Block dynamic_vars;
Editing_File_Markers markers;
Editing_File_Name base_name;
Editing_File_Name unique_name;

View File

@ -15,7 +15,6 @@
struct View_Persistent{
i32 id;
Coroutine_Head *coroutine;
Event_Message message_passing_slot;
};
struct File_Viewing_Data{

View File

@ -66,7 +66,7 @@ working_set_extend_memory(Working_Set *working_set, Editing_File *new_space, i16
}
internal Editing_File*
working_set_alloc(Working_Set *working_set){
working_set_alloc(Working_Set *working_set, General_Memory *general){
Editing_File *result = 0;
if (working_set->file_count < working_set->file_max){
@ -83,6 +83,7 @@ working_set_alloc(Working_Set *working_set){
result->settings.minimum_base_display_width = working_set->default_minimum_base_display_width;
result->settings.wrap_indicator = WrapIndicator_Show_At_Wrap_Edge;
init_file_markers_state(&result->markers);
dynamic_variables_block_init(general, &result->dynamic_vars);
++working_set->file_count;
}
@ -97,7 +98,7 @@ working_set_alloc_always(Working_Set *working_set, General_Memory *general){
Editing_File *new_chunk = gen_array(general, Editing_File, new_count);
working_set_extend_memory(working_set, new_chunk, new_count);
}
result = working_set_alloc(working_set);
result = working_set_alloc(working_set, general);
return(result);
}

View File

@ -1,6 +1,6 @@
name = "sunlight";
Back = 0xFFDFDFDF;
Back = 0xFFDFD5D0;
Margin = 0xFFC7C7C7;
Margin_Hover = 0xFFBFBFBF;
Margin_Active = 0xFFB7B7B7;
@ -22,7 +22,7 @@ Float_Constant = Str_Constant;
Bool_Constant = Str_Constant;
Include = Str_Constant;
Preproc = 0xFF000000;
Special_Character = 0xFF00FFFF;
Special_Character = 0xFFFF00FF;
Ghost_Character = 0xFF929292;
Paste = 0xFFFF0000;