fixed multiple view editing scrolling issue

master
Allen Webster 2016-07-03 18:00:02 -04:00
parent 2e87d8bfaa
commit eec3475ee2
2 changed files with 27 additions and 40 deletions

View File

@ -1478,41 +1478,6 @@ execute_standard_build(Application_Links *app, View_Summary *view,
}
CUSTOM_COMMAND_SIG(build_search_regular){
// NOTE(allen|a3.3): An example of traversing the filesystem through parent
// directories looking for a file, in this case a batch file to execute.
//
//
// Step 1: Grab all of the user memory (or, you know, less if you've got better
// thing to do with some of it). Make a string and store the hot directory in it.
//
// Step 2: app->file_exists queries the file system to see if "<somedir>/build.bat" exists.
// If it does exist several parameters are pushed and cmdid_command_line is executed:
// - par_flags: flags for specifiying behaviors
// CLI_OverlapWithConflict - (on by default) if another CLI is still using the output buffer
// that process is detached from the buffer and this process executes outputing to the buffer
// CLI_AlwaysBindToView - if set, the current view always switches to the output buffer
// even if the output buffer is open in another view
//
// - par_name: the name of the buffer to fill with the output from the process
// - par_buffer_id: the buffer_id of the buffer to to fill with output
// If both are set buffer_id is used and the name is ignored.
// If neither is set the command runs without storing output anywhere.
//
// - par_cli_path: sets the path from which the command is executed
// If this parameter is unset the command runs from the hot directory.
//
// - par_cli_command: sets the actual command to be executed, this can be almost any
// command that you could execute through a command line interface.
// If this parameter is unset the command get's it's command from the range between
// the mark and cursor.
//
// Step 3: If the batch file did not exist change the dir string to the parent directory using
// app->directory_cd. The cd function can also be used to navigate to subdirectories.
// It returns true if it can actually move in the specified direction, and false otherwise.
//
// This doesn't actually change the hot directory of 4coder, it's only effect is to
// modify the string you passed in to reflect the change in directory if that change was possible.
unsigned int access = AccessAll;
View_Summary view = app->get_active_view(app, access);
Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);

View File

@ -592,6 +592,20 @@ view_set_scroll(View *view,
}
}
internal void
view_set_cursor_and_scroll(View *view,
Full_Cursor cursor,
b32 set_preferred_x,
b32 unwrapped_lines,
GUI_Scroll_Vars scroll){
File_Edit_Positions *edit_pos = view->edit_pos;
if (edit_pos_move_to_front(view->file_data.file, edit_pos)){
edit_pos_set_cursor_(edit_pos, cursor, set_preferred_x, unwrapped_lines);
edit_pos_set_scroll_(edit_pos, scroll);
edit_pos->last_set_type = EditPos_None;
}
}
struct View_And_ID{
View *view;
i32 id;
@ -1988,7 +2002,6 @@ file_edit_cursor_fix(System_Functions *system,
Editing_File *file, Editing_Layout *layout,
Cursor_Fix_Descriptor desc){
Full_Cursor temp_cursor;
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);
@ -2028,13 +2041,20 @@ file_edit_cursor_fix(System_Functions *system,
view = panel->view;
if (view->file_data.file == file){
Assert(view->edit_pos);
view_cursor_move(view, cursors[cursor_count++].pos);
i32 cursor_pos = cursors[cursor_count++].pos;
Full_Cursor new_cursor =
view_compute_cursor_from_pos(view, cursor_pos);
GUI_Scroll_Vars scroll = view->edit_pos->scroll;
view->edit_pos->mark = cursors[cursor_count++].pos + 1;
i32 new_scroll_i = cursors[cursor_count++].pos + 1;
if (view->edit_pos->scroll_i != new_scroll_i){
view->edit_pos->scroll_i = new_scroll_i;
temp_cursor = view_compute_cursor_from_pos(view, view->edit_pos->scroll_i);
Full_Cursor temp_cursor =
view_compute_cursor_from_pos(view, view->edit_pos->scroll_i);
f32 y_offset = MOD(view->edit_pos->scroll.scroll_y, view->line_height);
f32 y_position = temp_cursor.wrapped_y;
@ -2043,12 +2063,14 @@ file_edit_cursor_fix(System_Functions *system,
}
y_position += y_offset;
GUI_Scroll_Vars scroll = view->edit_pos->scroll;
scroll.target_y +=
ROUND32(y_position - scroll.scroll_y);
scroll.scroll_y = y_position;
view_set_scroll(view, scroll);
}
view_set_cursor_and_scroll(view, new_cursor,
true, view->file_data.unwrapped_lines,
scroll);
}
}
}