unifying use of working_set's table
This commit is contained in:
parent
959bdcd8cf
commit
5abea3ce3c
22
4ed.cpp
22
4ed.cpp
|
@ -789,6 +789,7 @@ app_open_file_background(App_Vars *vars, Exchange *exchange, Working_Set *workin
|
||||||
if (file_id){
|
if (file_id){
|
||||||
result.is_new = 1;
|
result.is_new = 1;
|
||||||
result.file = file.file;
|
result.file = file.file;
|
||||||
|
file_init_strings(result.file);
|
||||||
file_set_name(result.file, filename.str);
|
file_set_name(result.file, filename.str);
|
||||||
file_set_to_loading(result.file);
|
file_set_to_loading(result.file);
|
||||||
table_add(&working_set->table, result.file->name.source_path, file.index);
|
table_add(&working_set->table, result.file->name.source_path, file.index);
|
||||||
|
@ -923,16 +924,17 @@ COMMAND_DECL(save){
|
||||||
ProfileMomentFunction();
|
ProfileMomentFunction();
|
||||||
REQ_FILE_VIEW(view);
|
REQ_FILE_VIEW(view);
|
||||||
REQ_FILE(file, view);
|
REQ_FILE(file, view);
|
||||||
USE_VARS(vars);
|
USE_DELAY(delay);
|
||||||
USE_MEM(mem);
|
USE_PANEL(panel);
|
||||||
USE_EXCHANGE(exchange);
|
|
||||||
USE_WORKING_SET(working_set);
|
|
||||||
|
|
||||||
|
delayed_action(delay, DACT_SAVE, file->name.source_path, panel);
|
||||||
|
#if 0
|
||||||
String *file_path = &file->name.source_path;
|
String *file_path = &file->name.source_path;
|
||||||
if (file_path->size > 0){
|
if (file_path->size > 0){
|
||||||
i32 sys_id = file_save(system, exchange, mem, file, file_path->str);
|
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));
|
app_push_file_binding(vars, sys_id, get_file_id(working_set, file));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
COMMAND_DECL(interactive_save_as){
|
COMMAND_DECL(interactive_save_as){
|
||||||
|
@ -1678,6 +1680,7 @@ build(System_Functions *system, Mem_Options *mem,
|
||||||
Font_Set *font_set, Style *style,
|
Font_Set *font_set, Style *style,
|
||||||
Live_Views *live_set, Exchange *exchange,
|
Live_Views *live_set, Exchange *exchange,
|
||||||
Panel *panel, Command_Data *command,
|
Panel *panel, Command_Data *command,
|
||||||
|
String hot_directory,
|
||||||
char *buffer_name, i32 buffer_name_len,
|
char *buffer_name, i32 buffer_name_len,
|
||||||
char *path, i32 path_len,
|
char *path, i32 path_len,
|
||||||
char *script, i32 script_len,
|
char *script, i32 script_len,
|
||||||
|
@ -1725,7 +1728,7 @@ build(System_Functions *system, Mem_Options *mem,
|
||||||
if (file){
|
if (file){
|
||||||
file_create_super_locked(system, mem, file, buffer_name, font_set, style->font_id);
|
file_create_super_locked(system, mem, file, buffer_name, font_set, style->font_id);
|
||||||
file->settings.unimportant = 1;
|
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){
|
if (bind_to_new_view){
|
||||||
View *new_view = live_set_alloc_view(live_set, mem);
|
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,
|
view_set_file(system, file_view, file, font_set, style,
|
||||||
vars->hooks[hook_open_file], command, &app_links);
|
vars->hooks[hook_open_file], command, &app_links);
|
||||||
new_view->map = app_get_map(vars, file->settings.base_map_id);
|
new_view->map = app_get_map(vars, file->settings.base_map_id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
i32 i = vars->cli_processes.count++;
|
i32 i = vars->cli_processes.count++;
|
||||||
|
@ -1830,6 +1832,7 @@ COMMAND_DECL(build){
|
||||||
build(system, mem, vars, working_set,
|
build(system, mem, vars, working_set,
|
||||||
font_set, style, live_set, exchange,
|
font_set, style, live_set, exchange,
|
||||||
panel, command,
|
panel, command,
|
||||||
|
vars->hot_directory.string,
|
||||||
buffer_name, buffer_name_len,
|
buffer_name, buffer_name_len,
|
||||||
path, path_len,
|
path, path_len,
|
||||||
script, script_len,
|
script, script_len,
|
||||||
|
@ -1877,6 +1880,7 @@ COMMAND_DECL(build_here){
|
||||||
build(system, mem, vars, working_set,
|
build(system, mem, vars, working_set,
|
||||||
font_set, style, live_set, exchange,
|
font_set, style, live_set, exchange,
|
||||||
panel, command,
|
panel, command,
|
||||||
|
vars->hot_directory.string,
|
||||||
buffer_name, buffer_name_len,
|
buffer_name, buffer_name_len,
|
||||||
path.str, path.size,
|
path.str, path.size,
|
||||||
dir.str, dir.size,
|
dir.str, dir.size,
|
||||||
|
@ -3461,7 +3465,8 @@ App_Step_Sig(app_step){
|
||||||
if (fview){
|
if (fview){
|
||||||
Editing_File *file = fview->file;
|
Editing_File *file = fview->file;
|
||||||
if (file && !file->state.is_dummy){
|
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;
|
}break;
|
||||||
|
@ -3470,7 +3475,8 @@ App_Step_Sig(app_step){
|
||||||
{
|
{
|
||||||
Editing_File *file = working_set_lookup_file(working_set, *string);
|
Editing_File *file = working_set_lookup_file(working_set, *string);
|
||||||
if (!file->state.is_dummy){
|
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;
|
}break;
|
||||||
|
|
||||||
|
|
|
@ -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)){
|
if (do_file_option(100+i, state, layout, file->name.live_name, 0, message)){
|
||||||
result = 1;
|
result = 1;
|
||||||
*selected = 1;
|
*selected = 1;
|
||||||
copy(string, file->name.live_name);
|
copy(string, file->name.source_path);
|
||||||
terminate_with_null(string);
|
terminate_with_null(string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1205,15 +1205,18 @@ file_init_strings(Editing_File *file){
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
file_set_name(Editing_File *file, char *filename){
|
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);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
String f, ext;
|
String f, ext;
|
||||||
|
|
||||||
|
Assert(file->name.live_name.str != 0);
|
||||||
|
|
||||||
f = make_string_slowly(filename);
|
f = make_string_slowly(filename);
|
||||||
copy_checked(&file->name.source_path, f);
|
copy_checked(&file->name.source_path, f);
|
||||||
|
file->name.live_name.size = 0;
|
||||||
get_front_of_directory(&file->name.live_name, f);
|
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{
|
||||||
ext = file_extension(f);
|
ext = file_extension(f);
|
||||||
copy(&file->name.extension, ext);
|
copy(&file->name.extension, ext);
|
||||||
}
|
}
|
||||||
|
@ -1270,8 +1273,8 @@ inline b32
|
||||||
file_save_and_set_names(System_Functions *system, Exchange *exchange,
|
file_save_and_set_names(System_Functions *system, Exchange *exchange,
|
||||||
Mem_Options *mem, Editing_File *file, char *filename){
|
Mem_Options *mem, Editing_File *file, char *filename){
|
||||||
b32 result = 0;
|
b32 result = 0;
|
||||||
if (file_save(system, exchange, mem, file, filename)){
|
result = file_save(system, exchange, mem, file, filename);
|
||||||
result = 1;
|
if (result){
|
||||||
file_set_name(file, filename);
|
file_set_name(file, filename);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -2223,7 +2226,7 @@ view_compute_cursor_from_unwrapped_xy(File_View *view, f32 seek_x, f32 seek_y,
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Full_Cursor
|
internal Full_Cursor
|
||||||
view_compute_cursor_from_wrapped_xy(File_View *view, f32 seek_x, f32 seek_y,
|
view_compute_cursor_from_wrapped_xy(File_View *view, f32 seek_x, f32 seek_y,
|
||||||
b32 round_down = 0){
|
b32 round_down = 0){
|
||||||
#if BUFFER_EXPERIMENT_SCALPEL <= 3
|
#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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Full_Cursor
|
internal Full_Cursor
|
||||||
view_compute_cursor_from_line_pos(File_View *view, i32 line, i32 pos){
|
view_compute_cursor_from_line_pos(File_View *view, i32 line, i32 pos){
|
||||||
#if BUFFER_EXPERIMENT_SCALPEL <= 3
|
#if BUFFER_EXPERIMENT_SCALPEL <= 3
|
||||||
Editing_File *file = view->file;
|
Editing_File *file = view->file;
|
||||||
|
@ -2726,20 +2729,22 @@ file_edit_cursor_fix(System_Functions *system,
|
||||||
Editing_File *file, Editing_Layout *layout,
|
Editing_File *file, Editing_Layout *layout,
|
||||||
Cursor_Fix_Descriptor desc){
|
Cursor_Fix_Descriptor desc){
|
||||||
Full_Cursor temp_cursor;
|
Full_Cursor temp_cursor;
|
||||||
|
File_View *current_view;
|
||||||
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 * 2;
|
||||||
Cursor_With_Index *cursors = push_array(part, Cursor_With_Index, cursor_max);
|
Cursor_With_Index *cursors = push_array(part, Cursor_With_Index, cursor_max);
|
||||||
|
|
||||||
|
f32 y_offset = 0, y_position = 0;
|
||||||
i32 cursor_count = 0;
|
i32 cursor_count = 0;
|
||||||
i32 panel_count = layout->panel_count;
|
i32 panel_count = layout->panel_count;
|
||||||
Panel *current_panel = layout->panels;
|
Panel *current_panel = layout->panels;
|
||||||
for (i32 i = 0; i < panel_count; ++i, ++current_panel){
|
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){
|
if (current_view && current_view->file == file){
|
||||||
view_measure_wraps(system, general, current_view);
|
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->cursor.pos);
|
||||||
write_cursor_with_index(cursors, &cursor_count, current_view->mark);
|
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;
|
cursor_count = 0;
|
||||||
current_panel = layout->panels;
|
current_panel = layout->panels;
|
||||||
for (i32 i = 0; i < panel_count; ++i, ++current_panel){
|
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){
|
if (current_view && current_view->file == file){
|
||||||
view_cursor_move(current_view, cursors[cursor_count++].pos);
|
view_cursor_move(current_view, cursors[cursor_count++].pos);
|
||||||
current_view->preferred_x = view_get_cursor_x(current_view);
|
current_view->preferred_x = view_get_cursor_x(current_view);
|
||||||
|
|
||||||
current_view->mark = cursors[cursor_count++].pos;
|
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);
|
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){
|
if (current_view->unwrapped_lines){
|
||||||
current_view->target_y += (temp_cursor.unwrapped_y - current_view->scroll_y);
|
y_position = temp_cursor.unwrapped_y + y_offset;
|
||||||
current_view->scroll_y = temp_cursor.unwrapped_y;
|
current_view->target_y += (y_position - current_view->scroll_y);
|
||||||
|
current_view->scroll_y = y_position;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
current_view->target_y += (temp_cursor.wrapped_y - current_view->scroll_y);
|
y_position = temp_cursor.wrapped_y + y_offset;
|
||||||
current_view->scroll_y = temp_cursor.wrapped_y;
|
current_view->target_y += (y_position - current_view->scroll_y);
|
||||||
|
current_view->scroll_y = y_position;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4189,7 +4198,7 @@ draw_file_bar(File_View *view, Interactive_Bar *bar, Render_Target *target){
|
||||||
|
|
||||||
intbar_draw_string(target, bar, line_number, base_color);
|
intbar_draw_string(target, bar, line_number, base_color);
|
||||||
|
|
||||||
if (file){
|
if (!file->settings.unimportant){
|
||||||
switch (buffer_get_sync(file)){
|
switch (buffer_get_sync(file)){
|
||||||
case SYNC_BEHIND_OS:
|
case SYNC_BEHIND_OS:
|
||||||
{
|
{
|
||||||
|
|
22
4ed_math.cpp
22
4ed_math.cpp
|
@ -21,37 +21,37 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inline real32
|
inline f32
|
||||||
ABS(real32 x){
|
ABS(f32 x){
|
||||||
if (x < 0) x = -x;
|
if (x < 0) x = -x;
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline real32
|
inline f32
|
||||||
MOD(real32 x, i32 m){
|
MOD(f32 x, i32 m){
|
||||||
#if C_MATH
|
#if C_MATH
|
||||||
real32 whole, frac;
|
f32 whole, frac;
|
||||||
frac = modff(x, &whole);
|
frac = modff(x, &whole);
|
||||||
return ((i32)(whole) % m) + frac;
|
return ((i32)(whole) % m) + frac;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline real32
|
inline f32
|
||||||
SQRT(real32 x){
|
SQRT(f32 x){
|
||||||
#if C_MATH
|
#if C_MATH
|
||||||
return sqrt(x);
|
return sqrt(x);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline real32
|
inline f32
|
||||||
SIN(real32 x_degrees){
|
SIN(f32 x_degrees){
|
||||||
#if C_MATH
|
#if C_MATH
|
||||||
return sinf(x_degrees * DEG_TO_RAD);
|
return sinf(x_degrees * DEG_TO_RAD);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline real32
|
inline f32
|
||||||
COS(real32 x_degrees){
|
COS(f32 x_degrees){
|
||||||
#if C_MATH
|
#if C_MATH
|
||||||
return cosf(x_degrees * DEG_TO_RAD);
|
return cosf(x_degrees * DEG_TO_RAD);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -75,6 +75,8 @@ struct Win32_Input_Chunk_Transient{
|
||||||
b8 mouse_r_press, mouse_r_release;
|
b8 mouse_r_press, mouse_r_release;
|
||||||
b32 out_of_window;
|
b32 out_of_window;
|
||||||
i16 mouse_wheel;
|
i16 mouse_wheel;
|
||||||
|
|
||||||
|
b32 redraw;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Win32_Input_Chunk_Persistent{
|
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->folder = (find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
|
||||||
info->filename.str = name;
|
info->filename.str = name;
|
||||||
|
|
||||||
char *name_base = name;
|
|
||||||
i32 i = 0;
|
i32 i = 0;
|
||||||
for(;find_data.cFileName[i];++i) *name++ = find_data.cFileName[i];
|
for(;find_data.cFileName[i];++i) *name++ = find_data.cFileName[i];
|
||||||
info->filename.size = i;
|
info->filename.size = i;
|
||||||
|
@ -1247,6 +1248,7 @@ Win32Callback(HWND hwnd, UINT uMsg,
|
||||||
i32 new_height = HIWORD(lParam);
|
i32 new_height = HIWORD(lParam);
|
||||||
|
|
||||||
Win32Resize(new_width, new_height);
|
Win32Resize(new_width, new_height);
|
||||||
|
win32vars.input_chunk.trans.redraw = 1;
|
||||||
}
|
}
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
|
@ -1378,6 +1380,8 @@ UpdateLoop(LPVOID param){
|
||||||
|
|
||||||
u32 redraw = exchange_vars.thread.force_redraw;
|
u32 redraw = exchange_vars.thread.force_redraw;
|
||||||
if (redraw) exchange_vars.thread.force_redraw = 0;
|
if (redraw) exchange_vars.thread.force_redraw = 0;
|
||||||
|
redraw = redraw || input_chunk.trans.redraw;
|
||||||
|
|
||||||
|
|
||||||
Key_Input_Data input_data;
|
Key_Input_Data input_data;
|
||||||
Mouse_State mouse;
|
Mouse_State mouse;
|
||||||
|
|
Loading…
Reference in New Issue