From 3fd4565eaba82fc55e348103b2c14939342d5b71 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Sun, 20 Mar 2016 18:43:28 -0400 Subject: [PATCH] intended interface for stdout capture --- 4ed.cpp | 2 +- 4ed.h | 31 ++++++++++++++++--------------- 4ed_file.cpp | 1 - 4ed_system.h | 7 ++++++- TODO.txt | 22 +++++++++++++--------- win32_4ed.cpp | 29 ++++++++++++++++++++--------- 6 files changed, 56 insertions(+), 36 deletions(-) diff --git a/4ed.cpp b/4ed.cpp index d97c3a8c..2d1acf0c 100644 --- a/4ed.cpp +++ b/4ed.cpp @@ -3732,7 +3732,7 @@ App_Step_Sig(app_step){ "-The file count limit is over 8 million now\n" "-File equality is handled better so renamings (such as 'subst') are safe now\n" "-This buffer will report events including errors that happen in 4coder\n" - "-Super users can post their own messages here with app->do_message\n" + "-Super users can post their own messages here with printf\n" "-Set font size on command line with -f N, N = 16 by default\n\n" ); diff --git a/4ed.h b/4ed.h index 524ee181..c6f7ff3b 100644 --- a/4ed.h +++ b/4ed.h @@ -68,18 +68,18 @@ struct Plat_Settings{ i32 name(System_Functions *system, \ Application_Memory *memory, \ String current_directory, \ - Plat_Settings *plat_settings, \ - char ***files, i32 **file_count, \ + Plat_Settings *plat_settings, \ + char ***files, i32 **file_count, \ Command_Line_Parameters clparams) typedef App_Read_Command_Line_Sig(App_Read_Command_Line); -#define App_Init_Sig(name) void \ -name(System_Functions *system, \ +#define App_Init_Sig(name) void \ +name(System_Functions *system, \ Render_Target *target, \ Application_Memory *memory, \ Exchange *exchange, \ - String clipboard, \ + String clipboard, \ String current_directory, \ Custom_API api) @@ -103,16 +103,17 @@ struct Application_Step_Result{ b32 perform_kill; }; -#define App_Step_Sig(name) void \ - name(System_Functions *system, \ - Key_Input_Data *input, \ - Mouse_State *mouse, \ - Render_Target *target, \ - Application_Memory *memory, \ - Exchange *exchange, \ - String clipboard, \ - b32 time_step, b32 first_step, b32 force_redraw, \ - Application_Step_Result *result) +#define App_Step_Sig(name) void \ +name(System_Functions *system, \ + Key_Input_Data *input, \ + Mouse_State *mouse, \ + CLI_Handles self, \ + Render_Target *target, \ + Application_Memory *memory, \ + Exchange *exchange, \ + String clipboard, \ + b32 time_step, b32 first_step, b32 force_redraw, \ + Application_Step_Result *result) typedef App_Step_Sig(App_Step); diff --git a/4ed_file.cpp b/4ed_file.cpp index 37856703..2e9eeefb 100644 --- a/4ed_file.cpp +++ b/4ed_file.cpp @@ -193,7 +193,6 @@ tbl_file_hash(void *item, void *arg){ hash = ((hash << 6) + hash) + uhash.d[1]; hash = ((hash << 6) + hash) + uhash.d[2]; hash = ((hash << 6) + hash) + uhash.d[3]; - hash = ((hash << 6) + hash) + uhash.non_file_id; return(hash); } diff --git a/4ed_system.h b/4ed_system.h index 2d7d06b2..ce83b457 100644 --- a/4ed_system.h +++ b/4ed_system.h @@ -13,9 +13,14 @@ struct Plat_Handle{ u32 d[4]; }; +inline int +handle_equal(Plat_Handle a, Plat_Handle b){ + int result = (memcmp(&a, &b, sizeof(a)) == 0); + return(result); +} + struct Unique_Hash{ u32 d[4]; - u32 non_file_id; }; inline Unique_Hash diff --git a/TODO.txt b/TODO.txt index 67d2302e..559b1b8a 100644 --- a/TODO.txt +++ b/TODO.txt @@ -98,19 +98,22 @@ ; [X] get key stroke in custom callback ; [X] tab option for auto-indent ; [X] catch unsaved files on close +; [X] feedback messages ; ; [] file status in custom API ; [] user file bar string +; [] feedback message API +; [] simple multi-line ; -; [] feedback messages ; [] command meta data ; [] additional hooks -; [] new file +; [X] new file ; [] file out of sync ; [] double binding warnings ; [] kill rect -; [] simple multi-line ; +; [] manipulate scroll starget API +; ; search related tech ; [X] replace word (incremental and/or in range) ; [] optimize search @@ -136,16 +139,14 @@ ; [] "thin cursor" ; ; [] switch over to gap buffer -; [] multiple chunk lexer input +; [] lexer with multiple chunk input ; ; [] macros ; -; [X] cuber's return to previous buffer idea +; [] cuber's return to previous buffer idea ; [] miblo's various number editors ; -; [] out of sync options -; [] hook -; [] keep copy of unedited orignal, somewhere (compressed, restore by history?) +; [] keep copy of unedited orignal, somewhere (compressed, restore by history?) ; ; [] diff ; [] cloc @@ -160,7 +161,9 @@ ; [] error text at line ; [] word complete ghosting ; -; [] main_4coder experiment +; [] the main_4coder experiment +; +; [] tutorials ; ; INTERNAL TODOS @@ -184,6 +187,7 @@ ; HARD BUGS ; [] fyoucon's segfaults with malloc on win10 +; [] minimize and reopen problem (reported by two users now, still not reproduced here) ; [] repainting too slow for resize looks really dumb ; [] handling cursor in non-client part of window so it doesn't spaz ; [] fill screen right away diff --git a/win32_4ed.cpp b/win32_4ed.cpp index 94b54940..ffdfb3ac 100644 --- a/win32_4ed.cpp +++ b/win32_4ed.cpp @@ -164,6 +164,10 @@ struct Win32_Vars{ // it up if needed. Win32_Coroutine coroutine_data[2]; Win32_Coroutine *coroutine_free; + + // TODO(allen): Initialize this by redirecting std out to these CLI + // handles so that the application step can read from them. + CLI_Handles cli_self; }; globalvar Win32_Vars win32vars; @@ -989,15 +993,21 @@ Sys_CLI_End_Update_Sig(system_cli_end_update){ DWORD result = 0; if (WaitForSingleObject(proc, 0) == WAIT_OBJECT_0){ - if (GetExitCodeProcess(proc, &result) == 0) - cli->exit = -1; - else - cli->exit = (i32)result; - - close_me = 1; - CloseHandle(*(HANDLE*)&cli->proc); - CloseHandle(*(HANDLE*)&cli->out_read); - CloseHandle(*(HANDLE*)&cli->out_write); + if (!handle_equal(cli->proc, win32vars.cli_self.proc)){ + if (GetExitCodeProcess(proc, &result) == 0) + cli->exit = -1; + else + cli->exit = (i32)result; + + close_me = 1; + CloseHandle(*(HANDLE*)&cli->proc); + CloseHandle(*(HANDLE*)&cli->out_read); + CloseHandle(*(HANDLE*)&cli->out_write); + } + else{ + // TODO(allen): wtf? How does this happen? It doesn't right? + Assert(0); + } } return close_me; } @@ -1550,6 +1560,7 @@ UpdateLoop(LPVOID param){ win32vars.app.step(win32vars.system, &input_data, &mouse, + win32vars.cli_self, &win32vars.target, &memory_vars, &exchange_vars,