unifying use of working_set's table

This commit is contained in:
Allen Webster 2016-02-07 16:15:58 -05:00
parent 959bdcd8cf
commit 5abea3ce3c
8 changed files with 3158 additions and 3139 deletions

22
4ed.cpp
View File

@ -789,6 +789,7 @@ app_open_file_background(App_Vars *vars, Exchange *exchange, Working_Set *workin
if (file_id){
result.is_new = 1;
result.file = file.file;
file_init_strings(result.file);
file_set_name(result.file, filename.str);
file_set_to_loading(result.file);
table_add(&working_set->table, result.file->name.source_path, file.index);
@ -923,16 +924,17 @@ COMMAND_DECL(save){
ProfileMomentFunction();
REQ_FILE_VIEW(view);
REQ_FILE(file, view);
USE_VARS(vars);
USE_MEM(mem);
USE_EXCHANGE(exchange);
USE_WORKING_SET(working_set);
USE_DELAY(delay);
USE_PANEL(panel);
delayed_action(delay, DACT_SAVE, file->name.source_path, panel);
#if 0
String *file_path = &file->name.source_path;
if (file_path->size > 0){
i32 sys_id = file_save(system, exchange, mem, file, file_path->str);
app_push_file_binding(vars, sys_id, get_file_id(working_set, file));
}
#endif
}
COMMAND_DECL(interactive_save_as){
@ -1678,6 +1680,7 @@ build(System_Functions *system, Mem_Options *mem,
Font_Set *font_set, Style *style,
Live_Views *live_set, Exchange *exchange,
Panel *panel, Command_Data *command,
String hot_directory,
char *buffer_name, i32 buffer_name_len,
char *path, i32 path_len,
char *script, i32 script_len,
@ -1725,7 +1728,7 @@ build(System_Functions *system, Mem_Options *mem,
if (file){
file_create_super_locked(system, mem, file, buffer_name, font_set, style->font_id);
file->settings.unimportant = 1;
table_add(&working_set->table, file->name.live_name, index);
table_add(&working_set->table, file->name.source_path, index);
if (bind_to_new_view){
View *new_view = live_set_alloc_view(live_set, mem);
@ -1735,7 +1738,6 @@ build(System_Functions *system, Mem_Options *mem,
view_set_file(system, file_view, file, font_set, style,
vars->hooks[hook_open_file], command, &app_links);
new_view->map = app_get_map(vars, file->settings.base_map_id);
}
i32 i = vars->cli_processes.count++;
@ -1830,6 +1832,7 @@ COMMAND_DECL(build){
build(system, mem, vars, working_set,
font_set, style, live_set, exchange,
panel, command,
vars->hot_directory.string,
buffer_name, buffer_name_len,
path, path_len,
script, script_len,
@ -1877,6 +1880,7 @@ COMMAND_DECL(build_here){
build(system, mem, vars, working_set,
font_set, style, live_set, exchange,
panel, command,
vars->hot_directory.string,
buffer_name, buffer_name_len,
path.str, path.size,
dir.str, dir.size,
@ -3461,7 +3465,8 @@ App_Step_Sig(app_step){
if (fview){
Editing_File *file = fview->file;
if (file && !file->state.is_dummy){
file_save_and_set_names(system, exchange, mem, file, string->str);
i32 sys_id = file_save_and_set_names(system, exchange, mem, file, string->str);
app_push_file_binding(vars, sys_id, get_file_id(working_set, file));
}
}
}break;
@ -3470,7 +3475,8 @@ App_Step_Sig(app_step){
{
Editing_File *file = working_set_lookup_file(working_set, *string);
if (!file->state.is_dummy){
file_save(system, exchange, mem, file, file->name.source_path.str);
i32 sys_id = file_save(system, exchange, mem, file, file->name.source_path.str);
app_push_file_binding(vars, sys_id, get_file_id(working_set, file));
}
}break;

View File

@ -1575,7 +1575,7 @@ do_live_file_list_box(System_Functions *system, UI_State *state, UI_Layout *layo
if (do_file_option(100+i, state, layout, file->name.live_name, 0, message)){
result = 1;
*selected = 1;
copy(string, file->name.live_name);
copy(string, file->name.source_path);
terminate_with_null(string);
}
}

View File

@ -1205,15 +1205,18 @@ file_init_strings(Editing_File *file){
inline void
file_set_name(Editing_File *file, char *filename){
if (file->name.live_name.str == 0) file_init_strings(file);
if (filename[0] == '*'){
copy(&file->name.live_name, filename);
String f, ext;
Assert(file->name.live_name.str != 0);
f = make_string_slowly(filename);
copy_checked(&file->name.source_path, f);
file->name.live_name.size = 0;
get_front_of_directory(&file->name.live_name, f);
if (file->name.source_path.size == file->name.live_name.size){
file->name.extension.size = 0;
}
else{
String f, ext;
f = make_string_slowly(filename);
copy_checked(&file->name.source_path, f);
get_front_of_directory(&file->name.live_name, f);
ext = file_extension(f);
copy(&file->name.extension, ext);
}
@ -1270,8 +1273,8 @@ inline b32
file_save_and_set_names(System_Functions *system, Exchange *exchange,
Mem_Options *mem, Editing_File *file, char *filename){
b32 result = 0;
if (file_save(system, exchange, mem, file, filename)){
result = 1;
result = file_save(system, exchange, mem, file, filename);
if (result){
file_set_name(file, filename);
}
return result;
@ -2223,7 +2226,7 @@ view_compute_cursor_from_unwrapped_xy(File_View *view, f32 seek_x, f32 seek_y,
#endif
}
inline Full_Cursor
internal Full_Cursor
view_compute_cursor_from_wrapped_xy(File_View *view, f32 seek_x, f32 seek_y,
b32 round_down = 0){
#if BUFFER_EXPERIMENT_SCALPEL <= 3
@ -2246,7 +2249,7 @@ view_compute_cursor_from_wrapped_xy(File_View *view, f32 seek_x, f32 seek_y,
#endif
}
inline Full_Cursor
internal Full_Cursor
view_compute_cursor_from_line_pos(File_View *view, i32 line, i32 pos){
#if BUFFER_EXPERIMENT_SCALPEL <= 3
Editing_File *file = view->file;
@ -2726,20 +2729,22 @@ file_edit_cursor_fix(System_Functions *system,
Editing_File *file, Editing_Layout *layout,
Cursor_Fix_Descriptor desc){
Full_Cursor temp_cursor;
File_View *current_view;
Temp_Memory cursor_temp = begin_temp_memory(part);
i32 cursor_max = layout->panel_max_count * 2;
Cursor_With_Index *cursors = push_array(part, Cursor_With_Index, cursor_max);
f32 y_offset = 0, y_position = 0;
i32 cursor_count = 0;
i32 panel_count = layout->panel_count;
Panel *current_panel = layout->panels;
for (i32 i = 0; i < panel_count; ++i, ++current_panel){
File_View *current_view = view_to_file_view(current_panel->view);
current_view = view_to_file_view(current_panel->view);
if (current_view && current_view->file == file){
view_measure_wraps(system, general, current_view);
write_cursor_with_index(cursors, &cursor_count, current_view->cursor.pos);
write_cursor_with_index(cursors, &cursor_count, current_view->mark);
write_cursor_with_index(cursors, &cursor_count, current_view->scroll_i);
write_cursor_with_index(cursors, &cursor_count, current_view->scroll_i - 1);
}
}
@ -2760,21 +2765,25 @@ file_edit_cursor_fix(System_Functions *system,
cursor_count = 0;
current_panel = layout->panels;
for (i32 i = 0; i < panel_count; ++i, ++current_panel){
File_View *current_view = view_to_file_view(current_panel->view);
current_view = view_to_file_view(current_panel->view);
if (current_view && current_view->file == file){
view_cursor_move(current_view, cursors[cursor_count++].pos);
current_view->preferred_x = view_get_cursor_x(current_view);
current_view->mark = cursors[cursor_count++].pos;
current_view->scroll_i = cursors[cursor_count++].pos;
current_view->scroll_i = cursors[cursor_count++].pos + 1;
temp_cursor = view_compute_cursor_from_pos(current_view, current_view->scroll_i);
y_offset = MOD(current_view->scroll_y, current_view->font_height);
if (current_view->unwrapped_lines){
current_view->target_y += (temp_cursor.unwrapped_y - current_view->scroll_y);
current_view->scroll_y = temp_cursor.unwrapped_y;
y_position = temp_cursor.unwrapped_y + y_offset;
current_view->target_y += (y_position - current_view->scroll_y);
current_view->scroll_y = y_position;
}
else{
current_view->target_y += (temp_cursor.wrapped_y - current_view->scroll_y);
current_view->scroll_y = temp_cursor.wrapped_y;
y_position = temp_cursor.wrapped_y + y_offset;
current_view->target_y += (y_position - current_view->scroll_y);
current_view->scroll_y = y_position;
}
}
}
@ -4189,19 +4198,19 @@ draw_file_bar(File_View *view, Interactive_Bar *bar, Render_Target *target){
intbar_draw_string(target, bar, line_number, base_color);
if (file){
if (!file->settings.unimportant){
switch (buffer_get_sync(file)){
case SYNC_BEHIND_OS:
{
persist String out_of_sync = make_lit_string(" !");
intbar_draw_string(target, bar, out_of_sync, pop2_color);
}break;
case SYNC_BEHIND_OS:
{
persist String out_of_sync = make_lit_string(" !");
intbar_draw_string(target, bar, out_of_sync, pop2_color);
}break;
case SYNC_UNSAVED:
{
persist String out_of_sync = make_lit_string(" *");
intbar_draw_string(target, bar, out_of_sync, pop2_color);
}break;
case SYNC_UNSAVED:
{
persist String out_of_sync = make_lit_string(" *");
intbar_draw_string(target, bar, out_of_sync, pop2_color);
}break;
}
}
}

View File

@ -21,37 +21,37 @@
#include <math.h>
#endif
inline real32
ABS(real32 x){
inline f32
ABS(f32 x){
if (x < 0) x = -x;
return x;
}
inline real32
MOD(real32 x, i32 m){
inline f32
MOD(f32 x, i32 m){
#if C_MATH
real32 whole, frac;
f32 whole, frac;
frac = modff(x, &whole);
return ((i32)(whole) % m) + frac;
#endif
}
inline real32
SQRT(real32 x){
inline f32
SQRT(f32 x){
#if C_MATH
return sqrt(x);
#endif
}
inline real32
SIN(real32 x_degrees){
inline f32
SIN(f32 x_degrees){
#if C_MATH
return sinf(x_degrees * DEG_TO_RAD);
#endif
}
inline real32
COS(real32 x_degrees){
inline f32
COS(f32 x_degrees){
#if C_MATH
return cosf(x_degrees * DEG_TO_RAD);
#endif

BIN
vc120.pdb

Binary file not shown.

View File

@ -75,6 +75,8 @@ struct Win32_Input_Chunk_Transient{
b8 mouse_r_press, mouse_r_release;
b32 out_of_window;
i16 mouse_wheel;
b32 redraw;
};
struct Win32_Input_Chunk_Persistent{
@ -411,7 +413,6 @@ Sys_Set_File_List_Sig(system_set_file_list){
info->folder = (find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
info->filename.str = name;
char *name_base = name;
i32 i = 0;
for(;find_data.cFileName[i];++i) *name++ = find_data.cFileName[i];
info->filename.size = i;
@ -1247,6 +1248,7 @@ Win32Callback(HWND hwnd, UINT uMsg,
i32 new_height = HIWORD(lParam);
Win32Resize(new_width, new_height);
win32vars.input_chunk.trans.redraw = 1;
}
}break;
@ -1378,6 +1380,8 @@ UpdateLoop(LPVOID param){
u32 redraw = exchange_vars.thread.force_redraw;
if (redraw) exchange_vars.thread.force_redraw = 0;
redraw = redraw || input_chunk.trans.redraw;
Key_Input_Data input_data;
Mouse_State mouse;