intended interface for stdout capture

master
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"
"-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"
);

31
4ed.h
View File

@ -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);

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[2];
hash = ((hash << 6) + hash) + uhash.d[3];
hash = ((hash << 6) + hash) + uhash.non_file_id;
return(hash);
}

View File

@ -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

View File

@ -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

View File

@ -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,