print_message
This commit is contained in:
parent
ef3fff35d4
commit
4a43a580c5
|
@ -383,6 +383,7 @@ struct Application_Links;
|
||||||
// Queries
|
// Queries
|
||||||
#define START_QUERY_BAR_SIG(n) int n(Application_Links *app, Query_Bar *bar, unsigned int flags)
|
#define START_QUERY_BAR_SIG(n) int n(Application_Links *app, Query_Bar *bar, unsigned int flags)
|
||||||
#define END_QUERY_BAR_SIG(n) void n(Application_Links *app, Query_Bar *bar, unsigned int flags)
|
#define END_QUERY_BAR_SIG(n) void n(Application_Links *app, Query_Bar *bar, unsigned int flags)
|
||||||
|
#define PRINT_MESSAGE_SIG(n) void n(Application_Links *app, char *string, int len)
|
||||||
|
|
||||||
// Color settings
|
// Color settings
|
||||||
#define CHANGE_THEME_SIG(n) void n(Application_Links *app, char *name, int len)
|
#define CHANGE_THEME_SIG(n) void n(Application_Links *app, char *name, int len)
|
||||||
|
@ -463,6 +464,7 @@ extern "C"{
|
||||||
// Queries
|
// Queries
|
||||||
typedef START_QUERY_BAR_SIG(Start_Query_Bar_Function);
|
typedef START_QUERY_BAR_SIG(Start_Query_Bar_Function);
|
||||||
typedef END_QUERY_BAR_SIG(End_Query_Bar_Function);
|
typedef END_QUERY_BAR_SIG(End_Query_Bar_Function);
|
||||||
|
typedef PRINT_MESSAGE_SIG(Print_Message_Function);
|
||||||
|
|
||||||
// Color settings
|
// Color settings
|
||||||
typedef CHANGE_THEME_SIG(Change_Theme_Function);
|
typedef CHANGE_THEME_SIG(Change_Theme_Function);
|
||||||
|
@ -525,6 +527,7 @@ struct Application_Links{
|
||||||
// Queries
|
// Queries
|
||||||
Start_Query_Bar_Function *start_query_bar;
|
Start_Query_Bar_Function *start_query_bar;
|
||||||
End_Query_Bar_Function *end_query_bar;
|
End_Query_Bar_Function *end_query_bar;
|
||||||
|
Print_Message_Function *print_message;
|
||||||
|
|
||||||
// Theme
|
// Theme
|
||||||
Change_Theme_Function *change_theme;
|
Change_Theme_Function *change_theme;
|
||||||
|
|
|
@ -568,7 +568,7 @@ CUSTOM_COMMAND_SIG(execute_arbitrary_command){
|
||||||
exec_command(app, cmdid_eol_nixify);
|
exec_command(app, cmdid_eol_nixify);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
// TODO(allen): feedback message
|
app->print_message(app, literal("unrecognized command\n"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -646,7 +646,7 @@ CUSTOM_COMMAND_SIG(build_search){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(allen): feedback message - couldn't find build.bat
|
app->print_message(app, literal("couldn't find build.bat\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
CUSTOM_COMMAND_SIG(auto_tab_line_at_cursor){
|
CUSTOM_COMMAND_SIG(auto_tab_line_at_cursor){
|
||||||
|
|
78
4ed.cpp
78
4ed.cpp
|
@ -2515,11 +2515,16 @@ extern "C"{
|
||||||
END_QUERY_BAR_SIG(external_end_query_bar){
|
END_QUERY_BAR_SIG(external_end_query_bar){
|
||||||
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||||
View *vptr;
|
View *vptr;
|
||||||
|
|
||||||
vptr = cmd->view;
|
vptr = cmd->view;
|
||||||
free_query_slot(&vptr->query_set, bar);
|
free_query_slot(&vptr->query_set, bar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PRINT_MESSAGE_SIG(external_print_message){
|
||||||
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||||
|
Models *models = cmd->models;
|
||||||
|
do_feedback_message(cmd->system, models, make_string(string, len));
|
||||||
|
}
|
||||||
|
|
||||||
CHANGE_THEME_SIG(external_change_theme){
|
CHANGE_THEME_SIG(external_change_theme){
|
||||||
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||||
Style_Library *styles = &cmd->models->styles;
|
Style_Library *styles = &cmd->models->styles;
|
||||||
|
@ -2630,6 +2635,7 @@ app_links_init(System_Functions *system, void *data, int size){
|
||||||
|
|
||||||
app_links.start_query_bar = external_start_query_bar;
|
app_links.start_query_bar = external_start_query_bar;
|
||||||
app_links.end_query_bar = external_end_query_bar;
|
app_links.end_query_bar = external_end_query_bar;
|
||||||
|
app_links.print_message = external_print_message;
|
||||||
|
|
||||||
app_links.change_theme = external_change_theme;
|
app_links.change_theme = external_change_theme;
|
||||||
app_links.change_font = external_change_font;
|
app_links.change_font = external_change_font;
|
||||||
|
@ -3091,6 +3097,7 @@ execute_special_tool(void *memory, i32 size, Command_Line_Parameters clparams){
|
||||||
if (match(clparams.argv[2], "version")){
|
if (match(clparams.argv[2], "version")){
|
||||||
result = sizeof(VERSION) - 1;
|
result = sizeof(VERSION) - 1;
|
||||||
memcpy(memory, VERSION, result);
|
memcpy(memory, VERSION, result);
|
||||||
|
((char*)memory)[result++] = '\n';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return(result);
|
return(result);
|
||||||
|
@ -3133,7 +3140,6 @@ extern "C" SCROLL_RULE_SIG(fallback_scroll_rule){
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
App_Init_Sig(app_init){
|
App_Init_Sig(app_init){
|
||||||
App_Vars *vars;
|
App_Vars *vars;
|
||||||
Models *models;
|
Models *models;
|
||||||
|
@ -3446,6 +3452,43 @@ App_Init_Sig(app_init){
|
||||||
models->buffer_param_indices = push_array(partition, i32, models->buffer_param_max);
|
models->buffer_param_indices = push_array(partition, i32, models->buffer_param_max);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal i32
|
||||||
|
update_cli_handle_with_file(System_Functions *system, Models *models,
|
||||||
|
CLI_Handles *cli, Editing_File *file, char *dest, i32 max, b32 cursor_at_end){
|
||||||
|
i32 result = 0;
|
||||||
|
u32 amount;
|
||||||
|
|
||||||
|
for (system->cli_begin_update(cli);
|
||||||
|
system->cli_update_step(cli, dest, max, &amount);){
|
||||||
|
amount = eol_in_place_convert_in(dest, amount);
|
||||||
|
output_file_append(system, models, file, make_string(dest, amount), cursor_at_end);
|
||||||
|
result = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (system->cli_end_update(cli)){
|
||||||
|
char str_space[256];
|
||||||
|
String str = make_fixed_width_string(str_space);
|
||||||
|
append(&str, "exited with code ");
|
||||||
|
append_int_to_str(cli->exit, &str);
|
||||||
|
output_file_append(system, models, file, str, cursor_at_end);
|
||||||
|
result = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
i32 new_cursor = 0;
|
||||||
|
|
||||||
|
if (cursor_at_end){
|
||||||
|
new_cursor = buffer_size(&file->state.buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (View_Iter iter = file_view_iter_init(&models->layout, file, 0);
|
||||||
|
file_view_iter_good(iter);
|
||||||
|
iter = file_view_iter_next(iter)){
|
||||||
|
view_cursor_move(iter.view, new_cursor);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
App_Step_Sig(app_step){
|
App_Step_Sig(app_step){
|
||||||
ProfileStart(OS_syncing);
|
ProfileStart(OS_syncing);
|
||||||
Application_Step_Result app_result = *result;
|
Application_Step_Result app_result = *result;
|
||||||
|
@ -3498,7 +3541,6 @@ App_Step_Sig(app_step){
|
||||||
Temp_Memory temp = begin_temp_memory(&models->mem.part);
|
Temp_Memory temp = begin_temp_memory(&models->mem.part);
|
||||||
u32 max = Kbytes(32);
|
u32 max = Kbytes(32);
|
||||||
char *dest = push_array(&models->mem.part, char, max);
|
char *dest = push_array(&models->mem.part, char, max);
|
||||||
u32 amount;
|
|
||||||
|
|
||||||
i32 count = vars->cli_processes.count;
|
i32 count = vars->cli_processes.count;
|
||||||
for (i32 i = 0; i < count; ++i){
|
for (i32 i = 0; i < count; ++i){
|
||||||
|
@ -3506,33 +3548,11 @@ App_Step_Sig(app_step){
|
||||||
Editing_File *file = proc->out_file;
|
Editing_File *file = proc->out_file;
|
||||||
|
|
||||||
if (file != 0){
|
if (file != 0){
|
||||||
|
i32 r = update_cli_handle_with_file(system, models, &proc->cli, file, dest, max, 0);
|
||||||
for (system->cli_begin_update(&proc->cli);
|
if (r) app_result.redraw = 1;
|
||||||
system->cli_update_step(&proc->cli, dest, max, &amount);){
|
if (r < 0){
|
||||||
amount = eol_in_place_convert_in(dest, amount);
|
|
||||||
output_file_append(system, models, file, make_string(dest, amount), 0);
|
|
||||||
app_result.redraw = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (system->cli_end_update(&proc->cli)){
|
|
||||||
*proc = vars->cli_processes.procs[--count];
|
*proc = vars->cli_processes.procs[--count];
|
||||||
--i;
|
--i;
|
||||||
|
|
||||||
char str_space[256];
|
|
||||||
String str = make_fixed_width_string(str_space);
|
|
||||||
append(&str, "exited with code ");
|
|
||||||
append_int_to_str(proc->cli.exit, &str);
|
|
||||||
|
|
||||||
output_file_append(system, models, file, str, 0);
|
|
||||||
app_result.redraw = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
i32 new_cursor = 0;
|
|
||||||
|
|
||||||
for (View_Iter iter = file_view_iter_init(&models->layout, file, 0);
|
|
||||||
file_view_iter_good(iter);
|
|
||||||
iter = file_view_iter_next(iter)){
|
|
||||||
view_cursor_move(iter.view, new_cursor);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3732,7 +3752,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 printf\n"
|
"-Super users can post their own messages here with app->print_message\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"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
1
4ed.h
1
4ed.h
|
@ -107,7 +107,6 @@ struct Application_Step_Result{
|
||||||
name(System_Functions *system, \
|
name(System_Functions *system, \
|
||||||
Key_Input_Data *input, \
|
Key_Input_Data *input, \
|
||||||
Mouse_State *mouse, \
|
Mouse_State *mouse, \
|
||||||
CLI_Handles self, \
|
|
||||||
Render_Target *target, \
|
Render_Target *target, \
|
||||||
Application_Memory *memory, \
|
Application_Memory *memory, \
|
||||||
Exchange *exchange, \
|
Exchange *exchange, \
|
||||||
|
|
|
@ -95,12 +95,12 @@ struct Text_Effect{
|
||||||
|
|
||||||
// NOTE(allen): The Editing_File struct is now divided into two
|
// NOTE(allen): The Editing_File struct is now divided into two
|
||||||
// parts. Variables in the Settings part can be set even when the
|
// parts. Variables in the Settings part can be set even when the
|
||||||
// file is still streaming in, and all operations except for the
|
// file is still streaming in, and persists thorugh all operations except
|
||||||
// initial allocation of the file.
|
// for the initial allocation of the file.
|
||||||
struct Editing_File_Settings{
|
struct Editing_File_Settings{
|
||||||
i32 base_map_id;
|
i32 base_map_id;
|
||||||
i32 dos_write_mode;
|
i32 dos_write_mode;
|
||||||
b32 unwrapped_lines;
|
b8 unwrapped_lines;
|
||||||
b8 tokens_exist;
|
b8 tokens_exist;
|
||||||
b8 is_initialized;
|
b8 is_initialized;
|
||||||
b8 unimportant;
|
b8 unimportant;
|
||||||
|
|
3
TODO.txt
3
TODO.txt
|
@ -131,6 +131,7 @@
|
||||||
; theme related business
|
; theme related business
|
||||||
; [] fix the versioning system for themes
|
; [] fix the versioning system for themes
|
||||||
; [] theme switch per panel?
|
; [] theme switch per panel?
|
||||||
|
; [] allow multiple font faces with effects
|
||||||
;
|
;
|
||||||
; [] control schemes
|
; [] control schemes
|
||||||
; [] emacs style sub-maps
|
; [] emacs style sub-maps
|
||||||
|
@ -146,7 +147,7 @@
|
||||||
; [] cuber's return to previous buffer idea
|
; [] cuber's return to previous buffer idea
|
||||||
; [] miblo's various number editors
|
; [] miblo's various number editors
|
||||||
;
|
;
|
||||||
; [] keep copy of unedited orignal, somewhere (compressed, restore by history?)
|
; [] keep copy of unedited orignal, somewhere (compressed? restore by history?)
|
||||||
;
|
;
|
||||||
; [] diff
|
; [] diff
|
||||||
; [] cloc
|
; [] cloc
|
||||||
|
|
|
@ -1836,18 +1836,6 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
current_directory = make_string(curdir_mem, curdir_size, curdir_req);
|
current_directory = make_string(curdir_mem, curdir_size, curdir_req);
|
||||||
|
|
||||||
int stdout_redir[2] = {};
|
|
||||||
if(pipe(stdout_redir) == -1){
|
|
||||||
perror("pipe");
|
|
||||||
} else {
|
|
||||||
if(dup2(stdout_redir[1], STDOUT_FILENO) == -1){
|
|
||||||
perror("dup2");
|
|
||||||
} else {
|
|
||||||
memcpy(&linuxvars.cli_self.out_read, stdout_redir, sizeof(int));
|
|
||||||
memcpy(&linuxvars.cli_self.out_write, stdout_redir + 1, sizeof(int));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Command_Line_Parameters clparams;
|
Command_Line_Parameters clparams;
|
||||||
clparams.argv = argv;
|
clparams.argv = argv;
|
||||||
clparams.argc = argc;
|
clparams.argc = argc;
|
||||||
|
@ -1866,10 +1854,24 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
if (output_size > 0){
|
if (output_size > 0){
|
||||||
// TODO(allen): crt free version
|
// TODO(allen): crt free version
|
||||||
fprintf(stderr, "%.*s", output_size, (char*)memory_vars.target_memory);
|
fprintf(stdout, "%.*s", output_size, (char*)memory_vars.target_memory);
|
||||||
}
|
}
|
||||||
if (output_size != 0) return 0;
|
if (output_size != 0) return 0;
|
||||||
|
|
||||||
|
// NOTE(allen): Now that we are done using the normal stdout stuff
|
||||||
|
// redirect it to a pipe so the application can render future printf itself.
|
||||||
|
int stdout_redir[2] = {};
|
||||||
|
if(pipe(stdout_redir) == -1){
|
||||||
|
perror("pipe");
|
||||||
|
} else {
|
||||||
|
if(dup2(stdout_redir[1], STDOUT_FILENO) == -1){
|
||||||
|
perror("dup2");
|
||||||
|
} else {
|
||||||
|
memcpy(&linuxvars.cli_self.out_read, stdout_redir, sizeof(int));
|
||||||
|
memcpy(&linuxvars.cli_self.out_write, stdout_redir + 1, sizeof(int));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sysshared_filter_real_files(files, file_count);
|
sysshared_filter_real_files(files, file_count);
|
||||||
|
|
||||||
linuxvars.XDisplay = XOpenDisplay(0);
|
linuxvars.XDisplay = XOpenDisplay(0);
|
||||||
|
|
|
@ -164,10 +164,6 @@ 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;
|
||||||
|
@ -993,7 +989,6 @@ 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 (!handle_equal(cli->proc, win32vars.cli_self.proc)){
|
|
||||||
if (GetExitCodeProcess(proc, &result) == 0)
|
if (GetExitCodeProcess(proc, &result) == 0)
|
||||||
cli->exit = -1;
|
cli->exit = -1;
|
||||||
else
|
else
|
||||||
|
@ -1004,11 +999,6 @@ Sys_CLI_End_Update_Sig(system_cli_end_update){
|
||||||
CloseHandle(*(HANDLE*)&cli->out_read);
|
CloseHandle(*(HANDLE*)&cli->out_read);
|
||||||
CloseHandle(*(HANDLE*)&cli->out_write);
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1560,7 +1550,6 @@ 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,
|
||||||
|
@ -1671,10 +1660,11 @@ WinMain(HINSTANCE hInstance,
|
||||||
LPSTR lpCmdLine,
|
LPSTR lpCmdLine,
|
||||||
int nCmdShow){
|
int nCmdShow){
|
||||||
#else
|
#else
|
||||||
int
|
int
|
||||||
main(int argc, char **argv){
|
main(int argc, char **argv){
|
||||||
#endif
|
#endif
|
||||||
HINSTANCE hInstance = GetModuleHandle(0);
|
HINSTANCE hInstance = GetModuleHandle(0);
|
||||||
|
HANDLE original_out = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
|
|
||||||
win32vars = {};
|
win32vars = {};
|
||||||
exchange_vars = {};
|
exchange_vars = {};
|
||||||
|
@ -1764,12 +1754,11 @@ main(int argc, char **argv){
|
||||||
//
|
//
|
||||||
|
|
||||||
if (output_size > 0){
|
if (output_size > 0){
|
||||||
// TODO(allen): crt free version
|
DWORD written;
|
||||||
printf("%.*s", output_size, memory_vars.target_memory);
|
WriteFile(original_out, memory_vars.target_memory, output_size, &written, 0);
|
||||||
}
|
}
|
||||||
if (output_size != 0) return 0;
|
if (output_size != 0) return 0;
|
||||||
|
|
||||||
|
|
||||||
#ifdef FRED_SUPER
|
#ifdef FRED_SUPER
|
||||||
char *custom_file_default = "4coder_custom.dll";
|
char *custom_file_default = "4coder_custom.dll";
|
||||||
char *custom_file;
|
char *custom_file;
|
||||||
|
@ -1792,7 +1781,6 @@ main(int argc, char **argv){
|
||||||
printf("Error: application and custom version numbers don't match");
|
printf("Error: application and custom version numbers don't match");
|
||||||
return 22;
|
return 22;
|
||||||
}
|
}
|
||||||
|
|
||||||
win32vars.custom_api.get_bindings = (Get_Binding_Data_Function*)
|
win32vars.custom_api.get_bindings = (Get_Binding_Data_Function*)
|
||||||
GetProcAddress(win32vars.custom, "get_bindings");
|
GetProcAddress(win32vars.custom, "get_bindings");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue