print_message
This commit is contained in:
parent
ef3fff35d4
commit
4a43a580c5
|
@ -383,6 +383,7 @@ struct Application_Links;
|
|||
// Queries
|
||||
#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 PRINT_MESSAGE_SIG(n) void n(Application_Links *app, char *string, int len)
|
||||
|
||||
// Color settings
|
||||
#define CHANGE_THEME_SIG(n) void n(Application_Links *app, char *name, int len)
|
||||
|
@ -463,6 +464,7 @@ extern "C"{
|
|||
// Queries
|
||||
typedef START_QUERY_BAR_SIG(Start_Query_Bar_Function);
|
||||
typedef END_QUERY_BAR_SIG(End_Query_Bar_Function);
|
||||
typedef PRINT_MESSAGE_SIG(Print_Message_Function);
|
||||
|
||||
// Color settings
|
||||
typedef CHANGE_THEME_SIG(Change_Theme_Function);
|
||||
|
@ -525,6 +527,7 @@ struct Application_Links{
|
|||
// Queries
|
||||
Start_Query_Bar_Function *start_query_bar;
|
||||
End_Query_Bar_Function *end_query_bar;
|
||||
Print_Message_Function *print_message;
|
||||
|
||||
// Theme
|
||||
Change_Theme_Function *change_theme;
|
||||
|
|
|
@ -568,7 +568,7 @@ CUSTOM_COMMAND_SIG(execute_arbitrary_command){
|
|||
exec_command(app, cmdid_eol_nixify);
|
||||
}
|
||||
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){
|
||||
|
|
80
4ed.cpp
80
4ed.cpp
|
@ -2515,11 +2515,16 @@ extern "C"{
|
|||
END_QUERY_BAR_SIG(external_end_query_bar){
|
||||
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||
View *vptr;
|
||||
|
||||
vptr = cmd->view;
|
||||
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){
|
||||
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||
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.end_query_bar = external_end_query_bar;
|
||||
app_links.print_message = external_print_message;
|
||||
|
||||
app_links.change_theme = external_change_theme;
|
||||
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")){
|
||||
result = sizeof(VERSION) - 1;
|
||||
memcpy(memory, VERSION, result);
|
||||
((char*)memory)[result++] = '\n';
|
||||
}
|
||||
}
|
||||
return(result);
|
||||
|
@ -3133,7 +3140,6 @@ extern "C" SCROLL_RULE_SIG(fallback_scroll_rule){
|
|||
return(result);
|
||||
}
|
||||
|
||||
|
||||
App_Init_Sig(app_init){
|
||||
App_Vars *vars;
|
||||
Models *models;
|
||||
|
@ -3446,6 +3452,43 @@ App_Init_Sig(app_init){
|
|||
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){
|
||||
ProfileStart(OS_syncing);
|
||||
Application_Step_Result app_result = *result;
|
||||
|
@ -3498,7 +3541,6 @@ App_Step_Sig(app_step){
|
|||
Temp_Memory temp = begin_temp_memory(&models->mem.part);
|
||||
u32 max = Kbytes(32);
|
||||
char *dest = push_array(&models->mem.part, char, max);
|
||||
u32 amount;
|
||||
|
||||
i32 count = vars->cli_processes.count;
|
||||
for (i32 i = 0; i < count; ++i){
|
||||
|
@ -3506,33 +3548,11 @@ App_Step_Sig(app_step){
|
|||
Editing_File *file = proc->out_file;
|
||||
|
||||
if (file != 0){
|
||||
|
||||
for (system->cli_begin_update(&proc->cli);
|
||||
system->cli_update_step(&proc->cli, dest, max, &amount);){
|
||||
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)){
|
||||
i32 r = update_cli_handle_with_file(system, models, &proc->cli, file, dest, max, 0);
|
||||
if (r) app_result.redraw = 1;
|
||||
if (r < 0){
|
||||
*proc = vars->cli_processes.procs[--count];
|
||||
--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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3540,7 +3560,7 @@ App_Step_Sig(app_step){
|
|||
vars->cli_processes.count = count;
|
||||
end_temp_memory(temp);
|
||||
}
|
||||
|
||||
|
||||
// NOTE(allen): reorganizing panels on screen
|
||||
{
|
||||
i32 prev_width = models->layout.full_width;
|
||||
|
@ -3732,7 +3752,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 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"
|
||||
);
|
||||
|
||||
|
|
1
4ed.h
1
4ed.h
|
@ -107,7 +107,6 @@ struct Application_Step_Result{
|
|||
name(System_Functions *system, \
|
||||
Key_Input_Data *input, \
|
||||
Mouse_State *mouse, \
|
||||
CLI_Handles self, \
|
||||
Render_Target *target, \
|
||||
Application_Memory *memory, \
|
||||
Exchange *exchange, \
|
||||
|
|
|
@ -95,12 +95,12 @@ struct Text_Effect{
|
|||
|
||||
// NOTE(allen): The Editing_File struct is now divided into two
|
||||
// parts. Variables in the Settings part can be set even when the
|
||||
// file is still streaming in, and all operations except for the
|
||||
// initial allocation of the file.
|
||||
// file is still streaming in, and persists thorugh all operations except
|
||||
// for the initial allocation of the file.
|
||||
struct Editing_File_Settings{
|
||||
i32 base_map_id;
|
||||
i32 dos_write_mode;
|
||||
b32 unwrapped_lines;
|
||||
b8 unwrapped_lines;
|
||||
b8 tokens_exist;
|
||||
b8 is_initialized;
|
||||
b8 unimportant;
|
||||
|
|
3
TODO.txt
3
TODO.txt
|
@ -131,6 +131,7 @@
|
|||
; theme related business
|
||||
; [] fix the versioning system for themes
|
||||
; [] theme switch per panel?
|
||||
; [] allow multiple font faces with effects
|
||||
;
|
||||
; [] control schemes
|
||||
; [] emacs style sub-maps
|
||||
|
@ -146,7 +147,7 @@
|
|||
; [] cuber's return to previous buffer idea
|
||||
; [] 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
|
||||
; [] cloc
|
||||
|
|
|
@ -1836,18 +1836,6 @@ main(int argc, char **argv)
|
|||
|
||||
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;
|
||||
clparams.argv = argv;
|
||||
clparams.argc = argc;
|
||||
|
@ -1866,10 +1854,24 @@ main(int argc, char **argv)
|
|||
|
||||
if (output_size > 0){
|
||||
// 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;
|
||||
|
||||
// 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);
|
||||
|
||||
linuxvars.XDisplay = XOpenDisplay(0);
|
||||
|
|
926
win32_4ed.cpp
926
win32_4ed.cpp
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue