Compare commits

..

No commits in common. "46a0466ff4f80af01023205420edb80902fb32df" and "001cf5fa576556c4fb01a4451a1a029dc86fd85a" have entirely different histories.

7 changed files with 99 additions and 91 deletions

View File

@ -10,14 +10,12 @@ PRIME DIRECTIVE: SIMPLIFY
[] Look into removing *keyboard* buffer - seems like over long sessions, that could get out of hand [] Look into removing *keyboard* buffer - seems like over long sessions, that could get out of hand
- good first step: print out the memory footprint of this buffer when we exit 4coder, just so we can see what it's taking up - good first step: print out the memory footprint of this buffer when we exit 4coder, just so we can see what it's taking up
[] multi cursor editing [] multi cursor editing
[] matching curly brace highlight
[] yeet sheet
## Investigations ## Investigations
[] What are fade ranges? Do we need them? [] What are fade ranges? Do we need them?
# DONE # DONE
[x] matching curly brace highlight
[x] when buffers have the same filename, a short name is appended. I'd prefer to append the path relative to the project, and if the file is outside the project, append the full path. [x] when buffers have the same filename, a short name is appended. I'd prefer to append the path relative to the project, and if the file is outside the project, append the full path.
[x] reload dirty files if there are no local edits to them automatically [x] reload dirty files if there are no local edits to them automatically
[x] remove audio (search @Remove) [x] remove audio (search @Remove)

View File

@ -19,11 +19,13 @@ string_from_file_name(Editing_File_Name *name){
internal void internal void
file_edit_positions_set_cursor(File_Edit_Positions *edit_pos, i64 pos){ file_edit_positions_set_cursor(File_Edit_Positions *edit_pos, i64 pos){
edit_pos->cursor_pos = pos; edit_pos->cursor_pos = pos;
edit_pos->last_set_type = EditPos_CursorSet;
} }
internal void internal void
file_edit_positions_set_scroll(File_Edit_Positions *edit_pos, Buffer_Scroll scroll){ file_edit_positions_set_scroll(File_Edit_Positions *edit_pos, Buffer_Scroll scroll){
edit_pos->scroll = scroll; edit_pos->scroll = scroll;
edit_pos->last_set_type = EditPos_ScrollSet;
} }
internal void internal void
@ -122,13 +124,13 @@ internal b32
save_file_to_name(Thread_Context *tctx, Models *models, Editing_File *file, u8 *file_name){ save_file_to_name(Thread_Context *tctx, Models *models, Editing_File *file, u8 *file_name){
b32 result = false; b32 result = false;
b32 using_actual_file_name = false; b32 using_actual_file_name = false;
if (file_name == 0){ if (file_name == 0){
file_name_terminate(&file->canon); file_name_terminate(&file->canon);
file_name = file->canon.name_space; file_name = file->canon.name_space;
using_actual_file_name = true; using_actual_file_name = true;
} }
if (file_name != 0){ if (file_name != 0){
if (models->save_file != 0){ if (models->save_file != 0){
Application_Links app = {}; Application_Links app = {};
@ -136,12 +138,12 @@ save_file_to_name(Thread_Context *tctx, Models *models, Editing_File *file, u8 *
app.cmd_context = models; app.cmd_context = models;
models->save_file(&app, file->id); models->save_file(&app, file->id);
} }
Gap_Buffer *buffer = &file->state.buffer; Gap_Buffer *buffer = &file->state.buffer;
b32 dos_write_mode = file->settings.dos_write_mode; b32 dos_write_mode = file->settings.dos_write_mode;
Scratch_Block scratch(tctx); Scratch_Block scratch(tctx);
if (!using_actual_file_name){ if (!using_actual_file_name){
String_Const_u8 s_file_name = SCu8(file_name); String_Const_u8 s_file_name = SCu8(file_name);
String_Const_u8 canonical_file_name = system_get_canonical(scratch, s_file_name); String_Const_u8 canonical_file_name = system_get_canonical(scratch, s_file_name);
@ -149,9 +151,9 @@ save_file_to_name(Thread_Context *tctx, Models *models, Editing_File *file, u8 *
using_actual_file_name = true; using_actual_file_name = true;
} }
} }
String_Const_u8 saveable_string = buffer_stringify(scratch, buffer, Ii64(0, buffer_size(buffer))); String_Const_u8 saveable_string = buffer_stringify(scratch, buffer, Ii64(0, buffer_size(buffer)));
File_Attributes new_attributes = system_save_file(scratch, (char*)file_name, saveable_string); File_Attributes new_attributes = system_save_file(scratch, (char*)file_name, saveable_string);
if (new_attributes.last_write_time > 0 && if (new_attributes.last_write_time > 0 &&
using_actual_file_name){ using_actual_file_name){
@ -161,7 +163,7 @@ save_file_to_name(Thread_Context *tctx, Models *models, Editing_File *file, u8 *
LogEventF(log_string(M), scratch, file->id, 0, system_thread_get_id(), LogEventF(log_string(M), scratch, file->id, 0, system_thread_get_id(),
"save file [last_write_time=0x%llx]", new_attributes.last_write_time); "save file [last_write_time=0x%llx]", new_attributes.last_write_time);
} }
return(result); return(result);
} }
@ -193,30 +195,30 @@ file_get_layout_func(Editing_File *file){
internal void internal void
file_create_from_string(Thread_Context *tctx, Models *models, Editing_File *file, String_Const_u8 val, File_Attributes attributes){ file_create_from_string(Thread_Context *tctx, Models *models, Editing_File *file, String_Const_u8 val, File_Attributes attributes){
Scratch_Block scratch(tctx); Scratch_Block scratch(tctx);
Base_Allocator *allocator = tctx->allocator; Base_Allocator *allocator = tctx->allocator;
block_zero_struct(&file->state); block_zero_struct(&file->state);
buffer_init(&file->state.buffer, val.str, val.size, allocator); buffer_init(&file->state.buffer, val.str, val.size, allocator);
if (buffer_size(&file->state.buffer) < (i64)val.size){ if (buffer_size(&file->state.buffer) < (i64)val.size){
file->settings.dos_write_mode = true; file->settings.dos_write_mode = true;
} }
file_clear_dirty_flags(file); file_clear_dirty_flags(file);
file->attributes = attributes; file->attributes = attributes;
file->settings.layout_func = models->layout_func; file->settings.layout_func = models->layout_func;
file->settings.face_id = models->global_face_id; file->settings.face_id = models->global_face_id;
buffer_measure_starts(scratch, &file->state.buffer); buffer_measure_starts(scratch, &file->state.buffer);
file->lifetime_object = lifetime_alloc_object(&models->lifetime_allocator, DynamicWorkspace_Buffer, file); file->lifetime_object = lifetime_alloc_object(&models->lifetime_allocator, DynamicWorkspace_Buffer, file);
history_init(tctx, models, &file->state.history); history_init(tctx, models, &file->state.history);
file->state.cached_layouts_arena = make_arena(allocator); file->state.cached_layouts_arena = make_arena(allocator);
file->state.line_layout_table = make_table_Data_u64(allocator, 500); file->state.line_layout_table = make_table_Data_u64(allocator, 500);
file->settings.is_initialized = true; file->settings.is_initialized = true;
{ {
Temp_Memory temp = begin_temp(scratch); Temp_Memory temp = begin_temp(scratch);
String_Const_u8 name = SCu8(file->unique_name.name_space, file->unique_name.name_size); String_Const_u8 name = SCu8(file->unique_name.name_space, file->unique_name.name_size);
@ -226,9 +228,9 @@ file_create_from_string(Thread_Context *tctx, Models *models, Editing_File *file
attributes.last_write_time, string_expand(name)); attributes.last_write_time, string_expand(name));
end_temp(temp); end_temp(temp);
} }
//////////////////////////////// ////////////////////////////////
if (models->begin_buffer != 0){ if (models->begin_buffer != 0){
Application_Links app = {}; Application_Links app = {};
app.tctx = tctx; app.tctx = tctx;
@ -241,17 +243,17 @@ internal void
file_free(Thread_Context *tctx, Models *models, Editing_File *file){ file_free(Thread_Context *tctx, Models *models, Editing_File *file){
Lifetime_Allocator *lifetime_allocator = &models->lifetime_allocator; Lifetime_Allocator *lifetime_allocator = &models->lifetime_allocator;
Working_Set *working_set = &models->working_set; Working_Set *working_set = &models->working_set;
lifetime_free_object(lifetime_allocator, file->lifetime_object); lifetime_free_object(lifetime_allocator, file->lifetime_object);
Gap_Buffer *buffer = &file->state.buffer; Gap_Buffer *buffer = &file->state.buffer;
if (buffer->data){ if (buffer->data){
base_free(buffer->allocator, buffer->data); base_free(buffer->allocator, buffer->data);
base_free(buffer->allocator, buffer->line_starts); base_free(buffer->allocator, buffer->line_starts);
} }
history_free(tctx, &file->state.history); history_free(tctx, &file->state.history);
linalloc_clear(&file->state.cached_layouts_arena); linalloc_clear(&file->state.cached_layouts_arena);
table_free(&file->state.line_layout_table); table_free(&file->state.line_layout_table);
} }
@ -279,7 +281,7 @@ internal Layout_Item_List
file_get_line_layout(Thread_Context *tctx, Models *models, Editing_File *file, file_get_line_layout(Thread_Context *tctx, Models *models, Editing_File *file,
Layout_Function *layout_func, f32 width, Face *face, i64 line_number){ Layout_Function *layout_func, f32 width, Face *face, i64 line_number){
Layout_Item_List result = {}; Layout_Item_List result = {};
i64 line_count = buffer_line_count(&file->state.buffer); i64 line_count = buffer_line_count(&file->state.buffer);
if (1 <= line_number && line_number <= line_count){ if (1 <= line_number && line_number <= line_count){
Line_Layout_Key key = {}; Line_Layout_Key key = {};
@ -287,11 +289,11 @@ file_get_line_layout(Thread_Context *tctx, Models *models, Editing_File *file,
key.face_version_number = face->version_number; key.face_version_number = face->version_number;
key.width = width; key.width = width;
key.line_number = line_number; key.line_number = line_number;
String_Const_u8 key_data = make_data_struct(&key); String_Const_u8 key_data = make_data_struct(&key);
Layout_Item_List *list = 0; Layout_Item_List *list = 0;
Table_Lookup lookup = table_lookup(&file->state.line_layout_table, key_data); Table_Lookup lookup = table_lookup(&file->state.line_layout_table, key_data);
if (lookup.found_match){ if (lookup.found_match){
u64 val = 0; u64 val = 0;
@ -301,7 +303,7 @@ file_get_line_layout(Thread_Context *tctx, Models *models, Editing_File *file,
else{ else{
list = push_array(&file->state.cached_layouts_arena, Layout_Item_List, 1); list = push_array(&file->state.cached_layouts_arena, Layout_Item_List, 1);
Range_i64 line_range = buffer_get_pos_range_from_line_number(&file->state.buffer, line_number); Range_i64 line_range = buffer_get_pos_range_from_line_number(&file->state.buffer, line_number);
Application_Links app = {}; Application_Links app = {};
app.tctx = tctx; app.tctx = tctx;
app.cmd_context = models; app.cmd_context = models;
@ -312,7 +314,7 @@ file_get_line_layout(Thread_Context *tctx, Models *models, Editing_File *file,
} }
block_copy_struct(&result, list); block_copy_struct(&result, list);
} }
return(result); return(result);
} }
@ -327,9 +329,9 @@ file_line_shift_y(Thread_Context *tctx, Models *models, Editing_File *file,
Layout_Function *layout_func, f32 width, Face *face, Layout_Function *layout_func, f32 width, Face *face,
i64 line_number, f32 y_delta){ i64 line_number, f32 y_delta){
Line_Shift_Vertical result = {}; Line_Shift_Vertical result = {};
f32 line_y = 0.f; f32 line_y = 0.f;
if (y_delta < 0.f){ if (y_delta < 0.f){
// NOTE(allen): Iterating upward // NOTE(allen): Iterating upward
b32 has_result = false; b32 has_result = false;
@ -378,7 +380,7 @@ file_line_shift_y(Thread_Context *tctx, Models *models, Editing_File *file,
result.y_delta = line_y; result.y_delta = line_y;
} }
} }
return(result); return(result);
} }
@ -417,11 +419,11 @@ file_relative_box_of_pos(Thread_Context *tctx, Models *models, Editing_File *fil
i64 line_number = buffer_get_line_index(&file->state.buffer, pos) + 1; i64 line_number = buffer_get_line_index(&file->state.buffer, pos) + 1;
Layout_Item_List line = file_get_line_layout(tctx, models, file, layout_func, width, face, line_number); Layout_Item_List line = file_get_line_layout(tctx, models, file, layout_func, width, face, line_number);
Rect_f32 result = layout_box_of_pos(line, pos); Rect_f32 result = layout_box_of_pos(line, pos);
f32 y_difference = file_line_y_difference(tctx, models, file, layout_func, width, face, line_number, base_line); f32 y_difference = file_line_y_difference(tctx, models, file, layout_func, width, face, line_number, base_line);
result.y0 += y_difference; result.y0 += y_difference;
result.y1 += y_difference; result.y1 += y_difference;
return(result); return(result);
} }
@ -440,11 +442,11 @@ file_padded_box_of_pos(Thread_Context *tctx, Models *models, Editing_File *file,
i64 line_number = buffer_get_line_index(&file->state.buffer, pos) + 1; i64 line_number = buffer_get_line_index(&file->state.buffer, pos) + 1;
Layout_Item_List line = file_get_line_layout(tctx, models, file, layout_func, width, face, line_number); Layout_Item_List line = file_get_line_layout(tctx, models, file, layout_func, width, face, line_number);
Rect_f32 result = layout_padded_box_of_pos(line, pos); Rect_f32 result = layout_padded_box_of_pos(line, pos);
f32 y_difference = file_line_y_difference(tctx, models, file, layout_func, width, face, line_number, base_line); f32 y_difference = file_line_y_difference(tctx, models, file, layout_func, width, face, line_number, base_line);
result.y0 += y_difference; result.y0 += y_difference;
result.y1 += y_difference; result.y1 += y_difference;
return(result); return(result);
} }
@ -473,9 +475,9 @@ file_buffer_point_difference(Thread_Context *tctx, Models *models, Editing_File
internal Line_Shift_Character internal Line_Shift_Character
file_line_shift_characters(Thread_Context *tctx, Models *models, Editing_File *file, Layout_Function *layout_func, f32 width, Face *face, i64 line_number, i64 character_delta){ file_line_shift_characters(Thread_Context *tctx, Models *models, Editing_File *file, Layout_Function *layout_func, f32 width, Face *face, i64 line_number, i64 character_delta){
Line_Shift_Character result = {}; Line_Shift_Character result = {};
i64 line_character = 0; i64 line_character = 0;
if (character_delta < 0){ if (character_delta < 0){
// NOTE(allen): Iterating upward // NOTE(allen): Iterating upward
b32 has_result = false; b32 has_result = false;
@ -522,7 +524,7 @@ file_line_shift_characters(Thread_Context *tctx, Models *models, Editing_File *f
result.character_delta = line_character; result.character_delta = line_character;
} }
} }
return(result); return(result);
} }

View File

@ -12,7 +12,14 @@
#if !defined(FRED_FILE_H) #if !defined(FRED_FILE_H)
#define FRED_FILE_H #define FRED_FILE_H
typedef i32 Edit_Pos_Set_Type;
enum{
EditPos_None,
EditPos_CursorSet,
EditPos_ScrollSet
};
struct File_Edit_Positions{ struct File_Edit_Positions{
Edit_Pos_Set_Type last_set_type;
Buffer_Scroll scroll; Buffer_Scroll scroll;
i64 cursor_pos; i64 cursor_pos;
}; };
@ -43,19 +50,19 @@ enum{
struct Editing_File_State{ struct Editing_File_State{
Gap_Buffer buffer; Gap_Buffer buffer;
History history; History history;
i32 current_record_index; i32 current_record_index;
Dirty_State dirty; Dirty_State dirty;
File_Save_State save_state; File_Save_State save_state;
File_Edit_Positions edit_pos_most_recent; File_Edit_Positions edit_pos_most_recent;
File_Edit_Positions edit_pos_stack[16]; File_Edit_Positions edit_pos_stack[16];
i32 edit_pos_stack_top; i32 edit_pos_stack_top;
Child_Process_ID attached_child_process; Child_Process_ID attached_child_process;
Arena cached_layouts_arena; Arena cached_layouts_arena;
Table_Data_u64 line_layout_table; Table_Data_u64 line_layout_table;
}; };

View File

@ -42,12 +42,12 @@ internal void
free_query_slot(Query_Set *set, Query_Bar *match_bar){ free_query_slot(Query_Set *set, Query_Bar *match_bar){
Query_Slot *slot = 0; Query_Slot *slot = 0;
Query_Slot *prev = 0; Query_Slot *prev = 0;
for (slot = set->used_slot; slot != 0; slot = slot->next){ for (slot = set->used_slot; slot != 0; slot = slot->next){
if (slot->query_bar == match_bar) break; if (slot->query_bar == match_bar) break;
prev = slot; prev = slot;
} }
if (slot){ if (slot){
if (prev){ if (prev){
prev->next = slot->next; prev->next = slot->next;
@ -97,17 +97,17 @@ internal View*
live_set_alloc_view(Lifetime_Allocator *lifetime_allocator, Live_Views *live_set, Panel *panel){ live_set_alloc_view(Lifetime_Allocator *lifetime_allocator, Live_Views *live_set, Panel *panel){
Assert(live_set->count < live_set->max); Assert(live_set->count < live_set->max);
++live_set->count; ++live_set->count;
View *result = live_set->free_sentinel.next; View *result = live_set->free_sentinel.next;
dll_remove(result); dll_remove(result);
block_zero_struct(result); block_zero_struct(result);
result->in_use = true; result->in_use = true;
init_query_set(&result->query_set); init_query_set(&result->query_set);
result->lifetime_object = lifetime_alloc_object(lifetime_allocator, DynamicWorkspace_View, result); result->lifetime_object = lifetime_alloc_object(lifetime_allocator, DynamicWorkspace_View, result);
panel->view = result; panel->view = result;
result->panel = panel; result->panel = panel;
return(result); return(result);
} }
@ -115,13 +115,13 @@ internal void
live_set_free_view(Lifetime_Allocator *lifetime_allocator, Live_Views *live_set, View *view){ live_set_free_view(Lifetime_Allocator *lifetime_allocator, Live_Views *live_set, View *view){
Assert(live_set->count > 0); Assert(live_set->count > 0);
--live_set->count; --live_set->count;
view->next = live_set->free_sentinel.next; view->next = live_set->free_sentinel.next;
view->prev = &live_set->free_sentinel; view->prev = &live_set->free_sentinel;
live_set->free_sentinel.next = view; live_set->free_sentinel.next = view;
view->next->prev = view; view->next->prev = view;
view->in_use = false; view->in_use = false;
lifetime_free_object(lifetime_allocator, view->lifetime_object); lifetime_free_object(lifetime_allocator, view->lifetime_object);
} }
@ -335,31 +335,31 @@ view_move_view_to_cursor(Thread_Context *tctx, Models *models, View *view, Buffe
Face *face = file_get_face(models, file); Face *face = file_get_face(models, file);
Rect_f32 rect = view_get_buffer_rect(tctx, models, view); Rect_f32 rect = view_get_buffer_rect(tctx, models, view);
Vec2_f32 view_dim = rect_dim(rect); Vec2_f32 view_dim = rect_dim(rect);
Layout_Function *layout_func = file_get_layout_func(file); Layout_Function *layout_func = file_get_layout_func(file);
File_Edit_Positions edit_pos = view_get_edit_pos(view); File_Edit_Positions edit_pos = view_get_edit_pos(view);
Vec2_f32 p = file_relative_xy_of_pos(tctx, models, file, Vec2_f32 p = file_relative_xy_of_pos(tctx, models, file,
layout_func, view_dim.x, face, layout_func, view_dim.x, face,
scroll->target.line_number, edit_pos.cursor_pos); scroll->target.line_number, edit_pos.cursor_pos);
p -= scroll->target.pixel_shift; p -= scroll->target.pixel_shift;
f32 line_height = face->metrics.line_height; f32 line_height = face->metrics.line_height;
f32 normal_advance = face->metrics.normal_advance; f32 normal_advance = face->metrics.normal_advance;
Vec2_f32 margin = view->cursor_margin; Vec2_f32 margin = view->cursor_margin;
Vec2_f32 push_in = view->cursor_push_in_multiplier; Vec2_f32 push_in = view->cursor_push_in_multiplier;
Vec2_f32 lim_dim = view_dim*0.45f; Vec2_f32 lim_dim = view_dim*0.45f;
margin.x = clamp_top(margin.x, lim_dim.x); margin.x = clamp_top(margin.x, lim_dim.x);
margin.y = clamp_top(margin.y, lim_dim.y); margin.y = clamp_top(margin.y, lim_dim.y);
Vec2_f32 push_in_lim_dim = hadamard(lim_dim, V2f32(1.f/line_height, 1.f/normal_advance)) - margin; Vec2_f32 push_in_lim_dim = hadamard(lim_dim, V2f32(1.f/line_height, 1.f/normal_advance)) - margin;
push_in_lim_dim.x = clamp_bot(0.f, push_in_lim_dim.x); push_in_lim_dim.x = clamp_bot(0.f, push_in_lim_dim.x);
push_in_lim_dim.y = clamp_bot(0.f, push_in_lim_dim.y); push_in_lim_dim.y = clamp_bot(0.f, push_in_lim_dim.y);
push_in.x = clamp_top(push_in.x, push_in_lim_dim.x); push_in.x = clamp_top(push_in.x, push_in_lim_dim.x);
push_in.y = clamp_top(push_in.y, push_in_lim_dim.y); push_in.y = clamp_top(push_in.y, push_in_lim_dim.y);
Vec2_f32 target_p_relative = {}; Vec2_f32 target_p_relative = {};
if (p.y < margin.y){ if (p.y < margin.y){
target_p_relative.y = p.y - margin.y - line_height*push_in.y; target_p_relative.y = p.y - margin.y - line_height*push_in.y;
@ -377,7 +377,7 @@ view_move_view_to_cursor(Thread_Context *tctx, Models *models, View *view, Buffe
scroll->target = view_normalize_buffer_point(tctx, models, view, scroll->target); scroll->target = view_normalize_buffer_point(tctx, models, view, scroll->target);
scroll->target.pixel_shift.x = f32_round32(scroll->target.pixel_shift.x); scroll->target.pixel_shift.x = f32_round32(scroll->target.pixel_shift.x);
scroll->target.pixel_shift.y = f32_round32(scroll->target.pixel_shift.y); scroll->target.pixel_shift.y = f32_round32(scroll->target.pixel_shift.y);
return(target_p_relative != V2f32(0.f, 0.f)); return(target_p_relative != V2f32(0.f, 0.f));
} }
@ -387,16 +387,16 @@ view_move_cursor_to_view(Thread_Context *tctx, Models *models, View *view, Buffe
Face *face = file_get_face(models, file); Face *face = file_get_face(models, file);
Rect_f32 rect = view_get_buffer_rect(tctx, models, view); Rect_f32 rect = view_get_buffer_rect(tctx, models, view);
Vec2_f32 view_dim = rect_dim(rect); Vec2_f32 view_dim = rect_dim(rect);
Layout_Function *layout_func = file_get_layout_func(file); Layout_Function *layout_func = file_get_layout_func(file);
Vec2_f32 p = file_relative_xy_of_pos(tctx, models, file, Vec2_f32 p = file_relative_xy_of_pos(tctx, models, file,
layout_func, view_dim.x, face, layout_func, view_dim.x, face,
scroll.target.line_number, *pos_in_out); scroll.target.line_number, *pos_in_out);
p -= scroll.target.pixel_shift; p -= scroll.target.pixel_shift;
f32 line_height = face->metrics.line_height; f32 line_height = face->metrics.line_height;
b32 adjusted_y = true; b32 adjusted_y = true;
if (p.y < 0.f){ if (p.y < 0.f){
p.y = line_height*1.5f; p.y = line_height*1.5f;
@ -407,7 +407,7 @@ view_move_cursor_to_view(Thread_Context *tctx, Models *models, View *view, Buffe
else{ else{
adjusted_y = false; adjusted_y = false;
} }
b32 result = false; b32 result = false;
if (adjusted_y){ if (adjusted_y){
p += scroll.target.pixel_shift; p += scroll.target.pixel_shift;
@ -416,7 +416,7 @@ view_move_cursor_to_view(Thread_Context *tctx, Models *models, View *view, Buffe
scroll.target.line_number, p); scroll.target.line_number, p);
result = true; result = true;
} }
return(result); return(result);
} }
@ -450,6 +450,7 @@ view_set_cursor_and_scroll(Thread_Context *tctx, Models *models, View *view, i64
Vec2_f32 p = view_relative_xy_of_pos(tctx, models, view, cursor.line, pos); Vec2_f32 p = view_relative_xy_of_pos(tctx, models, view, cursor.line, pos);
view->preferred_x = p.x; view->preferred_x = p.x;
file_edit_positions_set_scroll(&edit_pos, scroll); file_edit_positions_set_scroll(&edit_pos, scroll);
edit_pos.last_set_type = EditPos_None;
view_set_edit_pos(view, edit_pos); view_set_edit_pos(view, edit_pos);
} }
@ -458,9 +459,9 @@ view_set_cursor_and_scroll(Thread_Context *tctx, Models *models, View *view, i64
internal void internal void
view_set_file(Thread_Context *tctx, Models *models, View *view, Editing_File *file){ view_set_file(Thread_Context *tctx, Models *models, View *view, Editing_File *file){
Assert(file != 0); Assert(file != 0);
Editing_File *old_file = view->file; Editing_File *old_file = view->file;
if (models->view_change_buffer != 0){ if (models->view_change_buffer != 0){
Application_Links app = {}; Application_Links app = {};
app.tctx = tctx; app.tctx = tctx;
@ -468,21 +469,21 @@ view_set_file(Thread_Context *tctx, Models *models, View *view, Editing_File *fi
models->view_change_buffer(&app, view_get_id(&models->view_set, view), models->view_change_buffer(&app, view_get_id(&models->view_set, view),
(old_file != 0)?old_file->id:0, file->id); (old_file != 0)?old_file->id:0, file->id);
} }
if (old_file != 0){ if (old_file != 0){
file_touch(&models->working_set, old_file); file_touch(&models->working_set, old_file);
file_edit_positions_push(old_file, view_get_edit_pos(view)); file_edit_positions_push(old_file, view_get_edit_pos(view));
} }
view->file = file; view->file = file;
File_Edit_Positions edit_pos = file_edit_positions_pop(file); File_Edit_Positions edit_pos = file_edit_positions_pop(file);
view_set_edit_pos(view, edit_pos); view_set_edit_pos(view, edit_pos);
view->mark = edit_pos.cursor_pos; view->mark = edit_pos.cursor_pos;
Buffer_Cursor cursor = view_compute_cursor(view, seek_pos(edit_pos.cursor_pos)); Buffer_Cursor cursor = view_compute_cursor(view, seek_pos(edit_pos.cursor_pos));
Vec2_f32 p = view_relative_xy_of_pos(tctx, models, view, cursor.line, edit_pos.cursor_pos); Vec2_f32 p = view_relative_xy_of_pos(tctx, models, view, cursor.line, edit_pos.cursor_pos);
view->preferred_x = p.x; view->preferred_x = p.x;
models->layout.panel_state_dirty = true; models->layout.panel_state_dirty = true;
} }
@ -543,7 +544,7 @@ co_handle_request(Thread_Context *tctx, Models *models, Coroutine *co, Co_Out *o
in.face_id = (face != 0)?face->id:0; in.face_id = (face != 0)?face->id:0;
result = coroutine_run(&models->coroutines, co, &in, out); result = coroutine_run(&models->coroutines, co, &in, out);
}break; }break;
case CoRequest_ModifyFace: case CoRequest_ModifyFace:
{ {
Face_Description *description = out->face_description; Face_Description *description = out->face_description;
@ -552,13 +553,13 @@ co_handle_request(Thread_Context *tctx, Models *models, Coroutine *co, Co_Out *o
in.success = font_set_modify_face(&models->font_set, face_id, description); in.success = font_set_modify_face(&models->font_set, face_id, description);
result = coroutine_run(&models->coroutines, co, &in, out); result = coroutine_run(&models->coroutines, co, &in, out);
}break; }break;
case CoRequest_AcquireGlobalFrameMutex: case CoRequest_AcquireGlobalFrameMutex:
{ {
system_acquire_global_frame_mutex(tctx); system_acquire_global_frame_mutex(tctx);
result = coroutine_run(&models->coroutines, co, 0, out); result = coroutine_run(&models->coroutines, co, 0, out);
}break; }break;
case CoRequest_ReleaseGlobalFrameMutex: case CoRequest_ReleaseGlobalFrameMutex:
{ {
system_release_global_frame_mutex(tctx); system_release_global_frame_mutex(tctx);
@ -593,18 +594,18 @@ function void
view_init(Thread_Context *tctx, Models *models, View *view, Editing_File *initial_buffer, view_init(Thread_Context *tctx, Models *models, View *view, Editing_File *initial_buffer,
Custom_Command_Function *event_context_base){ Custom_Command_Function *event_context_base){
view_set_file(tctx, models, view, initial_buffer); view_set_file(tctx, models, view, initial_buffer);
view->node_arena = make_arena_system(); view->node_arena = make_arena_system();
View_Context first_ctx = {}; View_Context first_ctx = {};
first_ctx.render_caller = models->render_caller; first_ctx.render_caller = models->render_caller;
first_ctx.delta_rule = models->delta_rule; first_ctx.delta_rule = models->delta_rule;
first_ctx.delta_rule_memory_size = models->delta_rule_memory_size; first_ctx.delta_rule_memory_size = models->delta_rule_memory_size;
view_push_context(view, &first_ctx); view_push_context(view, &first_ctx);
view->cursor_margin = V2f32(0.f, 0.f); view->cursor_margin = V2f32(0.f, 0.f);
view->cursor_push_in_multiplier = V2f32(1.5f, 1.5f); view->cursor_push_in_multiplier = V2f32(1.5f, 1.5f);
view->co = coroutine_create(&models->coroutines, view_event_context_base__inner); view->co = coroutine_create(&models->coroutines, view_event_context_base__inner);
view->co->user_data = view; view->co->user_data = view;
Co_In in = {}; Co_In in = {};
@ -677,10 +678,10 @@ co_full_abort(Thread_Context *tctx, Models *models, View *view){
function b32 function b32
co_send_event(Thread_Context *tctx, Models *models, View *view, Input_Event *event){ co_send_event(Thread_Context *tctx, Models *models, View *view, Input_Event *event){
b32 event_was_handled = false; b32 event_was_handled = false;
Coroutine *co = view->co; Coroutine *co = view->co;
Co_Out *co_out = &view->co_out; Co_Out *co_out = &view->co_out;
{ {
models->current_input_unhandled = false; models->current_input_unhandled = false;
Co_In in = {}; Co_In in = {};
@ -694,7 +695,7 @@ co_send_event(Thread_Context *tctx, Models *models, View *view, Input_Event *eve
} }
event_was_handled = !models->current_input_unhandled; event_was_handled = !models->current_input_unhandled;
} }
return(event_was_handled); return(event_was_handled);
} }

View File

@ -62,27 +62,27 @@ struct View{
View *prev; View *prev;
struct Panel *panel; struct Panel *panel;
b32 in_use; b32 in_use;
Editing_File *file; Editing_File *file;
Lifetime_Object *lifetime_object; Lifetime_Object *lifetime_object;
File_Edit_Positions edit_pos_; File_Edit_Positions edit_pos_;
i64 mark; i64 mark;
f32 preferred_x; f32 preferred_x;
Vec2_f32 cursor_margin; Vec2_f32 cursor_margin;
Vec2_f32 cursor_push_in_multiplier; Vec2_f32 cursor_push_in_multiplier;
b8 new_scroll_target; b8 new_scroll_target;
b8 hide_scrollbar; b8 hide_scrollbar;
b8 hide_file_bar; b8 hide_file_bar;
b8 show_whitespace; b8 show_whitespace;
Coroutine *co; Coroutine *co;
Co_Out co_out; Co_Out co_out;
Arena node_arena; Arena node_arena;
View_Context_Node *ctx; View_Context_Node *ctx;
Query_Set query_set; Query_Set query_set;
}; };

View File

@ -20,7 +20,7 @@ use_scope_highlight = true;
use_paren_helper = true; use_paren_helper = true;
use_comment_keywords = true; use_comment_keywords = true;
lister_whole_word_backspace_when_modified = true; lister_whole_word_backspace_when_modified = true;
show_line_number_margins = true; show_line_number_margins = false;
enable_output_wrapping = false; enable_output_wrapping = false;
enable_undo_fade_out = false; enable_undo_fade_out = false;

View File

@ -32,7 +32,7 @@ defcolor_highlight_junk = 0xFF3A0000;
defcolor_highlight_white = 0xFF003A3A; defcolor_highlight_white = 0xFF003A3A;
defcolor_paste = 0xFFDDEE00; defcolor_paste = 0xFFDDEE00;
defcolor_undo = 0xFF00DDEE; defcolor_undo = 0xFF00DDEE;
defcolor_back_cycle = { 0xff282828, 0xff323232, 0xff3C3C3C, defcolor_back, }; defcolor_back_cycle = { defcolor_back, defcolor_back, defcolor_back, defcolor_back, defcolor_back, defcolor_back, defcolor_back, defcolor_back, defcolor_back, defcolor_back, defcolor_back};
defcolor_text_cycle = { 0xFFA00000, 0xFF00A000, 0xFF0030B0, 0xFFA0A000 }; defcolor_text_cycle = { 0xFFA00000, 0xFF00A000, 0xFF0030B0, 0xFFA0A000 };
defcolor_line_numbers_back = defcolor_back; defcolor_line_numbers_back = defcolor_back;
defcolor_line_numbers_text = 0xFF404040; defcolor_line_numbers_text = 0xFF404040;