codified the view/file getting rule
This commit is contained in:
parent
df6eaf7e29
commit
f8c5738dc1
4
4ed.cpp
4
4ed.cpp
|
@ -983,9 +983,9 @@ update_command_data(App_Vars *vars, Command_Data *cmd){
|
||||||
|
|
||||||
globalvar Command_Function command_table[cmdid_count];
|
globalvar Command_Function command_table[cmdid_count];
|
||||||
|
|
||||||
extern "C"{
|
//extern "C"{
|
||||||
#include "4ed_api_implementation.cpp"
|
#include "4ed_api_implementation.cpp"
|
||||||
}
|
//}
|
||||||
|
|
||||||
struct Command_In{
|
struct Command_In{
|
||||||
Command_Data *cmd;
|
Command_Data *cmd;
|
||||||
|
|
|
@ -25,6 +25,12 @@ fill_buffer_summary(Buffer_Summary *buffer, Editing_File *file, Working_Set *wor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void
|
||||||
|
fill_buffer_summary(Buffer_Summary *buffer, Editing_File *file, Command_Data *cmd){
|
||||||
|
Working_Set *working_set = &cmd->models->working_set;
|
||||||
|
fill_buffer_summary(buffer, file, working_set);
|
||||||
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
fill_view_summary(View_Summary *view, View *vptr, Live_Views *live_set, Working_Set *working_set){
|
fill_view_summary(View_Summary *view, View *vptr, Live_Views *live_set, Working_Set *working_set){
|
||||||
i32 lock_level;
|
i32 lock_level;
|
||||||
|
@ -74,6 +80,11 @@ fill_view_summary(View_Summary *view, View *vptr, Live_Views *live_set, Working_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void
|
||||||
|
fill_view_summary(View_Summary *view, View *vptr, Command_Data *cmd){
|
||||||
|
fill_view_summary(view, vptr, &cmd->vars->live_set, &cmd->models->working_set);
|
||||||
|
}
|
||||||
|
|
||||||
internal Editing_File*
|
internal Editing_File*
|
||||||
get_file_from_identifier(System_Functions *system, Working_Set *working_set, Buffer_Identifier buffer){
|
get_file_from_identifier(System_Functions *system, Working_Set *working_set, Buffer_Identifier buffer){
|
||||||
i32 buffer_id = buffer.id;
|
i32 buffer_id = buffer.id;
|
||||||
|
@ -92,7 +103,7 @@ get_file_from_identifier(System_Functions *system, Working_Set *working_set, Buf
|
||||||
return(file);
|
return(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
String
|
internal String
|
||||||
make_string_terminated(Partition *part, char *str, int len){
|
make_string_terminated(Partition *part, char *str, int len){
|
||||||
char *space = (char*)push_array(part, char, len + 1);
|
char *space = (char*)push_array(part, char, len + 1);
|
||||||
String string = make_string(str, len, len+1);
|
String string = make_string(str, len, len+1);
|
||||||
|
@ -102,6 +113,36 @@ make_string_terminated(Partition *part, char *str, int len){
|
||||||
return(string);
|
return(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal Editing_File*
|
||||||
|
imp_get_file(Command_Data *cmd, Buffer_Summary *buffer){
|
||||||
|
Editing_File *file = 0;
|
||||||
|
Working_Set *working_set = &cmd->models->working_set;;
|
||||||
|
|
||||||
|
if (buffer->exists){
|
||||||
|
file = working_set_get_active_file(working_set, buffer->buffer_id);
|
||||||
|
if (file != 0 && !file_is_ready(file)){
|
||||||
|
file = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal View*
|
||||||
|
imp_get_view(Command_Data *cmd, View_Summary *view){
|
||||||
|
View *vptr = 0;
|
||||||
|
Live_Views *live_set = cmd->live_set;
|
||||||
|
int view_id = view->view_id - 1;
|
||||||
|
|
||||||
|
if (view->exists){
|
||||||
|
if (view_id >= 0 && view_id < live_set->max){
|
||||||
|
vptr = live_set->views + view_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return(vptr);
|
||||||
|
}
|
||||||
|
|
||||||
EXEC_COMMAND_SIG(external_exec_command){
|
EXEC_COMMAND_SIG(external_exec_command){
|
||||||
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||||
Command_Function function = command_table[command_id];
|
Command_Function function = command_table[command_id];
|
||||||
|
@ -409,13 +450,11 @@ REFRESH_BUFFER_SIG(external_refresh_buffer){
|
||||||
BUFFER_SEEK_SIG(external_buffer_seek){
|
BUFFER_SEEK_SIG(external_buffer_seek){
|
||||||
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||||
Editing_File *file;
|
Editing_File *file;
|
||||||
Working_Set *working_set;
|
int result = false;
|
||||||
int result = 0;
|
|
||||||
|
|
||||||
if (buffer->exists){
|
file = imp_get_file(cmd, buffer);
|
||||||
working_set = &cmd->models->working_set;
|
|
||||||
file = working_set_get_active_file(working_set, buffer->buffer_id);
|
if (file){
|
||||||
if (file && file_is_ready(file)){
|
|
||||||
// TODO(allen): reduce duplication?
|
// TODO(allen): reduce duplication?
|
||||||
{
|
{
|
||||||
i32 size = buffer_size(&file->state.buffer);
|
i32 size = buffer_size(&file->state.buffer);
|
||||||
|
@ -496,8 +535,7 @@ BUFFER_SEEK_SIG(external_buffer_seek){
|
||||||
result = new_pos;
|
result = new_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
fill_buffer_summary(buffer, file, working_set);
|
fill_buffer_summary(buffer, file, cmd);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return(result);
|
return(result);
|
||||||
|
@ -505,22 +543,17 @@ BUFFER_SEEK_SIG(external_buffer_seek){
|
||||||
|
|
||||||
BUFFER_READ_RANGE_SIG(external_buffer_read_range){
|
BUFFER_READ_RANGE_SIG(external_buffer_read_range){
|
||||||
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||||
Editing_File *file;
|
Editing_File *file = imp_get_file(cmd, buffer);
|
||||||
Working_Set *working_set;
|
int result = false;
|
||||||
int result = 0;
|
|
||||||
int size;
|
int size;
|
||||||
|
|
||||||
if (buffer->exists){
|
if (file){
|
||||||
working_set = &cmd->models->working_set;
|
|
||||||
file = working_set_get_active_file(working_set, buffer->buffer_id);
|
|
||||||
if (file && file_is_ready(file)){
|
|
||||||
size = buffer_size(&file->state.buffer);
|
size = buffer_size(&file->state.buffer);
|
||||||
if (0 <= start && start <= end && end <= size){
|
if (0 <= start && start <= end && end <= size){
|
||||||
result = 1;
|
result = true;
|
||||||
buffer_stringify(&file->state.buffer, start, end, out);
|
buffer_stringify(&file->state.buffer, start, end, out);
|
||||||
}
|
}
|
||||||
fill_buffer_summary(buffer, file, working_set);
|
fill_buffer_summary(buffer, file, cmd);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return(result);
|
return(result);
|
||||||
|
@ -528,20 +561,13 @@ BUFFER_READ_RANGE_SIG(external_buffer_read_range){
|
||||||
|
|
||||||
BUFFER_REPLACE_RANGE_SIG(external_buffer_replace_range){
|
BUFFER_REPLACE_RANGE_SIG(external_buffer_replace_range){
|
||||||
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||||
Editing_File *file;
|
Editing_File *file = imp_get_file(cmd, buffer);
|
||||||
Working_Set *working_set;
|
|
||||||
|
|
||||||
Models *models;
|
int result = false;
|
||||||
|
int size = 0;
|
||||||
|
int next_cursor = 0, pos = 0;
|
||||||
|
|
||||||
int result = 0;
|
if (file){
|
||||||
int size;
|
|
||||||
int next_cursor, pos;
|
|
||||||
|
|
||||||
if (buffer->exists){
|
|
||||||
models = cmd->models;
|
|
||||||
working_set = &models->working_set;
|
|
||||||
file = working_set_get_active_file(working_set, buffer->buffer_id);
|
|
||||||
if (file && file_is_ready(file)){
|
|
||||||
size = buffer_size(&file->state.buffer);
|
size = buffer_size(&file->state.buffer);
|
||||||
if (0 <= start && start <= end && end <= size){
|
if (0 <= start && start <= end && end <= size){
|
||||||
result = 1;
|
result = 1;
|
||||||
|
@ -551,57 +577,27 @@ BUFFER_REPLACE_RANGE_SIG(external_buffer_replace_range){
|
||||||
else if (pos < end) next_cursor = start;
|
else if (pos < end) next_cursor = start;
|
||||||
else next_cursor = pos + end - start - len;
|
else next_cursor = pos + end - start - len;
|
||||||
|
|
||||||
file_replace_range(cmd->system, models, file, start, end, str, len, next_cursor);
|
file_replace_range(cmd->system, cmd->models,
|
||||||
}
|
file, start, end, str, len, next_cursor);
|
||||||
fill_buffer_summary(buffer, file, working_set);
|
|
||||||
}
|
}
|
||||||
|
fill_buffer_summary(buffer, file, cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
BUFFER_SET_POS_SIG(external_buffer_set_pos){
|
|
||||||
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
||||||
Editing_File *file;
|
|
||||||
Working_Set *working_set;
|
|
||||||
|
|
||||||
int result = 0;
|
|
||||||
int size;
|
|
||||||
|
|
||||||
if (buffer->exists){
|
|
||||||
working_set = &cmd->models->working_set;
|
|
||||||
file = working_set_get_active_file(working_set, buffer->buffer_id);
|
|
||||||
if (file && file_is_ready(file)){
|
|
||||||
result = 1;
|
|
||||||
size = buffer_size(&file->state.buffer);
|
|
||||||
if (pos < 0) pos = 0;
|
|
||||||
if (pos > size) pos = size;
|
|
||||||
file->state.cursor_pos = pos;
|
|
||||||
fill_buffer_summary(buffer, file, working_set);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return(result);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
BUFFER_SET_SETTING_SIG(external_buffer_set_setting){
|
BUFFER_SET_SETTING_SIG(external_buffer_set_setting){
|
||||||
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||||
System_Functions *system = cmd->system;
|
System_Functions *system = cmd->system;
|
||||||
Models *models = cmd->models;
|
Models *models = cmd->models;
|
||||||
|
|
||||||
Editing_File *file;
|
Editing_File *file = imp_get_file(cmd, buffer);
|
||||||
Working_Set *working_set;
|
|
||||||
|
|
||||||
int result = false;
|
int result = false;
|
||||||
|
|
||||||
i32 new_mapid = 0;
|
i32 new_mapid = 0;
|
||||||
|
|
||||||
if (buffer->exists){
|
if (file){
|
||||||
working_set = &models->working_set;
|
|
||||||
file = working_set_get_active_file(working_set, buffer->buffer_id);
|
|
||||||
if (file && file_is_ready(file)){
|
|
||||||
result = true;
|
result = true;
|
||||||
switch (setting){
|
switch (setting){
|
||||||
case BufferSetting_Lex:
|
case BufferSetting_Lex:
|
||||||
|
@ -650,9 +646,7 @@ BUFFER_SET_SETTING_SIG(external_buffer_set_setting){
|
||||||
}
|
}
|
||||||
}break;
|
}break;
|
||||||
}
|
}
|
||||||
}
|
fill_buffer_summary(buffer, file, cmd);
|
||||||
|
|
||||||
fill_buffer_summary(buffer, file, working_set);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return(result);
|
return(result);
|
||||||
|
@ -663,20 +657,15 @@ BUFFER_SAVE_SIG(external_buffer_save){
|
||||||
System_Functions *system = cmd->system;
|
System_Functions *system = cmd->system;
|
||||||
Models *models = cmd->models;
|
Models *models = cmd->models;
|
||||||
|
|
||||||
Editing_File *file;
|
Editing_File *file = imp_get_file(cmd, buffer);
|
||||||
Working_Set *working_set;
|
|
||||||
|
|
||||||
int result = false;
|
int result = false;
|
||||||
|
|
||||||
if (buffer->exists){
|
if (file){
|
||||||
working_set = &models->working_set;
|
|
||||||
file = working_set_get_active_file(working_set, buffer->buffer_id);
|
|
||||||
if (file && !file->is_dummy && file_is_ready(file)){
|
|
||||||
result = true;
|
result = true;
|
||||||
String name = make_string(filename, filename_len);
|
String name = make_string(filename, filename_len);
|
||||||
view_save_file(system, models, file, 0, name, 0);
|
view_save_file(system, models, file, 0, name, 0);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
@ -689,7 +678,7 @@ GET_VIEW_FIRST_SIG(external_get_view_first){
|
||||||
Panel *panel = layout->used_sentinel.next;
|
Panel *panel = layout->used_sentinel.next;
|
||||||
|
|
||||||
Assert(panel != &layout->used_sentinel);
|
Assert(panel != &layout->used_sentinel);
|
||||||
fill_view_summary(&view, panel->view, &cmd->vars->live_set, &cmd->models->working_set);
|
fill_view_summary(&view, panel->view, cmd);
|
||||||
|
|
||||||
return(view);
|
return(view);
|
||||||
}
|
}
|
||||||
|
@ -755,16 +744,10 @@ VIEW_AUTO_TAB_SIG(external_view_auto_tab){
|
||||||
|
|
||||||
int result = false;
|
int result = false;
|
||||||
|
|
||||||
Live_Views *live_set;
|
Editing_File *file = 0;
|
||||||
Editing_File *file;
|
View *vptr = imp_get_view(cmd, view);
|
||||||
View *vptr;
|
|
||||||
int view_id;
|
|
||||||
|
|
||||||
if (view->exists){
|
if (vptr){
|
||||||
live_set = cmd->live_set;
|
|
||||||
view_id = view->view_id - 1;
|
|
||||||
if (view_id >= 0 && view_id < live_set->max){
|
|
||||||
vptr = live_set->views + view_id;
|
|
||||||
file = vptr->file_data.file;
|
file = vptr->file_data.file;
|
||||||
|
|
||||||
if (file && file->state.token_stack.tokens &&
|
if (file && file->state.token_stack.tokens &&
|
||||||
|
@ -777,7 +760,8 @@ VIEW_AUTO_TAB_SIG(external_view_auto_tab){
|
||||||
opts.tab_width = tab_width;
|
opts.tab_width = tab_width;
|
||||||
|
|
||||||
view_auto_tab_tokens(system, models, vptr, start, end, opts);
|
view_auto_tab_tokens(system, models, vptr, start, end, opts);
|
||||||
}
|
|
||||||
|
fill_view_summary(view, vptr, cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -786,25 +770,18 @@ VIEW_AUTO_TAB_SIG(external_view_auto_tab){
|
||||||
|
|
||||||
VIEW_COMPUTE_CURSOR_SIG(external_view_compute_cursor){
|
VIEW_COMPUTE_CURSOR_SIG(external_view_compute_cursor){
|
||||||
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||||
Live_Views *live_set;
|
View *vptr = imp_get_view(cmd, view);
|
||||||
View *vptr;
|
Editing_File *file = 0;
|
||||||
Editing_File *file;
|
|
||||||
Full_Cursor result = {0};
|
Full_Cursor result = {0};
|
||||||
int view_id;
|
|
||||||
|
|
||||||
if (view->exists){
|
if (vptr){
|
||||||
live_set = cmd->live_set;
|
|
||||||
view_id = view->view_id - 1;
|
|
||||||
if (view_id >= 0 && view_id < live_set->max){
|
|
||||||
vptr = live_set->views + view_id;
|
|
||||||
file = vptr->file_data.file;
|
file = vptr->file_data.file;
|
||||||
if (file && !file->is_loading){
|
if (file && !file->is_loading){
|
||||||
if (seek.type == buffer_seek_line_char && seek.character <= 0){
|
if (seek.type == buffer_seek_line_char && seek.character <= 0){
|
||||||
seek.character = 1;
|
seek.character = 1;
|
||||||
}
|
}
|
||||||
result = view_compute_cursor(vptr, seek);
|
result = view_compute_cursor(vptr, seek);
|
||||||
fill_view_summary(view, vptr, live_set, &cmd->models->working_set);
|
fill_view_summary(view, vptr, cmd);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -813,20 +790,14 @@ VIEW_COMPUTE_CURSOR_SIG(external_view_compute_cursor){
|
||||||
|
|
||||||
VIEW_SET_CURSOR_SIG(external_view_set_cursor){
|
VIEW_SET_CURSOR_SIG(external_view_set_cursor){
|
||||||
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||||
Live_Views *live_set;
|
View *vptr = imp_get_view(cmd, view);
|
||||||
View *vptr;
|
Editing_File *file = 0;
|
||||||
Editing_File *file;
|
int result = false;
|
||||||
int result = 0;
|
|
||||||
int view_id;
|
|
||||||
|
|
||||||
if (view->exists){
|
if (vptr){
|
||||||
live_set = cmd->live_set;
|
|
||||||
view_id = view->view_id - 1;
|
|
||||||
if (view_id >= 0 && view_id < live_set->max){
|
|
||||||
vptr = live_set->views + view_id;
|
|
||||||
file = vptr->file_data.file;
|
file = vptr->file_data.file;
|
||||||
if (file && !file->is_loading){
|
if (file && !file->is_loading){
|
||||||
result = 1;
|
result = true;
|
||||||
if (seek.type == buffer_seek_line_char && seek.character <= 0){
|
if (seek.type == buffer_seek_line_char && seek.character <= 0){
|
||||||
seek.character = 1;
|
seek.character = 1;
|
||||||
}
|
}
|
||||||
|
@ -834,29 +805,22 @@ VIEW_SET_CURSOR_SIG(external_view_set_cursor){
|
||||||
if (set_preferred_x){
|
if (set_preferred_x){
|
||||||
vptr->recent->preferred_x = view_get_cursor_x(vptr);
|
vptr->recent->preferred_x = view_get_cursor_x(vptr);
|
||||||
}
|
}
|
||||||
fill_view_summary(view, vptr, live_set, &cmd->models->working_set);
|
fill_view_summary(view, vptr, cmd);
|
||||||
file->state.cursor_pos = vptr->recent->cursor.pos;
|
file->state.cursor_pos = vptr->recent->cursor.pos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
VIEW_SET_MARK_SIG(external_view_set_mark){
|
VIEW_SET_MARK_SIG(external_view_set_mark){
|
||||||
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||||
Live_Views *live_set;
|
View *vptr = imp_get_view(cmd, view);
|
||||||
View *vptr;
|
Full_Cursor cursor = {0};
|
||||||
Full_Cursor cursor;
|
int result = false;
|
||||||
int result = 0;
|
|
||||||
int view_id;
|
|
||||||
|
|
||||||
if (view->exists){
|
if (vptr){
|
||||||
live_set = cmd->live_set;
|
result = true;
|
||||||
view_id = view->view_id - 1;
|
|
||||||
if (view_id >= 0 && view_id < live_set->max){
|
|
||||||
vptr = live_set->views + view_id;
|
|
||||||
result = 1;
|
|
||||||
if (seek.type != buffer_seek_pos){
|
if (seek.type != buffer_seek_pos){
|
||||||
cursor = view_compute_cursor(vptr, seek);
|
cursor = view_compute_cursor(vptr, seek);
|
||||||
vptr->recent->mark = cursor.pos;
|
vptr->recent->mark = cursor.pos;
|
||||||
|
@ -864,8 +828,7 @@ VIEW_SET_MARK_SIG(external_view_set_mark){
|
||||||
else{
|
else{
|
||||||
vptr->recent->mark = seek.pos;
|
vptr->recent->mark = seek.pos;
|
||||||
}
|
}
|
||||||
fill_view_summary(view, vptr, live_set, &cmd->models->working_set);
|
fill_view_summary(view, vptr, cmd);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return(result);
|
return(result);
|
||||||
|
@ -873,25 +836,18 @@ VIEW_SET_MARK_SIG(external_view_set_mark){
|
||||||
|
|
||||||
VIEW_SET_HIGHLIGHT_SIG(external_view_set_highlight){
|
VIEW_SET_HIGHLIGHT_SIG(external_view_set_highlight){
|
||||||
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||||
Live_Views *live_set;
|
View *vptr = imp_get_view(cmd, view);
|
||||||
View *vptr;
|
int result = false;
|
||||||
int result = 0;
|
|
||||||
int view_id;
|
|
||||||
|
|
||||||
if (view->exists){
|
if (vptr){
|
||||||
live_set = cmd->live_set;
|
result = true;
|
||||||
view_id = view->view_id - 1;
|
|
||||||
if (view_id >= 0 && view_id < live_set->max){
|
|
||||||
vptr = live_set->views + view_id;
|
|
||||||
result = 1;
|
|
||||||
if (turn_on){
|
if (turn_on){
|
||||||
view_set_temp_highlight(vptr, start, end);
|
view_set_temp_highlight(vptr, start, end);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
vptr->file_data.show_temp_highlight = 0;
|
vptr->file_data.show_temp_highlight = 0;
|
||||||
}
|
}
|
||||||
fill_view_summary(view, vptr, live_set, &cmd->models->working_set);
|
fill_view_summary(view, vptr, cmd);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return(result);
|
return(result);
|
||||||
|
@ -899,33 +855,23 @@ VIEW_SET_HIGHLIGHT_SIG(external_view_set_highlight){
|
||||||
|
|
||||||
VIEW_SET_BUFFER_SIG(external_view_set_buffer){
|
VIEW_SET_BUFFER_SIG(external_view_set_buffer){
|
||||||
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||||
Live_Views *live_set;
|
View *vptr = imp_get_view(cmd, view);
|
||||||
View *vptr;
|
Models *models = cmd->models;
|
||||||
Editing_File *file;
|
Editing_File *file = 0;
|
||||||
Working_Set *working_set;
|
int result = false;
|
||||||
Models *models;
|
|
||||||
int result = 0;
|
|
||||||
int view_id;
|
|
||||||
|
|
||||||
if (view->exists){
|
if (vptr){
|
||||||
models = cmd->models;
|
file = working_set_get_active_file(&models->working_set, buffer_id);
|
||||||
live_set = cmd->live_set;
|
|
||||||
view_id = view->view_id - 1;
|
|
||||||
if (view_id >= 0 && view_id < live_set->max){
|
|
||||||
vptr = live_set->views + view_id;
|
|
||||||
working_set = &models->working_set;
|
|
||||||
file = working_set_get_active_file(working_set, buffer_id);
|
|
||||||
|
|
||||||
if (file){
|
if (file){
|
||||||
result = 1;
|
result = true;
|
||||||
if (file != vptr->file_data.file){
|
if (file != vptr->file_data.file){
|
||||||
view_set_file(vptr, file, models);
|
view_set_file(vptr, file, models);
|
||||||
view_show_file(vptr);
|
view_show_file(vptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fill_view_summary(view, vptr, live_set, working_set);
|
fill_view_summary(view, vptr, cmd);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return(result);
|
return(result);
|
||||||
|
@ -933,72 +879,37 @@ VIEW_SET_BUFFER_SIG(external_view_set_buffer){
|
||||||
|
|
||||||
VIEW_POST_FADE_SIG(external_view_post_fade){
|
VIEW_POST_FADE_SIG(external_view_post_fade){
|
||||||
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||||
|
View *vptr = imp_get_view(cmd, view);
|
||||||
Live_Views *live_set;
|
|
||||||
View *vptr;
|
|
||||||
Models *models;
|
|
||||||
int view_id;
|
|
||||||
|
|
||||||
int result = false;
|
int result = false;
|
||||||
|
|
||||||
if (view->exists){
|
|
||||||
models = cmd->models;
|
|
||||||
live_set = cmd->live_set;
|
|
||||||
view_id = view->view_id - 1;
|
|
||||||
if (view_id >= 0 && view_id < live_set->max){
|
|
||||||
vptr = live_set->views + view_id;
|
|
||||||
|
|
||||||
if (end > start){
|
|
||||||
int size = end - start;
|
int size = end - start;
|
||||||
|
|
||||||
|
if (vptr){
|
||||||
|
if (size > 0){
|
||||||
result = true;
|
result = true;
|
||||||
view_post_paste_effect(vptr, ticks, start, size, color);
|
view_post_paste_effect(vptr, ticks, start, size, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(allen): standardize the safe get view/buffer code
|
|
||||||
VIEW_SET_PASTE_REWRITE__SIG(external_view_set_paste_rewrite_){
|
VIEW_SET_PASTE_REWRITE__SIG(external_view_set_paste_rewrite_){
|
||||||
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||||
|
View *vptr = imp_get_view(cmd, view);
|
||||||
Live_Views *live_set;
|
if (vptr){
|
||||||
View *vptr;
|
|
||||||
Models *models;
|
|
||||||
int view_id;
|
|
||||||
|
|
||||||
if (view->exists){
|
|
||||||
models = cmd->models;
|
|
||||||
live_set = cmd->live_set;
|
|
||||||
view_id = view->view_id - 1;
|
|
||||||
if (view_id >= 0 && view_id < live_set->max){
|
|
||||||
vptr = live_set->views + view_id;
|
|
||||||
vptr->next_mode.rewrite = true;
|
vptr->next_mode.rewrite = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
VIEW_GET_PASTE_REWRITE__SIG(external_view_get_paste_rewrite_){
|
VIEW_GET_PASTE_REWRITE__SIG(external_view_get_paste_rewrite_){
|
||||||
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||||
|
View *vptr = imp_get_view(cmd, view);
|
||||||
Live_Views *live_set;
|
|
||||||
View *vptr;
|
|
||||||
Models *models;
|
|
||||||
int view_id;
|
|
||||||
|
|
||||||
int result = false;
|
int result = false;
|
||||||
|
if (vptr){
|
||||||
if (view->exists){
|
|
||||||
models = cmd->models;
|
|
||||||
live_set = cmd->live_set;
|
|
||||||
view_id = view->view_id - 1;
|
|
||||||
if (view_id >= 0 && view_id < live_set->max){
|
|
||||||
vptr = live_set->views + view_id;
|
|
||||||
result = vptr->mode.rewrite;
|
result = vptr->mode.rewrite;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1014,7 +925,8 @@ VIEW_OPEN_FILE_SIG(external_view_open_file){
|
||||||
|
|
||||||
int result = false;
|
int result = false;
|
||||||
|
|
||||||
// TODO(allen): do in background option
|
// TODO(allen): do in background
|
||||||
|
// option happens in parallel.
|
||||||
|
|
||||||
Partition *part = &models->mem.part;
|
Partition *part = &models->mem.part;
|
||||||
Temp_Memory temp = begin_temp_memory(part);
|
Temp_Memory temp = begin_temp_memory(part);
|
||||||
|
@ -1045,28 +957,19 @@ VIEW_OPEN_FILE_SIG(external_view_open_file){
|
||||||
VIEW_KILL_BUFFER_SIG(external_view_kill_buffer){
|
VIEW_KILL_BUFFER_SIG(external_view_kill_buffer){
|
||||||
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
||||||
System_Functions *system = cmd->system;
|
System_Functions *system = cmd->system;
|
||||||
Live_Views *live_set;
|
Models *models = cmd->models;
|
||||||
View *vptr;
|
Working_Set *working_set = &models->working_set;
|
||||||
Editing_File *file;
|
View *vptr = imp_get_view(cmd, view);
|
||||||
Working_Set *working_set;
|
Editing_File *file = 0;
|
||||||
Models *models;
|
|
||||||
int result = false;
|
int result = false;
|
||||||
int view_id;
|
|
||||||
|
|
||||||
if (view->exists){
|
if (vptr){
|
||||||
models = cmd->models;
|
|
||||||
live_set = cmd->live_set;
|
|
||||||
view_id = view->view_id - 1;
|
|
||||||
if (view_id >= 0 && view_id < live_set->max){
|
|
||||||
vptr = live_set->views + view_id;
|
|
||||||
working_set = &models->working_set;
|
|
||||||
file = get_file_from_identifier(system, working_set, buffer);
|
file = get_file_from_identifier(system, working_set, buffer);
|
||||||
|
|
||||||
if (file){
|
if (file){
|
||||||
result = true;
|
result = true;
|
||||||
try_kill_file(system, models, file, vptr, string_zero());
|
try_kill_file(system, models, file, vptr, string_zero());
|
||||||
fill_view_summary(view, vptr, live_set, working_set);
|
fill_view_summary(view, vptr, cmd);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,6 @@ Buffer_Summary Get_Buffer_By_Name(Application_Links *app, char *filename, int le
|
||||||
int Refresh_Buffer(Application_Links *app, Buffer_Summary *buffer);
|
int Refresh_Buffer(Application_Links *app, Buffer_Summary *buffer);
|
||||||
int Buffer_Read_Range(Application_Links *app, Buffer_Summary *buffer, int start, int end, char *out);
|
int Buffer_Read_Range(Application_Links *app, Buffer_Summary *buffer, int start, int end, char *out);
|
||||||
int Buffer_Replace_Range(Application_Links *app, Buffer_Summary *buffer, int start, int end, char *str, int len);
|
int Buffer_Replace_Range(Application_Links *app, Buffer_Summary *buffer, int start, int end, char *str, int len);
|
||||||
//int Buffer_Set_Pos(Application_Links *app, Buffer_Summary *buffer, int pos);
|
|
||||||
|
|
||||||
int Buffer_Seek(Application_Links *app, Buffer_Summary *buffer, int start_pos, int seek_forward, unsigned int flags);
|
int Buffer_Seek(Application_Links *app, Buffer_Summary *buffer, int start_pos, int seek_forward, unsigned int flags);
|
||||||
int Buffer_Set_Setting(Application_Links *app, Buffer_Summary *buffer, int setting, int value);
|
int Buffer_Set_Setting(Application_Links *app, Buffer_Summary *buffer, int setting, int value);
|
||||||
|
|
Loading…
Reference in New Issue