eliminated the poopy-poop-sauce set/get rewrite functions

This commit is contained in:
Allen Webster 2016-06-29 14:23:14 -04:00
parent 7c87b44c81
commit f37b2032c1
10 changed files with 111 additions and 71 deletions

View File

@ -114,12 +114,6 @@ This is the documentation for alpha 4.0.9 super! The documentation has been made
<a href='#view_post_fade_doc'>view_post_fade</a>
</li>
<li>
<a href='#view_set_paste_rewrite__doc'>view_set_paste_rewrite_</a>
</li>
<li>
<a href='#view_get_paste_rewrite__doc'>view_get_paste_rewrite_</a>
</li>
<li>
<a href='#get_user_input_doc'>get_user_input</a>
</li>
<li>
@ -172,7 +166,7 @@ This is the documentation for alpha 4.0.9 super! The documentation has been made
<div id='exec_command_doc' style='margin-bottom: 1cm;'>
<h4>&sect;2.2.0: exec_command</h4>
<div style='font-family: "Courier New", Courier, monospace; text-align: left; margin-top: 3mm; margin-bottom: 3mm; font-size: .95em; background: #DFDFDF; padding: 0.25em;'>void app->exec_command(
<div style='margin-left: 4mm;'>Application_Links *app,<br>int command_id<br></div>)
<div style='margin-left: 4mm;'>Application_Links *app,<br>uint64_t command_id<br></div>)
</div>
<div style='margin-top: 3mm; margin-bottom: 3mm; color: #309030;'><b><i>Parameters</i></b></div><div>
<div style='font-weight: 600;'>command_id</div>
@ -733,22 +727,8 @@ cancels and dialogue shown in the view and displays the file.</div><div style='m
<div style='margin-bottom: 6mm;'><div style='margin-left: 5mm; margin-right: 5mm;'>the color to fade from</div></div>
</div>
</div><hr>
<div id='view_set_paste_rewrite__doc' style='margin-bottom: 1cm;'>
<h4>&sect;2.2.29: view_set_paste_rewrite_</h4>
<div style='font-family: "Courier New", Courier, monospace; text-align: left; margin-top: 3mm; margin-bottom: 3mm; font-size: .95em; background: #DFDFDF; padding: 0.25em;'>void app->view_set_paste_rewrite_(
<div style='margin-left: 4mm;'>Application_Links *app,<br>View_Summary *view<br></div>)
</div>
No documentation generated for this function, assume it is non-public.
</div><hr>
<div id='view_get_paste_rewrite__doc' style='margin-bottom: 1cm;'>
<h4>&sect;2.2.30: view_get_paste_rewrite_</h4>
<div style='font-family: "Courier New", Courier, monospace; text-align: left; margin-top: 3mm; margin-bottom: 3mm; font-size: .95em; background: #DFDFDF; padding: 0.25em;'>int app->view_get_paste_rewrite_(
<div style='margin-left: 4mm;'>Application_Links *app,<br>View_Summary *view<br></div>)
</div>
No documentation generated for this function, assume it is non-public.
</div><hr>
<div id='get_user_input_doc' style='margin-bottom: 1cm;'>
<h4>&sect;2.2.31: get_user_input</h4>
<h4>&sect;2.2.29: get_user_input</h4>
<div style='font-family: "Courier New", Courier, monospace; text-align: left; margin-top: 3mm; margin-bottom: 3mm; font-size: .95em; background: #DFDFDF; padding: 0.25em;'>User_Input app->get_user_input(
<div style='margin-left: 4mm;'>Application_Links *app,<br>unsigned int get_type,<br>unsigned int abort_type<br></div>)
</div>
@ -766,19 +746,19 @@ command is executed an abort signal is returned. If an abort signal is ever ret
command should finish execution without any more calls that preempt the command.
If a get condition is met the user input is returned</div><div style='margin-top: 3mm; margin-bottom: 3mm; color: #309030;'><b><i>See Also</i></b></div><div style='margin-left: 5mm; margin-right: 5mm;'><a href='#Input_Type_Flag_doc'>Input_Type_Flag</a></div><div style='margin-left: 5mm; margin-right: 5mm;'><a href='#User_Input_doc'>User_Input</a></div></div><hr>
<div id='get_command_input_doc' style='margin-bottom: 1cm;'>
<h4>&sect;2.2.32: get_command_input</h4>
<h4>&sect;2.2.30: get_command_input</h4>
<div style='font-family: "Courier New", Courier, monospace; text-align: left; margin-top: 3mm; margin-bottom: 3mm; font-size: .95em; background: #DFDFDF; padding: 0.25em;'>User_Input app->get_command_input(
<div style='margin-left: 4mm;'>Application_Links *app<br></div>)
</div>
<div style='margin-top: 3mm; margin-bottom: 3mm; color: #309030;'><b><i>Return</i></b></div><div style='margin-left: 5mm; margin-right: 5mm;'>returns the input that triggered the command in execution.</div><div style='margin-top: 3mm; margin-bottom: 3mm; color: #309030;'><b><i>See Also</i></b></div><div style='margin-left: 5mm; margin-right: 5mm;'><a href='#User_Input_doc'>User_Input</a></div></div><hr>
<div id='get_mouse_state_doc' style='margin-bottom: 1cm;'>
<h4>&sect;2.2.33: get_mouse_state</h4>
<h4>&sect;2.2.31: get_mouse_state</h4>
<div style='font-family: "Courier New", Courier, monospace; text-align: left; margin-top: 3mm; margin-bottom: 3mm; font-size: .95em; background: #DFDFDF; padding: 0.25em;'>Mouse_State app->get_mouse_state(
<div style='margin-left: 4mm;'>Application_Links *app<br></div>)
</div>
<div style='margin-top: 3mm; margin-bottom: 3mm; color: #309030;'><b><i>Return</i></b></div><div style='margin-left: 5mm; margin-right: 5mm;'>returns the current mouse state</div><div style='margin-top: 3mm; margin-bottom: 3mm; color: #309030;'><b><i>See Also</i></b></div><div style='margin-left: 5mm; margin-right: 5mm;'><a href='#Mouse_State_doc'>Mouse_State</a></div></div><hr>
<div id='start_query_bar_doc' style='margin-bottom: 1cm;'>
<h4>&sect;2.2.34: start_query_bar</h4>
<h4>&sect;2.2.32: start_query_bar</h4>
<div style='font-family: "Courier New", Courier, monospace; text-align: left; margin-top: 3mm; margin-bottom: 3mm; font-size: .95em; background: #DFDFDF; padding: 0.25em;'>int app->start_query_bar(
<div style='margin-left: 4mm;'>Application_Links *app,<br>Query_Bar *bar,<br>unsigned int flags<br></div>)
</div>
@ -793,7 +773,7 @@ If a get condition is met the user input is returned</div><div style='margin-top
<div style='margin-top: 3mm; margin-bottom: 3mm; color: #309030;'><b><i>Return</i></b></div><div style='margin-left: 5mm; margin-right: 5mm;'>returns non-zero on success</div><div style='margin-top: 3mm; margin-bottom: 3mm; color: #309030;'><b><i>Description</i></b></div><div style='margin-left: 5mm; margin-right: 5mm;'>The memory pointed to by bar must remain valid until a call to end_query_bar or
until the command returns.</div></div><hr>
<div id='end_query_bar_doc' style='margin-bottom: 1cm;'>
<h4>&sect;2.2.35: end_query_bar</h4>
<h4>&sect;2.2.33: end_query_bar</h4>
<div style='font-family: "Courier New", Courier, monospace; text-align: left; margin-top: 3mm; margin-bottom: 3mm; font-size: .95em; background: #DFDFDF; padding: 0.25em;'>void app->end_query_bar(
<div style='margin-left: 4mm;'>Application_Links *app,<br>Query_Bar *bar,<br>unsigned int flags<br></div>)
</div>
@ -807,7 +787,7 @@ until the command returns.</div></div><hr>
</div>
<div style='margin-top: 3mm; margin-bottom: 3mm; color: #309030;'><b><i>Description</i></b></div><div style='margin-left: 5mm; margin-right: 5mm;'>bar must be a pointer previously passed to start_query_bar previously in the same command.</div></div><hr>
<div id='print_message_doc' style='margin-bottom: 1cm;'>
<h4>&sect;2.2.36: print_message</h4>
<h4>&sect;2.2.34: print_message</h4>
<div style='font-family: "Courier New", Courier, monospace; text-align: left; margin-top: 3mm; margin-bottom: 3mm; font-size: .95em; background: #DFDFDF; padding: 0.25em;'>void app->print_message(
<div style='margin-left: 4mm;'>Application_Links *app,<br>char *str,<br>int len<br></div>)
</div>
@ -821,7 +801,7 @@ until the command returns.</div></div><hr>
</div>
</div><hr>
<div id='change_theme_doc' style='margin-bottom: 1cm;'>
<h4>&sect;2.2.37: change_theme</h4>
<h4>&sect;2.2.35: change_theme</h4>
<div style='font-family: "Courier New", Courier, monospace; text-align: left; margin-top: 3mm; margin-bottom: 3mm; font-size: .95em; background: #DFDFDF; padding: 0.25em;'>void app->change_theme(
<div style='margin-left: 4mm;'>Application_Links *app,<br>char *name,<br>int len<br></div>)
</div>
@ -835,7 +815,7 @@ until the command returns.</div></div><hr>
</div>
</div><hr>
<div id='change_font_doc' style='margin-bottom: 1cm;'>
<h4>&sect;2.2.38: change_font</h4>
<h4>&sect;2.2.36: change_font</h4>
<div style='font-family: "Courier New", Courier, monospace; text-align: left; margin-top: 3mm; margin-bottom: 3mm; font-size: .95em; background: #DFDFDF; padding: 0.25em;'>void app->change_font(
<div style='margin-left: 4mm;'>Application_Links *app,<br>char *name,<br>int len<br></div>)
</div>
@ -849,7 +829,7 @@ until the command returns.</div></div><hr>
</div>
</div><hr>
<div id='set_theme_colors_doc' style='margin-bottom: 1cm;'>
<h4>&sect;2.2.39: set_theme_colors</h4>
<h4>&sect;2.2.37: set_theme_colors</h4>
<div style='font-family: "Courier New", Courier, monospace; text-align: left; margin-top: 3mm; margin-bottom: 3mm; font-size: .95em; background: #DFDFDF; padding: 0.25em;'>void app->set_theme_colors(
<div style='margin-left: 4mm;'>Application_Links *app,<br>Theme_Color *colors,<br>int count<br></div>)
</div>
@ -864,7 +844,7 @@ until the command returns.</div></div><hr>
<div style='margin-top: 3mm; margin-bottom: 3mm; color: #309030;'><b><i>Description</i></b></div><div style='margin-left: 5mm; margin-right: 5mm;'>For each color struct in the array, the color in the style pallet is set to the color
code paired with the tag.</div></div><hr>
<div id='get_theme_colors_doc' style='margin-bottom: 1cm;'>
<h4>&sect;2.2.40: get_theme_colors</h4>
<h4>&sect;2.2.38: get_theme_colors</h4>
<div style='font-family: "Courier New", Courier, monospace; text-align: left; margin-top: 3mm; margin-bottom: 3mm; font-size: .95em; background: #DFDFDF; padding: 0.25em;'>void app->get_theme_colors(
<div style='margin-left: 4mm;'>Application_Links *app,<br>Theme_Color *colors,<br>int count<br></div>)
</div>
@ -879,7 +859,7 @@ code paired with the tag.</div></div><hr>
<div style='margin-top: 3mm; margin-bottom: 3mm; color: #309030;'><b><i>Description</i></b></div><div style='margin-left: 5mm; margin-right: 5mm;'>For each color struct in the array, the color field of the struct is filled with the
color from the specified color in the pallet.</div></div><hr>
<div id='directory_get_hot_doc' style='margin-bottom: 1cm;'>
<h4>&sect;2.2.41: directory_get_hot</h4>
<h4>&sect;2.2.39: directory_get_hot</h4>
<div style='font-family: "Courier New", Courier, monospace; text-align: left; margin-top: 3mm; margin-bottom: 3mm; font-size: .95em; background: #DFDFDF; padding: 0.25em;'>int app->directory_get_hot(
<div style='margin-left: 4mm;'>Application_Links *app,<br>char *out,<br>int capacity<br></div>)
</div>
@ -897,7 +877,7 @@ accessed in the GUI. Whenever the GUI is opened it shows the hot directory.
In the future this will be deprecated and eliminated in favor of more flexible
directories controlled by the custom side.</div></div><hr>
<div id='get_file_list_doc' style='margin-bottom: 1cm;'>
<h4>&sect;2.2.42: get_file_list</h4>
<h4>&sect;2.2.40: get_file_list</h4>
<div style='font-family: "Courier New", Courier, monospace; text-align: left; margin-top: 3mm; margin-bottom: 3mm; font-size: .95em; background: #DFDFDF; padding: 0.25em;'>File_List app->get_file_list(
<div style='margin-left: 4mm;'>Application_Links *app,<br>char *dir,<br>int len<br></div>)
</div>
@ -913,7 +893,7 @@ directories controlled by the custom side.</div></div><hr>
the specified directory. The File_List returned should be passed to free_file_list
when it is no longer in use.</div></div><hr>
<div id='free_file_list_doc' style='margin-bottom: 1cm;'>
<h4>&sect;2.2.43: free_file_list</h4>
<h4>&sect;2.2.41: free_file_list</h4>
<div style='font-family: "Courier New", Courier, monospace; text-align: left; margin-top: 3mm; margin-bottom: 3mm; font-size: .95em; background: #DFDFDF; padding: 0.25em;'>void app->free_file_list(
<div style='margin-left: 4mm;'>Application_Links *app,<br>File_List list<br></div>)
</div>
@ -923,7 +903,7 @@ when it is no longer in use.</div></div><hr>
</div>
<div style='margin-top: 3mm; margin-bottom: 3mm; color: #309030;'><b><i>Description</i></b></div><div style='margin-left: 5mm; margin-right: 5mm;'>after this call the file list passed in should not be read or written to</div></div><hr>
<div id='file_exists_doc' style='margin-bottom: 1cm;'>
<h4>&sect;2.2.44: file_exists</h4>
<h4>&sect;2.2.42: file_exists</h4>
<div style='font-family: "Courier New", Courier, monospace; text-align: left; margin-top: 3mm; margin-bottom: 3mm; font-size: .95em; background: #DFDFDF; padding: 0.25em;'>int app->file_exists(
<div style='margin-left: 4mm;'>Application_Links *app,<br>char *filename,<br>int len<br></div>)
</div>
@ -937,7 +917,7 @@ when it is no longer in use.</div></div><hr>
</div>
<div style='margin-top: 3mm; margin-bottom: 3mm; color: #309030;'><b><i>Return</i></b></div><div style='margin-left: 5mm; margin-right: 5mm;'>returns non-zero if the file exists, returns zero if the file does not exist</div></div><hr>
<div id='directory_cd_doc' style='margin-bottom: 1cm;'>
<h4>&sect;2.2.45: directory_cd</h4>
<h4>&sect;2.2.43: directory_cd</h4>
<div style='font-family: "Courier New", Courier, monospace; text-align: left; margin-top: 3mm; margin-bottom: 3mm; font-size: .95em; background: #DFDFDF; padding: 0.25em;'>int app->directory_cd(
<div style='margin-left: 4mm;'>Application_Links *app,<br>char *dir,<br>int *len,<br>int capacity,<br>char *rel_path,<br>int rel_len<br></div>)
</div>
@ -969,7 +949,7 @@ For instance if dir contains "C:/Users/MySelf" and rel is "Documents" the buffer
"C:/Users/MySelf/Documents" and len will contain the length of that string. This call can
also be used with rel set to ".." to traverse to parent folders.</div></div><hr>
<div id='get_4ed_path_doc' style='margin-bottom: 1cm;'>
<h4>&sect;2.2.46: get_4ed_path</h4>
<h4>&sect;2.2.44: get_4ed_path</h4>
<div style='font-family: "Courier New", Courier, monospace; text-align: left; margin-top: 3mm; margin-bottom: 3mm; font-size: .95em; background: #DFDFDF; padding: 0.25em;'>int app->get_4ed_path(
<div style='margin-left: 4mm;'>Application_Links *app,<br>char *out,<br>int capacity<br></div>)
</div>

View File

@ -2,6 +2,8 @@
#ifndef FCODER_CUSTOM_H
#define FCODER_CUSTOM_H
#include <stdint.h>
#include "4coder_version.h"
#include "4coder_keycodes.h"
#include "4coder_style.h"
@ -112,7 +114,9 @@ typedef struct Buffer_Identifier{
int id;
} Buffer_Identifier;
enum Command_ID{
typedef uint64_t Command_ID;
enum{
cmdid_null,
cmdid_center_view,
@ -177,6 +181,7 @@ enum Special_Hook_ID{
_hook_scroll_rule = hook_type_count,
_hook_new_file,
_hook_open_file,
_hook_command_caller,
};
// None of the members of *_Summary structs nor any of the data pointed
@ -336,15 +341,23 @@ enum Input_Type_Flag{
#define OPEN_FILE_HOOK_SIG(name) int name(struct Application_Links *app, int buffer_id)
#define SCROLL_RULE_SIG(name) int name(float target_x, float target_y, float *scroll_x, float *scroll_y, int view_id, int is_new_target, float dt)
extern "C"{
typedef VIEW_ROUTINE_SIG(View_Routine_Function);
typedef CUSTOM_COMMAND_SIG(Custom_Command_Function);
typedef GET_BINDING_DATA(Get_Binding_Data_Function);
typedef HOOK_SIG(Hook_Function);
typedef OPEN_FILE_HOOK_SIG(Open_File_Hook_Function);
typedef SCROLL_RULE_SIG(Scroll_Rule_Function);
}
typedef VIEW_ROUTINE_SIG(View_Routine_Function);
typedef CUSTOM_COMMAND_SIG(Custom_Command_Function);
typedef GET_BINDING_DATA(Get_Binding_Data_Function);
typedef HOOK_SIG(Hook_Function);
typedef OPEN_FILE_HOOK_SIG(Open_File_Hook_Function);
typedef SCROLL_RULE_SIG(Scroll_Rule_Function);
union Generic_Command{
Command_ID cmdid;
Custom_Command_Function *command;
};
#define COMMAND_CALLER_HOOK(name) int name(struct Application_Links *app, Generic_Command cmd)
typedef COMMAND_CALLER_HOOK(Command_Caller_Hook_Function);
struct Application_Links;
#include "4coder_custom_api.h"

View File

@ -1,4 +1,4 @@
#define EXEC_COMMAND_SIG(n) void n(Application_Links *app, int command_id)
#define EXEC_COMMAND_SIG(n) void n(Application_Links *app, uint64_t command_id)
#define EXEC_SYSTEM_COMMAND_SIG(n) int n(Application_Links *app, View_Summary *view, Buffer_Identifier buffer, char *path, int path_len, char *command, int command_len, unsigned int flags)
#define CLIPBOARD_POST_SIG(n) void n(Application_Links *app, char *str, int len)
#define CLIPBOARD_COUNT_SIG(n) int n(Application_Links *app)
@ -27,8 +27,6 @@
#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(n) int n(Application_Links *app, View_Summary *view, int buffer_id, unsigned int flags)
#define VIEW_POST_FADE_SIG(n) int n(Application_Links *app, View_Summary *view, float seconds, int start, int end, unsigned int color)
#define VIEW_SET_PASTE_REWRITE__SIG(n) void n(Application_Links *app, View_Summary *view)
#define VIEW_GET_PASTE_REWRITE__SIG(n) int n(Application_Links *app, View_Summary *view)
#define GET_USER_INPUT_SIG(n) User_Input n(Application_Links *app, unsigned int get_type, unsigned int 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)
@ -75,8 +73,6 @@ extern "C"{
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 VIEW_SET_PASTE_REWRITE__SIG(View_Set_Paste_Rewrite__Function);
typedef VIEW_GET_PASTE_REWRITE__SIG(View_Get_Paste_Rewrite__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);
@ -126,8 +122,6 @@ struct Application_Links{
View_Set_Highlight_Function *view_set_highlight;
View_Set_Buffer_Function *view_set_buffer;
View_Post_Fade_Function *view_post_fade;
View_Set_Paste_Rewrite__Function *view_set_paste_rewrite_;
View_Get_Paste_Rewrite__Function *view_get_paste_rewrite_;
Get_User_Input_Function *get_user_input;
Get_Command_Input_Function *get_command_input;
Get_Mouse_State_Function *get_mouse_state;
@ -179,8 +173,6 @@ 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->view_set_paste_rewrite_ = View_Set_Paste_Rewrite_;\
app_links->view_get_paste_rewrite_ = View_Get_Paste_Rewrite_;\
app_links->get_user_input = Get_User_Input;\
app_links->get_command_input = Get_Command_Input;\
app_links->get_mouse_state = Get_Mouse_State;\

View File

@ -148,12 +148,10 @@ HOOK_SIG(my_start){
}
OPEN_FILE_HOOK_SIG(my_file_settings){
// NOTE(allen|a4): In hooks that want parameters, such as this file
// opened hook. The file created hook is guaranteed to have only
// and exactly one buffer parameter. In normal command callbacks
// there are no parameter buffers.
// NOTE(allen|a4.0.8): The app->get_parameter_buffer was eliminated
// and instead the buffer is passed as an explicit parameter through
// the function call. That is where buffer_id comes from here.
unsigned int access = AccessProtected|AccessHidden;
//Buffer_Summary buffer = app->get_parameter_buffer(app, 0, access);
Buffer_Summary buffer = app->get_buffer(app, buffer_id, access);
assert(buffer.exists);
@ -184,6 +182,23 @@ OPEN_FILE_HOOK_SIG(my_file_settings){
return(0);
}
// NOTE(allen|a4.0.9): All command calls can now go through this hook
// If this hook is not implemented a default behavior of calling the
// command is used. It is important to note that paste_next does not
// work without this hook.
COMMAND_CALLER_HOOK(my_command_caller){
View_Summary view = app->get_active_view(app, AccessAll);
view_paste_index[view.view_id].next_rewrite = false;
exec_command(app, cmd);
view_paste_index[view.view_id].rewrite =
view_paste_index[view.view_id].next_rewrite;
return(0);
}
void
default_keys(Bind_Helper *context){
begin_map(context, mapid_global);
@ -338,6 +353,7 @@ get_bindings(void *data, int size){
set_hook(context, hook_start, my_start);
set_open_file_hook(context, my_file_settings);
set_command_caller(context, my_command_caller);
set_scroll_rule(context, smooth_scroll_rule);
default_keys(context);

View File

@ -275,6 +275,8 @@ CUSTOM_COMMAND_SIG(cut){
}
struct View_Paste_Index{
int rewrite;
int next_rewrite;
int index;
};
@ -287,10 +289,7 @@ CUSTOM_COMMAND_SIG(paste){
if (count > 0){
View_Summary view = app->get_active_view(app, access);
// NOTE(allen): THIS is a very temporary poop-sauce
// system that I just threw in to get this working.
// Please don't start calling it anywhere.
app->view_set_paste_rewrite_(app, &view);
view_paste_index[view.view_id].next_rewrite = true;
int paste_index = 0;
view_paste_index[view.view_id].index = paste_index;
@ -329,8 +328,8 @@ CUSTOM_COMMAND_SIG(paste_next){
// NOTE(allen): THIS is a very temporary poop-sauce
// system that I just threw in to get this working.
// Please don't start calling it anywhere.
if (app->view_get_paste_rewrite_(app, &view)){
app->view_set_paste_rewrite_(app, &view);
if (view_paste_index[view.view_id].rewrite){
view_paste_index[view.view_id].next_rewrite = true;
int paste_index = view_paste_index[view.view_id].index + 1;
view_paste_index[view.view_id].index = paste_index;

View File

@ -196,6 +196,16 @@ set_new_file_hook(Bind_Helper *helper, Open_File_Hook_Function *func){
write_unit(helper, unit);
}
inline void
set_command_caller(Bind_Helper *helper, Command_Caller_Hook_Function *func){
Binding_Unit unit;
unit.type = unit_hook;
unit.hook.hook_id = _hook_command_caller;
unit.hook.func = (void*) func;
write_unit(helper, unit);
}
inline void
set_scroll_rule(Bind_Helper *helper, Scroll_Rule_Function *func){
Binding_Unit unit;
@ -263,6 +273,16 @@ exec_command(Application_Links *app, Custom_Command_Function *func){
func(app);
}
inline void
exec_command(Application_Links *app, Generic_Command cmd){
if (cmd.cmdid < cmdid_count){
exec_command(app, cmd.cmdid);
}
else{
exec_command(app, cmd.command);
}
}
inline void
active_view_to_line(Application_Links *app, unsigned int access, int line_number){
View_Summary view;

22
4ed.cpp
View File

@ -1005,12 +1005,24 @@ internal void
command_caller(Coroutine *coroutine){
Command_In *cmd_in = (Command_In*)coroutine->in;
Command_Data *cmd = cmd_in->cmd;
Models *models = cmd->models;
View *view = cmd->view;
// TODO(allen): this isn't really super awesome, could have issues if
// the file view get's change out under us.
view->next_mode = view_mode_zero();
cmd_in->bind.function(cmd->system, cmd, cmd_in->bind);
if (models->command_caller){
Generic_Command generic;
if (cmd_in->bind.function == command_user_callback){
generic.command = cmd_in->bind.custom;
models->command_caller(&models->app_links, generic);
}
else{
generic.cmdid = (Command_ID)cmd_in->bind.custom_id;
models->command_caller(&models->app_links, generic);
}
}
else{
cmd_in->bind.function(cmd->system, cmd, cmd_in->bind);
}
view->mode = view->next_mode;
}
@ -1773,6 +1785,10 @@ App_Init_Sig(app_init){
models->hook_new_file = (Open_File_Hook_Function*)unit->hook.func;
break;
case _hook_command_caller:
models->command_caller = (Command_Caller_Hook_Function*)unit->hook.func;
break;
case _hook_scroll_rule:
models->scroll_rule = (Scroll_Rule_Function*)unit->hook.func;
break;

View File

@ -142,7 +142,7 @@ imp_get_view(Command_Data *cmd, View_Summary *view){
#define API_EXPORT
API_EXPORT void
Exec_Command(Application_Links *app, int command_id)/*
Exec_Command(Application_Links *app, uint64_t command_id)/*
DOC_PARAM(command_id, an integer id enumerated in 4coder_custom.h starting with cmdid)
DOC(Executes the command associated with the command_id passed in)
*/{
@ -1331,6 +1331,7 @@ DOC_PARAM(color, the color to fade from)
return(result);
}
/*
API_EXPORT void
View_Set_Paste_Rewrite_(Application_Links *app, View_Summary *view){
Command_Data *cmd = (Command_Data*)app->cmd_context;
@ -1350,6 +1351,7 @@ View_Get_Paste_Rewrite_(Application_Links *app, View_Summary *view){
}
return(result);
}
*/
API_EXPORT User_Input
Get_User_Input(Application_Links *app, unsigned int get_type, unsigned int abort_type)/*

View File

@ -79,6 +79,7 @@ struct Models{
Open_File_Hook_Function *hook_open_file;
Open_File_Hook_Function *hook_new_file;
Command_Caller_Hook_Function *command_caller;
Scroll_Rule_Function *scroll_rule;
b32 keep_playing;

View File

@ -273,6 +273,7 @@ get_bindings(void *data, int size){
set_hook(context, hook_start, experimental_start_hook);
set_open_file_hook(context, my_file_settings);
set_command_caller(context, my_command_caller);
set_scroll_rule(context, smooth_scroll_rule);