got rid of dead file
parent
c82dbd8e2c
commit
72ea42364d
|
@ -3,8 +3,7 @@
|
|||
#define FCODER_CUSTOM_H
|
||||
|
||||
#include <stdint.h>
|
||||
// TODO(allen): We need to eliminate our dependence on this
|
||||
// in the custom side.
|
||||
// TODO(allen): We need to eliminate our dependence on this soon.
|
||||
#include <string.h>
|
||||
|
||||
|
||||
|
@ -47,28 +46,21 @@ enum Special_Hook_ID{
|
|||
_hook_input_filter,
|
||||
};
|
||||
|
||||
#define CommandEqual(c1,c2) ((unsigned long long)(c1) == (unsigned long long)(c2))
|
||||
|
||||
#define CUSTOM_COMMAND_SIG(name) void name(struct Application_Links *app)
|
||||
typedef CUSTOM_COMMAND_SIG(Custom_Command_Function);
|
||||
|
||||
#include "4coder_types.h"
|
||||
#include "4coder_buffer_types.h"
|
||||
#include "4coder_seek_types.h"
|
||||
#include "4coder_gui.h"
|
||||
|
||||
#define COMMAND_CALLER_HOOK(name) int32_t name(struct Application_Links *app, Generic_Command cmd)
|
||||
typedef COMMAND_CALLER_HOOK(Command_Caller_Hook_Function);
|
||||
|
||||
inline Key_Event_Data
|
||||
key_event_data_zero(){
|
||||
Key_Event_Data data={0};
|
||||
return(data);
|
||||
}
|
||||
inline Mouse_State
|
||||
mouse_state_zero(){
|
||||
Mouse_State data={0};
|
||||
return(data);
|
||||
}
|
||||
static Key_Event_Data null_key_event_data = {0};
|
||||
static Mouse_State null_mouse_state = {0};
|
||||
static Buffer_Summary null_buffer_summary = {0};
|
||||
static View_Summary null_view_summary = {0};
|
||||
|
||||
inline Range
|
||||
make_range(int32_t p1, int32_t p2){
|
||||
Range range;
|
||||
|
@ -82,17 +74,6 @@ make_range(int32_t p1, int32_t p2){
|
|||
}
|
||||
return(range);
|
||||
}
|
||||
inline Buffer_Summary
|
||||
buffer_summary_zero(){
|
||||
Buffer_Summary summary={0};
|
||||
return(summary);
|
||||
}
|
||||
inline View_Summary
|
||||
view_summary_zero(){
|
||||
View_Summary summary={0};
|
||||
return(summary);
|
||||
}
|
||||
|
||||
|
||||
#define HOOK_SIG(name) int32_t name(struct Application_Links *app)
|
||||
#define OPEN_FILE_HOOK_SIG(name) int32_t name(struct Application_Links *app, int32_t buffer_id)
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#define FCODER_DEFAULT_BINDINGS
|
||||
|
||||
#include "4coder_default_include.cpp"
|
||||
#include "4coder_default_building.cpp"
|
||||
|
||||
// NOTE(allen|a3.3): All of your custom ids should be enumerated
|
||||
// as shown here, they may start at 0, and you can only have
|
||||
|
@ -212,7 +211,7 @@ static int32_t suppressing_mouse = false;
|
|||
|
||||
INPUT_FILTER_SIG(my_suppress_mouse_filter){
|
||||
if (suppressing_mouse){
|
||||
*mouse = mouse_state_zero();
|
||||
*mouse = null_mouse_state;
|
||||
mouse->x = -100;
|
||||
mouse->y = -100;
|
||||
}
|
||||
|
@ -266,7 +265,7 @@ default_keys(Bind_Helper *context){
|
|||
bind(context, 'n', MDFR_ALT, goto_next_error);
|
||||
bind(context, 'N', MDFR_ALT, goto_prev_error);
|
||||
bind(context, 'M', MDFR_ALT, goto_first_error);
|
||||
bind(context, 'm', MDFR_ALT, build_search);
|
||||
bind(context, 'm', MDFR_ALT, build_in_build_panel);
|
||||
|
||||
bind(context, 'z', MDFR_ALT, execute_any_cli);
|
||||
bind(context, 'Z', MDFR_ALT, execute_previous_cli);
|
||||
|
|
|
@ -1,184 +0,0 @@
|
|||
|
||||
#ifndef FCODER_DEFAULT_BUILDING
|
||||
#define FCODER_DEFAULT_BUILDING
|
||||
|
||||
#include "4coder_custom.h"
|
||||
|
||||
#define FSTRING_IMPLEMENTATION
|
||||
#include "4coder_string.h"
|
||||
|
||||
#include "4coder_helper.h"
|
||||
#include "4coder_jump_parsing.cpp"
|
||||
|
||||
//
|
||||
// Basic Build Behavior
|
||||
//
|
||||
|
||||
CUSTOM_COMMAND_SIG(build_in_build_panel){
|
||||
String comp_name = make_lit_string("*compilation*");
|
||||
|
||||
Buffer_Summary buffer =
|
||||
app->get_buffer_by_name(app, comp_name.str, comp_name.size, 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);
|
||||
}
|
||||
|
||||
if (!build_view.exists){
|
||||
exec_command(app, open_panel_hsplit);
|
||||
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);
|
||||
}
|
||||
|
||||
execute_standard_build(app, &build_view, &original_buffer);
|
||||
|
||||
buffer = app->get_buffer_by_name(app, comp_name.str, comp_name.size, AccessAll);
|
||||
app->buffer_set_font(app, &buffer, literal("Inconsolata"));
|
||||
|
||||
prev_location = null_location;
|
||||
|
||||
lock_jump_buffer(comp_name.str, comp_name.size);
|
||||
}
|
||||
|
||||
// TODO(allen): This is a bit nasty. I want a system for picking
|
||||
// the most advanced and correct version of a command to bind to a
|
||||
// name based on which files are included.
|
||||
#ifndef BUILD_SEARCH
|
||||
# define BUILD_SEARCH 2
|
||||
#elif BUILD_SEARCH <= 2
|
||||
# undef BUILD_SEARCH
|
||||
# define BUILD_SEARCH 2
|
||||
#endif
|
||||
|
||||
#if BUILD_SEARCH <= 2
|
||||
# ifdef build_search
|
||||
# undef build_search
|
||||
# endif
|
||||
# define build_search build_in_build_panel
|
||||
#endif
|
||||
|
||||
#define GET_COMP_BUFFER() app->get_buffer_by_name(app, literal("*compilation*"), AccessAll);
|
||||
|
||||
CUSTOM_COMMAND_SIG(close_build_panel){
|
||||
Buffer_Summary buffer = GET_COMP_BUFFER();
|
||||
View_Summary build_view = get_first_view_with_buffer(app, buffer.buffer_id);
|
||||
|
||||
if (build_view.exists){
|
||||
View_Summary original_view = app->get_active_view(app, AccessAll);
|
||||
|
||||
app->set_active_view(app, &build_view);
|
||||
exec_command(app, close_panel);
|
||||
app->set_active_view(app, &original_view);
|
||||
}
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(change_to_build_panel){
|
||||
Buffer_Summary buffer = GET_COMP_BUFFER();
|
||||
|
||||
if (buffer.exists){
|
||||
View_Summary build_view = get_first_view_with_buffer(app, buffer.buffer_id);
|
||||
|
||||
app->set_active_view(app, &build_view);
|
||||
}
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(change_active_panel_build){
|
||||
Buffer_Summary buffer = GET_COMP_BUFFER();
|
||||
|
||||
if (buffer.exists){
|
||||
View_Summary build_view = get_first_view_with_buffer(app, buffer.buffer_id);
|
||||
|
||||
View_Summary view = app->get_active_view(app, AccessAll);
|
||||
int32_t prev_view_id = view.view_id;
|
||||
|
||||
exec_command(app, change_active_panel_regular);
|
||||
view = app->get_active_view(app, AccessAll);
|
||||
|
||||
for (;(view.view_id != prev_view_id &&
|
||||
build_view.view_id == view.view_id);){
|
||||
prev_view_id = view.view_id;
|
||||
exec_command(app, change_active_panel_regular);
|
||||
view = app->get_active_view(app, AccessAll);
|
||||
}
|
||||
}
|
||||
else{
|
||||
exec_command(app, change_active_panel_regular);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(allen): This is a bit nasty. I want a system for picking
|
||||
// the most advanced and correct version of a command to bind to a
|
||||
// name based on which files are included.
|
||||
#ifndef CHANGE_ACTIVE_PANEL
|
||||
# define CHANGE_ACTIVE_PANEL 2
|
||||
#elif CHANGE_ACTIVE_PANEL <= 2
|
||||
# undef CHANGE_ACTIVE_PANEL
|
||||
# define CHANGE_ACTIVE_PANEL 2
|
||||
#endif
|
||||
|
||||
#if CHANGE_ACTIVE_PANEL <= 2
|
||||
# ifdef change_active_panel
|
||||
# undef change_active_panel
|
||||
# endif
|
||||
# define change_active_panel change_active_panel_build
|
||||
#endif
|
||||
|
||||
CUSTOM_COMMAND_SIG(open_file_in_quotes_build){
|
||||
char file_name_[256];
|
||||
String file_name = make_fixed_width_string(file_name_);
|
||||
|
||||
if (file_name_in_quotes(app, &file_name)){
|
||||
exec_command(app, change_active_panel_build);
|
||||
View_Summary view = app->get_active_view(app, AccessAll);
|
||||
view_open_file(app, &view, expand_str(file_name), true);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(allen): This is a bit nasty. I want a system for picking
|
||||
// the most advanced and correct version of a command to bind to a
|
||||
// name based on which files are included.
|
||||
#ifndef OPEN_FILE_IN_QUOTES
|
||||
# define OPEN_FILE_IN_QUOTES 2
|
||||
#elif OPEN_FILE_IN_QUOTES <= 2
|
||||
# undef OPEN_FILE_IN_QUOTES
|
||||
# define OPEN_FILE_IN_QUOTES 2
|
||||
#endif
|
||||
|
||||
#if OPEN_FILE_IN_QUOTES <= 2
|
||||
# ifdef open_file_in_quotes
|
||||
# undef open_file_in_quotes
|
||||
# endif
|
||||
# define open_file_in_quotes open_file_in_quotes_build
|
||||
#endif
|
||||
|
||||
CUSTOM_COMMAND_SIG(open_in_other_build){
|
||||
exec_command(app, change_active_panel_build);
|
||||
exec_command(app, cmdid_interactive_open);
|
||||
}
|
||||
|
||||
// TODO(allen): This is a bit nasty. I want a system for picking
|
||||
// the most advanced and correct version of a command to bind to a
|
||||
// name based on which files are included.
|
||||
#ifndef OPEN_IN_OTHER
|
||||
# define OPEN_IN_OTHER 1
|
||||
#elif OPEN_IN_OTHER <= 1
|
||||
# undef OPEN_IN_OTHER
|
||||
# define OPEN_IN_OTHER 1
|
||||
#endif
|
||||
|
||||
#if OPEN_IN_OTHER <= 1
|
||||
# ifdef open_in_other
|
||||
# undef open_in_other
|
||||
# endif
|
||||
# define open_in_other open_in_other_build
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -1573,34 +1573,57 @@ CUSTOM_COMMAND_SIG(hide_scrollbar){
|
|||
// Panel Management
|
||||
//
|
||||
|
||||
CUSTOM_COMMAND_SIG(change_active_panel_regular){
|
||||
View_Summary view = app->get_active_view(app, AccessAll);
|
||||
app->get_view_next(app, &view, AccessAll);
|
||||
if (!view.exists){
|
||||
view = app->get_view_first(app, AccessAll);
|
||||
static void
|
||||
get_view_next_looped(Application_Links *app, View_Summary *view, uint32_t access){
|
||||
app->get_view_next(app, view, access);
|
||||
if (!view->exists){
|
||||
*view = app->get_view_first(app, access);
|
||||
}
|
||||
}
|
||||
|
||||
static View_ID special_note_view_id = 0;
|
||||
|
||||
static void
|
||||
close_special_note_view(Application_Links *app){
|
||||
View_Summary special_view = app->get_view(app, special_note_view_id, AccessAll);
|
||||
if (special_view.exists){
|
||||
app->close_view(app, &special_view);
|
||||
}
|
||||
special_note_view_id = 0;
|
||||
}
|
||||
|
||||
static View_Summary
|
||||
open_special_note_view(Application_Links *app, bool32 create_if_not_exist = true){
|
||||
View_Summary special_view = app->get_view(app, special_note_view_id, AccessAll);
|
||||
|
||||
if (create_if_not_exist && !special_view.exists){
|
||||
View_Summary view = app->get_active_view(app, AccessAll);
|
||||
special_view = app->open_view(app, &view, ViewSplit_Bottom);
|
||||
app->view_set_setting(app, &special_view, ViewSetting_ShowScrollbar, false);
|
||||
app->view_set_split_proportion(app, &special_view, .2f);
|
||||
app->set_active_view(app, &view);
|
||||
special_note_view_id = special_view.view_id;
|
||||
}
|
||||
|
||||
return(special_view);
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(change_active_panel){
|
||||
View_Summary view = app->get_active_view(app, AccessAll);
|
||||
View_ID original_view_id = view.view_id;
|
||||
|
||||
do{
|
||||
get_view_next_looped(app, &view, AccessAll);
|
||||
if (view.view_id != special_note_view_id){
|
||||
break;
|
||||
}
|
||||
}while(view.view_id != original_view_id);
|
||||
|
||||
if (view.exists){
|
||||
app->set_active_view(app, &view);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(allen): This is a bit nasty. I want a system for picking
|
||||
// the most advanced and correct version of a command to bind to a
|
||||
// name based on which files are included.
|
||||
#ifndef CHANGE_ACTIVE_PANEL
|
||||
# define CHANGE_ACTIVE_PANEL 1
|
||||
#elif CHANGE_ACTIVE_PANEL <= 1
|
||||
# undef CHANGE_ACTIVE_PANEL
|
||||
# define CHANGE_ACTIVE_PANEL 1
|
||||
#endif
|
||||
|
||||
#if CHANGE_ACTIVE_PANEL <= 1
|
||||
# ifdef change_active_panel
|
||||
# undef change_active_panel
|
||||
# endif
|
||||
# define change_active_panel change_active_panel_regular
|
||||
#endif
|
||||
|
||||
CUSTOM_COMMAND_SIG(close_panel){
|
||||
View_Summary view = app->get_active_view(app, AccessAll);
|
||||
app->close_view(app, &view);
|
||||
|
@ -1655,57 +1678,22 @@ file_name_in_quotes(Application_Links *app, String *file_name){
|
|||
return(result);
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(open_file_in_quotes_regular){
|
||||
CUSTOM_COMMAND_SIG(open_file_in_quotes){
|
||||
char file_name_[256];
|
||||
String file_name = make_fixed_width_string(file_name_);
|
||||
|
||||
if (file_name_in_quotes(app, &file_name)){
|
||||
exec_command(app, change_active_panel_regular);
|
||||
exec_command(app, change_active_panel);
|
||||
View_Summary view = app->get_active_view(app, AccessAll);
|
||||
view_open_file(app, &view, expand_str(file_name), true);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(allen): This is a bit nasty. I want a system for picking
|
||||
// the most advanced and correct version of a command to bind to a
|
||||
// name based on which files are included.
|
||||
#ifndef OPEN_FILE_IN_QUOTES
|
||||
# define OPEN_FILE_IN_QUOTES 1
|
||||
#elif OPEN_FILE_IN_QUOTES <= 1
|
||||
# undef OPEN_FILE_IN_QUOTES
|
||||
# define OPEN_FILE_IN_QUOTES 1
|
||||
#endif
|
||||
|
||||
#if OPEN_FILE_IN_QUOTES <= 1
|
||||
# ifdef open_file_in_quotes
|
||||
# undef open_file_in_quotes
|
||||
# endif
|
||||
# define open_file_in_quotes open_file_in_quotes_regular
|
||||
#endif
|
||||
|
||||
CUSTOM_COMMAND_SIG(open_in_other_regular){
|
||||
exec_command(app, change_active_panel_regular);
|
||||
CUSTOM_COMMAND_SIG(open_in_other){
|
||||
exec_command(app, change_active_panel);
|
||||
exec_command(app, cmdid_interactive_open);
|
||||
}
|
||||
|
||||
// TODO(allen): This is a bit nasty. I want a system for picking
|
||||
// the most advanced and correct version of a command to bind to a
|
||||
// name based on which files are included.
|
||||
#ifndef OPEN_IN_OTHER
|
||||
# define OPEN_IN_OTHER 1
|
||||
#elif OPEN_IN_OTHER <= 1
|
||||
# undef OPEN_IN_OTHER
|
||||
# define OPEN_IN_OTHER 1
|
||||
#endif
|
||||
|
||||
#if OPEN_IN_OTHER <= 1
|
||||
# ifdef open_in_other
|
||||
# undef open_in_other
|
||||
# endif
|
||||
# define open_in_other open_in_other_regular
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
CUSTOM_COMMAND_SIG(save_as){
|
||||
exec_command(app, cmdid_save_as);
|
||||
|
@ -2085,216 +2073,6 @@ CUSTOM_COMMAND_SIG(execute_previous_cli){
|
|||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Default Building Stuff
|
||||
//
|
||||
|
||||
// NOTE(allen|a4.0.9): This is provided to establish a default method of getting
|
||||
// a "build directory". This function tries to setup the build directory in the
|
||||
// directory of the given buffer, if it cannot get that information it get's the
|
||||
// 4coder hot directory.
|
||||
//
|
||||
// There is no requirement that a custom build system in 4coder actually use the
|
||||
// directory given by this function.
|
||||
enum Get_Build_Directory_Result{
|
||||
BuildDir_None,
|
||||
BuildDir_AtFile,
|
||||
BuildDir_AtHot
|
||||
};
|
||||
|
||||
static int32_t
|
||||
get_build_directory(Application_Links *app, Buffer_Summary *buffer, String *dir_out){
|
||||
int32_t result = BuildDir_None;
|
||||
|
||||
if (buffer && buffer->file_name){
|
||||
if (!match_cc(buffer->file_name, buffer->buffer_name)){
|
||||
String dir = make_string_cap(buffer->file_name,
|
||||
buffer->file_name_len,
|
||||
buffer->file_name_len+1);
|
||||
remove_last_folder(&dir);
|
||||
append_ss(dir_out, dir);
|
||||
result = BuildDir_AtFile;
|
||||
}
|
||||
}
|
||||
|
||||
if (!result){
|
||||
int32_t 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 = BuildDir_AtHot;
|
||||
}
|
||||
}
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
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){
|
||||
int32_t result = false;
|
||||
|
||||
for(;;){
|
||||
int32_t old_size = dir->size;
|
||||
append_ss(dir, filename);
|
||||
|
||||
if (app->file_exists(app, dir->str, dir->size)){
|
||||
dir->size = old_size;
|
||||
|
||||
if (use_path_in_command){
|
||||
append_s_char(command, '"');
|
||||
append_ss(command, *dir);
|
||||
append_ss(command, commandname);
|
||||
append_s_char(command, '"');
|
||||
}
|
||||
else{
|
||||
append_ss(command, commandname);
|
||||
}
|
||||
|
||||
char space[512];
|
||||
String message = make_fixed_width_string(space);
|
||||
append_ss(&message, make_lit_string("Building with: "));
|
||||
append_ss(&message, *command);
|
||||
append_s_char(&message, '\n');
|
||||
app->print_message(app, message.str, message.size);
|
||||
|
||||
|
||||
app->exec_system_command(app, view,
|
||||
buffer_identifier(literal("*compilation*")),
|
||||
dir->str, dir->size,
|
||||
command->str, command->size,
|
||||
CLI_OverlapWithConflict);
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
dir->size = old_size;
|
||||
|
||||
if (app->directory_cd(app, dir->str, &dir->size, dir->memory_size, literal("..")) == 0){
|
||||
if (perform_backup){
|
||||
dir->size = app->directory_get_hot(app, dir->str, dir->memory_size);
|
||||
char backup_space[256];
|
||||
String backup_command = make_fixed_width_string(backup_space);
|
||||
append_ss(&backup_command, make_lit_string("echo could not find "));
|
||||
append_ss(&backup_command, filename);
|
||||
app->exec_system_command(app, view,
|
||||
buffer_identifier(literal("*compilation*")),
|
||||
dir->str, dir->size,
|
||||
backup_command.str, backup_command.size,
|
||||
CLI_OverlapWithConflict);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
||||
// NOTE(allen): Build search rule for windows.
|
||||
static int32_t
|
||||
execute_standard_build_search(Application_Links *app, View_Summary *view,
|
||||
Buffer_Summary *active_buffer,
|
||||
String *dir, String *command, int32_t perform_backup){
|
||||
int32_t result = standard_build_search(app, view,
|
||||
active_buffer,
|
||||
dir, command, perform_backup, true,
|
||||
make_lit_string("build.bat"),
|
||||
make_lit_string("build"));
|
||||
return(result);
|
||||
}
|
||||
|
||||
#elif defined(__linux__)
|
||||
|
||||
// NOTE(allen): Build search rule for linux.
|
||||
static int32_t
|
||||
execute_standard_build_search(Application_Links *app, View_Summary *view,
|
||||
Buffer_Summary *active_buffer,
|
||||
String *dir, String *command, int32_t perform_backup){
|
||||
|
||||
char dir_space[512];
|
||||
String dir_copy = make_fixed_width_string(dir_space);
|
||||
copy(&dir_copy, *dir);
|
||||
|
||||
int32_t result = standard_build_search(app, view,
|
||||
active_buffer,
|
||||
dir, command, false, true,
|
||||
make_lit_string("build.sh"),
|
||||
make_lit_string("build.sh"));
|
||||
|
||||
if (!result){
|
||||
result = standard_build_search(app, view,
|
||||
active_buffer,
|
||||
&dir_copy, command, perform_backup, false,
|
||||
make_lit_string("Makefile"),
|
||||
make_lit_string("make"));
|
||||
}
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
#else
|
||||
# error No build search rule for this platform.
|
||||
#endif
|
||||
|
||||
|
||||
static void
|
||||
execute_standard_build(Application_Links *app, View_Summary *view,
|
||||
Buffer_Summary *active_buffer){
|
||||
char dir_space[512];
|
||||
String dir = make_fixed_width_string(dir_space);
|
||||
|
||||
char command_str_space[512];
|
||||
String command = make_fixed_width_string(command_str_space);
|
||||
|
||||
int32_t build_dir_type = get_build_directory(app, active_buffer, &dir);
|
||||
|
||||
if (build_dir_type == BuildDir_AtFile){
|
||||
if (!execute_standard_build_search(app, view, active_buffer,
|
||||
&dir, &command, false)){
|
||||
dir.size = 0;
|
||||
command.size = 0;
|
||||
build_dir_type = get_build_directory(app, 0, &dir);
|
||||
}
|
||||
}
|
||||
|
||||
if (build_dir_type == BuildDir_AtHot){
|
||||
execute_standard_build_search(app, view, active_buffer,
|
||||
&dir, &command, true);
|
||||
}
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(build_search_regular){
|
||||
uint32_t access = AccessAll;
|
||||
View_Summary view = app->get_active_view(app, access);
|
||||
Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
|
||||
execute_standard_build(app, &view, &buffer);
|
||||
}
|
||||
|
||||
// TODO(allen): This is a bit nasty. I want a system for picking
|
||||
// the most advanced and correct version of a command to bind to a
|
||||
// name based on which files are included.
|
||||
#ifndef BUILD_SEARCH
|
||||
# define BUILD_SEARCH 1
|
||||
#elif BUILD_SEARCH <= 1
|
||||
# undef BUILD_SEARCH
|
||||
# define BUILD_SEARCH 1
|
||||
#endif
|
||||
|
||||
#if BUILD_SEARCH <= 1
|
||||
# ifdef build_search
|
||||
# undef build_search
|
||||
# endif
|
||||
# define build_search build_search_regular
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// Common Settings Commands
|
||||
//
|
||||
|
@ -2330,6 +2108,7 @@ CUSTOM_COMMAND_SIG(eol_nixify){
|
|||
app->buffer_set_setting(app, &buffer, BufferSetting_Eol, false);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// "Full Search" Based Commands
|
||||
//
|
||||
|
@ -2668,8 +2447,263 @@ CUSTOM_COMMAND_SIG(word_complete){
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Default Building Stuff
|
||||
//
|
||||
|
||||
// NOTE(allen|a4.0.9): This is provided to establish a default method of getting
|
||||
// a "build directory". This function tries to setup the build directory in the
|
||||
// directory of the given buffer, if it cannot get that information it get's the
|
||||
// 4coder hot directory.
|
||||
//
|
||||
// There is no requirement that a custom build system in 4coder actually use the
|
||||
// directory given by this function.
|
||||
enum Get_Build_Directory_Result{
|
||||
BuildDir_None,
|
||||
BuildDir_AtFile,
|
||||
BuildDir_AtHot
|
||||
};
|
||||
|
||||
static int32_t
|
||||
get_build_directory(Application_Links *app, Buffer_Summary *buffer, String *dir_out){
|
||||
int32_t result = BuildDir_None;
|
||||
|
||||
if (buffer && buffer->file_name){
|
||||
if (!match_cc(buffer->file_name, buffer->buffer_name)){
|
||||
String dir = make_string_cap(buffer->file_name,
|
||||
buffer->file_name_len,
|
||||
buffer->file_name_len+1);
|
||||
remove_last_folder(&dir);
|
||||
append_ss(dir_out, dir);
|
||||
result = BuildDir_AtFile;
|
||||
}
|
||||
}
|
||||
|
||||
if (!result){
|
||||
int32_t 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 = BuildDir_AtHot;
|
||||
}
|
||||
}
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
// TODO(allen): Better names for the "standard build search" family.
|
||||
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){
|
||||
int32_t result = false;
|
||||
|
||||
for(;;){
|
||||
int32_t old_size = dir->size;
|
||||
append_ss(dir, filename);
|
||||
|
||||
if (app->file_exists(app, dir->str, dir->size)){
|
||||
dir->size = old_size;
|
||||
|
||||
if (use_path_in_command){
|
||||
append_s_char(command, '"');
|
||||
append_ss(command, *dir);
|
||||
append_ss(command, commandname);
|
||||
append_s_char(command, '"');
|
||||
}
|
||||
else{
|
||||
append_ss(command, commandname);
|
||||
}
|
||||
|
||||
char space[512];
|
||||
String message = make_fixed_width_string(space);
|
||||
append_ss(&message, make_lit_string("Building with: "));
|
||||
append_ss(&message, *command);
|
||||
append_s_char(&message, '\n');
|
||||
app->print_message(app, message.str, message.size);
|
||||
|
||||
|
||||
app->exec_system_command(app, view,
|
||||
buffer_identifier(literal("*compilation*")),
|
||||
dir->str, dir->size,
|
||||
command->str, command->size,
|
||||
CLI_OverlapWithConflict);
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
dir->size = old_size;
|
||||
|
||||
if (app->directory_cd(app, dir->str, &dir->size, dir->memory_size, literal("..")) == 0){
|
||||
if (perform_backup){
|
||||
dir->size = app->directory_get_hot(app, dir->str, dir->memory_size);
|
||||
char backup_space[256];
|
||||
String backup_command = make_fixed_width_string(backup_space);
|
||||
append_ss(&backup_command, make_lit_string("echo could not find "));
|
||||
append_ss(&backup_command, filename);
|
||||
app->exec_system_command(app, view,
|
||||
buffer_identifier(literal("*compilation*")),
|
||||
dir->str, dir->size,
|
||||
backup_command.str, backup_command.size,
|
||||
CLI_OverlapWithConflict);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
||||
// NOTE(allen): Build search rule for windows.
|
||||
static int32_t
|
||||
execute_standard_build_search(Application_Links *app, View_Summary *view,
|
||||
Buffer_Summary *active_buffer,
|
||||
String *dir, String *command, int32_t perform_backup){
|
||||
int32_t result = standard_build_search(app, view,
|
||||
active_buffer,
|
||||
dir, command, perform_backup, true,
|
||||
make_lit_string("build.bat"),
|
||||
make_lit_string("build"));
|
||||
return(result);
|
||||
}
|
||||
|
||||
#elif defined(__linux__)
|
||||
|
||||
// NOTE(allen): Build search rule for linux.
|
||||
static int32_t
|
||||
execute_standard_build_search(Application_Links *app, View_Summary *view,
|
||||
Buffer_Summary *active_buffer,
|
||||
String *dir, String *command, int32_t perform_backup){
|
||||
|
||||
char dir_space[512];
|
||||
String dir_copy = make_fixed_width_string(dir_space);
|
||||
copy(&dir_copy, *dir);
|
||||
|
||||
int32_t result = standard_build_search(app, view,
|
||||
active_buffer,
|
||||
dir, command, false, true,
|
||||
make_lit_string("build.sh"),
|
||||
make_lit_string("build.sh"));
|
||||
|
||||
if (!result){
|
||||
result = standard_build_search(app, view,
|
||||
active_buffer,
|
||||
&dir_copy, command, perform_backup, false,
|
||||
make_lit_string("Makefile"),
|
||||
make_lit_string("make"));
|
||||
}
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
#else
|
||||
# error No build search rule for this platform.
|
||||
#endif
|
||||
|
||||
|
||||
// NOTE(allen): This searches first using the active file's directory,
|
||||
// then if no build script is found, it searches from 4coders hot directory.
|
||||
static void
|
||||
execute_standard_build(Application_Links *app, View_Summary *view,
|
||||
Buffer_Summary *active_buffer){
|
||||
char dir_space[512];
|
||||
String dir = make_fixed_width_string(dir_space);
|
||||
|
||||
char command_str_space[512];
|
||||
String command = make_fixed_width_string(command_str_space);
|
||||
|
||||
int32_t build_dir_type = get_build_directory(app, active_buffer, &dir);
|
||||
|
||||
if (build_dir_type == BuildDir_AtFile){
|
||||
if (!execute_standard_build_search(app, view, active_buffer,
|
||||
&dir, &command, false)){
|
||||
dir.size = 0;
|
||||
command.size = 0;
|
||||
build_dir_type = get_build_directory(app, 0, &dir);
|
||||
}
|
||||
}
|
||||
|
||||
if (build_dir_type == BuildDir_AtHot){
|
||||
execute_standard_build_search(app, view, active_buffer,
|
||||
&dir, &command, true);
|
||||
}
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(build_search){
|
||||
uint32_t access = AccessAll;
|
||||
View_Summary view = app->get_active_view(app, access);
|
||||
Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
|
||||
execute_standard_build(app, &view, &buffer);
|
||||
prev_location = null_location;
|
||||
lock_jump_buffer(literal("*compilation*"));
|
||||
}
|
||||
|
||||
#define GET_COMP_BUFFER(app) app->get_buffer_by_name(app, literal("*compilation*"), AccessAll)
|
||||
|
||||
static View_Summary
|
||||
get_or_open_build_panel(Application_Links *app){
|
||||
View_Summary view = {0};
|
||||
|
||||
Buffer_Summary buffer = GET_COMP_BUFFER(app);
|
||||
if (buffer.exists){
|
||||
view = get_first_view_with_buffer(app, buffer.buffer_id);
|
||||
}
|
||||
if (!view.exists){
|
||||
view = open_special_note_view(app);
|
||||
}
|
||||
|
||||
return(view);
|
||||
}
|
||||
|
||||
static void
|
||||
set_fancy_compilation_buffer_font(Application_Links *app){
|
||||
Buffer_Summary comp_buffer = app->get_buffer_by_name(app, literal("*compilation*"), AccessAll);
|
||||
app->buffer_set_font(app, &comp_buffer, literal("Inconsolata"));
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(build_in_build_panel){
|
||||
uint32_t access = AccessAll;
|
||||
View_Summary view = app->get_active_view(app, access);
|
||||
Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
|
||||
|
||||
View_Summary build_view = get_or_open_build_panel(app);
|
||||
|
||||
execute_standard_build(app, &build_view, &buffer);
|
||||
set_fancy_compilation_buffer_font(app);
|
||||
|
||||
prev_location = null_location;
|
||||
lock_jump_buffer(literal("*compilation*"));
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(close_build_panel){
|
||||
close_special_note_view(app);
|
||||
}
|
||||
|
||||
CUSTOM_COMMAND_SIG(change_to_build_panel){
|
||||
View_Summary view = open_special_note_view(app, false);
|
||||
|
||||
if (!view.exists){
|
||||
Buffer_Summary buffer = GET_COMP_BUFFER(app);
|
||||
if (buffer.exists){
|
||||
view = open_special_note_view(app);
|
||||
app->view_set_buffer(app, &view, buffer.buffer_id, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (view.exists){
|
||||
app->set_active_view(app, &view);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Other
|
||||
//
|
||||
|
||||
CUSTOM_COMMAND_SIG(execute_arbitrary_command){
|
||||
|
|
|
@ -386,7 +386,7 @@ seek_error(Application_Links *app,
|
|||
&location)){
|
||||
View_Summary active_view = app->get_active_view(app, AccessAll);
|
||||
if (active_view.view_id == view.view_id){
|
||||
exec_command(app, change_active_panel_regular);
|
||||
exec_command(app, change_active_panel);
|
||||
active_view = app->get_active_view(app, AccessAll);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
#define MEMORY_ALLOCATE_SIG(n) void* n(Application_Links *app, int32_t size)
|
||||
#define MEMORY_SET_PROTECTION_SIG(n) bool32 n(Application_Links *app, void *ptr, int32_t size, Memory_Protect_Flags flags)
|
||||
#define MEMORY_FREE_SIG(n) void n(Application_Links *app, void *mem, int32_t size)
|
||||
#define FILE_EXISTS_SIG(n) bool32 n(Application_Links *app, char *filename, int32_t len)
|
||||
#define DIRECTORY_CD_SIG(n) bool32 n(Application_Links *app, char *dir, int32_t *len, int32_t capacity, char *rel_path, int32_t rel_len)
|
||||
#define GET_4ED_PATH_SIG(n) bool32 n(Application_Links *app, char *out, int32_t capacity)
|
||||
#define SHOW_MOUSE_CURSOR_SIG(n) void n(Application_Links *app, Mouse_Cursor_Show_Type show)
|
|
@ -59,7 +59,6 @@ seek_line_char(int32_t line, int32_t character){
|
|||
return(result);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
// BOTTOM
|
5
4ed.cpp
5
4ed.cpp
|
@ -1912,7 +1912,7 @@ App_Step_Sig(app_step){
|
|||
cmd->screen_width = target->width;
|
||||
cmd->screen_height = target->height;
|
||||
|
||||
cmd->key = key_event_data_zero();
|
||||
cmd->key = null_key_event_data;
|
||||
|
||||
Temp_Memory param_stack_temp = begin_temp_memory(&models->mem.part);
|
||||
|
||||
|
@ -2479,7 +2479,8 @@ App_Step_Sig(app_step){
|
|||
"-The commands for going to next error, previous error, etc now work\n"
|
||||
" on any buffer with jump locations including *search*\n"
|
||||
"-4coder now supports proper, borderless, fullscreen with the flag -F\n"
|
||||
" and fullscreen can be toggled with <control pageup>\n"
|
||||
" and fullscreen can be toggled with <control pageup>.\n"
|
||||
" (This sometimes causes artifacts on the Windows task bar)\n"
|
||||
"\n"
|
||||
"New in alpha 4.0.10:\n"
|
||||
"-<control F> list all locations of a string across all open buffers\n"
|
||||
|
|
|
@ -17,7 +17,7 @@ access_test(u32 lock_flags, u32 access_flags){
|
|||
|
||||
internal void
|
||||
fill_buffer_summary(Buffer_Summary *buffer, Editing_File *file, Working_Set *working_set){
|
||||
*buffer = buffer_summary_zero();
|
||||
*buffer = null_buffer_summary;
|
||||
if (!file->is_dummy){
|
||||
buffer->exists = 1;
|
||||
buffer->ready = file_is_ready(file);
|
||||
|
@ -53,7 +53,7 @@ fill_view_summary(View_Summary *view, View *vptr, Live_Views *live_set, Working_
|
|||
Buffer_ID buffer_id = 0;
|
||||
File_Viewing_Data *data = &vptr->file_data;
|
||||
|
||||
*view = view_summary_zero();
|
||||
*view = null_view_summary;
|
||||
|
||||
if (vptr->in_use){
|
||||
view->exists = 1;
|
||||
|
@ -433,7 +433,7 @@ internal_get_buffer_next(Working_Set *working_set, Buffer_Summary *buffer){
|
|||
fill_buffer_summary(buffer, file, working_set);
|
||||
}
|
||||
else{
|
||||
*buffer = buffer_summary_zero();
|
||||
*buffer = null_buffer_summary;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -507,7 +507,7 @@ DOC_SEE(Buffer_ID)
|
|||
if (file){
|
||||
fill_buffer_summary(&buffer, file, working_set);
|
||||
if (!access_test(buffer.lock_flags, access)){
|
||||
buffer = buffer_summary_zero();
|
||||
buffer = null_buffer_summary;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -533,7 +533,7 @@ DOC_SEE(Access_Flag)
|
|||
if (file && !file->is_dummy){
|
||||
fill_buffer_summary(&buffer, file, working_set);
|
||||
if (!access_test(buffer.lock_flags, access)){
|
||||
buffer = buffer_summary_zero();
|
||||
buffer = null_buffer_summary;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1169,11 +1169,11 @@ internal_get_view_next(Command_Data *cmd, View_Summary *view){
|
|||
fill_view_summary(view, panel->view, &cmd->vars->live_set, &cmd->models->working_set);
|
||||
}
|
||||
else{
|
||||
*view = view_summary_zero();
|
||||
*view = null_view_summary;
|
||||
}
|
||||
}
|
||||
else{
|
||||
*view = view_summary_zero();
|
||||
*view = null_view_summary;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1242,7 +1242,7 @@ DOC_SEE(Access_Flag)
|
|||
vptr = live_set->views + view_id;
|
||||
fill_view_summary(&view, vptr, live_set, &cmd->models->working_set);
|
||||
if (!access_test(view.lock_flags, access)){
|
||||
view = view_summary_zero();
|
||||
view = null_view_summary;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1260,7 +1260,7 @@ DOC_SEE(Access_Flag)
|
|||
View_Summary view = {0};
|
||||
fill_view_summary(&view, cmd->view, &cmd->vars->live_set, &cmd->models->working_set);
|
||||
if (!access_test(view.lock_flags, access)){
|
||||
view = view_summary_zero();
|
||||
view = null_view_summary;
|
||||
}
|
||||
return(view);
|
||||
}
|
||||
|
@ -1950,12 +1950,14 @@ DOC(This call sets the display font of a particular buffer.)
|
|||
Models *models = cmd->models;
|
||||
Editing_File *file = imp_get_file(cmd, buffer);
|
||||
|
||||
Font_Set *set = models->font_set;
|
||||
String font_name = make_string(name, len);
|
||||
i16 font_id = 0;
|
||||
if (file){
|
||||
Font_Set *set = models->font_set;
|
||||
String font_name = make_string(name, len);
|
||||
i16 font_id = 0;
|
||||
|
||||
if (font_set_extract(set, font_name, &font_id)){
|
||||
file_set_font(system, models, file, font_id);
|
||||
if (font_set_extract(set, font_name, &font_id)){
|
||||
file_set_font(system, models, file, font_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,12 +13,12 @@
|
|||
#include <assert.h>
|
||||
#include "4ed_defines.h"
|
||||
|
||||
#include "4coder_custom.h"
|
||||
|
||||
#define FSTRING_IMPLEMENTATION
|
||||
#define FSTRING_C
|
||||
#include "4coder_string.h"
|
||||
|
||||
#include "4coder_custom.h"
|
||||
|
||||
#define BUFFER_EXPERIMENT_SCALPEL 0
|
||||
|
||||
#include "4ed_math.h"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Distribution Date: 30.8.2016 (dd.mm.yyyy)
|
||||
Distribution Date: 1.9.2016 (dd.mm.yyyy)
|
||||
|
||||
Thank you for contributing to the 4coder project!
|
||||
|
||||
|
|
17
TODO.txt
17
TODO.txt
|
@ -84,14 +84,18 @@
|
|||
; BEFORE I SHIP
|
||||
;
|
||||
; [X] flag in create buffer to prevent making new files
|
||||
; [X] locking to a view for next position jumping
|
||||
; [X] break down the build system and get away from the preproc hack
|
||||
; [X] full screen option
|
||||
; [] add to APIs
|
||||
; [X] add to APIs
|
||||
; [] try to make win32 version better
|
||||
;
|
||||
; [] tokens in the custom API
|
||||
; [] auto indent on the custom side
|
||||
; [] expose dirty flags
|
||||
; [] option to not open *messages* every startup
|
||||
; [] command for resizing panels
|
||||
; [] commands for resizing panels
|
||||
; [] make panel resizing not whacky with child panels
|
||||
; [] control over how mouse effects panel focus
|
||||
; [] API docs as text file
|
||||
; [] user file bar string
|
||||
|
@ -99,8 +103,6 @@
|
|||
; [] hook on exit
|
||||
; [] exit command
|
||||
; [] read only files
|
||||
; [] break down the build system and get away from the preproc hack
|
||||
; [] locking to a view for next position jumping
|
||||
;
|
||||
|
||||
; TODOS
|
||||
|
@ -135,6 +137,8 @@
|
|||
; [] support full length unicode file names
|
||||
; [] switch based word complete
|
||||
;
|
||||
; [] query buffer font info
|
||||
; [] break buffer name ties by adding parent directories instead of <#>
|
||||
; [] undo groups
|
||||
; [] cursor/scroll grouping
|
||||
; [] file status in custom API
|
||||
|
@ -148,6 +152,11 @@
|
|||
; [] multi-line editing
|
||||
; [] multi-cursor editing
|
||||
;
|
||||
; meta programming system
|
||||
; [] profile and optimize the current metagen system
|
||||
; [] expand the use of 4coder_types.h to also allow static variable and function declarations
|
||||
; [] get more of the helper functions going through the documentation system
|
||||
;
|
||||
; GUI related tech
|
||||
; [X] consolidate all GUI code properly
|
||||
; [X] rewrite GUI
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
// TOP
|
||||
|
||||
#include "../4coder_buffer_types.h"
|
||||
#include "../4coder_seek_types.h"
|
||||
|
||||
#ifndef inline_4tech
|
||||
#define inline_4tech inline
|
||||
|
|
4
build.c
4
build.c
|
@ -264,7 +264,7 @@ buildsuper(char *code_path, char *out_path, char *filename){
|
|||
|
||||
static void
|
||||
standard_build(char *cdir, uint32_t flags){
|
||||
#if 1
|
||||
#if 0
|
||||
{
|
||||
BEGIN_TIME_SECTION();
|
||||
build(OPTS, cdir, "fsm_table_generator.cpp",
|
||||
|
@ -305,7 +305,7 @@ standard_build(char *cdir, uint32_t flags){
|
|||
}
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
#if 0
|
||||
{
|
||||
BEGIN_TIME_SECTION();
|
||||
build(OPTS | INCLUDES | SHARED_CODE | flags, cdir, "4ed_app_target.cpp",
|
||||
|
|
|
@ -15,7 +15,6 @@ Allen Webster
|
|||
#define TEST_FILES "w:/4ed/data/test"
|
||||
|
||||
#include "4coder_default_include.cpp"
|
||||
#include "4coder_default_building.cpp"
|
||||
|
||||
#include <intrin.h>
|
||||
#pragma intrinsic(__rdtsc)
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
// TOP
|
||||
|
||||
#include "4coder_default_include.cpp"
|
||||
#include "4coder_default_building.cpp"
|
||||
|
||||
#define NO_BINDING
|
||||
#include "4coder_default_bindings.cpp"
|
||||
|
|
Loading…
Reference in New Issue