intended interface for stdout capture

This commit is contained in:
Allen Webster 2016-03-20 18:43:28 -04:00
parent 0fea10aaef
commit 3fd4565eab
6 changed files with 56 additions and 36 deletions

View File

@ -3732,7 +3732,7 @@ App_Step_Sig(app_step){
"-The file count limit is over 8 million now\n" "-The file count limit is over 8 million now\n"
"-File equality is handled better so renamings (such as 'subst') are safe 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" "-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" "-Set font size on command line with -f N, N = 16 by default\n\n"
); );

31
4ed.h
View File

@ -68,18 +68,18 @@ struct Plat_Settings{
i32 name(System_Functions *system, \ i32 name(System_Functions *system, \
Application_Memory *memory, \ Application_Memory *memory, \
String current_directory, \ String current_directory, \
Plat_Settings *plat_settings, \ Plat_Settings *plat_settings, \
char ***files, i32 **file_count, \ char ***files, i32 **file_count, \
Command_Line_Parameters clparams) Command_Line_Parameters clparams)
typedef App_Read_Command_Line_Sig(App_Read_Command_Line); typedef App_Read_Command_Line_Sig(App_Read_Command_Line);
#define App_Init_Sig(name) void \ #define App_Init_Sig(name) void \
name(System_Functions *system, \ name(System_Functions *system, \
Render_Target *target, \ Render_Target *target, \
Application_Memory *memory, \ Application_Memory *memory, \
Exchange *exchange, \ Exchange *exchange, \
String clipboard, \ String clipboard, \
String current_directory, \ String current_directory, \
Custom_API api) Custom_API api)
@ -103,16 +103,17 @@ struct Application_Step_Result{
b32 perform_kill; b32 perform_kill;
}; };
#define App_Step_Sig(name) void \ #define App_Step_Sig(name) void \
name(System_Functions *system, \ name(System_Functions *system, \
Key_Input_Data *input, \ Key_Input_Data *input, \
Mouse_State *mouse, \ Mouse_State *mouse, \
Render_Target *target, \ CLI_Handles self, \
Application_Memory *memory, \ Render_Target *target, \
Exchange *exchange, \ Application_Memory *memory, \
String clipboard, \ Exchange *exchange, \
b32 time_step, b32 first_step, b32 force_redraw, \ String clipboard, \
Application_Step_Result *result) b32 time_step, b32 first_step, b32 force_redraw, \
Application_Step_Result *result)
typedef App_Step_Sig(App_Step); typedef App_Step_Sig(App_Step);

View File

@ -193,7 +193,6 @@ tbl_file_hash(void *item, void *arg){
hash = ((hash << 6) + hash) + uhash.d[1]; hash = ((hash << 6) + hash) + uhash.d[1];
hash = ((hash << 6) + hash) + uhash.d[2]; hash = ((hash << 6) + hash) + uhash.d[2];
hash = ((hash << 6) + hash) + uhash.d[3]; hash = ((hash << 6) + hash) + uhash.d[3];
hash = ((hash << 6) + hash) + uhash.non_file_id;
return(hash); return(hash);
} }

View File

@ -13,9 +13,14 @@ struct Plat_Handle{
u32 d[4]; 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{ struct Unique_Hash{
u32 d[4]; u32 d[4];
u32 non_file_id;
}; };
inline Unique_Hash inline Unique_Hash

View File

@ -98,19 +98,22 @@
; [X] get key stroke in custom callback ; [X] get key stroke in custom callback
; [X] tab option for auto-indent ; [X] tab option for auto-indent
; [X] catch unsaved files on close ; [X] catch unsaved files on close
; [X] feedback messages
; ;
; [] file status in custom API ; [] file status in custom API
; [] user file bar string ; [] user file bar string
; [] feedback message API
; [] simple multi-line
; ;
; [] feedback messages
; [] command meta data ; [] command meta data
; [] additional hooks ; [] additional hooks
; [] new file ; [X] new file
; [] file out of sync ; [] file out of sync
; [] double binding warnings ; [] double binding warnings
; [] kill rect ; [] kill rect
; [] simple multi-line
; ;
; [] manipulate scroll starget API
;
; search related tech ; search related tech
; [X] replace word (incremental and/or in range) ; [X] replace word (incremental and/or in range)
; [] optimize search ; [] optimize search
@ -136,16 +139,14 @@
; [] "thin cursor" ; [] "thin cursor"
; ;
; [] switch over to gap buffer ; [] switch over to gap buffer
; [] multiple chunk lexer input ; [] lexer with multiple chunk input
; ;
; [] macros ; [] macros
; ;
; [X] cuber's return to previous buffer idea ; [] cuber's return to previous buffer idea
; [] miblo's various number editors ; [] miblo's various number editors
; ;
; [] out of sync options ; [] keep copy of unedited orignal, somewhere (compressed, restore by history?)
; [] hook
; [] keep copy of unedited orignal, somewhere (compressed, restore by history?)
; ;
; [] diff ; [] diff
; [] cloc ; [] cloc
@ -160,7 +161,9 @@
; [] error text at line ; [] error text at line
; [] word complete ghosting ; [] word complete ghosting
; ;
; [] main_4coder experiment ; [] the main_4coder experiment
;
; [] tutorials
; ;
; INTERNAL TODOS ; INTERNAL TODOS
@ -184,6 +187,7 @@
; HARD BUGS ; HARD BUGS
; [] fyoucon's segfaults with malloc on win10 ; [] 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 ; [] repainting too slow for resize looks really dumb
; [] handling cursor in non-client part of window so it doesn't spaz ; [] handling cursor in non-client part of window so it doesn't spaz
; [] fill screen right away ; [] fill screen right away

View File

@ -164,6 +164,10 @@ struct Win32_Vars{
// it up if needed. // it up if needed.
Win32_Coroutine coroutine_data[2]; Win32_Coroutine coroutine_data[2];
Win32_Coroutine *coroutine_free; 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; globalvar Win32_Vars win32vars;
@ -989,15 +993,21 @@ Sys_CLI_End_Update_Sig(system_cli_end_update){
DWORD result = 0; DWORD result = 0;
if (WaitForSingleObject(proc, 0) == WAIT_OBJECT_0){ if (WaitForSingleObject(proc, 0) == WAIT_OBJECT_0){
if (GetExitCodeProcess(proc, &result) == 0) if (!handle_equal(cli->proc, win32vars.cli_self.proc)){
cli->exit = -1; if (GetExitCodeProcess(proc, &result) == 0)
else cli->exit = -1;
cli->exit = (i32)result; else
cli->exit = (i32)result;
close_me = 1;
CloseHandle(*(HANDLE*)&cli->proc); close_me = 1;
CloseHandle(*(HANDLE*)&cli->out_read); CloseHandle(*(HANDLE*)&cli->proc);
CloseHandle(*(HANDLE*)&cli->out_write); 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; return close_me;
} }
@ -1550,6 +1560,7 @@ UpdateLoop(LPVOID param){
win32vars.app.step(win32vars.system, win32vars.app.step(win32vars.system,
&input_data, &input_data,
&mouse, &mouse,
win32vars.cli_self,
&win32vars.target, &win32vars.target,
&memory_vars, &memory_vars,
&exchange_vars, &exchange_vars,