From 367a72fa039f627339cdb39ae24cced7cca4ae88 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Mon, 17 Jul 2017 17:13:57 -0400 Subject: [PATCH] cleaned up the arbitrary system command code a little --- 4coder_system_command.cpp | 34 +++++++++++++++------------------- 4ed_api_implementation.cpp | 12 ++++++++---- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/4coder_system_command.cpp b/4coder_system_command.cpp index 3737a8f0..cec2c8ab 100644 --- a/4coder_system_command.cpp +++ b/4coder_system_command.cpp @@ -11,6 +11,20 @@ TYPE: 'drop-in-command-pack' #include "4coder_default_framework.h" +CUSTOM_COMMAND_SIG(execute_previous_cli){ + String out_buffer = make_string_slowly(out_buffer_space); + String cmd = make_string_slowly(command_space); + String hot_directory = make_string_slowly(hot_directory_space); + + if (out_buffer.size > 0 && cmd.size > 0 && hot_directory.size > 0){ + uint32_t access = AccessAll; + View_Summary view = get_active_view(app, access); + + exec_system_command(app, &view, buffer_identifier(out_buffer.str, out_buffer.size), hot_directory.str, hot_directory.size, cmd.str, cmd.size, CLI_OverlapWithConflict | CLI_CursorAtEnd); + lock_jump_buffer(out_buffer.str, out_buffer.size); + } +} + CUSTOM_COMMAND_SIG(execute_any_cli){ Query_Bar bar_out = {0}; Query_Bar bar_cmd = {0}; @@ -26,25 +40,7 @@ CUSTOM_COMMAND_SIG(execute_any_cli){ String hot_directory = make_fixed_width_string(hot_directory_space); hot_directory.size = directory_get_hot(app, hot_directory.str, hot_directory.memory_size); - uint32_t access = AccessAll; - View_Summary view = get_active_view(app, access); - - exec_system_command(app, &view, buffer_identifier(bar_out.string.str, bar_out.string.size), hot_directory.str, hot_directory.size, bar_cmd.string.str, bar_cmd.string.size, CLI_OverlapWithConflict | CLI_CursorAtEnd); - lock_jump_buffer(bar_out.string.str, bar_out.string.size); -} - -CUSTOM_COMMAND_SIG(execute_previous_cli){ - String out_buffer = make_string_slowly(out_buffer_space); - String cmd = make_string_slowly(command_space); - String hot_directory = make_string_slowly(hot_directory_space); - - if (out_buffer.size > 0 && cmd.size > 0 && hot_directory.size > 0){ - uint32_t access = AccessAll; - View_Summary view = get_active_view(app, access); - - exec_system_command(app, &view, buffer_identifier(out_buffer.str, out_buffer.size), hot_directory.str, hot_directory.size, cmd.str, cmd.size, CLI_OverlapWithConflict | CLI_CursorAtEnd); - lock_jump_buffer(out_buffer.str, out_buffer.size); - } + execute_previous_cli(app); } #endif diff --git a/4ed_api_implementation.cpp b/4ed_api_implementation.cpp index 38a904fa..49bceab4 100644 --- a/4ed_api_implementation.cpp +++ b/4ed_api_implementation.cpp @@ -290,7 +290,7 @@ DOC_SEE(Command_Line_Interface_Flag) init_read_only_file(system, models, file); } - if (file){ + if (file != 0){ i32 proc_count = vars->cli_processes.count; for (i32 i = 0; i < proc_count; ++i){ if (procs[i].out_file == file){ @@ -299,7 +299,8 @@ DOC_SEE(Command_Line_Interface_Flag) } else{ file = 0; - }break; + } + break; } } @@ -1228,10 +1229,13 @@ DOC(Whenever a buffer is killed an end signal is sent which triggers the end fil API_EXPORT Buffer_Summary Create_Buffer(Application_Links *app, char *filename, int32_t filename_len, Buffer_Create_Flag flags) /* -DOC_PARAM(filename, The name of the file to associate to the new buffer. If the file is not found, the buffer will be created empty and will not be associated to a file until it is saved.) +DOC_PARAM(filename, The name of the file to associate to the new buffer.) DOC_PARAM(filename_len, The length of the filename string.) DOC_PARAM(flags, Flags controlling the buffer creation behavior.) -DOC() +DOC_RETURN(Returns the newly created buffer or an already existing buffer with the given name.) +DOC(Try to create a new buffer. This call first checks to see if a buffer already exists that goes by the given name, if so, that buffer is returned. + +If no buffer exists with the given name, then a new buffer is created. If a file that matches the given filename exists, the file is loaded as the contents of the new buffer. Otherwise a buffer is created without a matching file until the buffer is saved and the buffer is left blank.) DOC_SEE(Buffer_Create_Flag) */{ PRFL_FUNC_GROUP();