4.0.21 pretty much ready to go barring any bug discoveries, (need to add README.txt LICENSE.txt and new features list in messages, and setup new casey customization file)

This commit is contained in:
Allen Webster 2017-06-23 19:07:18 -04:00
parent 3fb6e627a5
commit 6cc2182f42
9 changed files with 130 additions and 90 deletions

View File

@ -790,8 +790,6 @@ STRUCT User_Input{
/* DOC(Hook_IDs name the various hooks into 4coder, these hooks use the Hook_Function signature.)
DOC_SEE(Hook_Function) */
ENUM(int32_t, Hook_ID){
/* DOC(TODO) */
hook_start,
/* DOC(TODO) */
hook_file_out_of_sync,
/* DOC(TODO) */
@ -818,6 +816,8 @@ ENUM(int32_t, Special_Hook_ID){
special_hook_command_caller,
/* DOC(TODO) */
special_hook_input_filter,
/* DOC(TODO) */
special_hook_start,
};
TYPEDEF_FUNC int32_t Command_Caller_Hook_Function(struct Application_Links *app, Generic_Command cmd);
@ -836,6 +836,10 @@ TYPEDEF_FUNC int32_t Scroll_Rule_Function(float target_x, float target_y, float
#define SCROLL_RULE_SIG(name) \
int32_t name(float target_x, float target_y, float *scroll_x, float *scroll_y, int32_t view_id, int32_t is_new_target, float dt)
TYPEDEF_FUNC int32_t Start_Hook_Function(struct Application_Links *app, char **files, int32_t file_count, char **flags, int32_t flag_count);
#define START_HOOK_SIG(name) \
int32_t name(struct Application_Links *app, char **files, int32_t file_count, char **flags, int32_t flag_count)
TYPEDEF_FUNC int32_t Get_Binding_Data_Function(void *data, int32_t size);
#define GET_BINDING_DATA(name) int32_t name(void *data, int32_t size)

View File

@ -1023,23 +1023,74 @@ default_4coder_initialize(Application_Links *app){
}
static void
default_4coder_side_by_side_panels(Application_Links *app){
default_4coder_side_by_side_panels(Application_Links *app, Buffer_Identifier left_buffer, Buffer_Identifier right_buffer){
Buffer_ID left_id = buffer_identifier_to_id(app, left_buffer);
Buffer_ID right_id = buffer_identifier_to_id(app, right_buffer);
// Left Panel
View_Summary view = get_active_view(app, AccessAll);
new_view_settings(app, &view);
view_set_buffer(app, &view, left_id, 0);
// Right Panel
open_panel_vsplit(app);
View_Summary right_view = get_active_view(app, AccessAll);
view_set_buffer(app, &right_view, right_id, 0);
// Restore Active to Left
set_active_view(app, &view);
}
static void
default_4coder_one_panel(Application_Links *app){
View_Summary view = get_active_view(app, AccessAll);
new_view_settings(app, &view);
default_4coder_side_by_side_panels(Application_Links *app, char **command_line_files, int32_t file_count){
Buffer_Identifier left = buffer_identifier(literal("*scratch*"));
Buffer_Identifier right = buffer_identifier(literal("*messages*"));
if (file_count > 0){
char *name = command_line_files[0];
int32_t len = str_size(name);
left = buffer_identifier(name, len);
if (file_count > 1){
char *name = command_line_files[1];
int32_t len = str_size(name);
right = buffer_identifier(name, len);
}
}
default_4coder_side_by_side_panels(app, left, right);
}
static void
default_4coder_full_width_bottom_side_by_side_panels(Application_Links *app){
open_special_note_view(app);
default_4coder_side_by_side_panels(app);
default_4coder_side_by_side_panels(Application_Links *app){
default_4coder_side_by_side_panels(app, 0, 0);
}
static void
default_4coder_one_panel(Application_Links *app, Buffer_Identifier buffer){
Buffer_ID id = buffer_identifier_to_id(app, buffer);
View_Summary view = get_active_view(app, AccessAll);
new_view_settings(app, &view);
view_set_buffer(app, &view, id, 0);
}
static void
default_4coder_one_panel(Application_Links *app, char **command_line_files, int32_t file_count){
Buffer_Identifier buffer = buffer_identifier(literal("*messages*"));
if (file_count > 0){
char *name = command_line_files[0];
int32_t len = str_size(name);
buffer = buffer_identifier(name, len);
}
default_4coder_one_panel(app, buffer);
}
static void
default_4coder_one_panel(Application_Links *app){
default_4coder_one_panel(app, 0, 0);
}
#endif

View File

@ -18,9 +18,9 @@ TYPE: 'internal-for-default-system'
#include "languages/4coder_language_cs.h"
#include "languages/4coder_language_java.h"
HOOK_SIG(default_start){
START_HOOK_SIG(default_start){
default_4coder_initialize(app);
default_4coder_side_by_side_panels(app);
default_4coder_side_by_side_panels(app, files, file_count);
if (automatically_load_project){
load_project(app);
@ -321,10 +321,10 @@ SCROLL_RULE_SIG(smooth_scroll_rule){
static void
set_all_default_hooks(Bind_Helper *context){
set_hook(context, hook_start, default_start);
set_hook(context, hook_exit, default_exit);
set_hook(context, hook_view_size_change, default_view_adjust);
set_start_hook(context, default_start);
set_open_file_hook(context, default_file_settings);
set_new_file_hook(context, default_new_file);
set_save_file_hook(context, default_file_save);

View File

@ -175,6 +175,16 @@ set_new_file_hook(Bind_Helper *helper, Open_File_Hook_Function *func){
write_unit(helper, unit);
}
inline void
set_start_hook(Bind_Helper *helper, Start_Hook_Function *func){
Binding_Unit unit;
unit.type = unit_hook;
unit.hook.hook_id = special_hook_start;
unit.hook.func = (void*) func;
write_unit(helper, unit);
}
inline void
set_open_file_hook(Bind_Helper *helper, Open_File_Hook_Function *func){
Binding_Unit unit;

View File

@ -170,7 +170,7 @@ buffer_identifier(char *str, int32_t len){
}
static Buffer_Identifier
buffer_identifier(int32_t id){
buffer_identifier(Buffer_ID id){
Buffer_Identifier identifier;
identifier.name = 0;
identifier.name_len = 0;
@ -178,6 +178,19 @@ buffer_identifier(int32_t id){
return(identifier);
}
static Buffer_ID
buffer_identifier_to_id(Application_Links *app, Buffer_Identifier identifier){
Buffer_ID id = 0;
if (identifier.id != 0){
id = identifier.id;
}
else{
Buffer_Summary buffer = get_buffer_by_name(app, identifier.name, identifier.name_len, AccessAll);
id = buffer.buffer_id;
}
return(id);
}
static Buffer_Summary
create_buffer(Application_Links *app, char *filename, int32_t filename_len, Buffer_Create_Flag flags){
Buffer_Summary buffer = {0};

90
4ed.cpp
View File

@ -657,7 +657,7 @@ enum Command_Line_Mode{
CLMode_Custom
};
void
internal void
init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings, Command_Line_Parameters clparams){
char *arg = 0;
Command_Line_Mode mode = CLMode_App;
@ -677,8 +677,6 @@ init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings,
char *long_arg_name = arg+2;
if (match_cc(long_arg_name, "custom")){
mode = CLMode_Custom;
settings->custom_arg_start = i+1;
settings->custom_arg_end = i+1;
continue;
}
}
@ -819,7 +817,10 @@ init_command_line_settings(App_Settings *settings, Plat_Settings *plat_settings,
case CLMode_Custom:
{
settings->custom_arg_end = i+1;
settings->custom_flags = clparams.argv + i;
settings->custom_flags_count = clparams.argc - i;
i = clparams.argc;
mode = CLMode_App;
}break;
}
}
@ -1118,6 +1119,11 @@ App_Init_Sig(app_init){
{
models->input_filter = (Input_Filter_Function*)unit->hook.func;
}break;
case special_hook_start:
{
models->hook_start = (Start_Hook_Function*)unit->hook.func;
}break;
}
}
}
@ -1491,51 +1497,15 @@ App_Step_Sig(app_step){
cmd->key = null_key_event_data;
if (input->first_step){
#if 0
{
View *view = 0;
View_Persistent *persistent = 0;
i32 i = 0;
i32 max = 0;
max = vars->live_set.max;
view = vars->live_set.views;
for (i = 1; i <= max; ++i, ++view){
persistent = &view->persistent;
persistent->coroutine =
system->create_coroutine(view_caller);
persistent->coroutine =
app_launch_coroutine(system, &models->app_links, Co_View,
persistent->coroutine, view, 0);
if (!persistent->coroutine){
// TODO(allen): Error message and recover
NotImplemented;
}
}
}
#endif
if (models->hooks[hook_start]){
models->hooks[hook_start](&models->app_links);
}
// Open command line files.
char space[512];
String cl_filename = make_fixed_width_string(space);
copy_ss(&cl_filename, models->hot_directory.string);
i32 cl_filename_len = cl_filename.size;
i32 i = 0;
Panel *panel = models->layout.used_sentinel.next;
for (; i < models->settings.init_files_count; ++i, panel = panel->next){
for (i32 i = 0; i < models->settings.init_files_count; ++i){
cl_filename.size = cl_filename_len;
String filename = {0};
Editing_File_Canon_Name canon_name;
if (get_canon_name(system, &canon_name, make_string_slowly(models->settings.init_files[i]))){
filename = canon_name.name;
@ -1545,35 +1515,21 @@ App_Step_Sig(app_step){
filename = cl_filename;
}
if (i < models->layout.panel_count){
view_open_file(system, models, panel->view, filename);
view_show_file(panel->view);
Assert("Earlier" && panel->view->file_data.file != 0);
#if 0
if (i == 0){
if (panel->view->file_data.file){
// TODO(allen): How to set the cursor of a file on the first frame?
view_compute_cursor_from_line_pos(panel->view, models->settings.initial_line, 1);
view_move_view_to_cursor(panel->view, &panel->view->recent.scroll);
}
}
#endif
}
else{
view_open_file(system, models, 0, filename);
open_file(system, models, filename);
}
if (models->hook_start != 0){
char **files = models->settings.init_files;
i32 files_count = models->settings.init_files_count;
char **flags = models->settings.custom_flags;
i32 flags_count = models->settings.custom_flags_count;
models->hook_start(&models->app_links, files, files_count, flags, flags_count);
}
if (i < models->layout.panel_count){
view_set_file(system, panel->view, models->message_buffer, models);
view_show_file(panel->view);
++i;
panel = panel->next;
}
panel = models->layout.used_sentinel.next;
for (i = 0; i < models->settings.init_files_count; ++i, panel = panel->next){
Panel *panel = models->layout.used_sentinel.next;
for (i32 i = 0; i < models->settings.init_files_count; ++i, panel = panel->next){
Assert(panel->view->file_data.file != 0);
}
}

View File

@ -14,15 +14,15 @@ struct App_Settings{
i32 init_files_count;
i32 init_files_max;
char **custom_flags;
i32 custom_flags_count;
i32 initial_line;
b32 lctrl_lalt_is_altgr;
char *custom_font_file;
char *custom_font_name;
i32 custom_font_size;
i32 custom_arg_start;
i32 custom_arg_end;
};
global_const App_Settings null_app_settings = {0};
@ -65,6 +65,7 @@ struct Models{
Custom_API config_api;
Start_Hook_Function *hook_start;
Open_File_Hook_Function *hook_open_file;
Open_File_Hook_Function *hook_new_file;
Open_File_Hook_Function *hook_save_file;

View File

@ -24,7 +24,7 @@
// TODO(allen): set in compilation line
#define PREFERRED_ALIGNMENT 8
#define USE_DEBUG_MEMORY
//#define USE_DEBUG_MEMORY
#define FSTRING_IMPLEMENTATION
#define FSTRING_C

View File

@ -260,7 +260,7 @@ get_view_size(){
return(sizeof(View) - sizeof(View_Persistent));
}
// TODO(past-allen): Switch over to using an i32 for these.
// TODO(allen): Switch over to using an i32 for these.
inline f32
view_width(View *view){
i32_Rect file_rect = view->file_region;
@ -1788,7 +1788,7 @@ file_measure_wraps(System_Functions *system, Models *models, Editing_File *file,
}
if (!emit_comment_position){
step = wrap_state_consume_token(system, font, &wrap_state, next_line_start-1);
step = wrap_state_consume_token(system, font, &wrap_state, next_line_start);
}
b32 need_to_choose_a_wrap = 0;
@ -3885,8 +3885,8 @@ init_read_only_file(System_Functions *system, Models *models, Editing_File *file
}
}
internal void
view_open_file(System_Functions *system, Models *models, View *view, String filename){
internal Editing_File*
open_file(System_Functions *system, Models *models, String filename){
Working_Set *working_set = &models->working_set;
Editing_File *file = 0;
@ -3896,7 +3896,6 @@ view_open_file(System_Functions *system, Models *models, View *view, String file
file = working_set_canon_contains(working_set, canon_name.name);
if (!file){
Plat_Handle handle;
if (system->load_handle(canon_name.name.str, &handle)){
Mem_Options *mem = &models->mem;
@ -3939,6 +3938,12 @@ view_open_file(System_Functions *system, Models *models, View *view, String file
}
}
return(file);
}
internal void
view_open_file(System_Functions *system, Models *models, View *view, String filename){
Editing_File *file = open_file(system, models, filename);
if (file){
view_set_file(system, view, file, models);
}