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,95 +450,92 @@ 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 && file_is_ready(file)){
|
|
||||||
// TODO(allen): reduce duplication?
|
|
||||||
{
|
|
||||||
i32 size = buffer_size(&file->state.buffer);
|
|
||||||
i32 pos[4] = {0};
|
|
||||||
i32 new_pos = 0;
|
|
||||||
|
|
||||||
if (start_pos < 0){
|
if (file){
|
||||||
start_pos = 0;
|
// TODO(allen): reduce duplication?
|
||||||
}
|
{
|
||||||
else if (start_pos > size){
|
i32 size = buffer_size(&file->state.buffer);
|
||||||
start_pos = size;
|
i32 pos[4] = {0};
|
||||||
|
i32 new_pos = 0;
|
||||||
|
|
||||||
|
if (start_pos < 0){
|
||||||
|
start_pos = 0;
|
||||||
|
}
|
||||||
|
else if (start_pos > size){
|
||||||
|
start_pos = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (seek_forward){
|
||||||
|
for (i32 i = 0; i < ArrayCount(pos); ++i) pos[i] = size;
|
||||||
|
|
||||||
|
if (flags & (1)){
|
||||||
|
pos[0] = buffer_seek_whitespace_right(&file->state.buffer, start_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (seek_forward){
|
if (flags & (1 << 1)){
|
||||||
for (i32 i = 0; i < ArrayCount(pos); ++i) pos[i] = size;
|
if (file->state.tokens_complete){
|
||||||
|
pos[1] = seek_token_right(&file->state.token_stack, start_pos);
|
||||||
if (flags & (1)){
|
|
||||||
pos[0] = buffer_seek_whitespace_right(&file->state.buffer, start_pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flags & (1 << 1)){
|
|
||||||
if (file->state.tokens_complete){
|
|
||||||
pos[1] = seek_token_right(&file->state.token_stack, start_pos);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
pos[1] = buffer_seek_whitespace_right(&file->state.buffer, start_pos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flags & (1 << 2)){
|
|
||||||
pos[2] = buffer_seek_alphanumeric_right(&file->state.buffer, start_pos);
|
|
||||||
if (flags & (1 << 3)){
|
|
||||||
pos[3] = buffer_seek_range_camel_right(&file->state.buffer, start_pos, pos[2]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if (flags & (1 << 3)){
|
pos[1] = buffer_seek_whitespace_right(&file->state.buffer, start_pos);
|
||||||
pos[3] = buffer_seek_alphanumeric_or_camel_right(&file->state.buffer, start_pos);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
new_pos = size;
|
if (flags & (1 << 2)){
|
||||||
for (i32 i = 0; i < ArrayCount(pos); ++i){
|
pos[2] = buffer_seek_alphanumeric_right(&file->state.buffer, start_pos);
|
||||||
if (pos[i] < new_pos) new_pos = pos[i];
|
if (flags & (1 << 3)){
|
||||||
|
pos[3] = buffer_seek_range_camel_right(&file->state.buffer, start_pos, pos[2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if (flags & (1)){
|
if (flags & (1 << 3)){
|
||||||
pos[0] = buffer_seek_whitespace_left(&file->state.buffer, start_pos);
|
pos[3] = buffer_seek_alphanumeric_or_camel_right(&file->state.buffer, start_pos);
|
||||||
}
|
|
||||||
|
|
||||||
if (flags & (1 << 1)){
|
|
||||||
if (file->state.tokens_complete){
|
|
||||||
pos[1] = seek_token_left(&file->state.token_stack, start_pos);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
pos[1] = buffer_seek_whitespace_left(&file->state.buffer, start_pos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flags & (1 << 2)){
|
|
||||||
pos[2] = buffer_seek_alphanumeric_left(&file->state.buffer, start_pos);
|
|
||||||
if (flags & (1 << 3)){
|
|
||||||
pos[3] = buffer_seek_range_camel_left(&file->state.buffer, start_pos, pos[2]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
if (flags & (1 << 3)){
|
|
||||||
pos[3] = buffer_seek_alphanumeric_or_camel_left(&file->state.buffer, start_pos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
new_pos = 0;
|
|
||||||
for (i32 i = 0; i < ArrayCount(pos); ++i){
|
|
||||||
if (pos[i] > new_pos) new_pos = pos[i];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result = new_pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
fill_buffer_summary(buffer, file, working_set);
|
new_pos = size;
|
||||||
|
for (i32 i = 0; i < ArrayCount(pos); ++i){
|
||||||
|
if (pos[i] < new_pos) new_pos = pos[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if (flags & (1)){
|
||||||
|
pos[0] = buffer_seek_whitespace_left(&file->state.buffer, start_pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flags & (1 << 1)){
|
||||||
|
if (file->state.tokens_complete){
|
||||||
|
pos[1] = seek_token_left(&file->state.token_stack, start_pos);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
pos[1] = buffer_seek_whitespace_left(&file->state.buffer, start_pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flags & (1 << 2)){
|
||||||
|
pos[2] = buffer_seek_alphanumeric_left(&file->state.buffer, start_pos);
|
||||||
|
if (flags & (1 << 3)){
|
||||||
|
pos[3] = buffer_seek_range_camel_left(&file->state.buffer, start_pos, pos[2]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if (flags & (1 << 3)){
|
||||||
|
pos[3] = buffer_seek_alphanumeric_or_camel_left(&file->state.buffer, start_pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
new_pos = 0;
|
||||||
|
for (i32 i = 0; i < ArrayCount(pos); ++i){
|
||||||
|
if (pos[i] > new_pos) new_pos = pos[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result = new_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
size = buffer_size(&file->state.buffer);
|
||||||
file = working_set_get_active_file(working_set, buffer->buffer_id);
|
if (0 <= start && start <= end && end <= size){
|
||||||
if (file && file_is_ready(file)){
|
result = true;
|
||||||
size = buffer_size(&file->state.buffer);
|
buffer_stringify(&file->state.buffer, start, end, out);
|
||||||
if (0 <= start && start <= end && end <= size){
|
|
||||||
result = 1;
|
|
||||||
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,131 +561,92 @@ 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;
|
size = buffer_size(&file->state.buffer);
|
||||||
int next_cursor, pos;
|
if (0 <= start && start <= end && end <= size){
|
||||||
|
|
||||||
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);
|
|
||||||
if (0 <= start && start <= end && end <= size){
|
|
||||||
result = 1;
|
|
||||||
|
|
||||||
pos = file->state.cursor_pos;
|
|
||||||
if (pos < start) next_cursor = pos;
|
|
||||||
else if (pos < end) next_cursor = start;
|
|
||||||
else next_cursor = pos + end - start - len;
|
|
||||||
|
|
||||||
file_replace_range(cmd->system, models, file, start, end, str, len, next_cursor);
|
|
||||||
}
|
|
||||||
fill_buffer_summary(buffer, file, working_set);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
result = 1;
|
||||||
size = buffer_size(&file->state.buffer);
|
|
||||||
if (pos < 0) pos = 0;
|
pos = file->state.cursor_pos;
|
||||||
if (pos > size) pos = size;
|
if (pos < start) next_cursor = pos;
|
||||||
file->state.cursor_pos = pos;
|
else if (pos < end) next_cursor = start;
|
||||||
fill_buffer_summary(buffer, file, working_set);
|
else next_cursor = pos + end - start - len;
|
||||||
|
|
||||||
|
file_replace_range(cmd->system, cmd->models,
|
||||||
|
file, start, end, str, len, next_cursor);
|
||||||
}
|
}
|
||||||
|
fill_buffer_summary(buffer, file, cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
return(result);
|
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;
|
result = true;
|
||||||
file = working_set_get_active_file(working_set, buffer->buffer_id);
|
switch (setting){
|
||||||
if (file && file_is_ready(file)){
|
case BufferSetting_Lex:
|
||||||
result = true;
|
{
|
||||||
switch (setting){
|
|
||||||
case BufferSetting_Lex:
|
|
||||||
{
|
|
||||||
#if BUFFER_EXPERIMENT_SCALPEL <= 0
|
#if BUFFER_EXPERIMENT_SCALPEL <= 0
|
||||||
if (file->settings.tokens_exist){
|
if (file->settings.tokens_exist){
|
||||||
if (!value){
|
if (!value){
|
||||||
file_kill_tokens(system, &models->mem.general, file);
|
file_kill_tokens(system, &models->mem.general, file);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if (value){
|
||||||
|
file_first_lex_parallel(system, &models->mem.general, file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}break;
|
||||||
|
|
||||||
|
case BufferSetting_WrapLine:
|
||||||
|
{
|
||||||
|
file->settings.unwrapped_lines = !value;
|
||||||
|
}break;
|
||||||
|
|
||||||
|
case BufferSetting_MapID:
|
||||||
|
{
|
||||||
|
if (value == mapid_global){
|
||||||
|
file->settings.base_map_id = mapid_global;
|
||||||
|
}
|
||||||
|
else if (value == mapid_file){
|
||||||
|
file->settings.base_map_id = mapid_file;
|
||||||
|
}
|
||||||
|
else if (value < mapid_global){
|
||||||
|
new_mapid = get_map_index(models, value);
|
||||||
|
if (new_mapid < models->user_map_count){
|
||||||
|
file->settings.base_map_id = value;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if (value){
|
|
||||||
file_first_lex_parallel(system, &models->mem.general, file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}break;
|
|
||||||
|
|
||||||
case BufferSetting_WrapLine:
|
|
||||||
{
|
|
||||||
file->settings.unwrapped_lines = !value;
|
|
||||||
}break;
|
|
||||||
|
|
||||||
case BufferSetting_MapID:
|
|
||||||
{
|
|
||||||
if (value == mapid_global){
|
|
||||||
file->settings.base_map_id = mapid_global;
|
|
||||||
}
|
|
||||||
else if (value == mapid_file){
|
|
||||||
file->settings.base_map_id = mapid_file;
|
file->settings.base_map_id = mapid_file;
|
||||||
}
|
}
|
||||||
else if (value < mapid_global){
|
}
|
||||||
new_mapid = get_map_index(models, value);
|
|
||||||
if (new_mapid < models->user_map_count){
|
|
||||||
file->settings.base_map_id = value;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
file->settings.base_map_id = mapid_file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (View_Iter iter = file_view_iter_init(&models->layout, file, 0);
|
for (View_Iter iter = file_view_iter_init(&models->layout, file, 0);
|
||||||
file_view_iter_good(iter);
|
file_view_iter_good(iter);
|
||||||
iter = file_view_iter_next(iter)){
|
iter = file_view_iter_next(iter)){
|
||||||
iter.view->map = get_map(models, file->settings.base_map_id);
|
iter.view->map = get_map(models, file->settings.base_map_id);
|
||||||
}
|
}
|
||||||
}break;
|
}break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
fill_buffer_summary(buffer, file, cmd);
|
||||||
fill_buffer_summary(buffer, file, working_set);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return(result);
|
return(result);
|
||||||
|
@ -663,19 +657,14 @@ 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;
|
result = true;
|
||||||
file = working_set_get_active_file(working_set, buffer->buffer_id);
|
String name = make_string(filename, filename_len);
|
||||||
if (file && !file->is_dummy && file_is_ready(file)){
|
view_save_file(system, models, file, 0, name, 0);
|
||||||
result = true;
|
|
||||||
String name = make_string(filename, filename_len);
|
|
||||||
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,29 +744,24 @@ 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;
|
file = vptr->file_data.file;
|
||||||
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;
|
|
||||||
|
|
||||||
if (file && file->state.token_stack.tokens &&
|
if (file && file->state.token_stack.tokens &&
|
||||||
file->state.tokens_complete && !file->state.still_lexing){
|
file->state.tokens_complete && !file->state.still_lexing){
|
||||||
result = true;
|
result = true;
|
||||||
|
|
||||||
Indent_Options opts;
|
Indent_Options opts;
|
||||||
opts.empty_blank_lines = (flags & AutoTab_ClearLine);
|
opts.empty_blank_lines = (flags & AutoTab_ClearLine);
|
||||||
opts.use_tabs = (flags & AutoTab_UseTab);
|
opts.use_tabs = (flags & AutoTab_UseTab);
|
||||||
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;
|
file = vptr->file_data.file;
|
||||||
view_id = view->view_id - 1;
|
if (file && !file->is_loading){
|
||||||
if (view_id >= 0 && view_id < live_set->max){
|
if (seek.type == buffer_seek_line_char && seek.character <= 0){
|
||||||
vptr = live_set->views + view_id;
|
seek.character = 1;
|
||||||
file = vptr->file_data.file;
|
|
||||||
if (file && !file->is_loading){
|
|
||||||
if (seek.type == buffer_seek_line_char && seek.character <= 0){
|
|
||||||
seek.character = 1;
|
|
||||||
}
|
|
||||||
result = view_compute_cursor(vptr, seek);
|
|
||||||
fill_view_summary(view, vptr, live_set, &cmd->models->working_set);
|
|
||||||
}
|
}
|
||||||
|
result = view_compute_cursor(vptr, seek);
|
||||||
|
fill_view_summary(view, vptr, cmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -813,30 +790,23 @@ 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;
|
file = vptr->file_data.file;
|
||||||
view_id = view->view_id - 1;
|
if (file && !file->is_loading){
|
||||||
if (view_id >= 0 && view_id < live_set->max){
|
result = true;
|
||||||
vptr = live_set->views + view_id;
|
if (seek.type == buffer_seek_line_char && seek.character <= 0){
|
||||||
file = vptr->file_data.file;
|
seek.character = 1;
|
||||||
if (file && !file->is_loading){
|
|
||||||
result = 1;
|
|
||||||
if (seek.type == buffer_seek_line_char && seek.character <= 0){
|
|
||||||
seek.character = 1;
|
|
||||||
}
|
|
||||||
vptr->recent->cursor = view_compute_cursor(vptr, seek);
|
|
||||||
if (set_preferred_x){
|
|
||||||
vptr->recent->preferred_x = view_get_cursor_x(vptr);
|
|
||||||
}
|
|
||||||
fill_view_summary(view, vptr, live_set, &cmd->models->working_set);
|
|
||||||
file->state.cursor_pos = vptr->recent->cursor.pos;
|
|
||||||
}
|
}
|
||||||
|
vptr->recent->cursor = view_compute_cursor(vptr, seek);
|
||||||
|
if (set_preferred_x){
|
||||||
|
vptr->recent->preferred_x = view_get_cursor_x(vptr);
|
||||||
|
}
|
||||||
|
fill_view_summary(view, vptr, cmd);
|
||||||
|
file->state.cursor_pos = vptr->recent->cursor.pos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -845,27 +815,20 @@ VIEW_SET_CURSOR_SIG(external_view_set_cursor){
|
||||||
|
|
||||||
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 (seek.type != buffer_seek_pos){
|
||||||
if (view_id >= 0 && view_id < live_set->max){
|
cursor = view_compute_cursor(vptr, seek);
|
||||||
vptr = live_set->views + view_id;
|
vptr->recent->mark = cursor.pos;
|
||||||
result = 1;
|
|
||||||
if (seek.type != buffer_seek_pos){
|
|
||||||
cursor = view_compute_cursor(vptr, seek);
|
|
||||||
vptr->recent->mark = cursor.pos;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
vptr->recent->mark = seek.pos;
|
|
||||||
}
|
|
||||||
fill_view_summary(view, vptr, live_set, &cmd->models->working_set);
|
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
vptr->recent->mark = seek.pos;
|
||||||
|
}
|
||||||
|
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 (turn_on){
|
||||||
if (view_id >= 0 && view_id < live_set->max){
|
view_set_temp_highlight(vptr, start, end);
|
||||||
vptr = live_set->views + view_id;
|
|
||||||
result = 1;
|
|
||||||
if (turn_on){
|
|
||||||
view_set_temp_highlight(vptr, start, end);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
vptr->file_data.show_temp_highlight = 0;
|
|
||||||
}
|
|
||||||
fill_view_summary(view, vptr, live_set, &cmd->models->working_set);
|
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
vptr->file_data.show_temp_highlight = 0;
|
||||||
|
}
|
||||||
|
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){
|
int size = end - start;
|
||||||
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){
|
if (vptr){
|
||||||
int size = end - start;
|
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;
|
vptr->next_mode.rewrite = true;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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){
|
result = vptr->mode.rewrite;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
file = get_file_from_identifier(system, working_set, buffer);
|
||||||
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);
|
|
||||||
|
|
||||||
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