new mark setting system setup, not finished testing new write_character
This commit is contained in:
parent
5ceacd914d
commit
706b7dc617
|
@ -13,6 +13,10 @@ struct Application_Links;
|
||||||
#define BUFFER_REPLACE_RANGE_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, char *str, int32_t len)
|
#define BUFFER_REPLACE_RANGE_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, char *str, int32_t len)
|
||||||
#define BUFFER_COMPUTE_CURSOR_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, Buffer_Seek seek, Partial_Cursor *cursor_out)
|
#define BUFFER_COMPUTE_CURSOR_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, Buffer_Seek seek, Partial_Cursor *cursor_out)
|
||||||
#define BUFFER_BATCH_EDIT_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, char *str, int32_t str_len, Buffer_Edit *edits, int32_t edit_count, Buffer_Batch_Edit_Type type)
|
#define BUFFER_BATCH_EDIT_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, char *str, int32_t str_len, Buffer_Edit *edits, int32_t edit_count, Buffer_Batch_Edit_Type type)
|
||||||
|
#define BUFFER_ADD_MARKERS_SIG(n) Marker_Handle n(Application_Links *app, Buffer_Summary *buffer, uint32_t marker_count)
|
||||||
|
#define BUFFER_SET_MARKERS_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, Marker_Handle marker, uint32_t first_marker_index, uint32_t marker_count, Marker *source_markers)
|
||||||
|
#define BUFFER_GET_MARKERS_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, Marker_Handle marker, uint32_t first_marker_index, uint32_t marker_count, Marker *markers_out)
|
||||||
|
#define BUFFER_REMOVE_MARKERS_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, Marker_Handle marker)
|
||||||
#define BUFFER_GET_SETTING_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting, int32_t *value_out)
|
#define BUFFER_GET_SETTING_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting, int32_t *value_out)
|
||||||
#define BUFFER_SET_SETTING_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting, int32_t value)
|
#define BUFFER_SET_SETTING_SIG(n) bool32 n(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting, int32_t value)
|
||||||
#define BUFFER_TOKEN_COUNT_SIG(n) int32_t n(Application_Links *app, Buffer_Summary *buffer)
|
#define BUFFER_TOKEN_COUNT_SIG(n) int32_t n(Application_Links *app, Buffer_Summary *buffer)
|
||||||
|
@ -80,6 +84,10 @@ typedef BUFFER_READ_RANGE_SIG(Buffer_Read_Range_Function);
|
||||||
typedef BUFFER_REPLACE_RANGE_SIG(Buffer_Replace_Range_Function);
|
typedef BUFFER_REPLACE_RANGE_SIG(Buffer_Replace_Range_Function);
|
||||||
typedef BUFFER_COMPUTE_CURSOR_SIG(Buffer_Compute_Cursor_Function);
|
typedef BUFFER_COMPUTE_CURSOR_SIG(Buffer_Compute_Cursor_Function);
|
||||||
typedef BUFFER_BATCH_EDIT_SIG(Buffer_Batch_Edit_Function);
|
typedef BUFFER_BATCH_EDIT_SIG(Buffer_Batch_Edit_Function);
|
||||||
|
typedef BUFFER_ADD_MARKERS_SIG(Buffer_Add_Markers_Function);
|
||||||
|
typedef BUFFER_SET_MARKERS_SIG(Buffer_Set_Markers_Function);
|
||||||
|
typedef BUFFER_GET_MARKERS_SIG(Buffer_Get_Markers_Function);
|
||||||
|
typedef BUFFER_REMOVE_MARKERS_SIG(Buffer_Remove_Markers_Function);
|
||||||
typedef BUFFER_GET_SETTING_SIG(Buffer_Get_Setting_Function);
|
typedef BUFFER_GET_SETTING_SIG(Buffer_Get_Setting_Function);
|
||||||
typedef BUFFER_SET_SETTING_SIG(Buffer_Set_Setting_Function);
|
typedef BUFFER_SET_SETTING_SIG(Buffer_Set_Setting_Function);
|
||||||
typedef BUFFER_TOKEN_COUNT_SIG(Buffer_Token_Count_Function);
|
typedef BUFFER_TOKEN_COUNT_SIG(Buffer_Token_Count_Function);
|
||||||
|
@ -149,6 +157,10 @@ Buffer_Read_Range_Function *buffer_read_range;
|
||||||
Buffer_Replace_Range_Function *buffer_replace_range;
|
Buffer_Replace_Range_Function *buffer_replace_range;
|
||||||
Buffer_Compute_Cursor_Function *buffer_compute_cursor;
|
Buffer_Compute_Cursor_Function *buffer_compute_cursor;
|
||||||
Buffer_Batch_Edit_Function *buffer_batch_edit;
|
Buffer_Batch_Edit_Function *buffer_batch_edit;
|
||||||
|
Buffer_Add_Markers_Function *buffer_add_markers;
|
||||||
|
Buffer_Set_Markers_Function *buffer_set_markers;
|
||||||
|
Buffer_Get_Markers_Function *buffer_get_markers;
|
||||||
|
Buffer_Remove_Markers_Function *buffer_remove_markers;
|
||||||
Buffer_Get_Setting_Function *buffer_get_setting;
|
Buffer_Get_Setting_Function *buffer_get_setting;
|
||||||
Buffer_Set_Setting_Function *buffer_set_setting;
|
Buffer_Set_Setting_Function *buffer_set_setting;
|
||||||
Buffer_Token_Count_Function *buffer_token_count;
|
Buffer_Token_Count_Function *buffer_token_count;
|
||||||
|
@ -217,6 +229,10 @@ Buffer_Read_Range_Function *buffer_read_range_;
|
||||||
Buffer_Replace_Range_Function *buffer_replace_range_;
|
Buffer_Replace_Range_Function *buffer_replace_range_;
|
||||||
Buffer_Compute_Cursor_Function *buffer_compute_cursor_;
|
Buffer_Compute_Cursor_Function *buffer_compute_cursor_;
|
||||||
Buffer_Batch_Edit_Function *buffer_batch_edit_;
|
Buffer_Batch_Edit_Function *buffer_batch_edit_;
|
||||||
|
Buffer_Add_Markers_Function *buffer_add_markers_;
|
||||||
|
Buffer_Set_Markers_Function *buffer_set_markers_;
|
||||||
|
Buffer_Get_Markers_Function *buffer_get_markers_;
|
||||||
|
Buffer_Remove_Markers_Function *buffer_remove_markers_;
|
||||||
Buffer_Get_Setting_Function *buffer_get_setting_;
|
Buffer_Get_Setting_Function *buffer_get_setting_;
|
||||||
Buffer_Set_Setting_Function *buffer_set_setting_;
|
Buffer_Set_Setting_Function *buffer_set_setting_;
|
||||||
Buffer_Token_Count_Function *buffer_token_count_;
|
Buffer_Token_Count_Function *buffer_token_count_;
|
||||||
|
@ -293,6 +309,10 @@ app_links->buffer_read_range_ = Buffer_Read_Range;\
|
||||||
app_links->buffer_replace_range_ = Buffer_Replace_Range;\
|
app_links->buffer_replace_range_ = Buffer_Replace_Range;\
|
||||||
app_links->buffer_compute_cursor_ = Buffer_Compute_Cursor;\
|
app_links->buffer_compute_cursor_ = Buffer_Compute_Cursor;\
|
||||||
app_links->buffer_batch_edit_ = Buffer_Batch_Edit;\
|
app_links->buffer_batch_edit_ = Buffer_Batch_Edit;\
|
||||||
|
app_links->buffer_add_markers_ = Buffer_Add_Markers;\
|
||||||
|
app_links->buffer_set_markers_ = Buffer_Set_Markers;\
|
||||||
|
app_links->buffer_get_markers_ = Buffer_Get_Markers;\
|
||||||
|
app_links->buffer_remove_markers_ = Buffer_Remove_Markers;\
|
||||||
app_links->buffer_get_setting_ = Buffer_Get_Setting;\
|
app_links->buffer_get_setting_ = Buffer_Get_Setting;\
|
||||||
app_links->buffer_set_setting_ = Buffer_Set_Setting;\
|
app_links->buffer_set_setting_ = Buffer_Set_Setting;\
|
||||||
app_links->buffer_token_count_ = Buffer_Token_Count;\
|
app_links->buffer_token_count_ = Buffer_Token_Count;\
|
||||||
|
@ -361,6 +381,10 @@ static inline bool32 buffer_read_range(Application_Links *app, Buffer_Summary *b
|
||||||
static inline bool32 buffer_replace_range(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, char *str, int32_t len){return(app->buffer_replace_range(app, buffer, start, end, str, len));}
|
static inline bool32 buffer_replace_range(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, char *str, int32_t len){return(app->buffer_replace_range(app, buffer, start, end, str, len));}
|
||||||
static inline bool32 buffer_compute_cursor(Application_Links *app, Buffer_Summary *buffer, Buffer_Seek seek, Partial_Cursor *cursor_out){return(app->buffer_compute_cursor(app, buffer, seek, cursor_out));}
|
static inline bool32 buffer_compute_cursor(Application_Links *app, Buffer_Summary *buffer, Buffer_Seek seek, Partial_Cursor *cursor_out){return(app->buffer_compute_cursor(app, buffer, seek, cursor_out));}
|
||||||
static inline bool32 buffer_batch_edit(Application_Links *app, Buffer_Summary *buffer, char *str, int32_t str_len, Buffer_Edit *edits, int32_t edit_count, Buffer_Batch_Edit_Type type){return(app->buffer_batch_edit(app, buffer, str, str_len, edits, edit_count, type));}
|
static inline bool32 buffer_batch_edit(Application_Links *app, Buffer_Summary *buffer, char *str, int32_t str_len, Buffer_Edit *edits, int32_t edit_count, Buffer_Batch_Edit_Type type){return(app->buffer_batch_edit(app, buffer, str, str_len, edits, edit_count, type));}
|
||||||
|
static inline Marker_Handle buffer_add_markers(Application_Links *app, Buffer_Summary *buffer, uint32_t marker_count){return(app->buffer_add_markers(app, buffer, marker_count));}
|
||||||
|
static inline bool32 buffer_set_markers(Application_Links *app, Buffer_Summary *buffer, Marker_Handle marker, uint32_t first_marker_index, uint32_t marker_count, Marker *source_markers){return(app->buffer_set_markers(app, buffer, marker, first_marker_index, marker_count, source_markers));}
|
||||||
|
static inline bool32 buffer_get_markers(Application_Links *app, Buffer_Summary *buffer, Marker_Handle marker, uint32_t first_marker_index, uint32_t marker_count, Marker *markers_out){return(app->buffer_get_markers(app, buffer, marker, first_marker_index, marker_count, markers_out));}
|
||||||
|
static inline bool32 buffer_remove_markers(Application_Links *app, Buffer_Summary *buffer, Marker_Handle marker){return(app->buffer_remove_markers(app, buffer, marker));}
|
||||||
static inline bool32 buffer_get_setting(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting, int32_t *value_out){return(app->buffer_get_setting(app, buffer, setting, value_out));}
|
static inline bool32 buffer_get_setting(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting, int32_t *value_out){return(app->buffer_get_setting(app, buffer, setting, value_out));}
|
||||||
static inline bool32 buffer_set_setting(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting, int32_t value){return(app->buffer_set_setting(app, buffer, setting, value));}
|
static inline bool32 buffer_set_setting(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting, int32_t value){return(app->buffer_set_setting(app, buffer, setting, value));}
|
||||||
static inline int32_t buffer_token_count(Application_Links *app, Buffer_Summary *buffer){return(app->buffer_token_count(app, buffer));}
|
static inline int32_t buffer_token_count(Application_Links *app, Buffer_Summary *buffer){return(app->buffer_token_count(app, buffer));}
|
||||||
|
@ -429,6 +453,10 @@ static inline bool32 buffer_read_range(Application_Links *app, Buffer_Summary *b
|
||||||
static inline bool32 buffer_replace_range(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, char *str, int32_t len){return(app->buffer_replace_range_(app, buffer, start, end, str, len));}
|
static inline bool32 buffer_replace_range(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, char *str, int32_t len){return(app->buffer_replace_range_(app, buffer, start, end, str, len));}
|
||||||
static inline bool32 buffer_compute_cursor(Application_Links *app, Buffer_Summary *buffer, Buffer_Seek seek, Partial_Cursor *cursor_out){return(app->buffer_compute_cursor_(app, buffer, seek, cursor_out));}
|
static inline bool32 buffer_compute_cursor(Application_Links *app, Buffer_Summary *buffer, Buffer_Seek seek, Partial_Cursor *cursor_out){return(app->buffer_compute_cursor_(app, buffer, seek, cursor_out));}
|
||||||
static inline bool32 buffer_batch_edit(Application_Links *app, Buffer_Summary *buffer, char *str, int32_t str_len, Buffer_Edit *edits, int32_t edit_count, Buffer_Batch_Edit_Type type){return(app->buffer_batch_edit_(app, buffer, str, str_len, edits, edit_count, type));}
|
static inline bool32 buffer_batch_edit(Application_Links *app, Buffer_Summary *buffer, char *str, int32_t str_len, Buffer_Edit *edits, int32_t edit_count, Buffer_Batch_Edit_Type type){return(app->buffer_batch_edit_(app, buffer, str, str_len, edits, edit_count, type));}
|
||||||
|
static inline Marker_Handle buffer_add_markers(Application_Links *app, Buffer_Summary *buffer, uint32_t marker_count){return(app->buffer_add_markers_(app, buffer, marker_count));}
|
||||||
|
static inline bool32 buffer_set_markers(Application_Links *app, Buffer_Summary *buffer, Marker_Handle marker, uint32_t first_marker_index, uint32_t marker_count, Marker *source_markers){return(app->buffer_set_markers_(app, buffer, marker, first_marker_index, marker_count, source_markers));}
|
||||||
|
static inline bool32 buffer_get_markers(Application_Links *app, Buffer_Summary *buffer, Marker_Handle marker, uint32_t first_marker_index, uint32_t marker_count, Marker *markers_out){return(app->buffer_get_markers_(app, buffer, marker, first_marker_index, marker_count, markers_out));}
|
||||||
|
static inline bool32 buffer_remove_markers(Application_Links *app, Buffer_Summary *buffer, Marker_Handle marker){return(app->buffer_remove_markers_(app, buffer, marker));}
|
||||||
static inline bool32 buffer_get_setting(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting, int32_t *value_out){return(app->buffer_get_setting_(app, buffer, setting, value_out));}
|
static inline bool32 buffer_get_setting(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting, int32_t *value_out){return(app->buffer_get_setting_(app, buffer, setting, value_out));}
|
||||||
static inline bool32 buffer_set_setting(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting, int32_t value){return(app->buffer_set_setting_(app, buffer, setting, value));}
|
static inline bool32 buffer_set_setting(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting, int32_t value){return(app->buffer_set_setting_(app, buffer, setting, value));}
|
||||||
static inline int32_t buffer_token_count(Application_Links *app, Buffer_Summary *buffer){return(app->buffer_token_count_(app, buffer));}
|
static inline int32_t buffer_token_count(Application_Links *app, Buffer_Summary *buffer){return(app->buffer_token_count_(app, buffer));}
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
|
|
||||||
|
|
||||||
#if !defined(FCODER_TYPES_H)
|
#if !defined(FCODER_TYPES_H)
|
||||||
#define FCODER_TYPES_H
|
#define FCODER_TYPES_H
|
||||||
|
|
||||||
|
@ -609,6 +608,13 @@ STRUCT Buffer_Summary{
|
||||||
|
|
||||||
GLOBAL_VAR Buffer_Summary null_buffer_summary = {0};
|
GLOBAL_VAR Buffer_Summary null_buffer_summary = {0};
|
||||||
|
|
||||||
|
STRUCT Marker{
|
||||||
|
int32_t pos;
|
||||||
|
bool32 lean_right;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef void* Marker_Handle;
|
||||||
|
|
||||||
STRUCT i32_Rect{
|
STRUCT i32_Rect{
|
||||||
int32_t x0;
|
int32_t x0;
|
||||||
int32_t y0;
|
int32_t y0;
|
||||||
|
|
|
@ -34,8 +34,20 @@ CUSTOM_COMMAND_SIG(write_character){
|
||||||
if (length != 0){
|
if (length != 0){
|
||||||
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
|
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
|
||||||
int32_t pos = view.cursor.pos;
|
int32_t pos = view.cursor.pos;
|
||||||
|
|
||||||
|
Marker next_cursor_marker = {0};
|
||||||
|
next_cursor_marker.pos = character_pos_to_pos(app, &view, &buffer, view.cursor.character_pos);
|
||||||
|
next_cursor_marker.lean_right = true;
|
||||||
|
|
||||||
|
Marker_Handle handle = buffer_add_markers(app, &buffer, 1);
|
||||||
|
buffer_set_markers(app, &buffer, handle, 0, 1, &next_cursor_marker);
|
||||||
|
|
||||||
buffer_replace_range(app, &buffer, pos, pos, (char*)character, length);
|
buffer_replace_range(app, &buffer, pos, pos, (char*)character, length);
|
||||||
view_set_cursor(app, &view, seek_character_pos(view.cursor.character_pos + 1), true);
|
|
||||||
|
buffer_get_markers(app, &buffer, handle, 0, 1, &next_cursor_marker);
|
||||||
|
buffer_remove_markers(app, &buffer, handle);
|
||||||
|
|
||||||
|
view_set_cursor(app, &view, seek_pos(next_cursor_marker.pos), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,12 @@
|
||||||
|
|
||||||
#include "4coder_seek_types.h"
|
#include "4coder_seek_types.h"
|
||||||
|
|
||||||
inline void
|
static void
|
||||||
exec_command(Application_Links *app, Custom_Command_Function *func){
|
exec_command(Application_Links *app, Custom_Command_Function *func){
|
||||||
func(app);
|
func(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
static void
|
||||||
exec_command(Application_Links *app, Generic_Command cmd){
|
exec_command(Application_Links *app, Generic_Command cmd){
|
||||||
if (cmd.cmdid < cmdid_count){
|
if (cmd.cmdid < cmdid_count){
|
||||||
exec_command(app, cmd.cmdid);
|
exec_command(app, cmd.cmdid);
|
||||||
|
@ -22,7 +22,7 @@ exec_command(Application_Links *app, Generic_Command cmd){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline View_Summary
|
static View_Summary
|
||||||
get_first_view_with_buffer(Application_Links *app, int32_t buffer_id){
|
get_first_view_with_buffer(Application_Links *app, int32_t buffer_id){
|
||||||
View_Summary result = {};
|
View_Summary result = {};
|
||||||
View_Summary test = {};
|
View_Summary test = {};
|
||||||
|
@ -45,7 +45,7 @@ get_first_view_with_buffer(Application_Links *app, int32_t buffer_id){
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int32_t
|
static int32_t
|
||||||
key_is_unmodified(Key_Event_Data *key){
|
key_is_unmodified(Key_Event_Data *key){
|
||||||
char *mods = key->modifiers;
|
char *mods = key->modifiers;
|
||||||
int32_t unmodified = !mods[MDFR_CONTROL_INDEX] && !mods[MDFR_ALT_INDEX];
|
int32_t unmodified = !mods[MDFR_CONTROL_INDEX] && !mods[MDFR_ALT_INDEX];
|
||||||
|
@ -135,19 +135,19 @@ query_user_general(Application_Links *app, Query_Bar *bar, bool32 force_number){
|
||||||
return(success);
|
return(success);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int32_t
|
static int32_t
|
||||||
query_user_string(Application_Links *app, Query_Bar *bar){
|
query_user_string(Application_Links *app, Query_Bar *bar){
|
||||||
int32_t success = query_user_general(app, bar, false);
|
int32_t success = query_user_general(app, bar, false);
|
||||||
return(success);
|
return(success);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int32_t
|
static int32_t
|
||||||
query_user_number(Application_Links *app, Query_Bar *bar){
|
query_user_number(Application_Links *app, Query_Bar *bar){
|
||||||
int32_t success = query_user_general(app, bar, true);
|
int32_t success = query_user_general(app, bar, true);
|
||||||
return(success);
|
return(success);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline char
|
static char
|
||||||
buffer_get_char(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
|
buffer_get_char(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
|
||||||
char result = ' ';
|
char result = ' ';
|
||||||
*buffer = get_buffer(app, buffer->buffer_id, AccessAll);
|
*buffer = get_buffer(app, buffer->buffer_id, AccessAll);
|
||||||
|
@ -157,7 +157,7 @@ buffer_get_char(Application_Links *app, Buffer_Summary *buffer, int32_t pos){
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Buffer_Identifier
|
static Buffer_Identifier
|
||||||
buffer_identifier(char *str, int32_t len){
|
buffer_identifier(char *str, int32_t len){
|
||||||
Buffer_Identifier identifier;
|
Buffer_Identifier identifier;
|
||||||
identifier.name = str;
|
identifier.name = str;
|
||||||
|
@ -166,7 +166,7 @@ buffer_identifier(char *str, int32_t len){
|
||||||
return(identifier);
|
return(identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Buffer_Identifier
|
static Buffer_Identifier
|
||||||
buffer_identifier(int32_t id){
|
buffer_identifier(int32_t id){
|
||||||
Buffer_Identifier identifier;
|
Buffer_Identifier identifier;
|
||||||
identifier.name = 0;
|
identifier.name = 0;
|
||||||
|
@ -187,7 +187,7 @@ create_buffer(Application_Links *app, char *filename, int32_t filename_len, Buff
|
||||||
return(buffer);
|
return(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Range
|
static Range
|
||||||
make_range(int32_t p1, int32_t p2){
|
make_range(int32_t p1, int32_t p2){
|
||||||
Range range;
|
Range range;
|
||||||
if (p1 < p2){
|
if (p1 < p2){
|
||||||
|
@ -211,6 +211,17 @@ adjust_all_buffer_wrap_widths(Application_Links *app, int32_t wrap_width, int32_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(allen): Setup buffer seeking to do character_pos and get View_Summary out of this parameter list.
|
||||||
|
static int32_t
|
||||||
|
character_pos_to_pos(Application_Links *app, View_Summary *view, Buffer_Summary *buffer, int32_t character_pos){
|
||||||
|
int32_t result = 0;
|
||||||
|
Full_Cursor cursor = {0};
|
||||||
|
if (view_compute_cursor(app, view, seek_character_pos(character_pos), &cursor)){
|
||||||
|
result = cursor.pos;
|
||||||
|
}
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
struct Buffer_Rect{
|
struct Buffer_Rect{
|
||||||
int32_t char0, line0;
|
int32_t char0, line0;
|
||||||
int32_t char1, line1;
|
int32_t char1, line1;
|
||||||
|
@ -220,7 +231,7 @@ struct Buffer_Rect{
|
||||||
#define Swap(T,a,b) do{ T t = a; a = b; b = t; } while(0)
|
#define Swap(T,a,b) do{ T t = a; a = b; b = t; } while(0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inline Buffer_Rect
|
static Buffer_Rect
|
||||||
get_rect(View_Summary *view){
|
get_rect(View_Summary *view){
|
||||||
Buffer_Rect rect = {0};
|
Buffer_Rect rect = {0};
|
||||||
|
|
||||||
|
@ -240,7 +251,7 @@ get_rect(View_Summary *view){
|
||||||
return(rect);
|
return(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline i32_Rect
|
static i32_Rect
|
||||||
get_line_x_rect(View_Summary *view){
|
get_line_x_rect(View_Summary *view){
|
||||||
i32_Rect rect = {0};
|
i32_Rect rect = {0};
|
||||||
|
|
||||||
|
@ -371,7 +382,7 @@ refresh_view(Application_Links *app, View_Summary *view){
|
||||||
*view = get_view(app, view->view_id, AccessAll);
|
*view = get_view(app, view->view_id, AccessAll);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline float
|
static float
|
||||||
get_view_y(View_Summary *view){
|
get_view_y(View_Summary *view){
|
||||||
float y = view->cursor.wrapped_y;
|
float y = view->cursor.wrapped_y;
|
||||||
if (view->unwrapped_lines){
|
if (view->unwrapped_lines){
|
||||||
|
@ -380,7 +391,7 @@ get_view_y(View_Summary *view){
|
||||||
return(y);
|
return(y);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline float
|
static float
|
||||||
get_view_x(View_Summary *view){
|
get_view_x(View_Summary *view){
|
||||||
float x = view->cursor.wrapped_x;
|
float x = view->cursor.wrapped_x;
|
||||||
if (view->unwrapped_lines){
|
if (view->unwrapped_lines){
|
||||||
|
@ -389,7 +400,7 @@ get_view_x(View_Summary *view){
|
||||||
return(x);
|
return(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Range
|
static Range
|
||||||
get_range(View_Summary *view){
|
get_range(View_Summary *view){
|
||||||
Range range = make_range(view->cursor.pos, view->mark.pos);
|
Range range = make_range(view->cursor.pos, view->mark.pos);
|
||||||
return(range);
|
return(range);
|
||||||
|
|
|
@ -702,6 +702,66 @@ DOC_SEE(Buffer_Batch_Edit_Type)
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
API_EXPORT Marker_Handle
|
||||||
|
Buffer_Add_Markers(Application_Links *app, Buffer_Summary *buffer, uint32_t marker_count){
|
||||||
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||||
|
Models *models = cmd->models;
|
||||||
|
Editing_File *file = imp_get_file(cmd, buffer);
|
||||||
|
|
||||||
|
Marker_Handle result = 0;
|
||||||
|
if (file != 0){
|
||||||
|
result = allocate_markers_state(&models->mem.general, file, marker_count);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
API_EXPORT bool32
|
||||||
|
Buffer_Set_Markers(Application_Links *app, Buffer_Summary *buffer, Marker_Handle marker, uint32_t first_marker_index, uint32_t marker_count, Marker *source_markers){
|
||||||
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||||
|
Editing_File *file = imp_get_file(cmd, buffer);
|
||||||
|
|
||||||
|
bool32 result = false;
|
||||||
|
if (file != 0){
|
||||||
|
if (markers_set(file, marker, first_marker_index, marker_count, source_markers)){
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
API_EXPORT bool32
|
||||||
|
Buffer_Get_Markers(Application_Links *app, Buffer_Summary *buffer, Marker_Handle marker, uint32_t first_marker_index, uint32_t marker_count, Marker *markers_out){
|
||||||
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||||
|
Editing_File *file = imp_get_file(cmd, buffer);
|
||||||
|
|
||||||
|
bool32 result = false;
|
||||||
|
if (file != 0){
|
||||||
|
if (markers_get(file, marker, first_marker_index, marker_count, markers_out)){
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
API_EXPORT bool32
|
||||||
|
Buffer_Remove_Markers(Application_Links *app, Buffer_Summary *buffer, Marker_Handle marker){
|
||||||
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||||
|
Models *models = cmd->models;
|
||||||
|
Editing_File *file = imp_get_file(cmd, buffer);
|
||||||
|
|
||||||
|
bool32 result = false;
|
||||||
|
if (file != 0){
|
||||||
|
if (markers_free(&models->mem.general, file, marker)){
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
API_EXPORT bool32
|
API_EXPORT bool32
|
||||||
Buffer_Get_Setting(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting, int32_t *value_out)
|
Buffer_Get_Setting(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting, int32_t *value_out)
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
#define dll_init_sentinel(s) do{ (s)->next=(s); (s)->prev=(s); }while(0)
|
#define dll_init_sentinel(s) do{ (s)->next=(s); (s)->prev=(s); }while(0)
|
||||||
#define dll_insert(p,v) do{ (v)->next=(p)->next; (v)->prev=(p); (p)->next=(v); (v)->next->prev=(v); }while(0)
|
#define dll_insert(p,v) do{ (v)->next=(p)->next; (v)->prev=(p); (p)->next=(v); (v)->next->prev=(v); }while(0)
|
||||||
|
#define dll_back_insert(p,v) do{ (v)->prev=(p)->prev; (v)->next=(p); (p)->prev=(v); (v)->prev->next=(v); }while(0)
|
||||||
#define dll_remove(v) do{ (v)->next->prev = (v)->prev; (v)->prev->next = (v)->next; }while(0)
|
#define dll_remove(v) do{ (v)->next->prev = (v)->prev; (v)->prev->next = (v)->next; }while(0)
|
||||||
|
|
||||||
// for(dll_items(iterator, sentinel_ptr)){...}
|
// for(dll_items(iterator, sentinel_ptr)){...}
|
||||||
|
|
|
@ -3096,17 +3096,19 @@ struct Cursor_Fix_Descriptor{
|
||||||
};
|
};
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
file_edit_cursor_fix(System_Functions *system, Models *models,
|
file_edit_cursor_fix(System_Functions *system, Models *models, Editing_File *file, Editing_Layout *layout, Cursor_Fix_Descriptor desc){
|
||||||
Editing_File *file, Editing_Layout *layout,
|
|
||||||
Cursor_Fix_Descriptor desc){
|
|
||||||
|
|
||||||
Partition *part = &models->mem.part;
|
Partition *part = &models->mem.part;
|
||||||
|
|
||||||
Temp_Memory cursor_temp = begin_temp_memory(part);
|
Temp_Memory cursor_temp = begin_temp_memory(part);
|
||||||
i32 cursor_max = layout->panel_max_count * 2;
|
i32 cursor_max = layout->panel_max_count * 3;
|
||||||
|
cursor_max += file->markers.marker_count;
|
||||||
Cursor_With_Index *cursors = push_array(part, Cursor_With_Index, cursor_max);
|
Cursor_With_Index *cursors = push_array(part, Cursor_With_Index, cursor_max);
|
||||||
|
Cursor_With_Index *r_cursors = push_array(part, Cursor_With_Index, cursor_max);
|
||||||
|
Assert(cursors != 0);
|
||||||
|
|
||||||
i32 cursor_count = 0;
|
i32 cursor_count = 0;
|
||||||
|
i32 r_cursor_count = 0;
|
||||||
|
|
||||||
View *view = 0;
|
View *view = 0;
|
||||||
Panel *panel = 0, *used_panels = &layout->used_sentinel;
|
Panel *panel = 0, *used_panels = &layout->used_sentinel;
|
||||||
|
@ -3120,20 +3122,37 @@ file_edit_cursor_fix(System_Functions *system, Models *models,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Marker_Array *marker_it = 0;
|
||||||
|
Marker_Array *marker_sent = &file->markers.sentinel;
|
||||||
|
for (dll_items(marker_it, marker_sent)){
|
||||||
|
u32 count = marker_it->count;
|
||||||
|
Marker *markers = &marker_it->marker_0;
|
||||||
|
for (u32 i = 0; i < count; ++i){
|
||||||
|
if (markers[i].lean_right){
|
||||||
|
write_cursor_with_index(r_cursors, &r_cursor_count, markers[i].pos);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
write_cursor_with_index(cursors, &cursor_count, markers[i].pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO(NAME): dump all the markers in the file and then read them back out.
|
||||||
|
// Make a plan for "right leaning" markers.
|
||||||
if (cursor_count > 0){
|
if (cursor_count > 0){
|
||||||
buffer_sort_cursors(cursors, cursor_count);
|
buffer_sort_cursors(cursors, cursor_count);
|
||||||
if (desc.is_batch){
|
if (desc.is_batch){
|
||||||
buffer_batch_edit_update_cursors(cursors, cursor_count,
|
buffer_batch_edit_update_cursors(cursors, cursor_count, desc.batch, desc.batch_size, false);
|
||||||
desc.batch, desc.batch_size);
|
buffer_batch_edit_update_cursors(r_cursors, r_cursor_count, desc.batch, desc.batch_size, true);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
buffer_update_cursors(cursors, cursor_count,
|
buffer_update_cursors(cursors, cursor_count, desc.start, desc.end, desc.shift_amount + (desc.end - desc.start), false);
|
||||||
desc.start, desc.end,
|
buffer_update_cursors(r_cursors, r_cursor_count, desc.start, desc.end, desc.shift_amount + (desc.end - desc.start), true);
|
||||||
desc.shift_amount + (desc.end - desc.start));
|
|
||||||
}
|
}
|
||||||
buffer_unsort_cursors(cursors, cursor_count);
|
buffer_unsort_cursors(cursors, cursor_count);
|
||||||
|
|
||||||
cursor_count = 0;
|
cursor_count = 0;
|
||||||
|
r_cursor_count = 0;
|
||||||
for (dll_items(panel, used_panels)){
|
for (dll_items(panel, used_panels)){
|
||||||
view = panel->view;
|
view = panel->view;
|
||||||
if (view->file_data.file == file){
|
if (view->file_data.file == file){
|
||||||
|
@ -3167,6 +3186,19 @@ file_edit_cursor_fix(System_Functions *system, Models *models,
|
||||||
scroll);
|
scroll);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (dll_items(marker_it, marker_sent)){
|
||||||
|
u32 count = marker_it->count;
|
||||||
|
Marker *markers = &marker_it->marker_0;
|
||||||
|
for (u32 i = 0; i < count; ++i){
|
||||||
|
if (markers[i].lean_right){
|
||||||
|
markers[i].pos = r_cursors[r_cursor_count++].pos;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
markers[i].pos = cursors[cursor_count++].pos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
end_temp_memory(cursor_temp);
|
end_temp_memory(cursor_temp);
|
||||||
|
@ -3245,11 +3277,10 @@ file_do_single_edit(System_Functions *system, Models *models, Editing_File *file
|
||||||
file_measure_wraps(models, file, (f32)font->height, font->codepoint_advance_data, font->byte_advance);
|
file_measure_wraps(models, file, (f32)font->height, font->codepoint_advance_data, font->byte_advance);
|
||||||
|
|
||||||
// NOTE(allen): cursor fixing
|
// NOTE(allen): cursor fixing
|
||||||
Cursor_Fix_Descriptor desc = {};
|
Cursor_Fix_Descriptor desc = {0};
|
||||||
desc.start = start;
|
desc.start = start;
|
||||||
desc.end = end;
|
desc.end = end;
|
||||||
desc.shift_amount = shift_amount;
|
desc.shift_amount = shift_amount;
|
||||||
|
|
||||||
file_edit_cursor_fix(system, models, file, layout, desc);
|
file_edit_cursor_fix(system, models, file, layout, desc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3368,8 +3399,7 @@ file_do_batch_edit(System_Functions *system, Models *models, Editing_File *file,
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
file_replace_range(System_Functions *system, Models *models, Editing_File *file,
|
file_replace_range(System_Functions *system, Models *models, Editing_File *file, i32 start, i32 end, char *str, i32 len){
|
||||||
i32 start, i32 end, char *str, i32 len){
|
|
||||||
Edit_Spec spec = {};
|
Edit_Spec spec = {};
|
||||||
spec.step.type = ED_NORMAL;
|
spec.step.type = ED_NORMAL;
|
||||||
spec.step.edit.start = start;
|
spec.step.edit.start = start;
|
||||||
|
@ -3413,9 +3443,7 @@ main_style(Models *models){
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
apply_history_edit(System_Functions *system, Models *models,
|
apply_history_edit(System_Functions *system, Models *models, Editing_File *file, View *view, Edit_Stack *stack, Edit_Step step, History_Mode history_mode){
|
||||||
Editing_File *file, View *view,
|
|
||||||
Edit_Stack *stack, Edit_Step step, History_Mode history_mode){
|
|
||||||
Edit_Spec spec = {};
|
Edit_Spec spec = {};
|
||||||
spec.step = step;
|
spec.step = step;
|
||||||
|
|
||||||
|
@ -3929,13 +3957,13 @@ internal void
|
||||||
kill_file(System_Functions *system, Models *models, Editing_File *file){
|
kill_file(System_Functions *system, Models *models, Editing_File *file){
|
||||||
Working_Set *working_set = &models->working_set;
|
Working_Set *working_set = &models->working_set;
|
||||||
|
|
||||||
if (file && !file->settings.never_kill){
|
if (file != 0 && !file->settings.never_kill){
|
||||||
buffer_unbind_name(working_set, file);
|
buffer_unbind_name(working_set, file);
|
||||||
if (file->canon.name.size != 0){
|
if (file->canon.name.size != 0){
|
||||||
buffer_unbind_file(system, working_set, file);
|
buffer_unbind_file(system, working_set, file);
|
||||||
}
|
}
|
||||||
file_close(system, &models->mem.general, file);
|
file_close(system, &models->mem.general, file);
|
||||||
working_set_free_file(working_set, file);
|
working_set_free_file(&models->mem.general, working_set, file);
|
||||||
|
|
||||||
File_Node *used = &models->working_set.used_sentinel;
|
File_Node *used = &models->working_set.used_sentinel;
|
||||||
File_Node *node = used->next;
|
File_Node *node = used->next;
|
||||||
|
@ -3958,9 +3986,7 @@ kill_file(System_Functions *system, Models *models, Editing_File *file){
|
||||||
internal void
|
internal void
|
||||||
kill_file_by_name(System_Functions *system, Models *models, String name){
|
kill_file_by_name(System_Functions *system, Models *models, String name){
|
||||||
Editing_File *file = working_set_name_contains(&models->working_set, name);
|
Editing_File *file = working_set_name_contains(&models->working_set, name);
|
||||||
if (file){
|
kill_file(system, models, file);
|
||||||
kill_file(system, models, file);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
|
|
BIN
4ed_site.ctm
BIN
4ed_site.ctm
Binary file not shown.
|
@ -77,12 +77,26 @@ buffer_unsort_cursors(Cursor_With_Index *positions, i32 count){
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
buffer_update_cursors(Cursor_With_Index *sorted_positions, i32 count, i32 start, i32 end, i32 len){
|
buffer_update_cursors(Cursor_With_Index *sorted_positions, i32 count, i32 start, i32 end, i32 len, b32 lean_right){
|
||||||
i32 shift_amount = (len - (end - start));
|
i32 shift_amount = (len - (end - start));
|
||||||
Cursor_With_Index *position = sorted_positions + count - 1;
|
Cursor_With_Index *position = sorted_positions + count - 1;
|
||||||
|
|
||||||
for (; position >= sorted_positions && position->pos > end; --position) position->pos += shift_amount;
|
if (lean_right){
|
||||||
for (; position >= sorted_positions && position->pos >= start; --position) position->pos = start;
|
for (; position >= sorted_positions && position->pos > end; --position){
|
||||||
|
position->pos += shift_amount;
|
||||||
|
}
|
||||||
|
for (; position >= sorted_positions && position->pos >= start; --position){
|
||||||
|
position->pos = start + len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
for (; position >= sorted_positions && position->pos > end; --position){
|
||||||
|
position->pos += shift_amount;
|
||||||
|
}
|
||||||
|
for (; position >= sorted_positions && position->pos >= start; --position){
|
||||||
|
position->pos = start;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal i32
|
internal i32
|
||||||
|
@ -109,34 +123,55 @@ buffer_batch_edit_max_shift(Buffer_Edit *sorted_edits, i32 edit_count){
|
||||||
Buffer_Edit *edit = sorted_edits;
|
Buffer_Edit *edit = sorted_edits;
|
||||||
for (i = 0; i < edit_count; ++i, ++edit){
|
for (i = 0; i < edit_count; ++i, ++edit){
|
||||||
shift_total += (edit->len - (edit->end - edit->start));
|
shift_total += (edit->len - (edit->end - edit->start));
|
||||||
if (shift_total > shift_max) shift_max = shift_total;
|
if (shift_total > shift_max){
|
||||||
|
shift_max = shift_total;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return(shift_max);
|
return(shift_max);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal i32
|
internal i32
|
||||||
buffer_batch_edit_update_cursors(Cursor_With_Index *sorted_positions, i32 count, Buffer_Edit *sorted_edits, i32 edit_count){
|
buffer_batch_edit_update_cursors(Cursor_With_Index *sorted_positions, i32 count, Buffer_Edit *sorted_edits, i32 edit_count, b32 lean_right){
|
||||||
Cursor_With_Index *position = sorted_positions;
|
Cursor_With_Index *position = sorted_positions;
|
||||||
Cursor_With_Index *end_position = sorted_positions + count;
|
Cursor_With_Index *end_position = sorted_positions + count;
|
||||||
Buffer_Edit *edit = sorted_edits;
|
Buffer_Edit *edit = sorted_edits;
|
||||||
Buffer_Edit *end_edit = sorted_edits + edit_count;
|
Buffer_Edit *end_edit = sorted_edits + edit_count;
|
||||||
i32 shift_amount = 0;
|
i32 shift_amount = 0;
|
||||||
i32 start = 0, end = 0;
|
|
||||||
|
|
||||||
for (; edit < end_edit && position < end_position; ++edit){
|
if (lean_right){
|
||||||
start = edit->start;
|
for (; edit < end_edit && position < end_position; ++edit){
|
||||||
end = edit->end;
|
i32 start = edit->start;
|
||||||
|
i32 end = edit->end;
|
||||||
|
|
||||||
for (; position->pos < start && position < end_position; ++position){
|
for (; position->pos < start && position < end_position; ++position){
|
||||||
position->pos += shift_amount;
|
position->pos += shift_amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
i32 new_end = start + edit->len + shift_amount;
|
||||||
|
for (; position->pos <= end && position < end_position; ++position){
|
||||||
|
position->pos = new_end;
|
||||||
|
}
|
||||||
|
|
||||||
|
shift_amount += (edit->len - (end - start));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
for (; edit < end_edit && position < end_position; ++edit){
|
||||||
|
i32 start = edit->start;
|
||||||
|
i32 end = edit->end;
|
||||||
|
|
||||||
for (; position->pos <= end && position < end_position; ++position){
|
for (; position->pos < start && position < end_position; ++position){
|
||||||
position->pos = start + shift_amount;
|
position->pos += shift_amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
i32 new_end = start + shift_amount;
|
||||||
|
for (; position->pos <= end && position < end_position; ++position){
|
||||||
|
position->pos = new_end;
|
||||||
|
}
|
||||||
|
|
||||||
|
shift_amount += (edit->len - (end - start));
|
||||||
}
|
}
|
||||||
|
|
||||||
shift_amount += (edit->len - (end - start));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (; position < end_position; ++position){
|
for (; position < end_position; ++position){
|
||||||
|
|
|
@ -48,6 +48,7 @@ edit_pos_set_scroll(File_Edit_Positions *edit_pos, GUI_Scroll_Vars scroll){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// TODO(NAME): Replace this with markers over time.
|
||||||
//
|
//
|
||||||
// Highlighting Information
|
// Highlighting Information
|
||||||
//
|
//
|
||||||
|
@ -58,11 +59,35 @@ struct Text_Effect{
|
||||||
f32 seconds_down, seconds_max;
|
f32 seconds_down, seconds_max;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Editing_File
|
// Editing_File
|
||||||
//
|
//
|
||||||
|
|
||||||
|
union Buffer_Slot_ID{
|
||||||
|
i32 id;
|
||||||
|
i16 part[2];
|
||||||
|
};
|
||||||
|
inline Buffer_Slot_ID
|
||||||
|
to_file_id(i32 id){
|
||||||
|
Buffer_Slot_ID result;
|
||||||
|
result.id = id;
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Marker_Array{
|
||||||
|
Marker_Array *next, *prev;
|
||||||
|
Buffer_Slot_ID buffer_id;
|
||||||
|
u32 count, sim_max, max;
|
||||||
|
Marker marker_0;
|
||||||
|
};
|
||||||
|
global_const u32 sizeof_marker_array = sizeof(Marker_Array) - sizeof(Marker);
|
||||||
|
|
||||||
|
struct Editing_File_Markers{
|
||||||
|
Marker_Array sentinel;
|
||||||
|
u32 array_count;
|
||||||
|
u32 marker_count;
|
||||||
|
};
|
||||||
|
|
||||||
struct Editing_File_Settings{
|
struct Editing_File_Settings{
|
||||||
i32 base_map_id;
|
i32 base_map_id;
|
||||||
i32 display_width;
|
i32 display_width;
|
||||||
|
@ -78,7 +103,7 @@ struct Editing_File_Settings{
|
||||||
b8 read_only;
|
b8 read_only;
|
||||||
b8 never_kill;
|
b8 never_kill;
|
||||||
};
|
};
|
||||||
static Editing_File_Settings null_editing_file_settings = {0};
|
global_const Editing_File_Settings null_editing_file_settings = {0};
|
||||||
|
|
||||||
struct Editing_File_State{
|
struct Editing_File_State{
|
||||||
Gap_Buffer buffer;
|
Gap_Buffer buffer;
|
||||||
|
@ -115,7 +140,7 @@ struct Editing_File_State{
|
||||||
File_Edit_Positions *edit_poss[16];
|
File_Edit_Positions *edit_poss[16];
|
||||||
i32 edit_poss_count;
|
i32 edit_poss_count;
|
||||||
};
|
};
|
||||||
static Editing_File_State null_editing_file_state = {0};
|
global_const Editing_File_State null_editing_file_state = {0};
|
||||||
|
|
||||||
struct Editing_File_Name{
|
struct Editing_File_Name{
|
||||||
char live_name_[256];
|
char live_name_[256];
|
||||||
|
@ -135,35 +160,122 @@ struct File_Node{
|
||||||
File_Node *next, *prev;
|
File_Node *next, *prev;
|
||||||
};
|
};
|
||||||
|
|
||||||
union Buffer_Slot_ID{
|
|
||||||
i32 id;
|
|
||||||
i16 part[2];
|
|
||||||
};
|
|
||||||
|
|
||||||
inline Buffer_Slot_ID
|
|
||||||
to_file_id(i32 id){
|
|
||||||
Buffer_Slot_ID result;
|
|
||||||
result.id = id;
|
|
||||||
return(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Editing_File{
|
struct Editing_File{
|
||||||
// NOTE(allen): node must be the first member of Editing_File!
|
// NOTE(allen): node must be the first member of Editing_File!
|
||||||
File_Node node;
|
File_Node node;
|
||||||
Editing_File_Settings settings;
|
Editing_File_Settings settings;
|
||||||
struct{
|
b32 is_loading;
|
||||||
b32 is_loading;
|
b32 is_dummy;
|
||||||
b32 is_dummy;
|
Editing_File_State state;
|
||||||
Editing_File_State state;
|
Editing_File_Markers markers;
|
||||||
};
|
|
||||||
Editing_File_Name name;
|
Editing_File_Name name;
|
||||||
Editing_File_Canon_Name canon;
|
Editing_File_Canon_Name canon;
|
||||||
Buffer_Slot_ID id;
|
Buffer_Slot_ID id;
|
||||||
u64 unique_buffer_id;
|
//u64 unique_buffer_id;
|
||||||
};
|
};
|
||||||
static Editing_File null_editing_file = {0};
|
static Editing_File null_editing_file = {0};
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Handling a file's Marker Arrays
|
||||||
|
//
|
||||||
|
|
||||||
|
internal void
|
||||||
|
init_file_markers_state(Editing_File_Markers *markers){
|
||||||
|
Marker_Array *sentinel = &markers->sentinel;
|
||||||
|
dll_init_sentinel(sentinel);
|
||||||
|
markers->array_count = 0;
|
||||||
|
markers->marker_count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void
|
||||||
|
clear_file_markers_state(General_Memory *general, Editing_File_Markers *markers){
|
||||||
|
Marker_Array *sentinel = &markers->sentinel;
|
||||||
|
for (Marker_Array *marker_array = sentinel->next;
|
||||||
|
marker_array != sentinel;
|
||||||
|
marker_array = sentinel->next){
|
||||||
|
dll_remove(marker_array);
|
||||||
|
general_memory_free(general, marker_array);
|
||||||
|
}
|
||||||
|
Assert(sentinel->next == sentinel);
|
||||||
|
Assert(sentinel->prev == sentinel);
|
||||||
|
markers->array_count = 0;
|
||||||
|
markers->marker_count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void*
|
||||||
|
allocate_markers_state(General_Memory *general, Editing_File *file, u32 new_array_max){
|
||||||
|
u32 memory_size = sizeof_marker_array + sizeof(Marker)*new_array_max;
|
||||||
|
memory_size = l_round_up_u32(memory_size, KB(4));
|
||||||
|
u32 real_max = (memory_size - sizeof_marker_array)/sizeof(Marker);
|
||||||
|
Marker_Array *array = (Marker_Array*)general_memory_allocate(general, memory_size);
|
||||||
|
|
||||||
|
dll_back_insert(&file->markers.sentinel, array);
|
||||||
|
array->buffer_id = file->id;
|
||||||
|
array->count = 0;
|
||||||
|
array->sim_max = new_array_max;
|
||||||
|
array->max = real_max;
|
||||||
|
|
||||||
|
++file->markers.array_count;
|
||||||
|
|
||||||
|
return(array);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal b32
|
||||||
|
markers_set(Editing_File *file, void *handle, u32 first_index, u32 count, Marker *source){
|
||||||
|
Assert(file != 0);
|
||||||
|
b32 result = false;
|
||||||
|
if (handle != 0){
|
||||||
|
Marker_Array *markers = (Marker_Array*)handle;
|
||||||
|
if (markers->buffer_id.id == file->id.id){
|
||||||
|
if (first_index + count <= markers->sim_max){
|
||||||
|
u32 new_count = first_index + count;
|
||||||
|
if (new_count > markers->count){
|
||||||
|
file->markers.marker_count += new_count - markers->count;
|
||||||
|
markers->count = new_count;
|
||||||
|
}
|
||||||
|
Marker *dst = &markers->marker_0;
|
||||||
|
memcpy(dst + first_index, source, sizeof(Marker)*count);
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal b32
|
||||||
|
markers_get(Editing_File *file, void *handle, u32 first_index, u32 count, Marker *output){
|
||||||
|
Assert(file != 0);
|
||||||
|
b32 result = false;
|
||||||
|
if (handle != 0){
|
||||||
|
Marker_Array *markers = (Marker_Array*)handle;
|
||||||
|
if (markers->buffer_id.id == file->id.id){
|
||||||
|
if (first_index + count <= markers->count){
|
||||||
|
Marker *src = &markers->marker_0;
|
||||||
|
memcpy(output, src + first_index, sizeof(Marker)*count);
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal b32
|
||||||
|
markers_free(General_Memory *general, Editing_File *file, void *handle){
|
||||||
|
Assert(file != 0);
|
||||||
|
b32 result = false;
|
||||||
|
if (handle != 0){
|
||||||
|
Marker_Array *markers = (Marker_Array*)handle;
|
||||||
|
if (markers->buffer_id.id == file->id.id){
|
||||||
|
dll_remove(markers);
|
||||||
|
file->markers.marker_count -= markers->count;
|
||||||
|
--file->markers.array_count;
|
||||||
|
general_memory_free(general, markers);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Manipulating a file's Edit_Pos array
|
// Manipulating a file's Edit_Pos array
|
||||||
//
|
//
|
||||||
|
@ -390,3 +502,4 @@ file_get_sync(Editing_File *file){
|
||||||
|
|
||||||
|
|
||||||
// BOTTOM
|
// BOTTOM
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ struct Working_Set{
|
||||||
i32 clipboard_size, clipboard_max_size;
|
i32 clipboard_size, clipboard_max_size;
|
||||||
i32 clipboard_current, clipboard_rolling;
|
i32 clipboard_current, clipboard_rolling;
|
||||||
|
|
||||||
u64 unique_file_counter;
|
//u64 unique_file_counter;
|
||||||
|
|
||||||
File_Node *sync_check_iter;
|
File_Node *sync_check_iter;
|
||||||
|
|
||||||
|
@ -104,11 +104,12 @@ working_set_alloc(Working_Set *working_set){
|
||||||
Buffer_Slot_ID id = result->id;
|
Buffer_Slot_ID id = result->id;
|
||||||
*result = null_editing_file;
|
*result = null_editing_file;
|
||||||
result->id = id;
|
result->id = id;
|
||||||
result->unique_buffer_id = ++working_set->unique_file_counter;
|
//result->unique_buffer_id = ++working_set->unique_file_counter;
|
||||||
dll_insert(&working_set->used_sentinel, node);
|
dll_insert(&working_set->used_sentinel, node);
|
||||||
result->settings.display_width = working_set->default_display_width;
|
result->settings.display_width = working_set->default_display_width;
|
||||||
result->settings.minimum_base_display_width = working_set->default_minimum_base_display_width;
|
result->settings.minimum_base_display_width = working_set->default_minimum_base_display_width;
|
||||||
result->settings.wrap_indicator = WrapIndicator_Show_At_Wrap_Edge;
|
result->settings.wrap_indicator = WrapIndicator_Show_At_Wrap_Edge;
|
||||||
|
init_file_markers_state(&result->markers);
|
||||||
++working_set->file_count;
|
++working_set->file_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,29 +119,23 @@ working_set_alloc(Working_Set *working_set){
|
||||||
internal Editing_File*
|
internal Editing_File*
|
||||||
working_set_alloc_always(Working_Set *working_set, General_Memory *general){
|
working_set_alloc_always(Working_Set *working_set, General_Memory *general){
|
||||||
Editing_File *result = 0;
|
Editing_File *result = 0;
|
||||||
Editing_File *new_chunk;
|
if (working_set->file_count == working_set->file_max && working_set->array_count < working_set->array_max){
|
||||||
i32 full_new_count = working_set->file_max;
|
i16 new_count = (i16)clamp_top(working_set->file_max, max_i16);
|
||||||
i16 new_count;
|
Editing_File *new_chunk = gen_array(general, Editing_File, new_count);
|
||||||
|
|
||||||
if (full_new_count > max_i16) new_count = max_i16;
|
|
||||||
else new_count = (i16)full_new_count;
|
|
||||||
|
|
||||||
if (working_set->file_count == working_set->file_max &&working_set->array_count < working_set->array_max){
|
|
||||||
new_chunk = gen_array(general, Editing_File, new_count);
|
|
||||||
working_set_extend_memory(working_set, new_chunk, new_count);
|
working_set_extend_memory(working_set, new_chunk, new_count);
|
||||||
}
|
}
|
||||||
result = working_set_alloc(working_set);
|
result = working_set_alloc(working_set);
|
||||||
|
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
working_set_free_file(Working_Set *working_set, Editing_File *file){
|
working_set_free_file(General_Memory *general, Working_Set *working_set, Editing_File *file){
|
||||||
if (working_set->sync_check_iter == &file->node){
|
if (working_set->sync_check_iter == &file->node){
|
||||||
working_set->sync_check_iter = working_set->sync_check_iter->next;
|
working_set->sync_check_iter = working_set->sync_check_iter->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
file->is_dummy = 1;
|
file->is_dummy = 1;
|
||||||
|
clear_file_markers_state(general, &file->markers);
|
||||||
dll_remove(&file->node);
|
dll_remove(&file->node);
|
||||||
dll_insert(&working_set->free_sentinel, &file->node);
|
dll_insert(&working_set->free_sentinel, &file->node);
|
||||||
--working_set->file_count;
|
--working_set->file_count;
|
||||||
|
@ -198,6 +193,8 @@ working_set_init(Working_Set *working_set, Partition *partition, General_Memory
|
||||||
Editing_File *files = push_array(partition, Editing_File, init_count);
|
Editing_File *files = push_array(partition, Editing_File, init_count);
|
||||||
working_set_extend_memory(working_set, files, init_count);
|
working_set_extend_memory(working_set, files, init_count);
|
||||||
|
|
||||||
|
// TODO(NAME): Unclear that this is still needed. But double check that the buffer id 0 does not start getting used by the next real buffer when this is removed before actually removing it. Buffer id cannot be allowed to be zero on real buffers.
|
||||||
|
#if 1
|
||||||
// NOTE(allen): init null file
|
// NOTE(allen): init null file
|
||||||
{
|
{
|
||||||
Editing_File *null_file = working_set_index(working_set, 0);
|
Editing_File *null_file = working_set_index(working_set, 0);
|
||||||
|
@ -205,6 +202,7 @@ working_set_init(Working_Set *working_set, Partition *partition, General_Memory
|
||||||
null_file->is_dummy = 1;
|
null_file->is_dummy = 1;
|
||||||
++working_set->file_count;
|
++working_set->file_count;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// NOTE(allen): init canon table
|
// NOTE(allen): init canon table
|
||||||
{
|
{
|
||||||
|
|
|
@ -64,16 +64,17 @@ static char platform_correct_slash = '/';
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
static char cmd[4096];
|
static char SF_CMD[4096];
|
||||||
static i32 error_state = 0;
|
static i32 error_state = 0;
|
||||||
static i32 prev_error = 0;
|
static i32 prev_error = 0;
|
||||||
|
|
||||||
#define systemf(...) do{ \
|
#define systemf(...) do{ \
|
||||||
int32_t n = snprintf(cmd, sizeof(cmd), __VA_ARGS__); \
|
int32_t n = snprintf(SF_CMD, sizeof(SF_CMD), __VA_ARGS__); \
|
||||||
AllowLocal(n); \
|
AllowLocal(n); \
|
||||||
Assert(n < sizeof(cmd)); \
|
Assert(n < sizeof(SF_CMD)); \
|
||||||
prev_error = system(cmd); \
|
/** printf("%s\n", SF_CMD); /**/ \
|
||||||
if (prev_error != 0) error_state = 1; \
|
prev_error = system(SF_CMD); \
|
||||||
|
if (prev_error != 0) error_state = 1; \
|
||||||
}while(0)
|
}while(0)
|
||||||
|
|
||||||
static void init_time_system();
|
static void init_time_system();
|
||||||
|
|
|
@ -190,14 +190,12 @@ build_cl(u32 flags, char *code_path, char *code_file, char *out_path, char *out_
|
||||||
build_ap(line, "/DFRED_KEEP_ASSERT");
|
build_ap(line, "/DFRED_KEEP_ASSERT");
|
||||||
}
|
}
|
||||||
|
|
||||||
swap_ptr(&line.build_options, &line.build_options_prev);
|
|
||||||
|
|
||||||
if (flags & X86){
|
if (flags & X86){
|
||||||
build_ap(link_line, CL_X86);
|
build_ap(link_line, CL_X86);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & DEBUG_INFO){
|
if (flags & DEBUG_INFO){
|
||||||
build_ap(link_line, "/DEBUG ");
|
build_ap(link_line, "/DEBUG");
|
||||||
}
|
}
|
||||||
|
|
||||||
char link_type_string[1024];
|
char link_type_string[1024];
|
||||||
|
@ -210,6 +208,8 @@ build_cl(u32 flags, char *code_path, char *code_file, char *out_path, char *out_
|
||||||
}
|
}
|
||||||
build_ap(link_line, "%s", link_type_string);
|
build_ap(link_line, "%s", link_type_string);
|
||||||
|
|
||||||
|
swap_ptr(&line.build_options, &line.build_options_prev);
|
||||||
|
swap_ptr(&link_line.build_options, &link_line.build_options_prev);
|
||||||
Temp_Dir temp = pushdir(out_path);
|
Temp_Dir temp = pushdir(out_path);
|
||||||
systemf("cl %s %s\\%s /Fe%s /link /INCREMENTAL:NO %s", line.build_options, code_path, code_file, out_file, link_line.build_options);
|
systemf("cl %s %s\\%s /Fe%s /link /INCREMENTAL:NO %s", line.build_options, code_path, code_file, out_file, link_line.build_options);
|
||||||
popdir(temp);
|
popdir(temp);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
1
|
1
|
||||||
0
|
0
|
||||||
61
|
62
|
||||||
|
|
||||||
|
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue