4.0.16 build ready

master
Allen Webster 2017-02-06 08:49:00 -05:00
parent 783d1f2fc6
commit 9fff7704df
12 changed files with 193 additions and 62 deletions

View File

@ -524,7 +524,6 @@ CUSTOM_COMMAND_SIG(exit_4coder){
send_exit_signal(app); send_exit_signal(app);
} }
// //
// Interactive Commands // Interactive Commands
// //

View File

@ -44,7 +44,7 @@ get_build_directory(Application_Links *app, Buffer_Summary *buffer, String *dir_
if (!result){ if (!result){
int32_t len = directory_get_hot(app, dir_out->str, int32_t len = directory_get_hot(app, dir_out->str,
dir_out->memory_size - dir_out->size); dir_out->memory_size - dir_out->size);
if (len + dir_out->size < dir_out->memory_size){ if (dir_out->size + len < dir_out->memory_size){
dir_out->size += len; dir_out->size += len;
result = BuildDir_AtHot; result = BuildDir_AtHot;
} }
@ -53,6 +53,17 @@ get_build_directory(Application_Links *app, Buffer_Summary *buffer, String *dir_
return(result); return(result);
} }
static void
save_all_dirty_buffers(Application_Links *app){
for (Buffer_Summary buffer = get_buffer_first(app, AccessOpen);
buffer.exists;
get_buffer_next(app, &buffer, AccessOpen)){
if (buffer.dirty == DirtyState_UnsavedChanges){
save_buffer(app, &buffer, buffer.file_name, buffer.file_name_len, 0);
}
}
}
// TODO(allen): Better names for the "standard build search" family. // TODO(allen): Better names for the "standard build search" family.
static int32_t static int32_t
standard_build_search(Application_Links *app, View_Summary *view, Buffer_Summary *active_buffer, String *dir, String *command, int32_t perform_backup, int32_t use_path_in_command, String filename, String commandname){ standard_build_search(Application_Links *app, View_Summary *view, Buffer_Summary *active_buffer, String *dir, String *command, int32_t perform_backup, int32_t use_path_in_command, String filename, String commandname){
@ -82,6 +93,10 @@ standard_build_search(Application_Links *app, View_Summary *view, Buffer_Summary
append_s_char(&message, '\n'); append_s_char(&message, '\n');
print_message(app, message.str, message.size); print_message(app, message.str, message.size);
if (automatically_save_changes_on_build){
save_all_dirty_buffers(app);
}
exec_system_command(app, view, buffer_identifier(literal("*compilation*")), dir->str, dir->size, command->str, command->size, CLI_OverlapWithConflict); exec_system_command(app, view, buffer_identifier(literal("*compilation*")), dir->str, dir->size, command->str, command->size, CLI_OverlapWithConflict);
result = true; result = true;
break; break;

View File

@ -45,8 +45,7 @@ default_keys(Bind_Helper *context){
bind(context, 's', MDFR_ALT, show_scrollbar); bind(context, 's', MDFR_ALT, show_scrollbar);
bind(context, 'w', MDFR_ALT, hide_scrollbar); bind(context, 'w', MDFR_ALT, hide_scrollbar);
// TODO(allen): This is apparently not working on Linux, must investigate. bind(context, '@', MDFR_ALT, toggle_mouse);
bind(context, key_f2, MDFR_CTRL, toggle_mouse);
bind(context, key_page_up, MDFR_CTRL, toggle_fullscreen); bind(context, key_page_up, MDFR_CTRL, toggle_fullscreen);
bind(context, 'E', MDFR_ALT, exit_4coder); bind(context, 'E', MDFR_ALT, exit_4coder);
@ -108,6 +107,7 @@ default_keys(Bind_Helper *context){
bind(context, '}', MDFR_CTRL, open_long_braces_break); bind(context, '}', MDFR_CTRL, open_long_braces_break);
bind(context, 'i', MDFR_ALT, if0_off); bind(context, 'i', MDFR_ALT, if0_off);
bind(context, '1', MDFR_ALT, open_file_in_quotes); bind(context, '1', MDFR_ALT, open_file_in_quotes);
bind(context, '2', MDFR_ALT, open_matching_file_cpp);
bind(context, '0', MDFR_CTRL, write_zero_struct); bind(context, '0', MDFR_CTRL, write_zero_struct);
bind(context, 'I', MDFR_CTRL, list_all_functions_current_buffer); bind(context, 'I', MDFR_CTRL, list_all_functions_current_buffer);

View File

@ -196,6 +196,7 @@ struct Fkey_Command{
char command[128]; char command[128];
char out[128]; char out[128];
bool32 use_build_panel; bool32 use_build_panel;
bool32 save_dirty_buffers;
}; };
struct Project{ struct Project{
@ -211,6 +212,8 @@ struct Project{
bool32 close_all_code_when_this_project_closes; bool32 close_all_code_when_this_project_closes;
bool32 close_all_files_when_project_opens; bool32 close_all_files_when_project_opens;
bool32 open_recursively;
}; };
static Project null_project = {}; static Project null_project = {};
@ -579,11 +582,14 @@ config_array_good(Config_Array_Reader *array_reader){
// Configuration // Configuration
// //
static bool32 enable_code_wrapping = 1; static bool32 enable_code_wrapping = true;
static bool32 automatically_adjust_wrapping = 1;
static bool32 automatically_adjust_wrapping = true;
static bool32 automatically_indent_text_on_save = true;
static bool32 automatically_save_changes_on_build = true;
static int32_t default_wrap_width = 672; static int32_t default_wrap_width = 672;
static int32_t default_min_base_width = 550; static int32_t default_min_base_width = 550;
static bool32 automatically_indent_text_on_save = 1;
static char default_theme_name_space[256] = {0}; static char default_theme_name_space[256] = {0};
static String default_theme_name = make_fixed_width_string(default_theme_name_space); static String default_theme_name = make_fixed_width_string(default_theme_name_space);
@ -625,6 +631,7 @@ get_default_font_name(){
} }
// TODO(allen): Stop handling files this way! My own API should be able to do this!!?!?!?!!?!?!!!!? // TODO(allen): Stop handling files this way! My own API should be able to do this!!?!?!?!!?!?!!!!?
// NOTE(allen): Actually need binary buffers for some stuff to work, but not this parsing thing here.
#include <stdio.h> #include <stdio.h>
static bool32 static bool32
@ -692,6 +699,7 @@ process_config_file(Application_Links *app){
config_bool_var(item, "enable_code_wrapping", 0, &enable_code_wrapping); config_bool_var(item, "enable_code_wrapping", 0, &enable_code_wrapping);
config_bool_var(item, "automatically_adjust_wrapping", 0, &automatically_adjust_wrapping); config_bool_var(item, "automatically_adjust_wrapping", 0, &automatically_adjust_wrapping);
config_bool_var(item, "automatically_indent_text_on_save", 0, &automatically_indent_text_on_save); config_bool_var(item, "automatically_indent_text_on_save", 0, &automatically_indent_text_on_save);
config_bool_var(item, "automatically_save_changes_on_build", 0, &automatically_save_changes_on_build);
config_int_var(item, "default_wrap_width", 0, &new_wrap_width); config_int_var(item, "default_wrap_width", 0, &new_wrap_width);
config_int_var(item, "default_min_base_width", 0, &new_min_base_width); config_int_var(item, "default_min_base_width", 0, &new_min_base_width);

View File

@ -339,6 +339,71 @@ CUSTOM_COMMAND_SIG(open_in_other){
} }
//
// File Navigating
//
static bool32
get_cpp_matching_file(Application_Links *app, Buffer_Summary buffer, Buffer_Summary *buffer_out){
bool32 result = false;
char space[512];
String file_name = make_string_cap(space, 0, sizeof(space));
append(&file_name, make_string(buffer.file_name, buffer.file_name_len));
String extension = file_extension(file_name);
String new_extensions[2] = {0};
int32_t new_extensions_count = 0;
if (match(extension, "cpp") || match(extension, "cc")){
new_extensions[0] = make_lit_string("h");
new_extensions[1] = make_lit_string("hpp");
new_extensions_count = 2;
}
else if (match(extension, "c")){
new_extensions[0] = make_lit_string("h");
new_extensions_count = 1;
}
else if (match(extension, "h")){
new_extensions[0] = make_lit_string("c");
new_extensions[1] = make_lit_string("cpp");
new_extensions_count = 2;
}
else if (match(extension, "hpp")){
new_extensions[0] = make_lit_string("cpp");
new_extensions_count = 1;
}
remove_extension(&file_name);
int32_t base_pos = file_name.size;
for (int32_t i = 0; i < new_extensions_count; ++i){
String ext = new_extensions[i];
file_name.size = base_pos;
append(&file_name, ext);
if (open_file(app, buffer_out, file_name.str, file_name.size, false, true)){
result = true;
break;
}
}
return(result);
}
CUSTOM_COMMAND_SIG(open_matching_file_cpp){
View_Summary view = get_active_view(app, AccessAll);
Buffer_Summary buffer = get_buffer(app, view.buffer_id, AccessAll);
Buffer_Summary new_buffer = {0};
if (get_cpp_matching_file(app, buffer, &new_buffer)){
get_view_next_looped(app, &view, AccessAll);
view_set_buffer(app, &view, new_buffer.buffer_id, 0);
set_active_view(app, &view);
}
}
// //
// Execute Arbitrary Command // Execute Arbitrary Command
// //
@ -367,6 +432,9 @@ CUSTOM_COMMAND_SIG(execute_arbitrary_command){
else if (match_ss(bar.string, make_lit_string("open all code"))){ else if (match_ss(bar.string, make_lit_string("open all code"))){
exec_command(app, open_all_code); exec_command(app, open_all_code);
} }
else if (match_ss(bar.string, make_lit_string("open all code recursive"))){
exec_command(app, open_all_code_recursive);
}
else if(match_ss(bar.string, make_lit_string("close all code"))){ else if(match_ss(bar.string, make_lit_string("close all code"))){
exec_command(app, close_all_code); exec_command(app, close_all_code);
} }

View File

@ -246,9 +246,9 @@ get_line_x_rect(View_Summary *view){
return(rect); return(rect);
} }
static int32_t static bool32
open_file(Application_Links *app, Buffer_Summary *buffer_out, char *filename, int32_t filename_len, int32_t background, int32_t never_new){ open_file(Application_Links *app, Buffer_Summary *buffer_out, char *filename, int32_t filename_len, bool32 background, bool32 never_new){
int32_t result = false; bool32 result = false;
Buffer_Summary buffer = get_buffer_by_name(app, filename, filename_len, AccessProtected|AccessHidden); Buffer_Summary buffer = get_buffer_by_name(app, filename, filename_len, AccessProtected|AccessHidden);
if (buffer.exists){ if (buffer.exists){

View File

@ -96,51 +96,57 @@ close_all_files_with_extension(Application_Links *app, Partition *scratch_part,
} }
static void static void
open_all_files_with_extension(Application_Links *app, Partition *scratch_part, char **extension_list, int32_t extension_count){ open_all_files_with_extension_internal(Application_Links *app, String dir, char **extension_list, int32_t extension_count, bool32 recursive){
Temp_Memory temp = begin_temp_memory(scratch_part);
int32_t max_size = partition_remaining(scratch_part);
char *memory = push_array(scratch_part, char, max_size);
String dir = make_string_cap(memory, 0, max_size);
dir.size = directory_get_hot(app, dir.str, dir.memory_size);
int32_t dir_size = dir.size;
// NOTE(allen|a3.4.4): Here we get the list of files in this directory.
// Notice that we free_file_list at the end.
File_List list = get_file_list(app, dir.str, dir.size); File_List list = get_file_list(app, dir.str, dir.size);
int32_t dir_size = dir.size;
for (int32_t i = 0; i < list.count; ++i){ for (int32_t i = 0; i < list.count; ++i){
File_Info *info = list.infos + i; File_Info *info = list.infos + i;
if (!info->folder){ if (info->folder){
bool32 is_match = 1; if (recursive){
dir.size = dir_size;
append(&dir, info->filename);
append(&dir, "/");
open_all_files_with_extension_internal(app, dir, extension_list, extension_count, recursive);
}
}
else{
bool32 is_match = true;
if (extension_count > 0){ if (extension_count > 0){
is_match = 0; is_match = false;
String extension = make_string_cap(info->filename, info->filename_len, info->filename_len+1); String extension = make_string_cap(info->filename, info->filename_len, info->filename_len+1);
extension = file_extension(extension); extension = file_extension(extension);
for (int32_t j = 0; j < extension_count; ++j){ for (int32_t j = 0; j < extension_count; ++j){
if (match(extension, extension_list[j])){ if (match(extension, extension_list[j])){
is_match = 1; is_match = true;
break; break;
} }
} }
}
if (is_match){
// NOTE(allen): There's no way in the 4coder API to use relative if (is_match){
// paths at the moment, so everything should be full paths. Which is dir.size = dir_size;
// managable. Here simply set the dir string size back to where it append(&dir, info->filename);
// was originally, so that new appends overwrite old ones. create_buffer(app, dir.str, dir.size, 0);
dir.size = dir_size;
append_sc(&dir, info->filename);
create_buffer(app, dir.str, dir.size, 0);
}
} }
} }
} }
free_file_list(app, list); free_file_list(app, list);
}
static void
open_all_files_with_extension(Application_Links *app, Partition *scratch_part, char **extension_list, int32_t extension_count, bool32 recursive){
Temp_Memory temp = begin_temp_memory(scratch_part);
int32_t max_size = 4096;
char *memory = push_array(scratch_part, char, max_size);
String dir = make_string_cap(memory, 0, max_size);
dir.size = directory_get_hot(app, dir.str, dir.memory_size);
open_all_files_with_extension_internal(app, dir, extension_list, extension_count, recursive);
end_temp_memory(temp); end_temp_memory(temp);
} }
@ -149,7 +155,13 @@ open_all_files_with_extension(Application_Links *app, Partition *scratch_part, c
CUSTOM_COMMAND_SIG(open_all_code){ CUSTOM_COMMAND_SIG(open_all_code){
int32_t extension_count = 0; int32_t extension_count = 0;
char **extension_list = get_current_code_extensions(&extension_count); char **extension_list = get_current_code_extensions(&extension_count);
open_all_files_with_extension(app, &global_part, extension_list, extension_count); open_all_files_with_extension(app, &global_part, extension_list, extension_count, false);
}
CUSTOM_COMMAND_SIG(open_all_code_recursive){
int32_t extension_count = 0;
char **extension_list = get_current_code_extensions(&extension_count);
open_all_files_with_extension(app, &global_part, extension_list, extension_count, true);
} }
CUSTOM_COMMAND_SIG(close_all_code){ CUSTOM_COMMAND_SIG(close_all_code){
@ -231,6 +243,13 @@ CUSTOM_COMMAND_SIG(load_project){
} }
} }
{
bool32 open_recursively = false;
if (config_bool_var(item, "open_recursively", 0, &open_recursively)){
current_project.open_recursively = open_recursively;
}
}
{ {
#if defined(_WIN32) #if defined(_WIN32)
#define FKEY_COMMAND "fkey_command_win" #define FKEY_COMMAND "fkey_command_win"
@ -257,7 +276,7 @@ CUSTOM_COMMAND_SIG(load_project){
config_array_good(&array_reader); config_array_good(&array_reader);
config_array_next_item(&array_reader, &array_item)){ config_array_next_item(&array_reader, &array_item)){
if (item_index >= 3){ if (item_index >= 4){
break; break;
} }
@ -265,8 +284,8 @@ CUSTOM_COMMAND_SIG(load_project){
append_int_to_str(&msg, item_index); append_int_to_str(&msg, item_index);
append(&msg, "] = "); append(&msg, "] = ");
bool32 read_string = 0; bool32 read_string = false;
bool32 read_bool = 0; bool32 read_bool = false;
char *dest_str = 0; char *dest_str = 0;
int32_t dest_str_size = 0; int32_t dest_str_size = 0;
@ -278,20 +297,26 @@ CUSTOM_COMMAND_SIG(load_project){
{ {
dest_str = current_project.fkey_commands[index-1].command; dest_str = current_project.fkey_commands[index-1].command;
dest_str_size = sizeof(current_project.fkey_commands[index-1].command); dest_str_size = sizeof(current_project.fkey_commands[index-1].command);
read_string = 1; read_string = true;
}break; }break;
case 1: case 1:
{ {
dest_str = current_project.fkey_commands[index-1].out; dest_str = current_project.fkey_commands[index-1].out;
dest_str_size = sizeof(current_project.fkey_commands[index-1].out); dest_str_size = sizeof(current_project.fkey_commands[index-1].out);
read_string = 1; read_string = true;
}break; }break;
case 2: case 2:
{ {
dest_bool = &current_project.fkey_commands[index-1].use_build_panel; dest_bool = &current_project.fkey_commands[index-1].use_build_panel;
read_bool = 1; read_bool = true;
}break;
case 3:
{
dest_bool = &current_project.fkey_commands[index-1].save_dirty_buffers;
read_bool = true;
}break; }break;
} }
@ -342,7 +367,12 @@ CUSTOM_COMMAND_SIG(load_project){
} }
// Open all project files // Open all project files
exec_command(app, open_all_code); if (current_project.open_recursively){
exec_command(app, open_all_code_recursive);
}
else{
exec_command(app, open_all_code);
}
} }
} }
@ -369,11 +399,18 @@ CUSTOM_COMMAND_SIG(load_project){
static void static void
exec_project_fkey_command(Application_Links *app, int32_t command_ind){ exec_project_fkey_command(Application_Links *app, int32_t command_ind){
char *command = current_project.fkey_commands[command_ind].command; Fkey_Command *fkey = &current_project.fkey_commands[command_ind];
char *out = current_project.fkey_commands[command_ind].out; char *command = fkey->command;
bool32 use_build_panel = current_project.fkey_commands[command_ind].use_build_panel;
if (command[0] != 0){ if (command[0] != 0){
char *out = fkey->out;
bool32 use_build_panel = fkey->use_build_panel;
bool32 save_dirty_buffers = fkey->save_dirty_buffers;
if (save_dirty_buffers){
save_all_dirty_buffers(app);
}
int32_t command_len = str_size(command); int32_t command_len = str_size(command);
View_Summary view_ = {0}; View_Summary view_ = {0};

View File

@ -2372,6 +2372,12 @@ App_Step_Sig(app_step){
"If you're new to 4coder there are some tutorials at http://4coder.net/tutorials.html\n" "If you're new to 4coder there are some tutorials at http://4coder.net/tutorials.html\n"
"\n" "\n"
"Newest features:\n" "Newest features:\n"
"-<alt 2> If the current file is a C++ code file, this opens the matching header.\n"" If the current file is a C++ header, this opens the matching code file.\n"
"-Option to automatically save changes on build in the config file.\n"
" This works for builds triggered by <alt m>.\n"
"-Option in project files to have certain fkey commands save changes.\n"
"\n"
"New in alpha 4.0.15:\n"
"-<ctrl I> find all functions in the current buffer and list them in a jump buffer\n" "-<ctrl I> find all functions in the current buffer and list them in a jump buffer\n"
"-option to set user name in config.4coder\n" "-option to set user name in config.4coder\n"
" The user name is used in <alt t> and <alt y> comment writing commands\n" " The user name is used in <alt t> and <alt y> comment writing commands\n"

View File

@ -1125,10 +1125,11 @@ API_EXPORT bool32
Save_Buffer(Application_Links *app, Buffer_Summary *buffer, char *filename, int32_t filename_len, uint32_t flags) Save_Buffer(Application_Links *app, Buffer_Summary *buffer, char *filename, int32_t filename_len, uint32_t flags)
/* /*
DOC_PARAM(buffer, The buffer parameter specifies the buffer to save to a file.) DOC_PARAM(buffer, The buffer parameter specifies the buffer to save to a file.)
DOC_PARAM(filename, The filename parameter specifies the name of the file to associated to the buffer; it need not be null terminated.) DOC_PARAM(filename, The filename parameter specifies the name of the file to write with the contents of the buffer; it need not be null terminated.)
DOC_PARAM(filename_len, The filename_len parameter specifies the length of the filename string.) DOC_PARAM(filename_len, The filename_len parameter specifies the length of the filename string.)
DOC_PARAM(flags, This parameter is not currently used and should be set to 0 for now.) DOC_PARAM(flags, This parameter is not currently used and should be set to 0 for now.)
DOC_RETURN(This call returns non-zero on success.) DOC_RETURN(This call returns non-zero on success.)
DOC(Often it will make sense to set filename and filename_len to buffer.filename and buffer.filename_len)
*/{ */{
Command_Data *cmd = (Command_Data*)app->cmd_context; Command_Data *cmd = (Command_Data*)app->cmd_context;
System_Functions *system = cmd->system; System_Functions *system = cmd->system;

Binary file not shown.

View File

@ -1,16 +1,13 @@
extensions=".c.cpp.h.hpp.bat.sh"; extensions=".c.cpp.h.hpp.bat.sh";
open_recursively=false;
fkey_command_win[1] = {"build.bat", "*compilation*", true}; fkey_command_win[1] = {"build.bat", "*compilation*", true , true };
fkey_command_win[2] = {"site\\build.bat", "*compilation*", true}; fkey_command_win[2] = {"site\\build.bat", "*compilation*", true , true };
fkey_command_win[3] = {"string\\build.bat", "*compilation*", true}; fkey_command_win[3] = {"string\\build.bat", "*compilation*", true , true };
fkey_command_win[5] = {"..\\misc\\run.bat", "*run*", false, false};
fkey_command_win[12] = {"package.bat", "*package*", false, true };
fkey_command_win[5] = {"..\\misc\\run.bat", "*run*"}; fkey_command_linux[1] = {"./build.sh", "*compilation*", true , true };
fkey_command_linux[2] = {"site/build.sh", "*compilation*", true , true };
fkey_command_win[12] = {"package.bat", "*package*"}; fkey_command_linux[5] = {"../build/4ed", "*run*", false, false};
fkey_command_linux[12] = {"./package.sh", "*package*", false, true };
fkey_command_linux[1] = {"./build.sh", "*compilation*", true};
fkey_command_linux[2] = {"site/build.sh", "*compilation*", true};
fkey_command_linux[5] = {"../build/4ed", "*run*"};
fkey_command_linux[12] = {"./package.sh", "*package*"};

View File

@ -1,4 +1,4 @@
This is the documentation for \VERSION. The documentation is still under construction so some of the links are linking to sections that have not been written yet. What is here should be correct and I suspect useful even without some of the other sections. This is the documentation for \VERSION. The documentation is still under construction so some of the links are linking to sections that have not been written yet. What is here should be correct and I suspect useful even without some of the other sections.
If you have questions or discover errors please contact \BEGIN_STYLE{code} editor@4coder.net \END_STYLE or to get help from members of the 4coder and handmade network community you can post on the 4coder forums hosted at \BEGIN_STYLE{code} 4coder.handmade.network \END_STYLE. If you have questions or discover errors please contact \BEGIN_STYLE{code}editor@4coder.net\END_STYLE or to get help from members of the 4coder and handmade network community you can post on the 4coder forums hosted at \BEGIN_STYLE{code}4coder.handmade.network\END_STYLE.