fixed initial file loading name issue; wrapped lexer string.h in include guard

master
Allen Webster 2016-09-09 18:56:43 -04:00
parent ac8ef58e95
commit 3970f1f338
11 changed files with 101 additions and 73 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
#define EXEC_COMMAND_SIG(n) bool32 n(Application_Links *app, Command_ID command_id) #define EXEC_COMMAND_SIG(n) bool32 n(Application_Links *app, Command_ID command_id)
#define EXEC_SYSTEM_COMMAND_SIG(n) bool32 n(Application_Links *app, View_Summary *view, Buffer_Identifier buffer, char *path, int32_t path_len, char *command, int32_t command_len, Command_Line_Input_Flag flags) #define EXEC_SYSTEM_COMMAND_SIG(n) bool32 n(Application_Links *app, View_Summary *view, Buffer_Identifier buffer, char *path, int32_t path_len, char *command, int32_t command_len, Command_Line_Interface_Flag flags)
#define CLIPBOARD_POST_SIG(n) void n(Application_Links *app, int32_t clipboard_id, char *str, int32_t len) #define CLIPBOARD_POST_SIG(n) void n(Application_Links *app, int32_t clipboard_id, char *str, int32_t len)
#define CLIPBOARD_COUNT_SIG(n) int32_t n(Application_Links *app, int32_t clipboard_id) #define CLIPBOARD_COUNT_SIG(n) int32_t n(Application_Links *app, int32_t clipboard_id)
#define CLIPBOARD_INDEX_SIG(n) int32_t n(Application_Links *app, int32_t clipboard_id, int32_t item_index, char *out, int32_t len) #define CLIPBOARD_INDEX_SIG(n) int32_t n(Application_Links *app, int32_t clipboard_id, int32_t item_index, char *out, int32_t len)

View File

@ -364,11 +364,10 @@ buffer_seek_string_forward(Application_Links *app, Buffer_Summary *buffer,
read_str.size = size; read_str.size = size;
char chunk[1024]; char chunk[1024];
int32_t chunk_size = sizeof(chunk);
Stream_Chunk stream = {0}; Stream_Chunk stream = {0};
stream.max_end = end; stream.max_end = end;
if (init_stream_chunk(&stream, app, buffer, pos, chunk, chunk_size)){ if (init_stream_chunk(&stream, app, buffer, pos, chunk, sizeof(chunk))){
int32_t still_looping = 1; int32_t still_looping = 1;
do{ do{
for(; pos < stream.end; ++pos){ for(; pos < stream.end; ++pos){
@ -419,11 +418,10 @@ buffer_seek_string_backward(Application_Links *app, Buffer_Summary *buffer,
read_str.size = size; read_str.size = size;
char chunk[1024]; char chunk[1024];
int32_t chunk_size = sizeof(chunk);
Stream_Chunk stream = {0}; Stream_Chunk stream = {0};
stream.min_start = min; stream.min_start = min;
if (init_stream_chunk(&stream, app, buffer, pos, chunk, chunk_size)){ if (init_stream_chunk(&stream, app, buffer, pos, chunk, sizeof(chunk))){
int32_t still_looping = 1; int32_t still_looping = 1;
do{ do{
for(; pos >= stream.start; --pos){ for(; pos >= stream.start; --pos){

View File

@ -201,7 +201,7 @@ access call. An access call is usually one the returns a summary struct. If a
4coder object has a particular protection flag set and the corresponding bit is 4coder object has a particular protection flag set and the corresponding bit is
not set in the access field, that 4coder object is hidden. On the other hand if not set in the access field, that 4coder object is hidden. On the other hand if
a protection flag is set in the access parameter and the object does not have a protection flag is set in the access parameter and the object does not have
that protection flag, the object is still returned from the access call.) TODO */ that protection flag, the object is still returned from the access call.) */
ENUM(uint32_t, Access_Flag){ ENUM(uint32_t, Access_Flag){
/* DOC(AccessOpen does not include any bits, it indicates that the access should /* DOC(AccessOpen does not include any bits, it indicates that the access should
only return objects that have no protection flags set.) */ only return objects that have no protection flags set.) */
@ -218,6 +218,23 @@ ENUM(uint32_t, Access_Flag){
AccessAll = 0xFF AccessAll = 0xFF
}; };
/* DOC(A Dirty_State value describes whether changes have been made to a buffer
or to an underlying file since the last sync time between the two. Saving a buffer
to it's file or loading the buffer from the file both act as sync points.) */
ENUM(uint32_t, Dirty_State){
/* DOC(DirtyState_UpToDate indicates that there are no unsaved changes and
the underlying system file still agrees with the buffer's state.) */
DirtyState_UpToDate,
/* DOC(DirtyState_UnsavedChanges indicates that there have been changes in the
buffer since the last sync point.) */
DirtyState_UnsavedChanges,
/* DOC(DirtyState_UnsavedChanges indicates that the underlying file has been
edited since the last sync point with the buffer.) */
DirtyState_UnloadedChanges
};
/* DOC(A Seek_Boundary_Flag field specifies a set of "boundary" types used in seeks for the /* DOC(A Seek_Boundary_Flag field specifies a set of "boundary" types used in seeks for the
beginning or end of different types of words.) */ beginning or end of different types of words.) */
ENUM(uint32_t, Seek_Boundary_Flag){ ENUM(uint32_t, Seek_Boundary_Flag){
@ -227,8 +244,8 @@ ENUM(uint32_t, Seek_Boundary_Flag){
BoundaryCamelCase = 0x8 BoundaryCamelCase = 0x8
}; };
/* DOC(A Command_Line_Input_Flag field specifies the behavior of a call to a command line interface.) */ /* DOC(A Command_Line_Interface_Flag field specifies the behavior of a call to a command line interface.) */
ENUM(uint32_t, Command_Line_Input_Flag){ ENUM(uint32_t, Command_Line_Interface_Flag){
/* DOC(If CLI_OverlapWithConflict is set if output buffer of the new command is already /* DOC(If CLI_OverlapWithConflict is set if output buffer of the new command is already
in use by another command which is still executing, the older command relinquishes control in use by another command which is still executing, the older command relinquishes control
of the buffer and both operate simultaneously with only the newer command outputting to of the buffer and both operate simultaneously with only the newer command outputting to
@ -561,7 +578,8 @@ struct Buffer_Edit{
}; };
/* DOC(Buffer_Summary acts as a handle to a buffer and describes the state of the buffer.) /* DOC(Buffer_Summary acts as a handle to a buffer and describes the state of the buffer.)
DOC_SEE(Access_Flag) */ DOC_SEE(Access_Flag)
DOC_SEE(Dirty_State) */
struct Buffer_Summary{ struct Buffer_Summary{
/* DOC( /* DOC(
This field indicates whether the Buffer_Summary describes a buffer that is open in 4coder. This field indicates whether the Buffer_Summary describes a buffer that is open in 4coder.
@ -595,6 +613,9 @@ struct Buffer_Summary{
/* DOC(This field specifies the length of the buffer_name string.) */ /* DOC(This field specifies the length of the buffer_name string.) */
int32_t buffer_name_len; int32_t buffer_name_len;
/* DOC(This field indicates the dirty state of the buffer.) */
Dirty_State dirty;
/* DOC(If this is not a null summary, this field indicates whether the buffer is set to lex tokens.) */ /* DOC(If this is not a null summary, this field indicates whether the buffer is set to lex tokens.) */
bool32 is_lexed; bool32 is_lexed;
/* DOC(If this is not a null summary, this field indicates whether the buffer has up to date tokens available. /* DOC(If this is not a null summary, this field indicates whether the buffer has up to date tokens available.

View File

@ -15,7 +15,9 @@
#define FCPP_INTERNAL FCPP_LINK #define FCPP_INTERNAL FCPP_LINK
#include <stdint.h> #include <stdint.h>
#define FSTRING_IMPLEMENTATION #if !defined(FSTRING_GUARD)
# define FSTRING_IMPLEMENTATION
#endif
#include "4coder_string.h" #include "4coder_string.h"
#include "4cpp_lexer_types.h" #include "4cpp_lexer_types.h"
#include "4cpp_lexer_tables.c" #include "4cpp_lexer_tables.c"

15
4ed.cpp
View File

@ -1989,13 +1989,20 @@ App_Step_Sig(app_step){
models->hooks[hook_start](&models->app_links); models->hooks[hook_start](&models->app_links);
} }
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; i32 i = 0;
Panel *panel = models->layout.used_sentinel.next; Panel *panel = models->layout.used_sentinel.next;
for (; i < models->settings.init_files_count; ++i, panel = panel->next){ for (; i < models->settings.init_files_count; ++i, panel = panel->next){
String filename = make_string_slowly(models->settings.init_files[i]); cl_filename.size = cl_filename_len;
append_sc(&cl_filename, models->settings.init_files[i]);
if (i < models->layout.panel_count){ if (i < models->layout.panel_count){
view_open_file(system, models, panel->view, filename); view_open_file(system, models, panel->view, cl_filename);
view_show_file(panel->view); view_show_file(panel->view);
Assert("Earlier" && panel->view->file_data.file != 0); Assert("Earlier" && panel->view->file_data.file != 0);
#if 0 #if 0
@ -2009,14 +2016,14 @@ App_Step_Sig(app_step){
#endif #endif
} }
else{ else{
view_open_file(system, models, 0, filename); view_open_file(system, models, 0, cl_filename);
} }
} }
if (i < models->layout.panel_count){ if (i < models->layout.panel_count){
view_set_file(panel->view, models->message_buffer, models); view_set_file(panel->view, models->message_buffer, models);
view_show_file(panel->view); view_show_file(panel->view);
++i; ++i;
panel = panel->next; panel = panel->next;
} }

View File

@ -31,6 +31,8 @@ fill_buffer_summary(Buffer_Summary *buffer, Editing_File *file, Working_Set *wor
buffer->file_name = file->name.source_path.str; buffer->file_name = file->name.source_path.str;
buffer->buffer_name = file->name.live_name.str; buffer->buffer_name = file->name.live_name.str;
buffer->dirty = file->state.dirty;
buffer->is_lexed = file->settings.tokens_exist; buffer->is_lexed = file->settings.tokens_exist;
if (file->state.token_array.tokens && if (file->state.token_array.tokens &&
@ -180,9 +182,9 @@ DOC_SEE(Command_ID)
return(result); return(result);
} }
// TODO(allen): This is a bit of a mess and needs to be fixed soon // TODO(allen): This is a bit of a mess and needs to be fixed soon.
API_EXPORT bool32 API_EXPORT bool32
Exec_System_Command(Application_Links *app, View_Summary *view, Buffer_Identifier buffer, char *path, int32_t path_len, char *command, int32_t command_len, Command_Line_Input_Flag flags)/* Exec_System_Command(Application_Links *app, View_Summary *view, Buffer_Identifier buffer, char *path, int32_t path_len, char *command, int32_t command_len, Command_Line_Interface_Flag flags)/*
DOC_PARAM(view, If the view parameter is non-null it specifies a view to display the command's output buffer.) DOC_PARAM(view, If the view parameter is non-null it specifies a view to display the command's output buffer.)
DOC_PARAM(buffer, The buffer the command will output to is specified by the buffer parameter. DOC_PARAM(buffer, The buffer the command will output to is specified by the buffer parameter.
See Buffer_Identifier for information on how this type specifies a buffer.) See Buffer_Identifier for information on how this type specifies a buffer.)

View File

@ -100,12 +100,6 @@ struct Undo_Data{
b32 current_block_normal; b32 current_block_normal;
}; };
enum File_Sync_State{
SYNC_GOOD,
SYNC_BEHIND_OS,
SYNC_UNSAVED
};
struct Text_Effect{ struct Text_Effect{
i32 start, end; i32 start, end;
u32 color; u32 color;
@ -143,7 +137,7 @@ struct Editing_File_State{
Text_Effect paste_effect; Text_Effect paste_effect;
File_Sync_State sync; Dirty_State dirty;
u32 ignore_behind_os; u32 ignore_behind_os;
File_Edit_Positions edit_pos_space[16]; File_Edit_Positions edit_pos_space[16];
@ -671,6 +665,7 @@ touch_file(Working_Set *working_set, Editing_File *file){
struct Hot_Directory{ struct Hot_Directory{
String string; String string;
File_List file_list; File_List file_list;
// TODO(allen): eliminate slash
char slash; char slash;
}; };
@ -765,7 +760,7 @@ inline b32
buffer_needs_save(Editing_File *file){ buffer_needs_save(Editing_File *file){
b32 result = 0; b32 result = 0;
if (!file->settings.unimportant){ if (!file->settings.unimportant){
if (file->state.sync == SYNC_UNSAVED){ if (file->state.dirty == DirtyState_UnsavedChanges){
result = 1; result = 1;
} }
} }
@ -776,8 +771,8 @@ inline b32
buffer_can_save(Editing_File *file){ buffer_can_save(Editing_File *file){
b32 result = 0; b32 result = 0;
if (!file->settings.unimportant){ if (!file->settings.unimportant){
if (file->state.sync == SYNC_UNSAVED || if (file->state.dirty == DirtyState_UnsavedChanges ||
file->state.sync == SYNC_BEHIND_OS){ file->state.dirty == DirtyState_UnloadedChanges){
result = 1; result = 1;
} }
} }
@ -814,26 +809,26 @@ file_set_to_loading(Editing_File *file){
inline void inline void
file_mark_clean(Editing_File *file){ file_mark_clean(Editing_File *file){
if (file->state.sync != SYNC_BEHIND_OS){ if (file->state.dirty != DirtyState_UnloadedChanges){
file->state.sync = SYNC_GOOD; file->state.dirty = DirtyState_UpToDate;
} }
} }
inline void inline void
file_mark_dirty(Editing_File *file){ file_mark_dirty(Editing_File *file){
if (file->state.sync != SYNC_BEHIND_OS){ if (file->state.dirty != DirtyState_UnloadedChanges){
file->state.sync = SYNC_UNSAVED; file->state.dirty = DirtyState_UnsavedChanges;
} }
} }
inline void inline void
file_mark_behind_os(Editing_File *file){ file_mark_behind_os(Editing_File *file){
file->state.sync = SYNC_BEHIND_OS; file->state.dirty = DirtyState_UnloadedChanges;
} }
inline File_Sync_State inline Dirty_State
file_get_sync(Editing_File *file){ file_get_sync(Editing_File *file){
return (file->state.sync); return (file->state.dirty);
} }
internal void internal void

View File

@ -782,7 +782,7 @@ starts_new_line(u8 character){
inline void inline void
file_synchronize_times(System_Functions *system, Editing_File *file){ file_synchronize_times(System_Functions *system, Editing_File *file){
file->state.sync = SYNC_GOOD; file->state.dirty = DirtyState_UpToDate;
} }
internal b32 internal b32
@ -3217,9 +3217,9 @@ get_exhaustive_info(System_Functions *system, Working_Set *working_set, Exhausti
result.message = null_string; result.message = null_string;
if (result.is_loaded){ if (result.is_loaded){
switch (file_get_sync(file)){ switch (file_get_sync(file)){
case SYNC_GOOD: result.message = message_loaded; break; case DirtyState_UpToDate: result.message = message_loaded; break;
case SYNC_BEHIND_OS: result.message = message_unsynced; break; case DirtyState_UnsavedChanges: result.message = message_unsaved; break;
case SYNC_UNSAVED: result.message = message_unsaved; break; case DirtyState_UnloadedChanges: result.message = message_unsynced; break;
} }
} }
@ -4037,8 +4037,8 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
message = null_string; message = null_string;
if (!file->settings.unimportant){ if (!file->settings.unimportant){
switch (file_get_sync(file)){ switch (file_get_sync(file)){
case SYNC_BEHIND_OS: message = message_unsynced; break; case DirtyState_UnloadedChanges: message = message_unsynced; break;
case SYNC_UNSAVED: message = message_unsaved; break; case DirtyState_UnsavedChanges: message = message_unsaved; break;
} }
} }
@ -4058,8 +4058,8 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
message = null_string; message = null_string;
if (!file->settings.unimportant){ if (!file->settings.unimportant){
switch (file_get_sync(file)){ switch (file_get_sync(file)){
case SYNC_BEHIND_OS: message = message_unsynced; break; case DirtyState_UnloadedChanges: message = message_unsynced; break;
case SYNC_UNSAVED: message = message_unsaved; break; case DirtyState_UnsavedChanges: message = message_unsaved; break;
} }
} }
@ -5132,13 +5132,13 @@ draw_file_bar(Render_Target *target, View *view, Editing_File *file, i32_Rect re
if (!file->settings.unimportant){ if (!file->settings.unimportant){
switch (file_get_sync(file)){ switch (file_get_sync(file)){
case SYNC_BEHIND_OS: case DirtyState_UnloadedChanges:
{ {
persist String out_of_sync = make_lit_string(" !"); persist String out_of_sync = make_lit_string(" !");
intbar_draw_string(target, &bar, out_of_sync, pop2_color); intbar_draw_string(target, &bar, out_of_sync, pop2_color);
}break; }break;
case SYNC_UNSAVED: case DirtyState_UnsavedChanges:
{ {
persist String out_of_sync = make_lit_string(" *"); persist String out_of_sync = make_lit_string(" *");
intbar_draw_string(target, &bar, out_of_sync, pop2_color); intbar_draw_string(target, &bar, out_of_sync, pop2_color);

View File

@ -41,7 +41,7 @@
; [X] switch to file "4ed.cpp" with "win32_4ed.cpp" open ; [X] switch to file "4ed.cpp" with "win32_4ed.cpp" open
; [X] inserting new line at top of file ~ scrolling jump when window is unaligned ; [X] inserting new line at top of file ~ scrolling jump when window is unaligned
; [X] saving/killing *compilation* doesn't work ; [X] saving/killing *compilation* doesn't work
; [X] line wrapping also doesn't work ; [X] line wrapping also doesn't work
; [X] save as corruptitates the filename ; [X] save as corruptitates the filename
; [X] crash when leaving maximized mode and view get's weird ; [X] crash when leaving maximized mode and view get's weird
; [X] decrease scroll speed on short windows ; [X] decrease scroll speed on short windows
@ -87,7 +87,6 @@
; BEFORE I SHIP ; BEFORE I SHIP
; ;
; [X] why are command line files not loading any more?
; [X] tokens in the custom API ; [X] tokens in the custom API
; [X] token seeking on custom side ; [X] token seeking on custom side
; [X] auto indent on the custom side ; [X] auto indent on the custom side
@ -95,10 +94,7 @@
; [] inserting lines at end of block comment ; [] inserting lines at end of block comment
; [] clean up and comment the auto indent code to allow for customizations ; [] clean up and comment the auto indent code to allow for customizations
; [] more built in options for auto indenting ; [] more built in options for auto indenting
; [] expose dirty flags
; [] occasionally missing the (!) mark on files on windows ; [] occasionally missing the (!) mark on files on windows
; [] scroll down on compilation buffer durring compilation
;
; ;
; TODOS ; TODOS
@ -143,6 +139,8 @@
; [X] file out of sync ; [X] file out of sync
; [X] mouse down/up distinction ; [X] mouse down/up distinction
; [X] case insensitive interactive switch buffer ; [X] case insensitive interactive switch buffer
; [X] expose dirty flags
; [X] why are command line files not loading any more?
; ;
; [] binary buffers ; [] binary buffers

View File

@ -904,7 +904,7 @@ win32_init_drive_strings(Drive_Strings *dstrings){
// for the ability to handle them very quickly when nothing strange is // for the ability to handle them very quickly when nothing strange is
// going on. // going on.
internal int32_t internal int32_t
win32_canonical_ansi_name(Drive_Strings *dstrings, char *src, i32 len, char *dst, i32 max){ win32_canonical_ascii_name(Drive_Strings *dstrings, char *src, i32 len, char *dst, i32 max){
char *wrt = dst; char *wrt = dst;
char *wrt_stop = dst + max; char *wrt_stop = dst + max;
char *src_stop = src + len; char *src_stop = src + len;
@ -978,7 +978,7 @@ win32_canonical_ansi_name(Drive_Strings *dstrings, char *src, i32 len, char *dst
internal internal
Sys_Get_Canonical_Sig(system_get_canonical){ Sys_Get_Canonical_Sig(system_get_canonical){
i32 result = win32_canonical_ansi_name(&win32vars.dstrings, filename, len, buffer, max); i32 result = win32_canonical_ascii_name(&win32vars.dstrings, filename, len, buffer, max);
return(result); return(result);
} }