exit hook ready

master
Allen Webster 2016-09-09 09:04:51 -04:00
parent 5b2077c6d7
commit aea67fa68b
9 changed files with 55 additions and 38 deletions

View File

@ -33,6 +33,7 @@ typedef struct Offset_String{
enum Hook_ID{
hook_start,
hook_file_out_of_sync,
hook_exit,
// never below this
hook_type_count
};

View File

@ -153,6 +153,11 @@ HOOK_SIG(my_start){
return(0);
}
HOOK_SIG(my_exit){
// if this returns zero it cancels the exit.
return(1);
}
CUSTOM_COMMAND_SIG(newline_or_goto_position){
View_Summary view = app->get_active_view(app, AccessProtected);
Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, AccessProtected);
@ -412,6 +417,7 @@ get_bindings(void *data, int32_t size){
// NOTE(allen|a3.1): Hooks have no loyalties to maps. All hooks are global
// and once set they always apply, regardless of what map is active.
set_hook(context, hook_start, my_start);
set_hook(context, hook_exit, my_exit);
set_open_file_hook(context, my_file_settings);
set_command_caller(context, default_command_caller);

View File

@ -182,7 +182,8 @@ ENUM(uint32_t, Buffer_Create_Flag){
cleared to empty even if it's associated file already has content.) */
BufferCreate_AlwaysNew = 0x2,
/* DOC(When BufferCreate_NeverNew is set it indicates that the buffer should
only be created if it is an existing file or an open buffer.) */
only be created if it is an existing file or if a buffer with the given name
is already open.) */
BufferCreate_NeverNew = 0x4,
};

View File

@ -2680,6 +2680,13 @@ App_Step_Sig(app_step){
}
}
// NOTE(allen): if this is the last frame, run the exit hook
if (!models->keep_playing && models->hooks[hook_exit]){
if (!models->hooks[hook_exit](&models->app_links)){
models->keep_playing = 1;
}
}
// NOTE(allen): rendering
{
begin_render_section(target, system);

View File

@ -979,12 +979,11 @@ DOC_PARAM(buffer, The buffer parameter specifies the buffer to try to kill.)
DOC_PARAM(view_id, The view_id parameter specifies the view that will contain the "are you sure" dialogue if the buffer is dirty.)
DOC_PARAM(flags, The flags parameter specifies behaviors for the buffer kill.)
DOC_RETURN(This call returns non-zero if the buffer is killed.)
DOC
(
Tries to kill the idenfied buffer. If the buffer is dirty and the "are you sure"
DOC(Tries to kill the idenfied buffer. If the buffer is dirty and the "are you sure"
dialogue needs to be displayed the provided view is used to show the dialogue.
If the view is not open the kill fails.
)
If the view is not open the kill fails.)
DOC_SEE(Buffer_Kill_Flag)
DOC_SEE(Buffer_Identifier)
*/{

View File

@ -58,6 +58,14 @@ struct Models{
Hook_Function *hooks[hook_type_count];
Application_Links app_links;
Custom_API config_api;
Open_File_Hook_Function *hook_open_file;
Open_File_Hook_Function *hook_new_file;
Command_Caller_Hook_Function *command_caller;
Input_Filter_Function *input_filter;
Scroll_Rule_Function *scroll_rule;
Font_Set *font_set;
Style_Font global_font;
Style_Library styles;
@ -75,14 +83,6 @@ struct Models{
Panel *prev_mouse_panel;
Custom_API config_api;
Open_File_Hook_Function *hook_open_file;
Open_File_Hook_Function *hook_new_file;
Command_Caller_Hook_Function *command_caller;
Input_Filter_Function *input_filter;
Scroll_Rule_Function *scroll_rule;
b32 keep_playing;
Debug_Data debug;

View File

@ -72,43 +72,37 @@
; [X] clean whitespace doesn't appear to be cleaning trailing whitespace anymore???
; [X] problem with end of line comments
; [X] paths with parens in them
; [X] killing compilation panel changes active panel
;
; [] indication on failure to save
; [] history is broken, revist the entire system
; [] 8.0\Include\um\dsound.h (not reproduced, get more info)
; [] paste external text from bug report (in email) (not reproduced, get more info)
;
; [] view fails to follow cursor when the view is shrunk
; [] view fails to follow cursor after deleting long line
;
;
; BEFORE I SHIP
;
; [X] killing compilation panel changes active panel
; [X] tokens in the custom API
; [X] token seeking on custom side
; [X] auto indent on the custom side
; [] indent whole comments
; [] inserting lines at end of block comment
; [] clean up and comment the auto indent code to allow for customizations
; [] more built in options for auto indenting
; [] expose dirty flags
; [] make panel resizing not whacky with child panels
; [] mouse down/up distinction
; [] hook on exit
; [] occasionally missing the (!) mark on files on windows
; [] case insensitive interactive switch buffer
; [] scroll down on compilation buffer durring compilation
; [] why are command line files not loading any more?
;
;
; [] commands for resizing panels
; [] user file bar string
; [] option to not open *messages* every startup
; [] API docs as text file
; [] read only files
; [] tab to complete folder names in the new file dialogue
; [] option to hide hidden files
; [] view fails to follow cursor when the view is shrunk
; [] view fails to follow cursor after deleting long line
; [] control over how mouse effects panel focus
; TODOS
; [X] success message when compiler works
; [X] auto-complete
@ -145,6 +139,18 @@
; [X] add to APIs
; [X] try to make win32 version better
; [X] don't execute frames on events dealing only with ctrl/alt/shift
; [X] hook on exit
;
; [] binary buffers
; [] commands for resizing panels
; [] user file bar string
; [] API docs as text file
; [] read only files
; [] tab to complete folder names in the new file dialogue
; [] option to hide hidden files
; [] control over how mouse effects panel focus
; [] option to not open *messages* every startup
;
; [] support full length unicode file names
; [] switch based word complete

16
build.c
View File

@ -679,18 +679,16 @@ metagen(char *cdir){
static void
do_buildsuper(char *cdir){
{
BEGIN_TIME_SECTION();
//buildsuper(cdir, BUILD_DIR, "../code/4coder_default_bindings.cpp");
BEGIN_TIME_SECTION();
buildsuper(cdir, BUILD_DIR, "../code/4coder_default_bindings.cpp");
#if defined(IS_WINDOWS)
buildsuper(cdir, BUILD_DIR, "../code/internal_4coder_tests.cpp");
//buildsuper(cdir, BUILD_DIR, "../code/internal_4coder_tests.cpp");
#else
buildsuper(cdir, BUILD_DIR, "../code/power/4coder_experiments.cpp");
buildsuper(cdir, BUILD_DIR, "../code/power/4coder_experiments.cpp");
#endif
//buildsuper(cdir, BUILD_DIR, "../code/power/4coder_casey.cpp");
//buildsuper(cdir, BUILD_DIR, "../4vim/4coder_chronal.cpp");
END_TIME_SECTION("build custom");
}
//buildsuper(cdir, BUILD_DIR, "../code/power/4coder_casey.cpp");
//buildsuper(cdir, BUILD_DIR, "../4vim/4coder_chronal.cpp");
END_TIME_SECTION("build custom");
}
static void

View File

@ -343,8 +343,7 @@ HOOK_SIG(experimental_start){
if (!file){
char module_path[512];
int len;
len = app->get_4ed_path(app, module_path, 448);
int len = app->get_4ed_path(app, module_path, 448);
memcpy(module_path+len, SETTINGS_FILE, sizeof(SETTINGS_FILE));
file = fopen(module_path, "rb");
}