standard build function fixed

This commit is contained in:
Allen Webster 2016-07-02 10:56:50 -04:00
parent d3975b2d26
commit 21b89b8ee6
7 changed files with 79 additions and 59 deletions

View File

@ -15,16 +15,18 @@ li:before { content: "4"; color: #005000; font-family:"Webdings"; }
</style>
</head>
<body>
<div style='font-family:Arial; margin: 0 auto; width: 900px; text-align: justify; line-height: 1.25;'>
<div style='font-family:Arial; margin: 0 auto; width: 800px; text-align: justify; line-height: 1.25;'>
<h1 style='margin-top: 5mm; margin-bottom: 5mm;'>4coder API</h1>
<h2>&sect;1 Introduction</h2>
<div>
<p>
This is the documentation for alpha 4.0.9 super! The documentation has been made as accurate as possible but there may be errors. If you have questions or discover errors please contact <span style='font-family: "Courier New", Courier, monospace; text-align: left;'>editor@4coder.net</span>.</p>
This is the documentation for alpha 4.0.9 super! 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. </p>
<p>
</p>
If you have questions or discover errors please contact <span style='font-family: "Courier New", Courier, monospace; text-align: left;'>editor@4coder.net</span> or to get help from community members you can post on the 4coder forums hosted on handmade.network at <span style='font-family: "Courier New", Courier, monospace; text-align: left;'>4coder.handmade.network</span></p>
</div>
<h2>&sect;2 4coder Systems</h2>
<div><i>
Coming Soon</i><div>
<h2>&sect;3 Types and Functions</h2>
<h3>&sect;3.1 Function List</h3>
<ul>
@ -1630,12 +1632,12 @@ int id;<br>
<div style='margin-top: 3mm; margin-bottom: 3mm; color: #309030;'><b><i>Description</i></b></div><div style='margin-left: 5mm; margin-right: 5mm;'>Buffer_Identifier acts as a loosely typed description of a buffer that
can either be a name or an id. If the</div><div style='margin-top: 3mm; margin-bottom: 3mm; color: #309030;'><b><i>Fields</i></b></div><div>
<div style='font-family: "Courier New", Courier, monospace; text-align: left;'><span style='font-weight: 600;'>name</span></div>
<div style='margin-bottom: 6mm;'><div style='margin-left: 5mm; margin-right: 5mm;'>This field is the name of the buffer, need not be null terminated.
If id is specified this should be NULL.</div></div>
<div style='margin-bottom: 6mm;'><div style='margin-left: 5mm; margin-right: 5mm;'>This field is the name of the buffer; it need not be null terminated.
If id is specified this pointer should be NULL.</div></div>
</div>
<div>
<div style='font-family: "Courier New", Courier, monospace; text-align: left;'><span style='font-weight: 600;'>name_len</span></div>
<div style='margin-bottom: 6mm;'><div style='margin-left: 5mm; margin-right: 5mm;'>This field is specifies the length of the name string.</div></div>
<div style='margin-bottom: 6mm;'><div style='margin-left: 5mm; margin-right: 5mm;'>This field specifies the length of the name string.</div></div>
</div>
<div>
<div style='font-family: "Courier New", Courier, monospace; text-align: left;'><span style='font-weight: 600;'>id</span></div>

View File

@ -1391,6 +1391,7 @@ get_build_directory(Application_Links *app, Buffer_Summary *buffer, String *dir_
int len = app->directory_get_hot(app, dir_out->str,
dir_out->memory_size - dir_out->size);
if (len + dir_out->size < dir_out->memory_size){
dir_out->size += len;
result = true;
}
}
@ -1398,6 +1399,49 @@ get_build_directory(Application_Links *app, Buffer_Summary *buffer, String *dir_
return(result);
}
static void
execute_standard_build(Application_Links *app, View_Summary *view, Buffer_Summary *active_buffer){
int old_size = 0;
int size = app->memory_size/2;
String dir = make_string(app->memory, 0, size);
get_build_directory(app, active_buffer, &dir);
String command = make_string((char*)app->memory + size, 0, size);
for(;;){
old_size = dir.size;
append(&dir, "build.bat");
if (app->file_exists(app, dir.str, dir.size)){
dir.size = old_size;
append(&command, '"');
append(&command, dir);
append(&command, "build\"");
app->exec_system_command(app, view,
buffer_identifier(literal("*compilation*")),
dir.str, dir.size,
command.str, command.size,
CLI_OverlapWithConflict);
break;
}
dir.size = old_size;
if (app->directory_cd(app, dir.str, &dir.size, dir.memory_size, literal("..")) == 0){
dir.size = app->directory_get_hot(app, dir.str, dir.memory_size);
command = make_lit_string("echo couldn't find build.bat");
app->exec_system_command(app, view,
buffer_identifier(literal("*compilation*")),
dir.str, dir.size,
command.str, command.size,
CLI_OverlapWithConflict);
break;
}
}
}
CUSTOM_COMMAND_SIG(build_search_regular){
// NOTE(allen|a3.3): An example of traversing the filesystem through parent
// directories looking for a file, in this case a batch file to execute.
@ -1434,49 +1478,10 @@ CUSTOM_COMMAND_SIG(build_search_regular){
// This doesn't actually change the hot directory of 4coder, it's only effect is to
// modify the string you passed in to reflect the change in directory if that change was possible.
int old_size = 0;
int size = app->memory_size/2;
unsigned int access = AccessAll;
View_Summary view = app->get_active_view(app, access);
Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
String dir = make_string(app->memory, 0, size);
get_build_directory(app, &buffer, &dir);
String command = make_string((char*)app->memory + size, 0, size);
for(;;){
old_size = dir.size;
append(&dir, "build.bat");
if (app->file_exists(app, dir.str, dir.size)){
dir.size = old_size;
append(&command, '"');
append(&command, dir);
append(&command, "build\"");
app->exec_system_command(app, &view,
buffer_identifier(literal("*compilation*")),
dir.str, dir.size,
command.str, command.size,
CLI_OverlapWithConflict);
break;
}
dir.size = old_size;
if (app->directory_cd(app, dir.str, &dir.size, dir.memory_size, literal("..")) == 0){
dir.size = app->directory_get_hot(app, dir.str, dir.memory_size);
command = make_lit_string("echo couldn't find build.bat");
app->exec_system_command(app, &view,
buffer_identifier(literal("*compilation*")),
dir.str, dir.size,
command.str, command.size,
CLI_OverlapWithConflict);
break;
}
}
execute_standard_build(app, &view, &buffer);
}
// TODO(allen): This is a bit nasty. I want a system for picking

View File

@ -414,12 +414,12 @@ can either be a name or an id. If the
) */
struct Buffer_Identifier{
/* DOC(
This field is the name of the buffer, need not be null terminated.
If id is specified this should be NULL.
This field is the name of the buffer; it need not be null terminated.
If id is specified this pointer should be NULL.
) */
char *name;
/* DOC(This field is specifies the length of the name string.) */
/* DOC(This field specifies the length of the name string.) */
int name_len;
/* DOC(This field is the id of the buffer. If name is specified this should be 0.) */

View File

@ -1769,7 +1769,7 @@ generate_custom_headers(){
"</head>\n"
"<body>\n"
"<div style='font-family:Arial; margin: 0 auto; "
"width: 900px; text-align: justify; line-height: 1.25;'>\n"
"width: 800px; text-align: justify; line-height: 1.25;'>\n"
"<h1 style='margin-top: 5mm; margin-bottom: 5mm;'>4coder API</h1>\n"
);
@ -1780,12 +1780,18 @@ generate_custom_headers(){
"<div>\n"
"<p>\n"
"This is the documentation for " VERSION " The documentation has been made as "
"accurate as possible but there may be errors. If you have questions or "
"discover errors please contact <span style='"CODE_STYLE"'>editor@4coder.net</span>."
"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. "
"</p>\n"
"<p>\n"
"If you have questions or discover errors please contact "
"<span style='"CODE_STYLE"'>editor@4coder.net</span> or "
"to get help from community members you can post on the "
"4coder forums hosted on handmade.network at "
"<span style='"CODE_STYLE"'>4coder.handmade.network</span>"
"</p>\n"
"</div>\n");
@ -1795,7 +1801,10 @@ generate_custom_headers(){
// TODO(allen): Write the 4coder system descriptions.
fprintf(file, "<h2>&sect;"MAJOR_SECTION" 4coder Systems</h2>\n");
{
fprintf(file,
"<div><i>\n"
"Coming Soon"
"</i><div>\n");
}
#undef MAJOR_SECTION

View File

@ -1,4 +1,4 @@
Distribution Date: 30.6.2016 (dd.mm.yyyy)
Distribution Date: 2.7.2016 (dd.mm.yyyy)
Thank you for contributing to the 4coder project!

View File

@ -1,4 +1,4 @@
Distribution Date: 30.6.2016 (dd.mm.yyyy)
Distribution Date: 2.7.2016 (dd.mm.yyyy)
Thank you for contributing to the 4coder project!

View File

@ -9,6 +9,7 @@
#include "4coder_helper.h"
//
// Basic Build Behavior
//
@ -24,7 +25,10 @@ CUSTOM_COMMAND_SIG(build_in_build_panel){
Buffer_Summary buffer =
app->get_buffer_by_name(app, literal("*compilation*"), AccessAll);
View_Summary build_view = {0};
View_Summary original_view = app->get_active_view(app, AccessAll);
Buffer_Summary original_buffer =
app->get_buffer(app, original_view.buffer_id, AccessAll);
if (buffer.exists){
build_view = get_first_view_with_buffer(app, buffer.buffer_id);
@ -35,11 +39,11 @@ CUSTOM_COMMAND_SIG(build_in_build_panel){
exec_command(app, hide_scrollbar);
build_view = app->get_active_view(app, AccessAll);
app->view_set_split_proportion(app, &build_view, .2f);
app->set_active_view(app, &original_view);
}
app->set_active_view(app, &build_view);
exec_command(app, build_search);
app->set_active_view(app, &original_view);
execute_standard_build(app, &build_view, &original_buffer);
prev_location = {0};
}