2016-06-13 18:54:26 +00:00
|
|
|
/*
|
2017-04-01 06:15:33 +00:00
|
|
|
* Mr. 4th Dimention - Allen Webster
|
|
|
|
*
|
|
|
|
* ??.??.????
|
|
|
|
*
|
|
|
|
* Implementation of the API functions.
|
|
|
|
*
|
2016-06-13 18:54:26 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
// TOP
|
|
|
|
|
2016-11-12 21:33:54 +00:00
|
|
|
#define API_EXPORT
|
|
|
|
|
2016-06-20 20:34:48 +00:00
|
|
|
inline b32
|
|
|
|
access_test(u32 lock_flags, u32 access_flags){
|
2018-03-24 10:06:45 +00:00
|
|
|
b32 result = ((lock_flags & ~access_flags) == 0);
|
2016-06-20 20:34:48 +00:00
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2016-06-13 18:54:26 +00:00
|
|
|
internal void
|
|
|
|
fill_buffer_summary(Buffer_Summary *buffer, Editing_File *file, Working_Set *working_set){
|
2016-09-01 19:40:25 +00:00
|
|
|
*buffer = null_buffer_summary;
|
2016-06-13 18:54:26 +00:00
|
|
|
if (!file->is_dummy){
|
|
|
|
buffer->exists = 1;
|
|
|
|
buffer->ready = file_is_ready(file);
|
|
|
|
|
|
|
|
buffer->buffer_id = file->id.id;
|
2016-09-18 15:24:43 +00:00
|
|
|
buffer->size = buffer_size(&file->state.buffer);
|
2016-07-08 21:47:37 +00:00
|
|
|
buffer->line_count = file->state.buffer.line_count;
|
2016-06-13 18:54:26 +00:00
|
|
|
|
2017-02-12 06:01:01 +00:00
|
|
|
buffer->file_name_len = file->canon.name.size;
|
|
|
|
buffer->file_name = file->canon.name.str;
|
|
|
|
|
2017-12-01 18:04:07 +00:00
|
|
|
buffer->buffer_name_len = file->unique_name.name.size;
|
|
|
|
buffer->buffer_name = file->unique_name.name.str;
|
2016-06-13 18:54:26 +00:00
|
|
|
|
2016-09-09 22:56:43 +00:00
|
|
|
buffer->dirty = file->state.dirty;
|
|
|
|
|
2016-07-04 20:40:57 +00:00
|
|
|
buffer->is_lexed = file->settings.tokens_exist;
|
2016-09-08 00:32:31 +00:00
|
|
|
|
|
|
|
if (file->state.token_array.tokens &&
|
|
|
|
file->state.tokens_complete &&
|
|
|
|
!file->state.still_lexing){
|
|
|
|
buffer->tokens_are_ready = 1;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
buffer->tokens_are_ready = 0;
|
|
|
|
}
|
|
|
|
|
2016-06-13 18:54:26 +00:00
|
|
|
buffer->map_id = file->settings.base_map_id;
|
2016-07-04 20:40:57 +00:00
|
|
|
buffer->unwrapped_lines = file->settings.unwrapped_lines;
|
2016-06-20 20:34:48 +00:00
|
|
|
|
|
|
|
buffer->lock_flags = 0;
|
|
|
|
if (file->settings.read_only){
|
|
|
|
buffer->lock_flags |= AccessProtected;
|
|
|
|
}
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-14 20:40:57 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2016-06-13 18:54:26 +00:00
|
|
|
internal void
|
2017-03-12 01:20:24 +00:00
|
|
|
fill_view_summary(System_Functions *system, View_Summary *view, View *vptr, Live_Views *live_set, Working_Set *working_set){
|
2018-03-24 10:06:45 +00:00
|
|
|
File_Viewing_Data *data = &vptr->transient.file_data;
|
2016-06-20 20:34:48 +00:00
|
|
|
|
2016-09-01 19:40:25 +00:00
|
|
|
*view = null_view_summary;
|
2016-06-13 18:54:26 +00:00
|
|
|
|
2018-03-24 10:06:45 +00:00
|
|
|
if (vptr->transient.in_use){
|
|
|
|
view->exists = true;
|
2016-08-29 01:03:26 +00:00
|
|
|
view->view_id = (int32_t)(vptr - live_set->views) + 1;
|
2018-03-24 10:06:45 +00:00
|
|
|
view->line_height = (f32)(vptr->transient.line_height);
|
2016-09-22 00:01:12 +00:00
|
|
|
view->unwrapped_lines = data->file->settings.unwrapped_lines;
|
|
|
|
view->show_whitespace = data->show_whitespace;
|
2016-06-20 20:34:48 +00:00
|
|
|
view->lock_flags = view_lock_flags(vptr);
|
2016-06-13 18:54:26 +00:00
|
|
|
|
2018-03-24 10:06:45 +00:00
|
|
|
view->buffer_id = vptr->transient.file_data.file->id.id;
|
2016-09-22 00:01:12 +00:00
|
|
|
|
2018-03-24 10:06:45 +00:00
|
|
|
Assert(data->file != 0);
|
|
|
|
view->mark = file_compute_cursor(system, data->file, seek_pos(vptr->transient.edit_pos->mark), 0);
|
|
|
|
view->cursor = vptr->transient.edit_pos->cursor;
|
|
|
|
view->preferred_x = vptr->transient.edit_pos->preferred_x;
|
2016-09-22 00:01:12 +00:00
|
|
|
|
2018-03-24 10:06:45 +00:00
|
|
|
view->view_region = vptr->transient.panel->inner;
|
|
|
|
view->file_region = vptr->transient.file_region;
|
|
|
|
view->scroll_vars = vptr->transient.edit_pos->scroll;
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-22 00:01:12 +00:00
|
|
|
|
2016-06-14 20:40:57 +00:00
|
|
|
inline void
|
2017-03-12 01:20:24 +00:00
|
|
|
fill_view_summary(System_Functions *system, View_Summary *view, View *vptr, Command_Data *cmd){
|
2017-07-17 23:35:13 +00:00
|
|
|
fill_view_summary(system, view, vptr, &cmd->models->live_set, &cmd->models->working_set);
|
2016-06-14 20:40:57 +00:00
|
|
|
}
|
|
|
|
|
2016-06-13 18:54:26 +00:00
|
|
|
internal Editing_File*
|
|
|
|
get_file_from_identifier(System_Functions *system, Working_Set *working_set, Buffer_Identifier buffer){
|
|
|
|
Editing_File *file = 0;
|
|
|
|
|
2016-08-24 23:01:33 +00:00
|
|
|
if (buffer.id){
|
|
|
|
file = working_set_get_active_file(working_set, buffer.id);
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
2016-08-24 23:01:33 +00:00
|
|
|
else if (buffer.name){
|
|
|
|
String name = make_string(buffer.name, buffer.name_len);
|
2017-11-30 23:25:49 +00:00
|
|
|
file = working_set_contains_name(working_set, name);
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return(file);
|
|
|
|
}
|
|
|
|
|
2016-06-14 20:40:57 +00:00
|
|
|
internal Editing_File*
|
|
|
|
imp_get_file(Command_Data *cmd, Buffer_Summary *buffer){
|
|
|
|
Editing_File *file = 0;
|
|
|
|
Working_Set *working_set = &cmd->models->working_set;;
|
|
|
|
|
2016-12-26 22:49:01 +00:00
|
|
|
if (buffer && buffer->exists){
|
2016-06-14 20:40:57 +00:00
|
|
|
file = working_set_get_active_file(working_set, buffer->buffer_id);
|
|
|
|
if (file != 0 && !file_is_ready(file)){
|
|
|
|
file = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return(file);
|
|
|
|
}
|
|
|
|
|
2016-06-17 03:31:15 +00:00
|
|
|
internal View*
|
2016-07-02 14:15:15 +00:00
|
|
|
imp_get_view(Command_Data *cmd, View_ID view_id){
|
2016-06-17 03:31:15 +00:00
|
|
|
Live_Views *live_set = cmd->live_set;
|
|
|
|
View *vptr = 0;
|
|
|
|
|
|
|
|
view_id = view_id - 1;
|
|
|
|
if (view_id >= 0 && view_id < live_set->max){
|
|
|
|
vptr = live_set->views + view_id;
|
2018-03-24 10:06:45 +00:00
|
|
|
if (!vptr->transient.in_use){
|
2016-07-03 00:37:24 +00:00
|
|
|
vptr = 0;
|
|
|
|
}
|
2016-06-17 03:31:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return(vptr);
|
|
|
|
}
|
|
|
|
|
2016-06-14 20:40:57 +00:00
|
|
|
internal View*
|
|
|
|
imp_get_view(Command_Data *cmd, View_Summary *view){
|
|
|
|
View *vptr = 0;
|
|
|
|
|
2016-12-26 22:49:01 +00:00
|
|
|
if (view && view->exists){
|
2016-06-17 03:31:15 +00:00
|
|
|
vptr = imp_get_view(cmd, view->view_id);
|
2016-06-14 20:40:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return(vptr);
|
|
|
|
}
|
|
|
|
|
2017-05-14 23:42:16 +00:00
|
|
|
API_EXPORT bool32
|
|
|
|
Global_Set_Setting(Application_Links *app, Global_Setting_ID setting, int32_t value)
|
|
|
|
/*
|
|
|
|
DOC_PARAM(setting, Which setting to change.)
|
|
|
|
DOC_PARAM(value, The new value to set ont he specified setting.)
|
|
|
|
DOC_SEE(Global_Setting_ID)
|
|
|
|
*/{
|
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
Models *models = cmd->models;
|
|
|
|
|
|
|
|
b32 result = true;
|
|
|
|
switch (setting){
|
|
|
|
case GlobalSetting_LAltLCtrlIsAltGr:
|
|
|
|
{
|
|
|
|
models->settings.lctrl_lalt_is_altgr = value;
|
|
|
|
}break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
result = false;
|
|
|
|
}break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2017-11-08 18:24:30 +00:00
|
|
|
API_EXPORT bool32
|
|
|
|
Global_Set_Mapping(Application_Links *app, void *data, int32_t size)
|
|
|
|
/*
|
|
|
|
DOC_PARAM(data, The beginning of a binding buffer. Bind_Helper is designed to make it easy to produce such a buffer.)
|
|
|
|
DOC_PARAM(size, The size of the binding buffer in bytes.)
|
|
|
|
DOC_RETURN(Returns non-zero if no errors occurred while interpretting the binding buffer. A return value of zero does not indicate that the old mappings are still in place.)
|
|
|
|
DOC(Dumps away the previous mappings and instantiates the mappings described in the binding buffer. If any of the open buffers were bound to a command map that used to exist, but no command map with the same id exist after the new mappings are instantiated, the buffer's command map will be set to mapid_file and a warning will be posted to *messages*.)
|
|
|
|
*/{
|
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
Models *models = cmd->models;
|
|
|
|
bool32 result = interpret_binding_buffer(models, data, size);
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2016-07-02 14:15:15 +00:00
|
|
|
API_EXPORT bool32
|
2016-10-08 20:20:49 +00:00
|
|
|
Exec_Command(Application_Links *app, Command_ID command_id)
|
|
|
|
/*
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_PARAM(command_id, The command_id parameter specifies which internal command to execute.)
|
|
|
|
DOC_RETURN(This call returns non-zero if command_id named a valid internal command.)
|
2016-11-12 21:33:54 +00:00
|
|
|
DOC(A call to exec_command executes an internal command. If command_id is invalid a warning is posted to *messages*.)
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_SEE(Command_ID)
|
2016-06-23 23:11:09 +00:00
|
|
|
*/{
|
2016-07-02 14:15:15 +00:00
|
|
|
bool32 result = false;
|
|
|
|
|
|
|
|
if (command_id < cmdid_count){
|
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
2017-11-08 18:24:30 +00:00
|
|
|
Command_Function *function = command_table[command_id];
|
2016-07-02 14:15:15 +00:00
|
|
|
Command_Binding binding = {};
|
|
|
|
binding.function = function;
|
|
|
|
if (function) function(cmd->system, cmd, binding);
|
|
|
|
|
|
|
|
result = true;
|
|
|
|
}
|
|
|
|
else{
|
2016-10-08 20:20:49 +00:00
|
|
|
print_message(app,literal("WARNING: An invalid Command_ID was passed to exec_command."));
|
2016-07-02 14:15:15 +00:00
|
|
|
}
|
2016-06-13 18:54:26 +00:00
|
|
|
|
2016-07-02 14:15:15 +00:00
|
|
|
return(result);
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
|
|
|
|
2016-07-02 14:15:15 +00:00
|
|
|
API_EXPORT bool32
|
2017-07-17 22:46:56 +00:00
|
|
|
Exec_System_Command(Application_Links *app, View_Summary *view, Buffer_Identifier buffer_id, char *path, int32_t path_len, char *command, int32_t command_len, Command_Line_Interface_Flag flags)
|
2016-10-08 20:20:49 +00:00
|
|
|
/*
|
2016-12-26 22:49:01 +00:00
|
|
|
DOC_PARAM(view, If the view parameter is non-null it specifies a view to display the command's output buffer, otherwise the command will still work but if there is a buffer capturing the output it will not automatically be displayed.)
|
2017-11-21 19:48:04 +00:00
|
|
|
DOC_PARAM(buffer_id, The buffer the command will output to is specified by the buffer parameter. See Buffer_Identifier for information on how this type specifies a buffer. If output from the command should just be ignored, then buffer_identifier(0) can be specified to indicate no output buffer.)
|
2017-04-01 06:15:33 +00:00
|
|
|
DOC_PARAM(path, The path parameter specifies the current working directory in which the command shall be executed. The string need not be null terminated.)
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_PARAM(path_len, The parameter path_len specifies the length of the path string.)
|
|
|
|
DOC_PARAM(command, The command parameter specifies the command that shall be executed. The string need not be null terminated.)
|
|
|
|
DOC_PARAM(command_len, The parameter command_len specifies the length of the command string.)
|
|
|
|
DOC_PARAM(flags, Flags for the behavior of the call are specified in the flags parameter.)
|
|
|
|
DOC_RETURN(This call returns non-zero on success.)
|
2017-11-21 19:48:04 +00:00
|
|
|
DOC(A call to exec_system_command executes a command as if called from the command line, and sends the output to a buffer. To output to an existing buffer, the buffer identifier can name a new buffer that does not exist, or provide the id of a buffer that does exist. If the buffer identifier uses a name for a buffer that does not exist, the buffer is created and used. If the buffer identifier uses an id that does not belong to an open buffer, then no buffer is used.
|
2016-06-23 23:11:09 +00:00
|
|
|
|
2017-11-21 19:48:04 +00:00
|
|
|
If there in an output buffer and it is not already in an open view and the view parameter is not NULL, then the provided view will display the output buffer.
|
2016-06-23 23:11:09 +00:00
|
|
|
|
2016-12-26 22:49:01 +00:00
|
|
|
If the view parameter is NULL, no view will switch to the output.)
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_SEE(Buffer_Identifier)
|
2016-12-26 22:49:01 +00:00
|
|
|
DOC_SEE(Command_Line_Interface_Flag)
|
2016-06-23 23:11:09 +00:00
|
|
|
*/{
|
2016-06-13 18:54:26 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
System_Functions *system = cmd->system;
|
|
|
|
App_Vars *vars = cmd->vars;
|
|
|
|
Models *models = cmd->models;
|
2017-07-17 22:46:56 +00:00
|
|
|
Partition *part = &models->mem.part;
|
|
|
|
General_Memory *general = &models->mem.general;
|
|
|
|
Working_Set *working_set = &models->working_set;
|
2016-06-13 18:54:26 +00:00
|
|
|
|
2017-07-17 22:46:56 +00:00
|
|
|
bool32 result = true;
|
2016-06-13 18:54:26 +00:00
|
|
|
char feedback_space[256];
|
|
|
|
String feedback_str = make_fixed_width_string(feedback_space);
|
|
|
|
|
|
|
|
Temp_Memory temp = begin_temp_memory(part);
|
|
|
|
|
2017-07-17 22:46:56 +00:00
|
|
|
{
|
|
|
|
// NOTE(allen): Check that it is possible to store a new child process.
|
|
|
|
if (!cli_list_has_space(&vars->cli_processes)){
|
|
|
|
append(&feedback_str, make_lit_string("ERROR: no available process slot\n"));
|
|
|
|
result = false;
|
|
|
|
goto done;
|
|
|
|
}
|
2016-12-26 22:49:01 +00:00
|
|
|
|
2017-07-17 22:46:56 +00:00
|
|
|
// NOTE(allen): Try to get the buffer that was specified if it exists.
|
|
|
|
Editing_File *file = get_file_from_identifier(system, working_set, buffer_id);
|
|
|
|
|
|
|
|
// NOTE(allen): If the file exists check that it is legal.
|
|
|
|
if (file != 0){
|
2016-06-13 18:54:26 +00:00
|
|
|
if (file->settings.read_only == 0){
|
2017-07-17 22:46:56 +00:00
|
|
|
append(&feedback_str, make_lit_string("ERROR: "));
|
2017-12-01 18:04:07 +00:00
|
|
|
append(&feedback_str, file->unique_name.name);
|
2017-07-17 22:46:56 +00:00
|
|
|
append(&feedback_str, make_lit_string(" is not a read-only buffer\n"));
|
2016-06-13 18:54:26 +00:00
|
|
|
result = false;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
if (file->settings.never_kill){
|
2017-07-17 22:46:56 +00:00
|
|
|
append(&feedback_str, make_lit_string("ERROR: The buffer "));
|
2017-12-01 18:04:07 +00:00
|
|
|
append(&feedback_str, file->unique_name.name);
|
2017-07-17 22:46:56 +00:00
|
|
|
append(&feedback_str, make_lit_string(" is not killable"));
|
2016-06-13 18:54:26 +00:00
|
|
|
result = false;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
}
|
2017-07-17 22:46:56 +00:00
|
|
|
|
|
|
|
// NOTE(allen): If the buffer is specified by name but does not already exist, then create it.
|
|
|
|
if (file == 0 && buffer_id.name){
|
2017-01-14 03:01:35 +00:00
|
|
|
file = working_set_alloc_always(working_set, general);
|
2016-06-13 18:54:26 +00:00
|
|
|
if (file == 0){
|
2017-07-17 22:46:56 +00:00
|
|
|
append(&feedback_str, make_lit_string("ERROR: unable to allocate a new buffer\n"));
|
2016-06-13 18:54:26 +00:00
|
|
|
result = false;
|
|
|
|
goto done;
|
|
|
|
}
|
2017-07-17 22:46:56 +00:00
|
|
|
|
|
|
|
String name = make_string_terminated(part, buffer_id.name, buffer_id.name_len);
|
2017-12-01 18:04:07 +00:00
|
|
|
buffer_bind_name(models, general, part, working_set, file, name);
|
2016-08-24 23:01:33 +00:00
|
|
|
init_read_only_file(system, models, file);
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
|
|
|
|
2017-07-17 22:46:56 +00:00
|
|
|
// NOTE(allen): If there are conflicts in output buffer with an existing child process resolve it.
|
2017-07-17 21:13:57 +00:00
|
|
|
if (file != 0){
|
2017-07-17 22:46:56 +00:00
|
|
|
CLI_List *list = &vars->cli_processes;
|
|
|
|
CLI_Process *proc_ptr = list->procs;
|
|
|
|
for (u32 i = 0; i < list->count; ++i, ++proc_ptr){
|
|
|
|
if (proc_ptr->out_file == file){
|
2016-06-13 18:54:26 +00:00
|
|
|
if (flags & CLI_OverlapWithConflict){
|
2017-07-17 22:46:56 +00:00
|
|
|
proc_ptr->out_file = 0;
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
|
|
|
else{
|
|
|
|
file = 0;
|
2017-07-17 21:13:57 +00:00
|
|
|
}
|
|
|
|
break;
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-17 22:46:56 +00:00
|
|
|
if (file == 0){
|
|
|
|
append(&feedback_str, "did not begin command-line command because the target buffer is already in use\n");
|
2016-06-13 18:54:26 +00:00
|
|
|
result = false;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-17 22:46:56 +00:00
|
|
|
// NOTE(allen): If we have an output file, prepare it for child proc output.
|
|
|
|
if (file != 0){
|
2018-03-24 21:43:57 +00:00
|
|
|
edit_clear(system, models, file);
|
2017-07-17 22:46:56 +00:00
|
|
|
file->settings.unimportant = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE(allen): If we have an output file and we need to bring it up in a new view, do so.
|
|
|
|
if (file != 0){
|
|
|
|
b32 bind_to_new_view = true;
|
|
|
|
if (!(flags & CLI_AlwaysBindToView)){
|
2018-03-24 10:06:45 +00:00
|
|
|
if (file_is_viewed(&models->layout, file)){
|
2017-07-17 22:46:56 +00:00
|
|
|
bind_to_new_view = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bind_to_new_view){
|
|
|
|
View *vptr = imp_get_view(cmd, view);
|
|
|
|
if (vptr != 0){
|
|
|
|
view_set_file(system, vptr, file, models);
|
2018-03-24 21:43:57 +00:00
|
|
|
view_show_file(vptr);
|
2017-07-17 22:46:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE(allen): Figure out the root path for the command.
|
2016-06-13 18:54:26 +00:00
|
|
|
String path_string = {0};
|
2017-07-17 22:46:56 +00:00
|
|
|
if (path == 0){
|
2016-06-13 18:54:26 +00:00
|
|
|
terminate_with_null(&models->hot_directory.string);
|
|
|
|
path_string = models->hot_directory.string;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
path_string = make_string_terminated(part, path, path_len);
|
|
|
|
}
|
|
|
|
|
2017-07-17 22:46:56 +00:00
|
|
|
// NOTE(allen): Figure out the command string.
|
|
|
|
String command_string = {0};
|
|
|
|
if (command == 0){
|
|
|
|
command_string = make_lit_string(" echo no script specified");
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
command_string = make_string_terminated(part, command, command_len);
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE(allen): Attept to execute the command.
|
|
|
|
if (!cli_list_call(system, &vars->cli_processes, path_string.str, command_string.str, file, ((flags & CLI_CursorAtEnd) != 0))){
|
|
|
|
append(&feedback_str, "ERROR: Failed to make the cli call\n");
|
|
|
|
result = false;
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
|
|
|
}
|
2017-07-17 22:46:56 +00:00
|
|
|
|
|
|
|
done:;
|
|
|
|
if (!result){
|
2016-06-13 18:54:26 +00:00
|
|
|
do_feedback_message(system, models, feedback_str);
|
|
|
|
}
|
|
|
|
|
|
|
|
end_temp_memory(temp);
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2016-06-27 15:52:58 +00:00
|
|
|
API_EXPORT void
|
2017-03-23 19:15:33 +00:00
|
|
|
Clipboard_Post(Application_Links *app, int32_t clipboard_id, char *str, int32_t len)
|
2016-10-08 20:20:49 +00:00
|
|
|
/*
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_PARAM(clipboard_id, This parameter is set up to prepare for future features, it should always be 0 for now.)
|
|
|
|
DOC_PARAM(str, The str parameter specifies the string to be posted to the clipboard, it need not be null terminated.)
|
|
|
|
DOC_PARAM(len, The len parameter specifies the length of the str string.)
|
2017-11-18 22:40:10 +00:00
|
|
|
DOC(Stores the string str in the clipboard initially with index 0. Also reports the copy to the operating system, so that it may be pasted into other applications.)
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_SEE(The_4coder_Clipboard)
|
2016-06-23 23:11:09 +00:00
|
|
|
*/{
|
2016-06-14 14:20:15 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
System_Functions *system = cmd->system;
|
|
|
|
Models *models = cmd->models;
|
|
|
|
General_Memory *general = &models->mem.general;
|
|
|
|
Working_Set *working = &models->working_set;
|
|
|
|
|
2017-03-23 19:15:33 +00:00
|
|
|
String *dest = working_set_next_clipboard_string(general, working, len);
|
|
|
|
copy_ss(dest, make_string(str, len));
|
2016-06-14 14:20:15 +00:00
|
|
|
system->post_clipboard(*dest);
|
|
|
|
}
|
|
|
|
|
2017-03-23 19:15:33 +00:00
|
|
|
API_EXPORT int32_t
|
|
|
|
Clipboard_Count(Application_Links *app, int32_t clipboard_id)
|
2016-10-08 20:20:49 +00:00
|
|
|
/*
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_PARAM(clipboard_id, This parameter is set up to prepare for future features, it should always be 0 for now.)
|
|
|
|
DOC(This call returns the number of items in the clipboard.)
|
|
|
|
DOC_SEE(The_4coder_Clipboard)
|
2016-06-23 23:11:09 +00:00
|
|
|
*/{
|
2016-06-14 14:20:15 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
Working_Set *working = &cmd->models->working_set;
|
2017-03-23 19:15:33 +00:00
|
|
|
int32_t count = working->clipboard_size;
|
2016-06-14 14:20:15 +00:00
|
|
|
return(count);
|
|
|
|
}
|
|
|
|
|
2017-03-23 19:15:33 +00:00
|
|
|
API_EXPORT int32_t
|
|
|
|
Clipboard_Index(Application_Links *app, int32_t clipboard_id, int32_t item_index, char *out, int32_t len)
|
2016-10-08 20:20:49 +00:00
|
|
|
/*
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_PARAM(clipboard_id, This parameter is set up to prepare for future features, it should always be 0 for now.)
|
|
|
|
DOC_PARAM(item_index, This parameter specifies which item to read, 0 is the most recent copy, 1 is the second most recent copy, etc.)
|
2016-07-06 19:18:10 +00:00
|
|
|
DOC_PARAM(out, This parameter provides a buffer where the clipboard contents are written. This parameter may be NULL.)
|
|
|
|
DOC_PARAM(len, This parameter specifies the length of the out buffer.)
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_RETURN(This call returns the size of the item associated with item_index.)
|
2016-11-02 03:27:51 +00:00
|
|
|
|
2017-05-21 01:22:20 +00:00
|
|
|
DOC(This function always returns the size of the item even if the output buffer is NULL. If the output buffer is too small to contain the whole string, it is filled with the first len character of the clipboard contents. The output string is not null terminated.)
|
2016-11-02 03:27:51 +00:00
|
|
|
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_SEE(The_4coder_Clipboard)
|
2016-06-23 23:11:09 +00:00
|
|
|
*/{
|
2016-06-14 14:20:15 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
Working_Set *working = &cmd->models->working_set;
|
|
|
|
|
2017-03-23 19:15:33 +00:00
|
|
|
int32_t size = 0;
|
2016-07-02 14:15:15 +00:00
|
|
|
String *str = working_set_clipboard_index(working, item_index);
|
2016-06-14 14:20:15 +00:00
|
|
|
if (str){
|
|
|
|
size = str->size;
|
|
|
|
if (out){
|
2017-03-23 19:15:33 +00:00
|
|
|
String out_str = make_string_cap(out, 0, len);
|
2016-08-28 04:31:06 +00:00
|
|
|
copy_ss(&out_str, *str);
|
2016-06-14 14:20:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return(size);
|
|
|
|
}
|
|
|
|
|
2017-05-21 01:22:20 +00:00
|
|
|
API_EXPORT Parse_Context_ID
|
|
|
|
Create_Parse_Context(Application_Links *app, Parser_String_And_Type *kw, uint32_t kw_count, Parser_String_And_Type *pp, uint32_t pp_count)
|
2017-05-29 19:35:48 +00:00
|
|
|
/*
|
|
|
|
DOC_PARAM(kw, The list of keywords and type of each.)
|
|
|
|
DOC_PARAM(kw_count, The number of keywords in the list.)
|
|
|
|
DOC_PARAM(pp, The list of preprocessor directives and the type of each.)
|
|
|
|
DOC_PARAM(pp_count, The number of preprocessor directives in the list.)
|
|
|
|
DOC_RETURN(On success returns an id for the new parse context. If id == 0, then the maximum number of parse contexts has been reached.)
|
|
|
|
*/{
|
2017-05-21 01:22:20 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
Models *models = cmd->models;
|
|
|
|
|
|
|
|
Parse_Context_ID id = parse_context_add(&models->parse_context_memory, &models->mem.general, kw, kw_count, pp, pp_count);
|
|
|
|
|
|
|
|
return(id);
|
|
|
|
}
|
|
|
|
|
2016-07-10 05:49:11 +00:00
|
|
|
API_EXPORT int32_t
|
2016-11-02 03:27:51 +00:00
|
|
|
Get_Buffer_Count(Application_Links *app)
|
|
|
|
/*
|
|
|
|
DOC(Gives the total number of buffers in the application.)
|
|
|
|
*/{
|
2016-07-10 05:49:11 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
Working_Set *working_set = &cmd->models->working_set;
|
|
|
|
int32_t result = working_set->file_count;
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2016-06-20 20:34:48 +00:00
|
|
|
internal void
|
|
|
|
internal_get_buffer_first(Working_Set *working_set, Buffer_Summary *buffer){
|
2016-06-13 18:54:26 +00:00
|
|
|
if (working_set->file_count > 0){
|
2016-06-20 20:34:48 +00:00
|
|
|
fill_buffer_summary(buffer, (Editing_File*)working_set->used_sentinel.next, working_set);
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-20 20:34:48 +00:00
|
|
|
internal void
|
|
|
|
internal_get_buffer_next(Working_Set *working_set, Buffer_Summary *buffer){
|
2017-05-27 20:04:13 +00:00
|
|
|
Editing_File *file = working_set_get_active_file(working_set, buffer->buffer_id);
|
2016-06-13 18:54:26 +00:00
|
|
|
if (file){
|
|
|
|
file = (Editing_File*)file->node.next;
|
2017-05-27 20:04:13 +00:00
|
|
|
if (file != (Editing_File*)&working_set->used_sentinel){
|
|
|
|
fill_buffer_summary(buffer, file, working_set);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
*buffer = null_buffer_summary;
|
|
|
|
}
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
|
|
|
else{
|
2016-09-01 19:40:25 +00:00
|
|
|
*buffer = null_buffer_summary;
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-27 15:52:58 +00:00
|
|
|
API_EXPORT Buffer_Summary
|
2016-10-08 20:20:49 +00:00
|
|
|
Get_Buffer_First(Application_Links *app, Access_Flag access)
|
|
|
|
/*
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_PARAM(access, The access parameter determines what levels of protection this call can access.)
|
|
|
|
DOC_RETURN(This call returns the summary of the first buffer in a buffer loop.)
|
2016-10-08 20:20:49 +00:00
|
|
|
DOC(
|
2016-07-02 14:15:15 +00:00
|
|
|
This call begins a loop across all the buffers.
|
|
|
|
If the buffer returned does not exist, the loop is finished.
|
|
|
|
Buffers should not be killed durring a buffer loop.
|
2016-06-23 23:11:09 +00:00
|
|
|
)
|
2016-07-12 18:20:06 +00:00
|
|
|
DOC_SEE(Buffer_Summary)
|
2016-06-23 23:11:09 +00:00
|
|
|
DOC_SEE(Access_Flag)
|
|
|
|
DOC_SEE(get_buffer_next)
|
|
|
|
*/{
|
2016-06-20 20:34:48 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
Working_Set *working_set = &cmd->models->working_set;
|
2017-06-28 15:15:54 +00:00
|
|
|
Buffer_Summary buffer = {0};
|
2016-06-20 20:34:48 +00:00
|
|
|
|
2017-06-28 15:15:54 +00:00
|
|
|
internal_get_buffer_first(working_set, &buffer);
|
|
|
|
while (buffer.exists && !access_test(buffer.lock_flags, access)){
|
|
|
|
internal_get_buffer_next(working_set, &buffer);
|
2016-06-20 20:34:48 +00:00
|
|
|
}
|
|
|
|
|
2017-06-28 15:15:54 +00:00
|
|
|
return(buffer);
|
2016-06-20 20:34:48 +00:00
|
|
|
}
|
|
|
|
|
2016-06-27 15:52:58 +00:00
|
|
|
API_EXPORT void
|
2016-10-08 20:20:49 +00:00
|
|
|
Get_Buffer_Next(Application_Links *app, Buffer_Summary *buffer, Access_Flag access)
|
|
|
|
/*
|
2016-07-05 01:36:30 +00:00
|
|
|
DOC_PARAM(buffer, The Buffer_Summary pointed to by buffer is iterated to the next buffer or to a null summary if this is the last buffer.)
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_PARAM(access, The access parameter determines what levels of protection this call can access. The buffer outputted will be the next buffer that is accessible.)
|
2016-10-08 20:20:49 +00:00
|
|
|
DOC(
|
2016-07-05 01:36:30 +00:00
|
|
|
This call steps a Buffer_Summary to the next buffer in the global buffer order.
|
2016-07-02 14:15:15 +00:00
|
|
|
The global buffer order is kept roughly in the order of most recently used to least recently used.
|
2016-06-23 23:11:09 +00:00
|
|
|
|
2016-07-02 14:15:15 +00:00
|
|
|
If the buffer outputted does not exist, the loop is finished.
|
|
|
|
Buffers should not be killed or created durring a buffer loop.
|
2016-06-23 23:11:09 +00:00
|
|
|
)
|
2016-07-12 18:20:06 +00:00
|
|
|
DOC_SEE(Buffer_Summary)
|
2016-06-23 23:11:09 +00:00
|
|
|
DOC_SEE(Access_Flag)
|
|
|
|
DOC_SEE(get_buffer_first)
|
|
|
|
*/{
|
2016-06-20 20:34:48 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
Working_Set *working_set = &cmd->models->working_set;
|
|
|
|
|
|
|
|
internal_get_buffer_next(working_set, buffer);
|
|
|
|
while (buffer->exists && !access_test(buffer->lock_flags, access)){
|
|
|
|
internal_get_buffer_next(working_set, buffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-27 15:52:58 +00:00
|
|
|
API_EXPORT Buffer_Summary
|
2016-10-08 20:20:49 +00:00
|
|
|
Get_Buffer(Application_Links *app, Buffer_ID buffer_id, Access_Flag access)
|
|
|
|
/*
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_PARAM(buffer_id, The parameter buffer_id specifies which buffer to try to get.)
|
|
|
|
DOC_PARAM(access, The access parameter determines what levels of protection this call can access.)
|
|
|
|
DOC_RETURN(This call returns a summary that describes the indicated buffer if it exists and is accessible.)
|
2016-07-12 18:20:06 +00:00
|
|
|
DOC_SEE(Buffer_Summary)
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_SEE(Access_Flag)
|
|
|
|
DOC_SEE(Buffer_ID)
|
2016-06-23 23:11:09 +00:00
|
|
|
*/{
|
2016-06-13 18:54:26 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
Working_Set *working_set = &cmd->models->working_set;
|
2017-06-28 15:15:54 +00:00
|
|
|
Buffer_Summary buffer = {0};
|
2016-06-13 18:54:26 +00:00
|
|
|
|
2017-04-15 21:47:23 +00:00
|
|
|
Editing_File *file = working_set_get_active_file(working_set, buffer_id);
|
2017-06-28 15:15:54 +00:00
|
|
|
if (file != 0 && !file->is_dummy){
|
2016-06-13 18:54:26 +00:00
|
|
|
fill_buffer_summary(&buffer, file, working_set);
|
2016-06-20 20:34:48 +00:00
|
|
|
if (!access_test(buffer.lock_flags, access)){
|
2016-09-01 19:40:25 +00:00
|
|
|
buffer = null_buffer_summary;
|
2016-06-20 20:34:48 +00:00
|
|
|
}
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return(buffer);
|
|
|
|
}
|
|
|
|
|
2016-06-27 15:52:58 +00:00
|
|
|
API_EXPORT Buffer_Summary
|
2016-10-08 20:20:49 +00:00
|
|
|
Get_Buffer_By_Name(Application_Links *app, char *name, int32_t len, Access_Flag access)
|
|
|
|
/*
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_PARAM(name, The name parameter specifies the buffer name to try to get. The string need not be null terminated.)
|
|
|
|
DOC_PARAM(len, The len parameter specifies the length of the name string.)
|
|
|
|
DOC_PARAM(access, The access parameter determines what levels of protection this call can access.)
|
|
|
|
DOC_RETURN(This call returns a summary that describes the indicated buffer if it exists and is accessible.)
|
2017-06-30 18:20:34 +00:00
|
|
|
|
|
|
|
DOC(This call searches the buffers by their buffer name. The buffer name is the short name in the file bar. The name must match exactly including any alterations put on the buffer name to avoid duplicates.)
|
|
|
|
|
|
|
|
DOC_SEE(get_buffer_by_file_name)
|
2016-07-12 18:20:06 +00:00
|
|
|
DOC_SEE(Buffer_Summary)
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_SEE(Access_Flag)
|
2016-06-23 23:11:09 +00:00
|
|
|
*/{
|
2016-06-13 18:54:26 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
2017-06-28 15:15:54 +00:00
|
|
|
Buffer_Summary buffer = {0};
|
2016-06-13 18:54:26 +00:00
|
|
|
Working_Set *working_set = &cmd->models->working_set;
|
|
|
|
|
2017-11-30 23:25:49 +00:00
|
|
|
Editing_File *file = working_set_contains_name(working_set, make_string(name, len));
|
2017-06-28 15:15:54 +00:00
|
|
|
if (file != 0 && !file->is_dummy){
|
|
|
|
fill_buffer_summary(&buffer, file, working_set);
|
|
|
|
if (!access_test(buffer.lock_flags, access)){
|
|
|
|
buffer = null_buffer_summary;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return(buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
API_EXPORT Buffer_Summary
|
2017-06-30 18:20:34 +00:00
|
|
|
Get_Buffer_By_File_Name(Application_Links *app, char *name, int32_t len, Access_Flag access)
|
|
|
|
/*
|
|
|
|
DOC_PARAM(name, The name parameter specifies the buffer name to try to get. The string need not be null terminated.)
|
|
|
|
DOC_PARAM(len, The len parameter specifies the length of the name string.)
|
|
|
|
DOC_PARAM(access, The access parameter determines what levels of protection this call can access.)
|
|
|
|
DOC_RETURN(This call returns a summary that describes the indicated buffer if it exists and is accessible.)
|
|
|
|
|
|
|
|
DOC(This call searches the buffers by their canonicalized file names. Not all buffers have file names, only buffers that are tied to files. For instance *scratch* does not have a file name. Every file has one canonicalized file name. For instance on windows this involves converting w:/a/b into W:\a\b. If the name passed is not canonicalized a canonicalized copy is made first. This includes turning relative paths to files that exist into full paths. So the passed in name can be relative to the working directory.)
|
|
|
|
|
|
|
|
DOC_SEE(get_buffer_by_name)
|
|
|
|
DOC_SEE(Buffer_Summary)
|
|
|
|
DOC_SEE(Access_Flag)
|
|
|
|
*/
|
|
|
|
{
|
2017-06-28 15:15:54 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
Buffer_Summary buffer = {0};
|
|
|
|
System_Functions *system = cmd->system;
|
|
|
|
Models *models = cmd->models;
|
|
|
|
Working_Set *working_set = &models->working_set;
|
|
|
|
|
|
|
|
String fname = make_string(name, len);
|
2017-11-30 23:25:49 +00:00
|
|
|
Editing_File_Name canon = {0};
|
2017-06-28 15:15:54 +00:00
|
|
|
if (get_canon_name(system, &canon, fname)){
|
2017-11-30 23:25:49 +00:00
|
|
|
Editing_File *file = working_set_contains_canon(working_set, canon.name);
|
2016-06-13 18:54:26 +00:00
|
|
|
fill_buffer_summary(&buffer, file, working_set);
|
2016-06-20 20:34:48 +00:00
|
|
|
if (!access_test(buffer.lock_flags, access)){
|
2016-09-01 19:40:25 +00:00
|
|
|
buffer = null_buffer_summary;
|
2016-06-20 20:34:48 +00:00
|
|
|
}
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return(buffer);
|
|
|
|
}
|
|
|
|
|
2016-07-02 14:15:15 +00:00
|
|
|
API_EXPORT bool32
|
2017-03-23 19:15:33 +00:00
|
|
|
Buffer_Read_Range(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, char *out)
|
2016-10-08 20:20:49 +00:00
|
|
|
/*
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_PARAM(buffer, This parameter specifies the buffer to read.)
|
|
|
|
DOC_PARAM(start, This parameter specifies absolute position of the first character in the read range.)
|
|
|
|
DOC_PARAM(end, This parameter specifies the absolute position of the the character one past the end of the read range.)
|
|
|
|
DOC_PARAM(out, This paramter provides the output character buffer to fill with the result of the read.)
|
|
|
|
DOC_RETURN(This call returns non-zero if the read succeeds.)
|
2016-06-23 23:11:09 +00:00
|
|
|
DOC
|
|
|
|
(
|
2016-06-28 22:58:50 +00:00
|
|
|
The output buffer must have a capacity of at least (end - start).
|
2016-06-23 23:11:09 +00:00
|
|
|
The output is not null terminated.
|
2016-06-27 14:25:17 +00:00
|
|
|
|
2016-07-02 14:15:15 +00:00
|
|
|
This call fails if the buffer does not exist,
|
|
|
|
or if the read range is not within the bounds of the buffer.
|
2016-06-23 23:11:09 +00:00
|
|
|
)
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_SEE(4coder_Buffer_Positioning_System)
|
2016-06-23 23:11:09 +00:00
|
|
|
*/{
|
2016-06-13 18:54:26 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
2016-06-14 20:40:57 +00:00
|
|
|
Editing_File *file = imp_get_file(cmd, buffer);
|
2016-07-02 14:15:15 +00:00
|
|
|
bool32 result = false;
|
|
|
|
int32_t size = 0;
|
2016-06-13 18:54:26 +00:00
|
|
|
|
2016-06-14 20:40:57 +00:00
|
|
|
if (file){
|
|
|
|
size = buffer_size(&file->state.buffer);
|
|
|
|
if (0 <= start && start <= end && end <= size){
|
|
|
|
result = true;
|
2017-03-23 19:15:05 +00:00
|
|
|
buffer_stringify(&file->state.buffer, start, end, out);
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
2016-06-14 20:40:57 +00:00
|
|
|
fill_buffer_summary(buffer, file, cmd);
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2016-07-02 14:15:15 +00:00
|
|
|
API_EXPORT bool32
|
2017-03-23 19:16:39 +00:00
|
|
|
Buffer_Replace_Range(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end, char *str, int32_t len)
|
2016-10-08 20:20:49 +00:00
|
|
|
/*
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_PARAM(buffer, This parameter specifies the buffer to edit.)
|
|
|
|
DOC_PARAM(start, This parameter specifies absolute position of the first character in the replace range.)
|
|
|
|
DOC_PARAM(end, This parameter specifies the absolute position of the the character one past the end of the replace range.)
|
|
|
|
DOC_PARAM(str, This parameter specifies the the string to write into the range; it need not be null terminated.)
|
|
|
|
DOC_PARAM(len, This parameter specifies the length of the str string.)
|
|
|
|
DOC_RETURN(This call returns non-zero if the replacement succeeds.)
|
2017-03-23 19:15:33 +00:00
|
|
|
DOC
|
|
|
|
(
|
|
|
|
If this call succeeds it deletes the range from start to end
|
|
|
|
and writes str in the same position. If end == start then
|
|
|
|
this call is equivalent to inserting the string at start.
|
|
|
|
If len == 0 this call is equivalent to deleteing the range
|
|
|
|
from start to end.
|
|
|
|
|
|
|
|
This call fails if the buffer does not exist, or if the replace
|
|
|
|
range is not within the bounds of the buffer.
|
|
|
|
)
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_SEE(4coder_Buffer_Positioning_System)
|
2016-06-23 23:11:09 +00:00
|
|
|
*/{
|
2017-03-29 20:50:29 +00:00
|
|
|
PRFL_FUNC_GROUP();
|
|
|
|
|
2016-06-13 18:54:26 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
2016-06-14 20:40:57 +00:00
|
|
|
Editing_File *file = imp_get_file(cmd, buffer);
|
2016-06-13 18:54:26 +00:00
|
|
|
|
2016-07-02 14:15:15 +00:00
|
|
|
bool32 result = false;
|
2017-03-23 19:15:33 +00:00
|
|
|
int32_t size = 0;
|
2016-06-13 18:54:26 +00:00
|
|
|
|
2016-06-14 20:40:57 +00:00
|
|
|
if (file){
|
2017-03-23 19:15:33 +00:00
|
|
|
size = buffer_size(&file->state.buffer);
|
2016-06-14 20:40:57 +00:00
|
|
|
if (0 <= start && start <= end && end <= size){
|
2016-06-23 23:11:09 +00:00
|
|
|
result = true;
|
2016-06-14 20:40:57 +00:00
|
|
|
|
2018-03-24 21:43:57 +00:00
|
|
|
edit_single(cmd->system, cmd->models,
|
|
|
|
file, start, end, str, len);
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
2016-06-14 20:40:57 +00:00
|
|
|
fill_buffer_summary(buffer, file, cmd);
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2016-07-12 18:20:06 +00:00
|
|
|
API_EXPORT bool32
|
2016-10-08 20:20:49 +00:00
|
|
|
Buffer_Compute_Cursor(Application_Links *app, Buffer_Summary *buffer, Buffer_Seek seek, Partial_Cursor *cursor_out)
|
|
|
|
/*
|
2016-07-12 18:20:06 +00:00
|
|
|
DOC_PARAM(buffer, The buffer parameter specifies the buffer on which to run the cursor computation.)
|
|
|
|
DOC_PARAM(seek, The seek parameter specifies the target position for the seek.)
|
|
|
|
DOC_PARAM(cursor_out, On success this struct is filled with the result of the seek.)
|
2016-09-08 00:32:31 +00:00
|
|
|
DOC_RETURN(This call returns non-zero on success. This call can fail if the buffer summary provided
|
|
|
|
does not summarize an actual buffer in 4coder, or if the provided seek format is invalid. The valid
|
|
|
|
seek types are seek_pos and seek_line_char.)
|
2016-07-12 18:20:06 +00:00
|
|
|
DOC(Computes a Partial_Cursor for the given seek position with no side effects.
|
|
|
|
The seek position must be one of the types supported by Partial_Cursor. Those
|
|
|
|
types are absolute position and line,column position.)
|
|
|
|
DOC_SEE(Buffer_Seek)
|
|
|
|
DOC_SEE(Partial_Cursor)
|
|
|
|
*/{
|
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
Editing_File *file = imp_get_file(cmd, buffer);
|
|
|
|
bool32 result = false;
|
|
|
|
|
|
|
|
if (file){
|
2016-09-23 20:02:58 +00:00
|
|
|
if (file_compute_partial_cursor(file, seek, cursor_out)){
|
2016-07-12 18:20:06 +00:00
|
|
|
result = true;
|
|
|
|
fill_buffer_summary(buffer, file, cmd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2016-07-02 14:15:15 +00:00
|
|
|
API_EXPORT bool32
|
2017-03-23 19:16:39 +00:00
|
|
|
Buffer_Batch_Edit(Application_Links *app, Buffer_Summary *buffer, char *str, int32_t str_len, Buffer_Edit *edits, int32_t edit_count, Buffer_Batch_Edit_Type type)
|
2016-10-08 20:20:49 +00:00
|
|
|
/*
|
2016-09-19 02:49:25 +00:00
|
|
|
DOC_PARAM(buffer, The buffer on which to apply the batch of edits.)
|
2016-07-08 21:47:37 +00:00
|
|
|
DOC_PARAM(str, This parameter provides all of the source string for the edits in the batch.)
|
|
|
|
DOC_PARAM(str_len, This parameter specifies the length of the str string.)
|
|
|
|
DOC_PARAM(edits, This parameter provides about the source string and destination range of each edit as an array.)
|
|
|
|
DOC_PARAM(edit_count, This parameter specifies the number of Buffer_Edit structs in edits.)
|
|
|
|
DOC_PARAM(type, This prameter specifies what type of batch edit to execute.)
|
2017-02-27 05:57:21 +00:00
|
|
|
DOC_RETURN(This call returns non-zero if the batch edit succeeds. This call can fail if the provided buffer summary does not refer to an actual buffer in 4coder.)
|
2017-07-17 20:43:01 +00:00
|
|
|
DOC(Apply an array of edits all at once. This combines all the edits into one undo operation.)
|
2016-07-08 21:47:37 +00:00
|
|
|
DOC_SEE(Buffer_Edit)
|
|
|
|
DOC_SEE(Buffer_Batch_Edit_Type)
|
|
|
|
*/{
|
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
2016-07-09 04:39:14 +00:00
|
|
|
Models *models = cmd->models;
|
|
|
|
Mem_Options *mem = &models->mem;
|
|
|
|
Partition *part = &mem->part;
|
2016-07-08 21:47:37 +00:00
|
|
|
Editing_File *file = imp_get_file(cmd, buffer);
|
2016-10-22 15:30:25 +00:00
|
|
|
System_Functions *system = cmd->system;
|
2016-07-08 21:47:37 +00:00
|
|
|
|
|
|
|
bool32 result = false;
|
|
|
|
|
|
|
|
if (file){
|
2016-07-15 15:45:02 +00:00
|
|
|
if (edit_count > 0){
|
|
|
|
Temp_Memory temp = begin_temp_memory(part);
|
|
|
|
Buffer_Edit *inverse_edits = push_array(part, Buffer_Edit, edit_count);
|
|
|
|
Assert(inverse_edits);
|
|
|
|
|
|
|
|
char *inv_str = (char*)part->base + part->pos;
|
2017-03-23 19:15:33 +00:00
|
|
|
int32_t inv_str_max = part->max - part->pos;
|
2016-07-15 15:45:02 +00:00
|
|
|
|
2017-03-23 19:15:33 +00:00
|
|
|
Edit_Spec spec = file_compute_edit(mem, file, edits, str, str_len, inverse_edits, inv_str, inv_str_max, edit_count, type);
|
2016-07-15 15:45:02 +00:00
|
|
|
|
2018-03-24 21:43:57 +00:00
|
|
|
edit_batch(system, models, file, spec, hist_normal, type);
|
2016-07-15 15:45:02 +00:00
|
|
|
|
|
|
|
end_temp_memory(temp);
|
|
|
|
}
|
2016-09-08 00:32:31 +00:00
|
|
|
|
|
|
|
result = true;
|
2016-07-08 21:47:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2017-02-24 02:30:29 +00:00
|
|
|
API_EXPORT Marker_Handle
|
2017-02-27 05:57:21 +00:00
|
|
|
Buffer_Add_Markers(Application_Links *app, Buffer_Summary *buffer, uint32_t marker_count)
|
|
|
|
/*
|
|
|
|
DOC_PARAM(buffer, The buffer on which to add the new markers.)
|
|
|
|
DOC_PARAM(marker_count, How many markers to be stored in the new marker array.)
|
|
|
|
DOC_RETURN(If this call succeeds it returns a handle to the new markers. If it fails it returns a null handle.)
|
|
|
|
DOC(This call makes an allocation of markers for the specified buffer. The newly allocated markers are not immediately activated. To activate a marker use buffer_set_markers to give the marker a value. The markers will remain allocated on the buffer until buffer_remove_markers is called or until the buffer is killed.)
|
|
|
|
DOC_SEE(Marker)
|
|
|
|
*/{
|
2017-02-24 02:30:29 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
Models *models = cmd->models;
|
|
|
|
Editing_File *file = imp_get_file(cmd, buffer);
|
|
|
|
|
|
|
|
Marker_Handle result = 0;
|
|
|
|
if (file != 0){
|
|
|
|
result = allocate_markers_state(&models->mem.general, file, marker_count);
|
|
|
|
}
|
|
|
|
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2017-04-15 21:47:23 +00:00
|
|
|
API_EXPORT Buffer_Summary
|
|
|
|
Get_Buffer_By_Marker_Handle(Application_Links *app, Marker_Handle marker, Access_Flag access)
|
|
|
|
/*
|
|
|
|
DOC_PARAM(marker, The marker handle to query.)
|
|
|
|
DOC_PARAM(access, The access parameter determines what levels of protection this call can access.)
|
|
|
|
DOC_SEE(Marker)
|
|
|
|
*/{
|
|
|
|
Buffer_ID buffer_id = get_buffer_id_from_marker_handle(marker);
|
|
|
|
Buffer_Summary buffer = Get_Buffer(app, buffer_id, access);
|
|
|
|
return(buffer);
|
|
|
|
}
|
|
|
|
|
2017-02-24 02:30:29 +00:00
|
|
|
API_EXPORT bool32
|
2017-02-27 05:57:21 +00:00
|
|
|
Buffer_Set_Markers(Application_Links *app, Buffer_Summary *buffer, Marker_Handle marker, uint32_t first_marker_index, uint32_t marker_count, Marker *source_markers)
|
|
|
|
/*
|
|
|
|
DOC_PARAM(buffer, The buffer on which the specified markers are attached.)
|
|
|
|
DOC_PARAM(marker, The marker handle refering to the markers to be set.)
|
|
|
|
DOC_PARAM(first_marker_index, The index of the first marker to be set by this call.)
|
|
|
|
DOC_PARAM(marker_count, The number of markers to be set by this call.)
|
|
|
|
DOC_PARAM(source_markers, An array of marker_count Markers to specify the values to set to the markers specified.)
|
|
|
|
DOC_RETURN(On success returns non-zero, on failure returns zero.)
|
|
|
|
DOC(This call sets the value of a Marker, eliminating whatever value was there before. Any markers that are set become active if they were not active before. If a marker of lower index than first_marker_index was not active before this call, it will be cleared to zero and made active as well, so that all markers between 0 and first_marker_index + marker_count - 1 are active after this call. If first_marker_index + marker_count exceeds the originally allocated size of the marker array, this call will fail.)
|
|
|
|
DOC_SEE(Marker)
|
|
|
|
*/{
|
2017-02-24 02:30:29 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
Editing_File *file = imp_get_file(cmd, buffer);
|
|
|
|
|
|
|
|
bool32 result = false;
|
|
|
|
if (file != 0){
|
|
|
|
if (markers_set(file, marker, first_marker_index, marker_count, source_markers)){
|
|
|
|
result = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
API_EXPORT bool32
|
2017-02-27 05:57:21 +00:00
|
|
|
Buffer_Get_Markers(Application_Links *app, Buffer_Summary *buffer, Marker_Handle marker, uint32_t first_marker_index, uint32_t marker_count, Marker *markers_out)
|
|
|
|
/*
|
|
|
|
DOC_PARAM(buffer, The buffer on which the specified markers are attached.)
|
|
|
|
DOC_PARAM(marker, The marker handle refering to the markers to be read.)
|
|
|
|
DOC_PARAM(first_marker_index, The index of the first marker to be read by this call.)
|
|
|
|
DOC_PARAM(marker_count, The number of markers to be read by this call.)
|
|
|
|
DOC_PARAM(markers_out, An array of marker_count Markers to be filled by the result of the read.)
|
|
|
|
DOC_RETURN(On success returns non-zero, on failure returns zero.)
|
|
|
|
DOC(When the range specified by first_marker_index and marker_count is a range of active markers in the array specified by the marker handle, this call succeeds and fills the markers_out buffer with the current values of the specified markers.)
|
|
|
|
DOC_SEE(Marker)
|
|
|
|
*/{
|
2017-02-24 02:30:29 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
Editing_File *file = imp_get_file(cmd, buffer);
|
|
|
|
|
|
|
|
bool32 result = false;
|
|
|
|
if (file != 0){
|
|
|
|
if (markers_get(file, marker, first_marker_index, marker_count, markers_out)){
|
|
|
|
result = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
API_EXPORT bool32
|
2017-02-27 05:57:21 +00:00
|
|
|
Buffer_Remove_Markers(Application_Links *app, Buffer_Summary *buffer, Marker_Handle marker)
|
|
|
|
/*
|
|
|
|
DOC_PARAM(buffer, The buffer on which the specified markers are attached.)
|
|
|
|
DOC_PARAM(marker, The marker handle refering to the markers to be detached from the buffer.)
|
|
|
|
DOC_RETURN(On success returns non-zero, on failure returns zero.)
|
|
|
|
DOC(Deactivates the entire range of markers specified by the marker handle and frees the memory used to store the markers internally.)
|
|
|
|
DOC_SEE(buffer_add_markers)
|
|
|
|
*/{
|
2017-02-24 02:30:29 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
Models *models = cmd->models;
|
|
|
|
Editing_File *file = imp_get_file(cmd, buffer);
|
|
|
|
|
|
|
|
bool32 result = false;
|
|
|
|
if (file != 0){
|
|
|
|
if (markers_free(&models->mem.general, file, marker)){
|
|
|
|
result = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2016-12-26 22:49:01 +00:00
|
|
|
API_EXPORT bool32
|
2016-11-02 03:27:51 +00:00
|
|
|
Buffer_Get_Setting(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting, int32_t *value_out)
|
|
|
|
/*
|
|
|
|
DOC_PARAM(buffer, the buffer from which to read a setting)
|
|
|
|
DOC_PARAM(setting, the setting to read from the buffer)
|
|
|
|
DOC_PARAM(value_out, address to write the setting value on success)
|
|
|
|
DOC_RETURN(returns non-zero on success)
|
|
|
|
*/{
|
2016-09-22 00:01:12 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
Editing_File *file = imp_get_file(cmd, buffer);
|
2016-12-26 22:49:01 +00:00
|
|
|
bool32 result = 0;
|
2017-01-14 03:01:35 +00:00
|
|
|
|
2016-09-22 00:01:12 +00:00
|
|
|
if (file){
|
2016-11-12 21:33:54 +00:00
|
|
|
result = 1;
|
2016-09-22 00:01:12 +00:00
|
|
|
switch (setting){
|
2018-03-24 21:43:57 +00:00
|
|
|
case BufferSetting_Lex:
|
|
|
|
{
|
|
|
|
*value_out = file->settings.tokens_exist;
|
|
|
|
}break;
|
|
|
|
|
|
|
|
case BufferSetting_LexWithoutStrings:
|
|
|
|
{
|
|
|
|
*value_out = file->settings.tokens_without_strings;
|
|
|
|
}break;
|
|
|
|
|
|
|
|
case BufferSetting_ParserContext:
|
|
|
|
{
|
|
|
|
*value_out = file->settings.parse_context_id;
|
|
|
|
}break;
|
|
|
|
|
|
|
|
case BufferSetting_WrapLine:
|
|
|
|
{
|
|
|
|
*value_out = !file->settings.unwrapped_lines;
|
|
|
|
}break;
|
|
|
|
|
|
|
|
case BufferSetting_WrapPosition:
|
|
|
|
{
|
|
|
|
*value_out = file->settings.display_width;
|
|
|
|
}break;
|
|
|
|
|
|
|
|
case BufferSetting_MinimumBaseWrapPosition:
|
|
|
|
{
|
|
|
|
*value_out = file->settings.minimum_base_display_width;
|
|
|
|
}break;
|
|
|
|
|
|
|
|
case BufferSetting_MapID:
|
|
|
|
{
|
|
|
|
*value_out = file->settings.base_map_id;
|
|
|
|
}break;
|
|
|
|
|
|
|
|
case BufferSetting_Eol:
|
|
|
|
{
|
|
|
|
*value_out = file->settings.dos_write_mode;
|
|
|
|
}break;
|
|
|
|
|
|
|
|
case BufferSetting_Unimportant:
|
|
|
|
{
|
|
|
|
*value_out = file->settings.unimportant;
|
|
|
|
}break;
|
|
|
|
|
|
|
|
case BufferSetting_ReadOnly:
|
|
|
|
{
|
|
|
|
*value_out = file->settings.read_only;
|
|
|
|
}break;
|
|
|
|
|
|
|
|
case BufferSetting_VirtualWhitespace:
|
|
|
|
{
|
|
|
|
*value_out = file->settings.virtual_white;
|
|
|
|
}break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
result = 0;
|
|
|
|
}break;
|
2016-09-22 00:01:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2016-07-08 21:47:37 +00:00
|
|
|
API_EXPORT bool32
|
2016-09-17 00:03:09 +00:00
|
|
|
Buffer_Set_Setting(Application_Links *app, Buffer_Summary *buffer, Buffer_Setting_ID setting, int32_t value)
|
|
|
|
/*
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_PARAM(buffer, The buffer parameter specifies the buffer on which to set a setting.)
|
|
|
|
DOC_PARAM(setting, The setting parameter identifies the setting that shall be changed.)
|
|
|
|
DOC_PARAM(value, The value parameter specifies the value to which the setting shall be changed.)
|
2016-06-24 02:21:11 +00:00
|
|
|
DOC_SEE(Buffer_Setting_ID)
|
|
|
|
*/{
|
2016-06-13 18:54:26 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
System_Functions *system = cmd->system;
|
|
|
|
Models *models = cmd->models;
|
2016-06-14 20:40:57 +00:00
|
|
|
Editing_File *file = imp_get_file(cmd, buffer);
|
2016-06-13 18:54:26 +00:00
|
|
|
|
2017-04-15 21:47:23 +00:00
|
|
|
bool32 result = false;
|
2016-06-13 18:54:26 +00:00
|
|
|
|
|
|
|
i32 new_mapid = 0;
|
|
|
|
|
2017-04-15 21:47:23 +00:00
|
|
|
if (file != 0){
|
|
|
|
result = true;
|
2016-06-14 20:40:57 +00:00
|
|
|
switch (setting){
|
|
|
|
case BufferSetting_Lex:
|
|
|
|
{
|
|
|
|
if (file->settings.tokens_exist){
|
|
|
|
if (!value){
|
|
|
|
file_kill_tokens(system, &models->mem.general, file);
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
2016-06-14 20:40:57 +00:00
|
|
|
}
|
|
|
|
else{
|
|
|
|
if (value){
|
2016-10-27 05:58:22 +00:00
|
|
|
if (!file->settings.virtual_white){
|
2017-05-19 23:55:50 +00:00
|
|
|
file_first_lex_parallel(system, models, file);
|
2016-10-27 05:58:22 +00:00
|
|
|
}
|
|
|
|
else{
|
2017-05-19 23:55:50 +00:00
|
|
|
file_first_lex_serial(models, file);
|
2016-10-27 05:58:22 +00:00
|
|
|
}
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
2016-06-14 20:40:57 +00:00
|
|
|
}
|
|
|
|
}break;
|
|
|
|
|
2017-04-15 21:47:23 +00:00
|
|
|
case BufferSetting_LexWithoutStrings:
|
|
|
|
{
|
|
|
|
if (file->settings.tokens_exist){
|
|
|
|
if ((b8)value != file->settings.tokens_without_strings){
|
|
|
|
file_kill_tokens(system, &models->mem.general, file);
|
|
|
|
file->settings.tokens_without_strings = (b8)value;
|
|
|
|
if (!file->settings.virtual_white){
|
2017-05-19 23:55:50 +00:00
|
|
|
file_first_lex_parallel(system, models, file);
|
2017-04-15 21:47:23 +00:00
|
|
|
}
|
|
|
|
else{
|
2017-05-19 23:55:50 +00:00
|
|
|
file_first_lex_serial(models, file);
|
2017-04-15 21:47:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
file->settings.tokens_without_strings = (b8)value;
|
|
|
|
}
|
|
|
|
}break;
|
|
|
|
|
2017-05-21 01:22:20 +00:00
|
|
|
case BufferSetting_ParserContext:
|
|
|
|
{
|
|
|
|
u32 fixed_value = parse_context_valid_id(&models->parse_context_memory, (u32)value);
|
|
|
|
|
|
|
|
if (file->settings.tokens_exist){
|
|
|
|
if (fixed_value != file->settings.parse_context_id){
|
|
|
|
file_kill_tokens(system, &models->mem.general, file);
|
|
|
|
file->settings.parse_context_id = fixed_value;
|
|
|
|
if (!file->settings.virtual_white){
|
|
|
|
file_first_lex_parallel(system, models, file);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
file_first_lex_serial(models, file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
file->settings.parse_context_id = fixed_value;
|
|
|
|
}
|
|
|
|
}break;
|
|
|
|
|
2016-06-14 20:40:57 +00:00
|
|
|
case BufferSetting_WrapLine:
|
|
|
|
{
|
|
|
|
file->settings.unwrapped_lines = !value;
|
|
|
|
}break;
|
|
|
|
|
2016-09-22 00:01:12 +00:00
|
|
|
case BufferSetting_WrapPosition:
|
|
|
|
{
|
|
|
|
i32 new_value = value;
|
|
|
|
if (new_value < 48){
|
|
|
|
new_value = 48;
|
|
|
|
}
|
|
|
|
if (new_value != file->settings.display_width){
|
2017-11-16 23:03:36 +00:00
|
|
|
Font_Pointers font = system->font.get_pointers_by_id(file->settings.font_id);
|
2017-05-21 01:22:20 +00:00
|
|
|
file->settings.display_width = new_value;
|
2018-03-24 21:43:57 +00:00
|
|
|
file_measure_wraps(system, &models->mem, file, font);
|
|
|
|
adjust_views_looking_at_files_to_new_cursor(system, models, file);
|
2016-09-22 00:01:12 +00:00
|
|
|
}
|
|
|
|
}break;
|
|
|
|
|
2016-10-27 23:45:41 +00:00
|
|
|
case BufferSetting_MinimumBaseWrapPosition:
|
|
|
|
{
|
|
|
|
i32 new_value = value;
|
|
|
|
if (new_value < 0){
|
|
|
|
new_value = 0;
|
|
|
|
}
|
|
|
|
if (new_value != file->settings.minimum_base_display_width){
|
2017-11-16 23:03:36 +00:00
|
|
|
Font_Pointers font = system->font.get_pointers_by_id(file->settings.font_id);
|
2017-05-21 01:22:20 +00:00
|
|
|
file->settings.minimum_base_display_width = new_value;
|
2018-03-24 21:43:57 +00:00
|
|
|
file_measure_wraps(system, &models->mem, file, font);
|
|
|
|
adjust_views_looking_at_files_to_new_cursor(system, models, file);
|
2016-10-27 23:45:41 +00:00
|
|
|
}
|
|
|
|
}break;
|
|
|
|
|
|
|
|
case BufferSetting_WrapIndicator:
|
|
|
|
{
|
|
|
|
file->settings.wrap_indicator = value;
|
|
|
|
}break;
|
|
|
|
|
2016-06-14 20:40:57 +00:00
|
|
|
case BufferSetting_MapID:
|
|
|
|
{
|
2017-03-29 16:32:06 +00:00
|
|
|
if (value < mapid_global){
|
2017-11-08 18:24:30 +00:00
|
|
|
new_mapid = get_map_index(&models->mapping, value);
|
|
|
|
if (new_mapid < models->mapping.user_map_count){
|
2016-06-14 20:40:57 +00:00
|
|
|
file->settings.base_map_id = value;
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
2016-06-14 20:40:57 +00:00
|
|
|
else{
|
2016-06-13 18:54:26 +00:00
|
|
|
file->settings.base_map_id = mapid_file;
|
|
|
|
}
|
2016-06-14 20:40:57 +00:00
|
|
|
}
|
2017-03-29 16:32:06 +00:00
|
|
|
else if (value <= mapid_nomap){
|
|
|
|
file->settings.base_map_id = value;
|
|
|
|
}
|
2016-06-14 20:40:57 +00:00
|
|
|
|
2018-03-24 10:06:45 +00:00
|
|
|
for (Panel *panel = models->layout.used_sentinel.next;
|
|
|
|
panel != &models->layout.used_sentinel;
|
|
|
|
panel = panel->next){
|
|
|
|
View *view = panel->view;
|
|
|
|
if (view->transient.file_data.file != file){
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
view->transient.map = file->settings.base_map_id;
|
2016-06-14 20:40:57 +00:00
|
|
|
}
|
|
|
|
}break;
|
2016-07-04 20:40:57 +00:00
|
|
|
|
|
|
|
case BufferSetting_Eol:
|
|
|
|
{
|
|
|
|
file->settings.dos_write_mode = value;
|
|
|
|
}break;
|
2016-07-12 18:20:06 +00:00
|
|
|
|
|
|
|
case BufferSetting_Unimportant:
|
|
|
|
{
|
|
|
|
if (value){
|
2017-02-12 06:01:01 +00:00
|
|
|
file->settings.unimportant = true;
|
2016-07-12 18:20:06 +00:00
|
|
|
}
|
|
|
|
else{
|
2017-02-12 06:01:01 +00:00
|
|
|
file->settings.unimportant = false;
|
2016-07-12 18:20:06 +00:00
|
|
|
}
|
|
|
|
}break;
|
|
|
|
|
|
|
|
case BufferSetting_ReadOnly:
|
|
|
|
{
|
|
|
|
if (value){
|
2017-05-19 23:55:50 +00:00
|
|
|
file->settings.read_only = true;
|
2016-07-12 18:20:06 +00:00
|
|
|
}
|
|
|
|
else{
|
2017-05-19 23:55:50 +00:00
|
|
|
file->settings.read_only = false;
|
2016-07-12 18:20:06 +00:00
|
|
|
}
|
|
|
|
}break;
|
2016-10-05 06:08:23 +00:00
|
|
|
|
|
|
|
case BufferSetting_VirtualWhitespace:
|
|
|
|
{
|
2017-05-19 23:55:50 +00:00
|
|
|
b32 full_remeasure = false;
|
2016-10-05 06:08:23 +00:00
|
|
|
if (value){
|
|
|
|
if (!file->settings.virtual_white){
|
2016-10-28 14:11:56 +00:00
|
|
|
if (!file->settings.tokens_exist){
|
2017-05-19 23:55:50 +00:00
|
|
|
file_first_lex_serial(models, file);
|
2016-10-28 14:11:56 +00:00
|
|
|
}
|
|
|
|
if (!file->state.still_lexing){
|
2017-05-19 23:55:50 +00:00
|
|
|
file->settings.virtual_white = true;
|
|
|
|
full_remeasure = true;
|
2016-10-27 05:58:22 +00:00
|
|
|
}
|
|
|
|
else{
|
2017-05-19 23:55:50 +00:00
|
|
|
result = false;
|
2016-10-27 05:58:22 +00:00
|
|
|
}
|
2016-10-05 06:08:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
if (file->settings.virtual_white){
|
2017-05-19 23:55:50 +00:00
|
|
|
file->settings.virtual_white = false;
|
|
|
|
full_remeasure = true;
|
2016-10-05 06:08:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (full_remeasure){
|
2017-11-16 23:03:36 +00:00
|
|
|
Font_Pointers font = system->font.get_pointers_by_id(file->settings.font_id);
|
2016-10-05 06:08:23 +00:00
|
|
|
|
2017-01-14 03:01:35 +00:00
|
|
|
file_allocate_character_starts_as_needed(&models->mem.general, file);
|
2017-03-12 23:24:18 +00:00
|
|
|
buffer_measure_character_starts(system, font, &file->state.buffer, file->state.character_starts, 0, file->settings.virtual_white);
|
2018-03-24 21:43:57 +00:00
|
|
|
file_measure_wraps(system, &models->mem, file, font);
|
|
|
|
adjust_views_looking_at_files_to_new_cursor(system, models, file);
|
2016-10-05 06:08:23 +00:00
|
|
|
}
|
|
|
|
}break;
|
2016-10-27 05:58:22 +00:00
|
|
|
|
|
|
|
default: result = 0; break;
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
2016-06-14 20:40:57 +00:00
|
|
|
fill_buffer_summary(buffer, file, cmd);
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2016-09-08 00:32:31 +00:00
|
|
|
API_EXPORT int32_t
|
2016-09-17 00:03:09 +00:00
|
|
|
Buffer_Token_Count(Application_Links *app, Buffer_Summary *buffer)
|
|
|
|
/*
|
2016-09-08 22:57:37 +00:00
|
|
|
DOC_PARAM(buffer, Specifies the buffer from which to read the token count.)
|
|
|
|
DOC_RETURN(If tokens are available for the buffer, the number of tokens on the buffer is returned.
|
|
|
|
If the buffer does not exist or if it is not a lexed buffer, the return is zero.)
|
|
|
|
*/{
|
2016-06-24 02:53:33 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
2016-09-08 00:32:31 +00:00
|
|
|
Editing_File *file = imp_get_file(cmd, buffer);
|
2016-06-24 02:53:33 +00:00
|
|
|
|
2016-09-08 00:32:31 +00:00
|
|
|
int32_t count = 0;
|
2016-06-24 02:53:33 +00:00
|
|
|
|
2016-09-08 00:32:31 +00:00
|
|
|
if (file && file->state.token_array.tokens && file->state.tokens_complete){
|
|
|
|
count = file->state.token_array.count;
|
|
|
|
}
|
|
|
|
|
|
|
|
return(count);
|
|
|
|
}
|
|
|
|
|
|
|
|
API_EXPORT bool32
|
2017-03-23 19:15:33 +00:00
|
|
|
Buffer_Read_Tokens(Application_Links *app, Buffer_Summary *buffer, int32_t start_token, int32_t end_token, Cpp_Token *tokens_out)
|
2016-09-17 00:03:09 +00:00
|
|
|
/*
|
2016-09-08 22:57:37 +00:00
|
|
|
DOC_PARAM(buffer, Specifies the buffer from which to read tokens.)
|
|
|
|
DOC_PARAM(first_token, Specifies the index of the first token to read.)
|
|
|
|
DOC_PARAM(end_token, Specifies the token to stop reading at.)
|
|
|
|
DOC_PARAM(tokens_out, The memory that will store the tokens read from the buffer.)
|
|
|
|
DOC_RETURN(Returns non-zero on success. This call can fail if the buffer doesn't
|
|
|
|
exist or doesn't have tokens ready, or if either the first or last index is out of bounds.)
|
|
|
|
DOC(Puts the data for the tokens with the indices [first_token,last_token) into the tokens_out array.
|
|
|
|
The number of output tokens will be end_token - start_token.)
|
|
|
|
*/{
|
2016-09-08 00:32:31 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
2016-06-24 02:53:33 +00:00
|
|
|
Editing_File *file = imp_get_file(cmd, buffer);
|
2016-09-08 22:57:37 +00:00
|
|
|
Cpp_Token_Array token_array = file->state.token_array;
|
2016-09-08 00:32:31 +00:00
|
|
|
|
|
|
|
bool32 result = 0;
|
2016-09-08 22:57:37 +00:00
|
|
|
if (file && token_array.tokens && file->state.tokens_complete){
|
|
|
|
if (0 <= start_token && start_token <= end_token && end_token <= token_array.count){
|
|
|
|
result = 1;
|
|
|
|
memcpy(tokens_out, token_array.tokens + start_token, sizeof(Cpp_Token)*(end_token - start_token));
|
|
|
|
}
|
2016-06-24 02:53:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2016-09-15 15:01:52 +00:00
|
|
|
API_EXPORT bool32
|
2017-03-23 19:15:33 +00:00
|
|
|
Buffer_Get_Token_Index(Application_Links *app, Buffer_Summary *buffer, int32_t pos, Cpp_Get_Token_Result *get_result)
|
2016-09-17 00:03:09 +00:00
|
|
|
/*
|
|
|
|
DOC_PARAM(buffer, The buffer from which to get a token.)
|
|
|
|
DOC_PARAM(pos, The position in the buffer in absolute coordinates.)
|
|
|
|
DOC_PARAM(get_result, The output struct specifying which token contains pos.)
|
2017-01-14 03:01:35 +00:00
|
|
|
DOC_RETURN(Returns non-zero on success. This call can fail if the buffer doesn't exist, or if the buffer doesn't have tokens ready.)
|
|
|
|
DOC(This call finds the token that contains a particular position, or if the position is in between tokens it finds the index of the token to the left of the position. The returned index can be -1 if the position is before the first token.)
|
2016-09-17 00:03:09 +00:00
|
|
|
DOC_SEE(Cpp_Get_Token_Result)
|
|
|
|
DOC_SEE(cpp_get_token)
|
|
|
|
*/{
|
2016-09-15 15:01:52 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
Editing_File *file = imp_get_file(cmd, buffer);
|
|
|
|
Cpp_Token_Array token_array = file->state.token_array;
|
|
|
|
|
2017-04-23 00:53:19 +00:00
|
|
|
bool32 result = false;
|
|
|
|
if (file != 0 && token_array.tokens != 0 && file->state.tokens_complete){
|
|
|
|
result = true;
|
|
|
|
*get_result = cpp_get_token(token_array, pos);
|
|
|
|
}
|
|
|
|
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
API_EXPORT bool32
|
2017-05-14 23:22:08 +00:00
|
|
|
Buffer_Send_End_Signal(Application_Links *app, Buffer_Summary *buffer)
|
|
|
|
/*
|
|
|
|
DOC_PARAM(buffer, The buffer to which to send the end signal.)
|
|
|
|
DOC_RETURN(Returns non-zero on success. This call can fail if the buffer doesn't exist.)
|
|
|
|
DOC(Whenever a buffer is killed an end signal is sent which triggers the end file hook. This call sends the end signal to the buffer without killing the buffer. This is useful in cases such as clearing a buffer and refilling it with new contents.)
|
|
|
|
*/{
|
2017-04-23 00:53:19 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
Models *models = cmd->models;
|
|
|
|
Editing_File *file = imp_get_file(cmd, buffer);
|
|
|
|
|
|
|
|
bool32 result = false;
|
|
|
|
if (file != 0){
|
2017-05-14 23:22:08 +00:00
|
|
|
result = true;
|
2017-04-23 00:53:19 +00:00
|
|
|
Open_File_Hook_Function *hook_end_file = models->hook_end_file;
|
|
|
|
if (hook_end_file != 0){
|
|
|
|
hook_end_file(app, file->id.id);
|
|
|
|
}
|
2016-09-15 15:01:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2016-06-27 15:52:58 +00:00
|
|
|
API_EXPORT Buffer_Summary
|
2017-07-17 20:59:28 +00:00
|
|
|
Create_Buffer(Application_Links *app, char *filename, int32_t filename_len, Buffer_Create_Flag flags)
|
|
|
|
/*
|
2017-07-17 21:13:57 +00:00
|
|
|
DOC_PARAM(filename, The name of the file to associate to the new buffer.)
|
2017-07-17 20:59:28 +00:00
|
|
|
DOC_PARAM(filename_len, The length of the filename string.)
|
|
|
|
DOC_PARAM(flags, Flags controlling the buffer creation behavior.)
|
2017-07-17 21:13:57 +00:00
|
|
|
DOC_RETURN(Returns the newly created buffer or an already existing buffer with the given name.)
|
|
|
|
DOC(Try to create a new buffer. This call first checks to see if a buffer already exists that goes by the given name, if so, that buffer is returned.
|
|
|
|
|
|
|
|
If no buffer exists with the given name, then a new buffer is created. If a file that matches the given filename exists, the file is loaded as the contents of the new buffer. Otherwise a buffer is created without a matching file until the buffer is saved and the buffer is left blank.)
|
2017-07-17 20:59:28 +00:00
|
|
|
DOC_SEE(Buffer_Create_Flag)
|
|
|
|
*/{
|
2017-03-29 20:50:29 +00:00
|
|
|
PRFL_FUNC_GROUP();
|
|
|
|
|
2016-10-08 20:20:49 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
System_Functions *system = cmd->system;
|
|
|
|
Models *models = cmd->models;
|
|
|
|
Working_Set *working_set = &models->working_set;
|
|
|
|
General_Memory *general = &models->mem.general;
|
|
|
|
Partition *part = &models->mem.part;
|
|
|
|
|
|
|
|
Buffer_Summary result = {0};
|
|
|
|
|
2017-07-17 20:43:01 +00:00
|
|
|
if (filename_len > 0){
|
2017-07-17 20:59:28 +00:00
|
|
|
Temp_Memory temp = begin_temp_memory(part);
|
2017-01-14 03:01:35 +00:00
|
|
|
|
2017-07-17 20:59:28 +00:00
|
|
|
// NOTE(allen): Try to get the file by canon name.
|
|
|
|
String fname = make_string(filename, filename_len);
|
2017-01-14 03:01:35 +00:00
|
|
|
Editing_File *file = 0;
|
2017-06-28 15:15:54 +00:00
|
|
|
b32 do_new_file = false;
|
2017-11-30 23:25:49 +00:00
|
|
|
Editing_File_Name canon = {0};
|
2016-10-08 20:20:49 +00:00
|
|
|
if (get_canon_name(system, &canon, fname)){
|
2017-11-30 23:25:49 +00:00
|
|
|
file = working_set_contains_canon(working_set, canon.name);
|
2016-10-08 20:20:49 +00:00
|
|
|
}
|
|
|
|
else{
|
2017-06-28 15:15:54 +00:00
|
|
|
do_new_file = true;
|
2016-10-08 20:20:49 +00:00
|
|
|
}
|
|
|
|
|
2017-07-17 20:59:28 +00:00
|
|
|
// NOTE(allen): Try to get the file by buffer name.
|
2017-06-28 15:15:54 +00:00
|
|
|
if (file == 0){
|
2017-11-30 23:25:49 +00:00
|
|
|
file = working_set_contains_name(working_set, fname);
|
2016-10-08 20:20:49 +00:00
|
|
|
}
|
|
|
|
|
2017-07-17 20:59:28 +00:00
|
|
|
// NOTE(allen): If there is still no file, create a new buffer.
|
2017-06-28 15:15:54 +00:00
|
|
|
if (file == 0){
|
2017-07-17 20:59:28 +00:00
|
|
|
Plat_Handle handle = {0};
|
|
|
|
|
|
|
|
// NOTE(allen): Figure out whether this is a new file, or an existing file.
|
2016-10-08 20:20:49 +00:00
|
|
|
if (!do_new_file){
|
|
|
|
if (flags & BufferCreate_AlwaysNew){
|
2017-06-28 15:15:54 +00:00
|
|
|
do_new_file = true;
|
2016-10-08 20:20:49 +00:00
|
|
|
}
|
|
|
|
else{
|
|
|
|
if (!system->load_handle(canon.name.str, &handle)){
|
2017-06-28 15:15:54 +00:00
|
|
|
do_new_file = true;
|
2016-10-08 20:20:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-17 20:59:28 +00:00
|
|
|
if (do_new_file){
|
|
|
|
if (!(flags & BufferCreate_NeverNew)){
|
|
|
|
file = working_set_alloc_always(working_set, general);
|
|
|
|
if (file != 0){
|
2017-12-01 18:04:07 +00:00
|
|
|
buffer_bind_name(models, general, part, working_set, file, fname);
|
2017-07-17 20:59:28 +00:00
|
|
|
init_normal_file(system, models, file, 0, 0);
|
|
|
|
fill_buffer_summary(&result, file, cmd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
2017-01-30 18:41:08 +00:00
|
|
|
Assert(!handle_equal(handle, null_plat_handle));
|
2016-10-08 20:20:49 +00:00
|
|
|
|
|
|
|
i32 size = system->load_size(handle);
|
2017-06-28 15:15:54 +00:00
|
|
|
b32 in_general_mem = false;
|
2016-10-08 20:20:49 +00:00
|
|
|
char *buffer = push_array(part, char, size);
|
|
|
|
|
|
|
|
if (buffer == 0){
|
2017-01-14 03:01:35 +00:00
|
|
|
buffer = (char*)general_memory_allocate(general, size);
|
2016-10-08 20:20:49 +00:00
|
|
|
Assert(buffer != 0);
|
2017-06-28 15:15:54 +00:00
|
|
|
in_general_mem = true;
|
2016-10-08 20:20:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (system->load_file(handle, buffer, size)){
|
2016-11-05 02:59:35 +00:00
|
|
|
system->load_close(handle);
|
2017-01-14 03:01:35 +00:00
|
|
|
file = working_set_alloc_always(working_set, general);
|
2017-11-21 21:30:40 +00:00
|
|
|
if (file != 0){
|
2016-10-08 20:20:49 +00:00
|
|
|
buffer_bind_file(system, general, working_set, file, canon.name);
|
2017-12-01 18:04:07 +00:00
|
|
|
buffer_bind_name(models, general, part, working_set, file, fname);
|
2016-10-08 20:20:49 +00:00
|
|
|
init_normal_file(system, models, file, buffer, size);
|
|
|
|
fill_buffer_summary(&result, file, cmd);
|
|
|
|
}
|
|
|
|
}
|
2016-11-05 02:59:35 +00:00
|
|
|
else{
|
|
|
|
system->load_close(handle);
|
|
|
|
}
|
2016-10-08 20:20:49 +00:00
|
|
|
|
|
|
|
if (in_general_mem){
|
2017-01-14 03:01:35 +00:00
|
|
|
general_memory_free(general, buffer);
|
2016-10-08 20:20:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
fill_buffer_summary(&result, file, cmd);
|
|
|
|
}
|
|
|
|
|
2017-11-21 21:30:40 +00:00
|
|
|
if (file != 0 && (flags & BufferCreate_JustChangedFile)){
|
|
|
|
file->state.ignore_behind_os = 1;
|
|
|
|
}
|
|
|
|
|
2016-10-08 20:20:49 +00:00
|
|
|
end_temp_memory(temp);
|
2017-01-14 03:01:35 +00:00
|
|
|
}
|
2016-06-17 03:31:15 +00:00
|
|
|
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2016-07-02 14:15:15 +00:00
|
|
|
API_EXPORT bool32
|
2017-11-21 21:30:40 +00:00
|
|
|
Save_Buffer(Application_Links *app, Buffer_Summary *buffer, char *file_name, int32_t file_name_len, uint32_t flags)
|
2016-10-08 20:20:49 +00:00
|
|
|
/*
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_PARAM(buffer, The buffer parameter specifies the buffer to save to a file.)
|
2017-11-21 21:30:40 +00:00
|
|
|
DOC_PARAM(file_name, The file_name parameter specifies the name of the file to write with the contents of the buffer; it need not be null terminated.)
|
|
|
|
DOC_PARAM(file_name_len, The file_name_len parameter specifies the length of the file_name string.)
|
|
|
|
DOC_PARAM(flags, Specifies special behaviors for the save routine.)
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_RETURN(This call returns non-zero on success.)
|
2017-11-21 21:30:40 +00:00
|
|
|
DOC(Often it will make sense to set file_name and file_name_len to buffer.file_name and buffer.file_name_len)
|
|
|
|
DOC_SEE(Buffer_Save_Flag)
|
2016-06-24 02:21:11 +00:00
|
|
|
*/{
|
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
System_Functions *system = cmd->system;
|
|
|
|
Models *models = cmd->models;
|
2017-11-21 21:30:40 +00:00
|
|
|
bool32 result = false;
|
2016-06-24 02:21:11 +00:00
|
|
|
|
|
|
|
Editing_File *file = imp_get_file(cmd, buffer);
|
2017-11-21 21:30:40 +00:00
|
|
|
if (file != 0){
|
|
|
|
b32 skip_save = false;
|
|
|
|
if (!(flags & BufferSave_IgnoreDirtyFlag)){
|
2018-03-24 21:43:57 +00:00
|
|
|
if (file->state.dirty == DirtyState_UpToDate){
|
2017-11-21 21:30:40 +00:00
|
|
|
skip_save = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!skip_save){
|
|
|
|
result = true;
|
2017-01-14 03:01:35 +00:00
|
|
|
|
|
|
|
Partition *part = &models->mem.part;
|
|
|
|
Temp_Memory temp = begin_temp_memory(part);
|
2017-11-21 21:30:40 +00:00
|
|
|
String name = make_string_terminated(part, file_name, file_name_len);
|
2016-12-26 22:49:01 +00:00
|
|
|
save_file_to_name(system, models, file, name.str);
|
2016-11-05 03:55:07 +00:00
|
|
|
end_temp_memory(temp);
|
|
|
|
}
|
2017-01-14 03:01:35 +00:00
|
|
|
}
|
2016-06-24 02:21:11 +00:00
|
|
|
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2016-07-02 14:15:15 +00:00
|
|
|
API_EXPORT bool32
|
2016-10-08 20:20:49 +00:00
|
|
|
Kill_Buffer(Application_Links *app, Buffer_Identifier buffer, View_ID view_id, Buffer_Kill_Flag flags)
|
|
|
|
/*
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_PARAM(buffer, The buffer parameter specifies the buffer to try to kill.)
|
|
|
|
DOC_PARAM(view_id, The view_id parameter specifies the view that will contain the "are you sure" dialogue if the buffer is dirty.)
|
|
|
|
DOC_PARAM(flags, The flags parameter specifies behaviors for the buffer kill.)
|
2016-08-27 17:48:10 +00:00
|
|
|
DOC_RETURN(This call returns non-zero if the buffer is killed.)
|
2016-09-09 13:04:51 +00:00
|
|
|
|
|
|
|
DOC(Tries to kill the idenfied buffer. If the buffer is dirty and the "are you sure"
|
2016-06-24 02:21:11 +00:00
|
|
|
dialogue needs to be displayed the provided view is used to show the dialogue.
|
2016-09-09 13:04:51 +00:00
|
|
|
If the view is not open the kill fails.)
|
|
|
|
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_SEE(Buffer_Kill_Flag)
|
|
|
|
DOC_SEE(Buffer_Identifier)
|
2016-06-24 02:21:11 +00:00
|
|
|
*/{
|
2016-06-17 03:31:15 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
System_Functions *system = cmd->system;
|
|
|
|
Models *models = cmd->models;
|
|
|
|
Working_Set *working_set = &models->working_set;
|
|
|
|
View *vptr = imp_get_view(cmd, view_id);
|
|
|
|
Editing_File *file = get_file_from_identifier(system, working_set, buffer);
|
2016-08-29 01:03:26 +00:00
|
|
|
int32_t result = false;
|
2016-06-17 03:31:15 +00:00
|
|
|
|
|
|
|
if (file){
|
2016-06-24 02:21:11 +00:00
|
|
|
if (flags & BufferKill_AlwaysKill){
|
|
|
|
result = true;
|
2016-08-24 23:01:33 +00:00
|
|
|
kill_file(system, models, file);
|
2016-06-17 03:31:15 +00:00
|
|
|
}
|
|
|
|
else{
|
2016-08-27 17:48:10 +00:00
|
|
|
Try_Kill_Result kill_result = interactive_try_kill_file(system, models, file);
|
|
|
|
if (kill_result == TryKill_NeedDialogue){
|
|
|
|
if (vptr){
|
2017-07-17 23:35:13 +00:00
|
|
|
interactive_begin_sure_to_kill(system, vptr, models, file);
|
2016-08-27 17:48:10 +00:00
|
|
|
}
|
|
|
|
else{
|
|
|
|
#define MESSAGE "CUSTOM WARNING: the buffer is dirty and no view was specified for a dialogue.\n"
|
2016-09-17 00:03:09 +00:00
|
|
|
print_message(app, literal(MESSAGE));
|
2016-08-27 17:48:10 +00:00
|
|
|
#undef MESSAGE
|
|
|
|
}
|
2016-06-24 02:21:11 +00:00
|
|
|
}
|
|
|
|
else{
|
2016-08-27 17:48:10 +00:00
|
|
|
if (kill_result == TryKill_Success){
|
|
|
|
result = true;
|
|
|
|
}
|
2016-06-24 02:21:11 +00:00
|
|
|
}
|
2016-06-17 03:31:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2016-06-20 20:34:48 +00:00
|
|
|
internal void
|
|
|
|
internal_get_view_first(Command_Data *cmd, View_Summary *view){
|
2016-06-13 18:54:26 +00:00
|
|
|
Editing_Layout *layout = &cmd->models->layout;
|
|
|
|
Panel *panel = layout->used_sentinel.next;
|
|
|
|
|
|
|
|
Assert(panel != &layout->used_sentinel);
|
2017-03-12 01:20:24 +00:00
|
|
|
System_Functions *system = cmd->system;
|
|
|
|
fill_view_summary(system, view, panel->view, cmd);
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
|
|
|
|
2016-06-20 20:34:48 +00:00
|
|
|
internal void
|
|
|
|
internal_get_view_next(Command_Data *cmd, View_Summary *view){
|
2017-03-12 01:20:24 +00:00
|
|
|
System_Functions *system = cmd->system;
|
2016-06-13 18:54:26 +00:00
|
|
|
Editing_Layout *layout = &cmd->models->layout;
|
2017-07-17 23:35:13 +00:00
|
|
|
Live_Views *live_set = &cmd->models->live_set;
|
2016-08-29 01:03:26 +00:00
|
|
|
int32_t index = view->view_id - 1;
|
2016-06-13 18:54:26 +00:00
|
|
|
|
|
|
|
if (index >= 0 && index < live_set->max){
|
2017-03-12 01:20:24 +00:00
|
|
|
View *vptr = live_set->views + index;
|
2018-03-24 10:06:45 +00:00
|
|
|
Panel *panel = vptr->transient.panel;
|
2017-07-17 23:35:13 +00:00
|
|
|
if (panel != 0){
|
2016-06-20 20:34:48 +00:00
|
|
|
panel = panel->next;
|
|
|
|
}
|
2017-07-17 23:35:13 +00:00
|
|
|
if (panel != 0 && panel != &layout->used_sentinel){
|
|
|
|
fill_view_summary(system, view, panel->view, live_set, &cmd->models->working_set);
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
|
|
|
else{
|
2016-09-01 19:40:25 +00:00
|
|
|
*view = null_view_summary;
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
2016-09-01 19:40:25 +00:00
|
|
|
*view = null_view_summary;
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-27 15:52:58 +00:00
|
|
|
API_EXPORT View_Summary
|
2016-10-08 20:20:49 +00:00
|
|
|
Get_View_First(Application_Links *app, Access_Flag access)
|
|
|
|
/*
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_PARAM(access, The access parameter determines what levels of protection this call can access.)
|
|
|
|
DOC_RETURN(This call returns the summary of the first view in a view loop.)
|
2016-10-08 20:20:49 +00:00
|
|
|
DOC(
|
2016-07-02 14:15:15 +00:00
|
|
|
This call begins a loop across all the open views.
|
2016-06-24 02:21:11 +00:00
|
|
|
|
2016-07-05 01:36:30 +00:00
|
|
|
If the View_Summary returned is a null summary, the loop is finished.
|
2016-06-24 02:21:11 +00:00
|
|
|
Views should not be closed or opened durring a view loop.
|
|
|
|
)
|
|
|
|
DOC_SEE(Access_Flag)
|
|
|
|
DOC_SEE(get_view_next)
|
|
|
|
*/{
|
2016-06-20 20:34:48 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
View_Summary view = {};
|
|
|
|
|
|
|
|
internal_get_view_first(cmd, &view);
|
|
|
|
while (view.exists && !access_test(view.lock_flags, access)){
|
|
|
|
internal_get_view_next(cmd, &view);
|
|
|
|
}
|
|
|
|
|
|
|
|
return(view);
|
|
|
|
}
|
|
|
|
|
2016-06-27 15:52:58 +00:00
|
|
|
API_EXPORT void
|
2016-10-08 20:20:49 +00:00
|
|
|
Get_View_Next(Application_Links *app, View_Summary *view, Access_Flag access)
|
|
|
|
/*
|
2016-07-05 01:36:30 +00:00
|
|
|
DOC_PARAM(view, The View_Summary pointed to by view is iterated to the next view or to a null summary if this is the last view.)
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_PARAM(access, The access parameter determines what levels of protection this call can access. The view outputted will be the next view that is accessible.)
|
2016-06-24 02:21:11 +00:00
|
|
|
DOC
|
|
|
|
(
|
2016-07-05 01:36:30 +00:00
|
|
|
This call steps a View_Summary to the next view in the global view order.
|
2016-06-24 02:21:11 +00:00
|
|
|
|
2016-07-02 14:15:15 +00:00
|
|
|
If the view outputted does not exist, the loop is finished.
|
2016-06-24 02:21:11 +00:00
|
|
|
Views should not be closed or opened durring a view loop.
|
|
|
|
)
|
|
|
|
DOC_SEE(Access_Flag)
|
|
|
|
DOC_SEE(get_view_first)
|
|
|
|
*/{
|
2016-06-20 20:34:48 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
|
|
|
|
internal_get_view_next(cmd, view);
|
|
|
|
while (view->exists && !access_test(view->lock_flags, access)){
|
|
|
|
internal_get_view_next(cmd, view);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-27 15:52:58 +00:00
|
|
|
API_EXPORT View_Summary
|
2016-10-08 20:20:49 +00:00
|
|
|
Get_View(Application_Links *app, View_ID view_id, Access_Flag access)
|
|
|
|
/*
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_PARAM(view_id, The view_id specifies the view to try to get.)
|
|
|
|
DOC_PARAM(access, The access parameter determines what levels of protection this call can access.)
|
|
|
|
DOC_RETURN(This call returns a summary that describes the indicated view if it is open and accessible.)
|
|
|
|
DOC_SEE(Access_Flag)
|
2016-06-24 02:21:11 +00:00
|
|
|
*/{
|
2016-06-13 18:54:26 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
2017-03-12 01:20:24 +00:00
|
|
|
System_Functions *system = cmd->system;
|
2016-06-24 02:21:11 +00:00
|
|
|
View_Summary view = {0};
|
2016-06-13 18:54:26 +00:00
|
|
|
Live_Views *live_set = cmd->live_set;
|
2016-07-02 14:15:15 +00:00
|
|
|
i32 max = live_set->max;
|
2016-06-13 18:54:26 +00:00
|
|
|
|
2016-06-24 02:21:11 +00:00
|
|
|
view_id -= 1;
|
|
|
|
if (view_id >= 0 && view_id < max){
|
2017-03-12 01:20:24 +00:00
|
|
|
View *vptr = live_set->views + view_id;
|
|
|
|
fill_view_summary(system, &view, vptr, live_set, &cmd->models->working_set);
|
2016-06-20 20:34:48 +00:00
|
|
|
if (!access_test(view.lock_flags, access)){
|
2016-09-01 19:40:25 +00:00
|
|
|
view = null_view_summary;
|
2016-06-20 20:34:48 +00:00
|
|
|
}
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return(view);
|
|
|
|
}
|
|
|
|
|
2016-06-27 15:52:58 +00:00
|
|
|
API_EXPORT View_Summary
|
2016-10-08 20:20:49 +00:00
|
|
|
Get_Active_View(Application_Links *app, Access_Flag access)
|
|
|
|
/*
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_PARAM(access, The access parameter determines what levels of protection this call can access.)
|
|
|
|
DOC_RETURN(This call returns a summary that describes the active view.)
|
2016-06-28 19:48:12 +00:00
|
|
|
DOC_SEE(set_active_view)
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_SEE(Access_Flag)
|
2016-06-24 02:21:11 +00:00
|
|
|
*/{
|
2016-06-13 18:54:26 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
2017-03-12 01:20:24 +00:00
|
|
|
System_Functions *system = cmd->system;
|
2017-07-17 23:35:13 +00:00
|
|
|
Models *models = cmd->models;
|
|
|
|
Panel *panel = models->layout.panels + models->layout.active_panel;
|
2016-09-17 01:53:31 +00:00
|
|
|
|
|
|
|
Assert(panel->view != 0);
|
|
|
|
|
2016-06-28 19:48:12 +00:00
|
|
|
View_Summary view = {0};
|
2017-07-17 23:35:13 +00:00
|
|
|
fill_view_summary(system, &view, panel->view, &models->live_set, &models->working_set);
|
2016-06-20 20:34:48 +00:00
|
|
|
if (!access_test(view.lock_flags, access)){
|
2016-09-01 19:40:25 +00:00
|
|
|
view = null_view_summary;
|
2016-06-20 20:34:48 +00:00
|
|
|
}
|
2016-06-13 18:54:26 +00:00
|
|
|
return(view);
|
|
|
|
}
|
|
|
|
|
2016-07-05 01:36:30 +00:00
|
|
|
API_EXPORT View_Summary
|
2016-10-08 20:20:49 +00:00
|
|
|
Open_View(Application_Links *app, View_Summary *view_location, View_Split_Position position)
|
|
|
|
/*
|
2016-07-05 01:36:30 +00:00
|
|
|
DOC_PARAM(view_location, The view_location parameter specifies the view to split to open the new view.)
|
|
|
|
DOC_PARAM(position, The position parameter specifies how to split the view and where to place the new view.)
|
|
|
|
DOC_RETURN(If this call succeeds it returns a View_Summary describing the newly created view, if it fails it
|
|
|
|
returns a null summary.)
|
2016-09-17 01:53:31 +00:00
|
|
|
DOC(4coder is built with a limit of 16 views. If 16 views are already open when this is called the call will fail.)
|
2016-07-05 01:36:30 +00:00
|
|
|
DOC_SEE(View_Split_Position)
|
|
|
|
*/{
|
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
System_Functions *system = cmd->system;
|
|
|
|
Models *models = cmd->models;
|
|
|
|
View *vptr = imp_get_view(cmd, view_location);
|
2018-03-24 10:06:45 +00:00
|
|
|
Panel *panel = vptr->transient.panel;
|
2016-07-05 01:36:30 +00:00
|
|
|
View_Summary result = {0};
|
|
|
|
|
|
|
|
if (models->layout.panel_count < models->layout.panel_max_count){
|
|
|
|
b32 vsplit = ((position == ViewSplit_Left) || (position == ViewSplit_Right));
|
|
|
|
b32 grtsplit = ((position == ViewSplit_Bottom) || (position == ViewSplit_Right));
|
|
|
|
|
|
|
|
Split_Result split = layout_split_panel(&models->layout, panel, vsplit);
|
|
|
|
|
|
|
|
Panel *grtpanel = split.panel;
|
|
|
|
Panel *lsrpanel = panel;
|
|
|
|
|
|
|
|
if (!grtsplit){
|
|
|
|
Swap(i32, panel->which_child, split.panel->which_child);
|
|
|
|
Swap(Panel*, grtpanel, lsrpanel);
|
|
|
|
}
|
|
|
|
|
|
|
|
split.panel->screen_region = panel->screen_region;
|
|
|
|
if (vsplit){
|
2017-01-23 06:19:43 +00:00
|
|
|
i32 x_pos = round32(lerp((f32)lsrpanel->full.x0, split.divider->pos, (f32)lsrpanel->full.x1));
|
2016-07-05 01:36:30 +00:00
|
|
|
|
|
|
|
grtpanel->full.x0 = x_pos;
|
|
|
|
grtpanel->full.x1 = lsrpanel->full.x1;
|
|
|
|
lsrpanel->full.x1 = x_pos;
|
|
|
|
}
|
|
|
|
else{
|
2017-01-23 06:19:43 +00:00
|
|
|
i32 y_pos = round32(lerp((f32)lsrpanel->full.y0, split.divider->pos, (f32)lsrpanel->full.y1));
|
2016-07-05 01:36:30 +00:00
|
|
|
|
|
|
|
grtpanel->full.y0 = y_pos;
|
|
|
|
grtpanel->full.y1 = lsrpanel->full.y1;
|
|
|
|
lsrpanel->full.y1 = y_pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
panel_fix_internal_area(panel);
|
|
|
|
panel_fix_internal_area(split.panel);
|
|
|
|
split.panel->prev_inner = split.panel->inner;
|
|
|
|
|
|
|
|
models->layout.active_panel = (i32)(split.panel - models->layout.panels);
|
2017-07-17 23:35:13 +00:00
|
|
|
panel_make_empty(system, cmd->models, split.panel);
|
2016-07-05 15:15:38 +00:00
|
|
|
|
2017-03-12 01:20:24 +00:00
|
|
|
fill_view_summary(system, &result, split.panel->view, cmd);
|
2016-07-05 01:36:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
API_EXPORT bool32
|
2016-10-08 20:20:49 +00:00
|
|
|
Close_View(Application_Links *app, View_Summary *view)
|
|
|
|
/*
|
2016-07-05 01:36:30 +00:00
|
|
|
DOC_PARAM(view, The view parameter specifies which view to close.)
|
|
|
|
DOC_RETURN(This call returns non-zero on success.)
|
2016-09-08 22:57:37 +00:00
|
|
|
|
|
|
|
DOC(If the given view is open and is not the last view, it will be closed.
|
2016-07-05 01:36:30 +00:00
|
|
|
If the given view is the active view, the next active view in the global
|
2016-09-08 22:57:37 +00:00
|
|
|
order of view will be made active. If the given view is the last open view
|
|
|
|
in the system, the call will fail.)
|
|
|
|
|
2016-07-05 01:36:30 +00:00
|
|
|
*/{
|
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
Models *models = cmd->models;
|
|
|
|
View *vptr = imp_get_view(cmd, view);
|
|
|
|
|
2016-09-17 01:53:31 +00:00
|
|
|
bool32 result = 0;
|
2016-07-05 01:36:30 +00:00
|
|
|
|
2018-03-24 10:06:45 +00:00
|
|
|
if (vptr != 0 && models->layout.panel_count > 1){
|
|
|
|
Panel *panel = vptr->transient.panel;
|
|
|
|
|
|
|
|
live_set_free_view(&models->live_set, vptr, models);
|
|
|
|
panel->view = 0;
|
|
|
|
|
|
|
|
Divider_And_ID div = layout_get_divider(&models->layout, panel->parent);
|
|
|
|
|
|
|
|
// This divider cannot have two child dividers.
|
|
|
|
Assert(div.divider->child1 == -1 || div.divider->child2 == -1);
|
|
|
|
|
|
|
|
// Get the child who needs to fill in this node's spot
|
|
|
|
i32 child = div.divider->child1;
|
|
|
|
if (child == -1) child = div.divider->child2;
|
|
|
|
|
|
|
|
i32 parent = div.divider->parent;
|
|
|
|
i32 which_child = div.divider->which_child;
|
|
|
|
|
|
|
|
// Fill the child in the slot this node use to hold
|
|
|
|
if (parent == -1){
|
|
|
|
Assert(models->layout.root == div.id);
|
|
|
|
models->layout.root = child;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
Divider_And_ID parent_div = layout_get_divider(&models->layout, parent);
|
|
|
|
if (which_child == -1){
|
|
|
|
parent_div.divider->child1 = child;
|
2016-07-05 01:36:30 +00:00
|
|
|
}
|
|
|
|
else{
|
2018-03-24 10:06:45 +00:00
|
|
|
parent_div.divider->child2 = child;
|
2016-07-05 01:36:30 +00:00
|
|
|
}
|
2018-03-24 10:06:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// If there was a child divider, give it information about it's new parent.
|
|
|
|
if (child != -1){
|
|
|
|
Divider_And_ID child_div = layout_get_divider(&models->layout, child);
|
|
|
|
child_div.divider->parent = parent;
|
|
|
|
child_div.divider->which_child = div.divider->which_child;
|
|
|
|
}
|
|
|
|
|
|
|
|
// What is the new active panel?
|
|
|
|
i32 active = -1;
|
|
|
|
if (child == -1){
|
|
|
|
for (Panel *panel_ptr = models->layout.used_sentinel.next;
|
|
|
|
panel_ptr != &models->layout.used_sentinel;
|
|
|
|
panel_ptr = panel_ptr->next){
|
|
|
|
if (panel_ptr != panel && panel_ptr->parent == div.id){
|
|
|
|
panel_ptr->parent = parent;
|
|
|
|
panel_ptr->which_child = which_child;
|
|
|
|
active = (i32)(panel_ptr - models->layout.panels);
|
|
|
|
break;
|
2016-07-05 01:36:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-03-24 10:06:45 +00:00
|
|
|
else{
|
|
|
|
Panel *panel_ptr = panel->next;
|
|
|
|
if (panel_ptr == &models->layout.used_sentinel) panel_ptr = panel_ptr->next;
|
|
|
|
Assert(panel_ptr != panel);
|
|
|
|
active = (i32)(panel_ptr - models->layout.panels);
|
|
|
|
}
|
|
|
|
Assert(active != -1 && panel != models->layout.panels + active);
|
|
|
|
|
|
|
|
// If the panel we're closing was previously active, we have to switch to it's sibling.
|
|
|
|
if (models->layout.active_panel == (i32)(panel - models->layout.panels)){
|
|
|
|
models->layout.active_panel = active;
|
|
|
|
}
|
|
|
|
|
|
|
|
layout_free_divider(&models->layout, div.divider);
|
|
|
|
layout_free_panel(&models->layout, panel);
|
|
|
|
layout_fix_all_panels(&models->layout);
|
2016-07-05 01:36:30 +00:00
|
|
|
}
|
|
|
|
|
2018-03-24 10:06:45 +00:00
|
|
|
|
2016-07-05 01:36:30 +00:00
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2016-07-02 14:15:15 +00:00
|
|
|
API_EXPORT bool32
|
2016-10-08 20:20:49 +00:00
|
|
|
Set_Active_View(Application_Links *app, View_Summary *view)
|
|
|
|
/*
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_PARAM(view, The view parameter specifies which view to make active.)
|
|
|
|
DOC_RETURN(This call returns non-zero on success.)
|
2016-09-17 01:53:31 +00:00
|
|
|
|
|
|
|
DOC(If the given view is open, it is set as the
|
2016-06-28 19:48:12 +00:00
|
|
|
active view, and takes subsequent commands and is returned
|
2016-09-17 01:53:31 +00:00
|
|
|
from get_active_view.)
|
|
|
|
|
2016-06-28 19:48:12 +00:00
|
|
|
DOC_SEE(get_active_view)
|
|
|
|
*/{
|
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
Models *models = cmd->models;
|
|
|
|
View *vptr = imp_get_view(cmd, view);
|
2016-07-02 14:15:15 +00:00
|
|
|
bool32 result = false;
|
2016-06-28 19:48:12 +00:00
|
|
|
|
2018-03-24 10:06:45 +00:00
|
|
|
if (vptr != 0){
|
2016-06-28 19:48:12 +00:00
|
|
|
result = true;
|
2018-03-24 10:06:45 +00:00
|
|
|
Panel *panel = vptr->transient.panel;
|
2016-06-28 19:48:12 +00:00
|
|
|
models->layout.active_panel = (i32)(panel - models->layout.panels);
|
|
|
|
}
|
|
|
|
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2016-11-02 03:27:51 +00:00
|
|
|
API_EXPORT bool32
|
|
|
|
View_Get_Setting(Application_Links *app, View_Summary *view, View_Setting_ID setting, int32_t *value_out)
|
|
|
|
/*
|
|
|
|
DOC_PARAM(view, the view from which to read a setting)
|
|
|
|
DOC_PARAM(setting, the view setting to read)
|
|
|
|
DOC_PARAM(value_out, address to write the setting value on success)
|
|
|
|
DOC_RETURN(returns non-zero on success)
|
|
|
|
*/{
|
2016-09-20 19:48:02 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
View *vptr = imp_get_view(cmd, view);
|
2016-11-12 21:33:54 +00:00
|
|
|
int32_t result = 0;
|
2016-09-20 19:48:02 +00:00
|
|
|
|
2018-03-24 10:06:45 +00:00
|
|
|
if (vptr != 0){
|
2016-11-12 21:33:54 +00:00
|
|
|
result = 1;
|
2016-09-20 19:48:02 +00:00
|
|
|
switch (setting){
|
2018-03-24 10:06:45 +00:00
|
|
|
case ViewSetting_ShowWhitespace:
|
|
|
|
{
|
|
|
|
*value_out = vptr->transient.file_data.show_whitespace;
|
|
|
|
}break;
|
|
|
|
|
|
|
|
case ViewSetting_ShowScrollbar:
|
|
|
|
{
|
|
|
|
*value_out = !vptr->transient.hide_scrollbar;
|
|
|
|
}break;
|
|
|
|
|
|
|
|
case ViewSetting_ShowFileBar:
|
|
|
|
{
|
|
|
|
*value_out = !vptr->transient.hide_file_bar;
|
|
|
|
}break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
result = 0;
|
|
|
|
}break;
|
2016-09-20 19:48:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2016-07-02 14:15:15 +00:00
|
|
|
API_EXPORT bool32
|
2016-10-08 20:20:49 +00:00
|
|
|
View_Set_Setting(Application_Links *app, View_Summary *view, View_Setting_ID setting, int32_t value)
|
|
|
|
/*
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_PARAM(view, The view parameter specifies the view on which to set a setting.)
|
|
|
|
DOC_PARAM(setting, The setting parameter identifies the setting that shall be changed.)
|
|
|
|
DOC_PARAM(value, The value parameter specifies the value to which the setting shall be changed.)
|
|
|
|
DOC_RETURN(This call returns non-zero on success.)
|
2016-06-29 18:38:58 +00:00
|
|
|
DOC_SEE(View_Setting_ID)
|
|
|
|
*/{
|
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
2017-03-12 01:20:24 +00:00
|
|
|
System_Functions *system = cmd->system;
|
2016-06-29 18:38:58 +00:00
|
|
|
View *vptr = imp_get_view(cmd, view);
|
2016-07-02 14:15:15 +00:00
|
|
|
bool32 result = false;
|
2016-06-29 18:38:58 +00:00
|
|
|
|
2018-03-24 10:06:45 +00:00
|
|
|
if (vptr != 0){
|
2016-07-04 20:40:57 +00:00
|
|
|
result = true;
|
2016-06-29 18:38:58 +00:00
|
|
|
switch (setting){
|
2016-07-04 20:40:57 +00:00
|
|
|
case ViewSetting_ShowWhitespace:
|
|
|
|
{
|
2018-03-24 10:06:45 +00:00
|
|
|
vptr->transient.file_data.show_whitespace = value;
|
2016-07-04 20:40:57 +00:00
|
|
|
}break;
|
|
|
|
|
2016-06-29 18:38:58 +00:00
|
|
|
case ViewSetting_ShowScrollbar:
|
|
|
|
{
|
2018-03-24 10:06:45 +00:00
|
|
|
vptr->transient.hide_scrollbar = !value;
|
2016-06-29 18:38:58 +00:00
|
|
|
}break;
|
2016-07-04 20:40:57 +00:00
|
|
|
|
2017-03-27 22:36:42 +00:00
|
|
|
case ViewSetting_ShowFileBar:
|
|
|
|
{
|
2018-03-24 10:06:45 +00:00
|
|
|
vptr->transient.hide_file_bar = !value;
|
2017-03-27 22:36:42 +00:00
|
|
|
}break;
|
|
|
|
|
2016-07-04 20:40:57 +00:00
|
|
|
default:
|
|
|
|
{
|
|
|
|
result = false;
|
|
|
|
}break;
|
2016-06-29 18:38:58 +00:00
|
|
|
}
|
|
|
|
|
2017-03-12 01:20:24 +00:00
|
|
|
fill_view_summary(system, view, vptr, cmd);
|
2016-06-29 18:38:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2016-07-02 14:15:15 +00:00
|
|
|
API_EXPORT bool32
|
2016-10-08 20:20:49 +00:00
|
|
|
View_Set_Split_Proportion(Application_Links *app, View_Summary *view, float t)
|
|
|
|
/*
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_PARAM(view, The view parameter specifies which view shall have it's size adjusted.)
|
|
|
|
DOC_PARAM(t, The t parameter specifies the proportion of the containing box that the view should occupy. t should be in [0,1].)
|
|
|
|
DOC_RETURN(This call returns non-zero on success.)
|
2016-06-28 22:58:50 +00:00
|
|
|
*/{
|
2016-07-02 14:15:15 +00:00
|
|
|
bool32 result = false;
|
2016-06-28 19:48:12 +00:00
|
|
|
|
2016-07-02 14:15:15 +00:00
|
|
|
if (0 <= t && t <= 1.f){
|
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
Models *models = cmd->models;
|
|
|
|
Editing_Layout *layout = &models->layout;
|
|
|
|
View *vptr = imp_get_view(cmd, view);
|
2016-06-28 22:58:50 +00:00
|
|
|
|
2018-03-24 10:06:45 +00:00
|
|
|
if (vptr != 0){
|
2016-07-02 14:15:15 +00:00
|
|
|
result = true;
|
|
|
|
|
2018-03-24 10:06:45 +00:00
|
|
|
Panel *panel = vptr->transient.panel;
|
2016-07-02 14:15:15 +00:00
|
|
|
Panel_Divider *div = layout->dividers + panel->parent;
|
|
|
|
|
|
|
|
if (panel->which_child == 1){
|
|
|
|
t = 1-t;
|
|
|
|
}
|
|
|
|
|
|
|
|
div->pos = t;
|
|
|
|
layout_fix_all_panels(layout);
|
2016-06-28 22:58:50 +00:00
|
|
|
}
|
2016-06-28 19:48:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2016-07-02 14:15:15 +00:00
|
|
|
API_EXPORT bool32
|
2016-10-08 20:20:49 +00:00
|
|
|
View_Compute_Cursor(Application_Links *app, View_Summary *view, Buffer_Seek seek, Full_Cursor *cursor_out)
|
|
|
|
/*
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_PARAM(view, The view parameter specifies the view on which to run the cursor computation.)
|
|
|
|
DOC_PARAM(seek, The seek parameter specifies the target position for the seek.)
|
|
|
|
DOC_PARAM(cursor_out, On success this struct is filled with the result of the seek.)
|
|
|
|
DOC_RETURN(This call returns non-zero on success.)
|
|
|
|
DOC(Computes a Full_Cursor for the given seek position with no side effects.)
|
2016-06-24 04:02:09 +00:00
|
|
|
DOC_SEE(Buffer_Seek)
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_SEE(Full_Cursor)
|
2016-06-24 04:02:09 +00:00
|
|
|
*/{
|
2016-06-13 18:54:26 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
2017-03-12 01:20:24 +00:00
|
|
|
System_Functions *system = cmd->system;
|
2016-06-14 20:40:57 +00:00
|
|
|
View *vptr = imp_get_view(cmd, view);
|
2016-07-02 14:15:15 +00:00
|
|
|
bool32 result = false;
|
2016-06-13 18:54:26 +00:00
|
|
|
|
2018-03-24 10:06:45 +00:00
|
|
|
if (vptr != 0){
|
|
|
|
Editing_File *file = vptr->transient.file_data.file;
|
|
|
|
Assert(file != 0);
|
|
|
|
if (!file->is_loading){
|
2016-06-24 04:02:09 +00:00
|
|
|
result = true;
|
2018-03-24 10:06:45 +00:00
|
|
|
*cursor_out = file_compute_cursor(system, file, seek, 0);
|
2017-03-12 01:20:24 +00:00
|
|
|
fill_view_summary(system, view, vptr, cmd);
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2016-07-02 14:15:15 +00:00
|
|
|
API_EXPORT bool32
|
2016-10-08 20:20:49 +00:00
|
|
|
View_Set_Cursor(Application_Links *app, View_Summary *view, Buffer_Seek seek, bool32 set_preferred_x)
|
|
|
|
/*
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_PARAM(view, The view parameter specifies the view in which to set the cursor.)
|
|
|
|
DOC_PARAM(seek, The seek parameter specifies the target position for the seek.)
|
|
|
|
DOC_PARAM(set_preferred_x, If this parameter is true the preferred x is updated to match the new cursor x.)
|
|
|
|
DOC_RETURN(This call returns non-zero on success.)
|
2017-07-17 20:43:01 +00:00
|
|
|
DOC(This call sets the the view's cursor position. set_preferred_x should usually be true unless the change in cursor position is is a vertical motion that tries to keep the cursor in the same column or x position.)
|
2016-06-24 04:02:09 +00:00
|
|
|
DOC_SEE(Buffer_Seek)
|
|
|
|
*/{
|
2016-06-13 18:54:26 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
2017-03-12 01:20:24 +00:00
|
|
|
System_Functions *system = cmd->system;
|
2016-06-14 20:40:57 +00:00
|
|
|
View *vptr = imp_get_view(cmd, view);
|
2016-07-02 14:15:15 +00:00
|
|
|
bool32 result = false;
|
2016-06-13 18:54:26 +00:00
|
|
|
|
2016-06-14 20:40:57 +00:00
|
|
|
if (vptr){
|
2018-03-24 10:06:45 +00:00
|
|
|
Editing_File *file = vptr->transient.file_data.file;
|
|
|
|
Assert(file != 0);
|
2016-09-22 00:01:12 +00:00
|
|
|
if (!file->is_loading){
|
2016-06-14 20:40:57 +00:00
|
|
|
result = true;
|
2018-03-24 10:06:45 +00:00
|
|
|
Full_Cursor cursor = file_compute_cursor(system, file, seek, 0);
|
2016-09-22 00:01:12 +00:00
|
|
|
view_set_cursor(vptr, cursor, set_preferred_x, file->settings.unwrapped_lines);
|
2017-03-12 01:20:24 +00:00
|
|
|
fill_view_summary(system, view, vptr, cmd);
|
2016-07-12 18:20:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
API_EXPORT bool32
|
2016-10-08 20:20:49 +00:00
|
|
|
View_Set_Scroll(Application_Links *app, View_Summary *view, GUI_Scroll_Vars scroll)
|
|
|
|
/*
|
2017-07-17 20:43:01 +00:00
|
|
|
DOC_PARAM(view, The view on which to change the scroll state.)
|
|
|
|
DOC_PARAM(scroll, The new scroll position for the view.)
|
|
|
|
DOC(Set the scrolling state of the view.)
|
2016-07-12 18:20:06 +00:00
|
|
|
DOC_SEE(GUI_Scroll_Vars)
|
|
|
|
*/{
|
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
2017-03-12 01:20:24 +00:00
|
|
|
System_Functions *system = cmd->system;
|
2016-07-12 18:20:06 +00:00
|
|
|
View *vptr = imp_get_view(cmd, view);
|
|
|
|
bool32 result = false;
|
|
|
|
|
2018-03-24 10:06:45 +00:00
|
|
|
if (vptr != 0){
|
|
|
|
Editing_File *file = vptr->transient.file_data.file;
|
|
|
|
Assert(file != 0);
|
|
|
|
if (!file->is_loading){
|
2016-07-12 18:20:06 +00:00
|
|
|
result = true;
|
2017-03-12 01:20:24 +00:00
|
|
|
view_set_scroll(system, vptr, scroll);
|
|
|
|
fill_view_summary(system, view, vptr, cmd);
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2016-07-02 14:15:15 +00:00
|
|
|
API_EXPORT bool32
|
2016-10-08 20:20:49 +00:00
|
|
|
View_Set_Mark(Application_Links *app, View_Summary *view, Buffer_Seek seek)
|
|
|
|
/*
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_PARAM(view, The view parameter specifies the view in which to set the mark.)
|
|
|
|
DOC_PARAM(seek, The seek parameter specifies the target position for the seek.)
|
|
|
|
DOC_RETURN(This call returns non-zero on success.)
|
|
|
|
DOC(This call sets the the view's mark position.)
|
2016-06-24 04:02:09 +00:00
|
|
|
DOC_SEE(Buffer_Seek)
|
|
|
|
*/{
|
2016-06-13 18:54:26 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
2017-03-12 01:20:24 +00:00
|
|
|
System_Functions *system = cmd->system;
|
2016-06-14 20:40:57 +00:00
|
|
|
View *vptr = imp_get_view(cmd, view);
|
2016-07-02 14:15:15 +00:00
|
|
|
bool32 result = false;
|
2016-06-13 18:54:26 +00:00
|
|
|
|
2018-03-24 10:06:45 +00:00
|
|
|
if (vptr != 0){
|
|
|
|
Editing_File *file = vptr->transient.file_data.file;
|
|
|
|
Assert(file != 0);
|
|
|
|
if (!file->is_loading){
|
2016-07-02 22:59:16 +00:00
|
|
|
if (seek.type != buffer_seek_pos){
|
2017-01-29 00:03:23 +00:00
|
|
|
result = true;
|
2018-03-24 10:06:45 +00:00
|
|
|
Full_Cursor cursor = file_compute_cursor(system, file, seek, 0);
|
|
|
|
vptr->transient.edit_pos->mark = cursor.pos;
|
2016-07-02 22:59:16 +00:00
|
|
|
}
|
|
|
|
else{
|
2017-01-29 00:03:23 +00:00
|
|
|
result = true;
|
2018-03-24 10:06:45 +00:00
|
|
|
vptr->transient.edit_pos->mark = seek.pos;
|
2016-07-02 22:59:16 +00:00
|
|
|
}
|
2017-03-12 01:20:24 +00:00
|
|
|
fill_view_summary(system, view, vptr, cmd);
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2016-07-02 14:15:15 +00:00
|
|
|
API_EXPORT bool32
|
2017-03-23 19:15:33 +00:00
|
|
|
View_Set_Highlight(Application_Links *app, View_Summary *view, int32_t start, int32_t end, bool32 turn_on)/*
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_PARAM(view, The view parameter specifies the view in which to set the highlight.)
|
|
|
|
DOC_PARAM(start, This parameter specifies the absolute position of the first character of the highlight range.)
|
|
|
|
DOC_PARAM(end, This parameter specifies the absolute position of the character one past the end of the highlight range.)
|
|
|
|
DOC_PARAM(turn_on, This parameter indicates whether the highlight is being turned on or off.)
|
|
|
|
DOC_RETURN(This call returns non-zero on success.)
|
2017-03-23 19:15:33 +00:00
|
|
|
DOC
|
|
|
|
(
|
|
|
|
The highlight is mutually exclusive to the cursor. When the turn_on parameter
|
|
|
|
is set to true the highlight will be shown and the cursor will be hidden. After
|
|
|
|
that either setting the cursor with view_set_cursor or calling view_set_highlight
|
|
|
|
and the turn_on set to false, will switch back to showing the cursor.
|
|
|
|
)
|
2016-06-24 04:02:09 +00:00
|
|
|
*/{
|
2016-06-13 18:54:26 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
2017-03-12 01:20:24 +00:00
|
|
|
System_Functions *system = cmd->system;
|
2016-06-14 20:40:57 +00:00
|
|
|
View *vptr = imp_get_view(cmd, view);
|
2016-07-02 14:15:15 +00:00
|
|
|
bool32 result = false;
|
2016-06-13 18:54:26 +00:00
|
|
|
|
2018-03-24 10:06:45 +00:00
|
|
|
if (vptr != 0){
|
2016-06-14 20:40:57 +00:00
|
|
|
result = true;
|
|
|
|
if (turn_on){
|
2017-03-23 19:15:05 +00:00
|
|
|
view_set_temp_highlight(system, vptr, start, end);
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
2016-06-14 20:40:57 +00:00
|
|
|
else{
|
2018-03-24 10:06:45 +00:00
|
|
|
vptr->transient.file_data.show_temp_highlight = false;
|
2016-06-14 20:40:57 +00:00
|
|
|
}
|
2017-03-12 01:20:24 +00:00
|
|
|
fill_view_summary(system, view, vptr, cmd);
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2016-07-02 14:15:15 +00:00
|
|
|
API_EXPORT bool32
|
2016-10-08 20:20:49 +00:00
|
|
|
View_Set_Buffer(Application_Links *app, View_Summary *view, Buffer_ID buffer_id, Set_Buffer_Flag flags)
|
|
|
|
/*
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_PARAM(view, The view parameter specifies the view in which to display the buffer.)
|
|
|
|
DOC_PARAM(buffer_id, The buffer_id parameter specifies which buffer to show in the view.)
|
|
|
|
DOC_PARAM(flags, The flags parameter specifies behaviors for setting the buffer.)
|
|
|
|
DOC_RETURN(This call returns non-zero on success.)
|
2017-03-12 01:20:24 +00:00
|
|
|
DOC(On success view_set_buffer sets the specified view's current buffer and cancels and dialogue shown in the view and displays the file.)
|
2016-06-24 04:02:09 +00:00
|
|
|
DOC_SEE(Set_Buffer_Flag)
|
|
|
|
*/{
|
2016-06-13 18:54:26 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
2017-03-12 01:20:24 +00:00
|
|
|
System_Functions *system = cmd->system;
|
2016-06-14 20:40:57 +00:00
|
|
|
View *vptr = imp_get_view(cmd, view);
|
|
|
|
Models *models = cmd->models;
|
2016-07-02 14:15:15 +00:00
|
|
|
bool32 result = false;
|
2016-06-13 18:54:26 +00:00
|
|
|
|
2018-03-24 10:06:45 +00:00
|
|
|
if (vptr != 0){
|
2017-03-12 01:20:24 +00:00
|
|
|
Editing_File *file = working_set_get_active_file(&models->working_set, buffer_id);
|
|
|
|
if (file != 0){
|
2016-06-14 20:40:57 +00:00
|
|
|
result = true;
|
2018-03-24 10:06:45 +00:00
|
|
|
if (file != vptr->transient.file_data.file){
|
2017-03-12 01:20:24 +00:00
|
|
|
view_set_file(system, vptr, file, models);
|
2016-06-24 04:02:09 +00:00
|
|
|
if (!(flags & SetBuffer_KeepOriginalGUI)){
|
2018-03-24 21:43:57 +00:00
|
|
|
view_show_file(vptr);
|
2016-06-24 04:02:09 +00:00
|
|
|
}
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
|
|
|
}
|
2016-06-14 20:40:57 +00:00
|
|
|
|
2017-03-12 01:20:24 +00:00
|
|
|
fill_view_summary(system, view, vptr, cmd);
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2016-07-02 14:15:15 +00:00
|
|
|
API_EXPORT bool32
|
2017-03-23 19:15:33 +00:00
|
|
|
View_Post_Fade(Application_Links *app, View_Summary *view, float seconds, int32_t start, int32_t end, int_color color)
|
2016-10-08 20:20:49 +00:00
|
|
|
/*
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_PARAM(view, The view parameter specifies the view onto which the fade effect shall be posted.)
|
|
|
|
DOC_PARAM(seconds, This parameter specifies the number of seconds the fade effect should last.)
|
|
|
|
DOC_PARAM(start, This parameter specifies the absolute position of the first character of the fade range.)
|
|
|
|
DOC_PARAM(end, This parameter specifies the absolute position of the character one past the end of the fdae range.)
|
|
|
|
DOC_PARAM(color, The color parameter specifies the initial color of the text before it fades to it's natural color.)
|
|
|
|
DOC_RETURN(This call returns non-zero on success.)
|
|
|
|
DOC_SEE(int_color)
|
2016-06-24 16:38:52 +00:00
|
|
|
*/{
|
2016-06-14 19:00:03 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
2016-06-14 20:40:57 +00:00
|
|
|
View *vptr = imp_get_view(cmd, view);
|
2016-06-14 19:00:03 +00:00
|
|
|
|
2016-07-02 14:15:15 +00:00
|
|
|
bool32 result = false;
|
2017-03-23 19:15:33 +00:00
|
|
|
|
|
|
|
int32_t size = end - start;
|
|
|
|
if (vptr){
|
|
|
|
if (size > 0){
|
|
|
|
result = true;
|
|
|
|
view_post_paste_effect(vptr, seconds, start, size, color | 0xFF000000);
|
|
|
|
}
|
2016-06-14 19:00:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2016-06-27 15:52:58 +00:00
|
|
|
API_EXPORT User_Input
|
2016-10-08 20:20:49 +00:00
|
|
|
Get_User_Input(Application_Links *app, Input_Type_Flag get_type, Input_Type_Flag abort_type)
|
|
|
|
/*
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_PARAM(get_type, The get_type parameter specifies the set of input types that should be returned.)
|
|
|
|
DOC_PARAM(abort_type, The get_type parameter specifies the set of input types that should trigger an abort signal.)
|
|
|
|
DOC_RETURN(This call returns a User_Input that describes a user input event.)
|
2016-10-08 20:20:49 +00:00
|
|
|
DOC(
|
2016-06-24 19:33:37 +00:00
|
|
|
This call preempts the command. The command is resumed if either a get or abort condition
|
|
|
|
is met, or if another command is executed. If either the abort condition is met or another
|
|
|
|
command is executed an abort signal is returned. If an abort signal is ever returned the
|
|
|
|
command should finish execution without any more calls that preempt the command.
|
2016-07-02 14:15:15 +00:00
|
|
|
If a get condition is met the user input is returned.
|
2016-06-24 19:33:37 +00:00
|
|
|
)
|
|
|
|
DOC_SEE(Input_Type_Flag)
|
|
|
|
DOC_SEE(User_Input)
|
|
|
|
*/{
|
2016-06-13 18:54:26 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
System_Functions *system = cmd->system;
|
2017-07-19 20:07:50 +00:00
|
|
|
Coroutine_Head *coroutine = (Coroutine_Head*)app->current_coroutine;
|
2016-06-13 18:54:26 +00:00
|
|
|
User_Input result = {0};
|
|
|
|
|
|
|
|
if (app->type_coroutine == Co_Command){
|
2017-07-19 20:07:50 +00:00
|
|
|
Assert(coroutine != 0);
|
2016-06-13 18:54:26 +00:00
|
|
|
*((u32*)coroutine->out+0) = get_type;
|
|
|
|
*((u32*)coroutine->out+1) = abort_type;
|
|
|
|
system->yield_coroutine(coroutine);
|
|
|
|
result = *(User_Input*)coroutine->in;
|
|
|
|
}
|
|
|
|
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2016-06-27 15:52:58 +00:00
|
|
|
API_EXPORT User_Input
|
2017-11-09 00:12:14 +00:00
|
|
|
Get_Command_Input(Application_Links *app)
|
2016-10-08 20:20:49 +00:00
|
|
|
/*
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_RETURN(This call returns the input that triggered the currently executing command.)
|
2016-06-24 19:33:37 +00:00
|
|
|
DOC_SEE(User_Input)
|
|
|
|
*/{
|
2016-06-13 18:54:26 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
User_Input result;
|
|
|
|
|
|
|
|
result.type = UserInputKey;
|
|
|
|
result.abort = 0;
|
|
|
|
result.key = cmd->key;
|
2016-07-02 14:15:15 +00:00
|
|
|
result.command.cmdid = 0;
|
2016-06-13 18:54:26 +00:00
|
|
|
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2016-06-27 15:52:58 +00:00
|
|
|
API_EXPORT Mouse_State
|
2016-10-08 20:20:49 +00:00
|
|
|
Get_Mouse_State(Application_Links *app)
|
|
|
|
/*
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_RETURN(This call returns the current mouse state as of the beginning of the frame.)
|
2016-06-24 19:33:37 +00:00
|
|
|
DOC_SEE(Mouse_State)
|
|
|
|
*/{
|
2016-06-13 18:54:26 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
App_Vars *vars = cmd->vars;
|
|
|
|
Mouse_State mouse = direct_get_mouse_state(&vars->available_input);
|
|
|
|
return(mouse);
|
|
|
|
}
|
|
|
|
|
2016-07-02 14:15:15 +00:00
|
|
|
/*
|
|
|
|
API_EXPORT Event_Message
|
2016-06-27 15:52:58 +00:00
|
|
|
Get_Event_Message (Application_Links *app){
|
2017-01-29 00:03:23 +00:00
|
|
|
Event_Message message = {0};
|
|
|
|
System_Functions *system = (System_Functions*)app->system_links;
|
|
|
|
Coroutine *coroutine = (Coroutine*)app->current_coroutine;
|
|
|
|
|
|
|
|
if (app->type_coroutine == Co_View){
|
|
|
|
Assert(coroutine);
|
|
|
|
system->yield_coroutine(coroutine);
|
|
|
|
message = *(Event_Message*)coroutine->in;
|
|
|
|
}
|
|
|
|
|
|
|
|
return(message);
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
2016-07-02 14:15:15 +00:00
|
|
|
*/
|
2016-06-13 18:54:26 +00:00
|
|
|
|
2016-07-02 14:15:15 +00:00
|
|
|
API_EXPORT bool32
|
2016-10-08 20:20:49 +00:00
|
|
|
Start_Query_Bar(Application_Links *app, Query_Bar *bar, uint32_t flags)
|
|
|
|
/*
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_PARAM(bar, This parameter provides a Query_Bar that should remain in valid memory
|
|
|
|
until end_query_bar or the end of the command. It is commonly a good idea to make
|
|
|
|
this a pointer to a Query_Bar stored on the stack.)
|
|
|
|
DOC_PARAM(flags, This parameter is not currently used and should be 0 for now.)
|
|
|
|
DOC_RETURN(This call returns non-zero on success.)
|
2016-06-24 19:33:37 +00:00
|
|
|
DOC
|
|
|
|
(
|
2016-07-02 14:15:15 +00:00
|
|
|
This call tells the active view to begin displaying a "Query_Bar" which is a small
|
|
|
|
GUI element that can overlap a buffer or other 4coder GUI. The contents of the bar
|
|
|
|
can be changed after the call to start_query_bar and the query bar shown by 4coder
|
|
|
|
will reflect the change. Since the bar stops showing when the command exits the
|
|
|
|
only use for this call is in an interactive command that makes calls to get_user_input.
|
2016-06-24 19:33:37 +00:00
|
|
|
)
|
|
|
|
*/{
|
2016-09-21 22:34:19 +00:00
|
|
|
Command_Data *command = (Command_Data*)app->cmd_context;
|
|
|
|
USE_VIEW(vptr);
|
2018-03-24 10:06:45 +00:00
|
|
|
Query_Slot *slot = alloc_query_slot(&vptr->transient.query_set);
|
2016-07-02 14:15:15 +00:00
|
|
|
bool32 result = (slot != 0);
|
2018-03-24 10:06:45 +00:00
|
|
|
if (result){
|
|
|
|
slot->query_bar = bar;
|
|
|
|
}
|
2016-07-02 14:15:15 +00:00
|
|
|
return(result);
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
|
|
|
|
2016-06-27 15:52:58 +00:00
|
|
|
API_EXPORT void
|
2016-10-08 20:20:49 +00:00
|
|
|
End_Query_Bar(Application_Links *app, Query_Bar *bar, uint32_t flags)
|
|
|
|
/*
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_PARAM(bar, This parameter should be a bar pointer of a currently active query bar.)
|
|
|
|
DOC_PARAM(flags, This parameter is not currently used and should be 0 for now.)
|
|
|
|
DOC(Stops showing the particular query bar specified by the bar parameter.)
|
2016-06-24 19:33:37 +00:00
|
|
|
*/{
|
2016-09-21 22:34:19 +00:00
|
|
|
Command_Data *command = (Command_Data*)app->cmd_context;
|
|
|
|
USE_VIEW(vptr);
|
2018-03-24 10:06:45 +00:00
|
|
|
free_query_slot(&vptr->transient.query_set, bar);
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
|
|
|
|
2016-06-27 15:52:58 +00:00
|
|
|
API_EXPORT void
|
2016-10-08 20:20:49 +00:00
|
|
|
Print_Message(Application_Links *app, char *str, int32_t len)
|
|
|
|
/*
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_PARAM(str, The str parameter specifies the string to post to *messages*; it need not be null terminated.)
|
|
|
|
DOC_PARAM(len, The len parameter specifies the length of the str string.)
|
|
|
|
DOC(This call posts a string to the *messages* buffer.)
|
2016-06-24 19:33:37 +00:00
|
|
|
*/{
|
2016-06-13 18:54:26 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
Models *models = cmd->models;
|
2016-06-24 19:33:37 +00:00
|
|
|
do_feedback_message(cmd->system, models, make_string(str, len));
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
|
|
|
|
2018-03-24 10:06:45 +00:00
|
|
|
internal void
|
|
|
|
style_set_colors(Style *style, Theme *theme){
|
|
|
|
for (u32 i = 0; i < Stag_COUNT; ++i){
|
|
|
|
u32 *color_ptr = style_index_by_tag(&style->main, i);
|
|
|
|
*color_ptr = theme->colors[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-05 21:48:49 +00:00
|
|
|
API_EXPORT void
|
|
|
|
Create_Theme(Application_Links *app, Theme *theme, char *name, int32_t len)
|
|
|
|
/*
|
|
|
|
DOC_PARAM(theme, The color data of the new theme.)
|
|
|
|
DOC_PARAM(name, The name of the new theme. This string need not be null terminated.)
|
|
|
|
DOC_PARAM(len, The length of the name string.)
|
|
|
|
DOC(This call creates a new theme. If the given name is already the name of a string, the old string will be replaced with the new one. This call does not set the current theme.)
|
|
|
|
*/{
|
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
2018-03-24 10:06:45 +00:00
|
|
|
Style_Library *library = &cmd->models->styles;
|
2017-06-05 21:48:49 +00:00
|
|
|
String theme_name = make_string(name, len);
|
|
|
|
|
|
|
|
b32 hit_existing_theme = false;
|
2018-03-24 10:06:45 +00:00
|
|
|
i32 count = library->count;
|
|
|
|
Style *style = library->styles;
|
|
|
|
for (i32 i = 0; i < count; ++i, ++style){
|
|
|
|
if (match(style->name, theme_name)){
|
|
|
|
style_set_colors(style, theme);
|
2017-06-05 21:48:49 +00:00
|
|
|
hit_existing_theme = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!hit_existing_theme){
|
2018-03-24 10:06:45 +00:00
|
|
|
if (library->count < library->max){
|
|
|
|
Style *style = &library->styles[library->count++];
|
|
|
|
style_set_colors(style, theme);
|
|
|
|
style_set_name(style, make_string(name, len));
|
|
|
|
}
|
2017-06-05 21:48:49 +00:00
|
|
|
}
|
|
|
|
}
|
2016-07-02 14:15:15 +00:00
|
|
|
|
2016-06-27 15:52:58 +00:00
|
|
|
API_EXPORT void
|
2016-10-08 20:20:49 +00:00
|
|
|
Change_Theme(Application_Links *app, char *name, int32_t len)
|
|
|
|
/*
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_PARAM(name, The name parameter specifies the name of the theme to begin using; it need not be null terminated.)
|
|
|
|
DOC_PARAM(len, The len parameter specifies the length of the name string.)
|
2016-07-14 16:41:23 +00:00
|
|
|
DOC(This call changes 4coder's color pallet to one of the built in themes.)
|
2016-06-24 19:33:37 +00:00
|
|
|
*/{
|
2016-06-13 18:54:26 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
Style_Library *styles = &cmd->models->styles;
|
|
|
|
String theme_name = make_string(name, len);
|
|
|
|
|
2016-06-23 23:11:09 +00:00
|
|
|
i32 count = styles->count;
|
|
|
|
Style *s = styles->styles;
|
2017-03-29 16:32:06 +00:00
|
|
|
for (i32 i = 0; i < count; ++i, ++s){
|
2016-08-28 04:31:06 +00:00
|
|
|
if (match_ss(s->name, theme_name)){
|
2018-03-24 21:43:57 +00:00
|
|
|
style_copy(&styles->styles[0], s);
|
2016-06-13 18:54:26 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-20 23:31:57 +00:00
|
|
|
API_EXPORT Face_ID
|
|
|
|
Get_Largest_Face_ID(Application_Links *app)
|
2017-11-21 00:35:35 +00:00
|
|
|
/*
|
|
|
|
DOC_RETURN(Returns the largest face ID that could be valid. There is no guarantee that the returned value is a valid face, or that every face less than the returned value is valid. The guarantee is that all valid face ids are in the range between 1 and the return value.)
|
|
|
|
*/
|
2017-11-20 23:31:57 +00:00
|
|
|
{
|
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
System_Functions *system = cmd->system;
|
|
|
|
Face_ID result = system->font.get_largest_id();
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
API_EXPORT bool32
|
|
|
|
Set_Global_Face(Application_Links *app, Face_ID id, bool32 apply_to_all_buffers)
|
2017-11-21 00:35:35 +00:00
|
|
|
/*
|
|
|
|
DOC_PARAM(id, The id of the face to try to make the global face.)
|
|
|
|
DOC_PARAM(apply_to_all_buffers, If the face is valid, apply the face to change to all open buffers as well as setting the global default.)
|
|
|
|
DOC(Tries to set the global default face, which new buffers will use upon creation.)
|
|
|
|
DOC_RETURN(Returns true if the given id was a valid face and the change was made successfully.)
|
|
|
|
*/
|
2017-11-20 23:31:57 +00:00
|
|
|
{
|
2016-06-13 18:54:26 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
2017-03-29 16:32:06 +00:00
|
|
|
System_Functions *system = cmd->system;
|
2016-07-14 16:41:23 +00:00
|
|
|
|
2017-11-20 23:31:57 +00:00
|
|
|
bool32 did_change = false;
|
2016-06-13 18:54:26 +00:00
|
|
|
|
2017-11-20 23:31:57 +00:00
|
|
|
Font_Pointers font = system->font.get_pointers_by_id(id);
|
|
|
|
if (font.valid){
|
|
|
|
did_change = true;
|
|
|
|
|
|
|
|
Models *models = cmd->models;
|
|
|
|
if (apply_to_all_buffers){
|
|
|
|
global_set_font(system, models, id);
|
2017-11-16 23:03:36 +00:00
|
|
|
}
|
|
|
|
else{
|
2017-11-20 23:31:57 +00:00
|
|
|
models->global_font_id = id;
|
2017-11-16 23:03:36 +00:00
|
|
|
}
|
2016-07-14 16:41:23 +00:00
|
|
|
}
|
2017-11-20 23:31:57 +00:00
|
|
|
|
|
|
|
return(did_change);
|
2016-07-14 16:41:23 +00:00
|
|
|
}
|
|
|
|
|
2017-11-20 23:31:57 +00:00
|
|
|
API_EXPORT bool32
|
|
|
|
Buffer_Set_Face(Application_Links *app, Buffer_Summary *buffer, Face_ID id)
|
2017-11-21 00:35:35 +00:00
|
|
|
/*
|
|
|
|
DOC_PARAM(buffer, The buffer on which to change the face.)
|
|
|
|
DOC_PARAM(id, The id of the face to try to set the buffer to use.)
|
|
|
|
DOC(Tries to set the buffer's face.)
|
|
|
|
DOC_RETURN(Returns true if the given id was a valid face and the change was made successfully.)
|
|
|
|
*/
|
2017-11-20 23:31:57 +00:00
|
|
|
{
|
2016-07-14 16:41:23 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
Editing_File *file = imp_get_file(cmd, buffer);
|
|
|
|
|
2017-11-20 23:31:57 +00:00
|
|
|
bool32 did_change = false;
|
|
|
|
|
2017-03-29 16:32:06 +00:00
|
|
|
if (file != 0){
|
2017-11-20 23:31:57 +00:00
|
|
|
System_Functions *system = cmd->system;
|
|
|
|
Font_Pointers font = system->font.get_pointers_by_id(id);
|
|
|
|
if (font.valid){
|
|
|
|
did_change = true;
|
|
|
|
|
|
|
|
Models *models = cmd->models;
|
|
|
|
file_set_font(system, models, file, id);
|
2017-11-16 23:03:36 +00:00
|
|
|
}
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
2017-11-20 23:31:57 +00:00
|
|
|
|
|
|
|
return(did_change);
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
|
|
|
|
2017-11-20 23:31:57 +00:00
|
|
|
internal void
|
|
|
|
font_pointers_to_face_description(Font_Pointers font, Face_Description *description){
|
|
|
|
Font_Metrics *metrics = font.metrics;
|
|
|
|
i32 len = str_size(metrics->name);
|
|
|
|
memcpy(description->font.name, metrics->name, len);
|
|
|
|
|
|
|
|
Font_Settings *settings = font.settings;
|
|
|
|
description->font.in_local_font_folder = settings->stub.in_font_folder;
|
|
|
|
description->pt_size = settings->parameters.pt_size;
|
|
|
|
description->bold = settings->parameters.bold;
|
|
|
|
description->italic = settings->parameters.italics;
|
|
|
|
description->underline = settings->parameters.underline;
|
|
|
|
description->hinting = settings->parameters.use_hinting;
|
|
|
|
}
|
|
|
|
|
|
|
|
internal b32
|
|
|
|
face_description_to_settings(System_Functions *system, Face_Description description, Font_Settings *settings){
|
|
|
|
b32 success = false;
|
|
|
|
|
|
|
|
if (description.font.in_local_font_folder){
|
|
|
|
i32 count = system->font.get_loadable_count();
|
|
|
|
for (i32 i = 0; i < count; ++i){
|
|
|
|
Font_Loadable_Description loadable = {0};
|
|
|
|
system->font.get_loadable(i, &loadable);
|
|
|
|
|
|
|
|
if (loadable.valid){
|
|
|
|
if (!loadable.stub.in_font_folder){
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (match(make_string(loadable.display_name, loadable.display_len), description.font.name)){
|
|
|
|
success = true;
|
|
|
|
memcpy(&settings->stub, &loadable.stub, sizeof(settings->stub));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
success = true;
|
|
|
|
|
|
|
|
settings->stub.load_from_path = false;
|
|
|
|
settings->stub.in_font_folder = false;
|
|
|
|
settings->stub.len = str_size(description.font.name);
|
|
|
|
memcpy(settings->stub.name, description.font.name, settings->stub.len + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (success){
|
|
|
|
settings->parameters.pt_size = description.pt_size;
|
|
|
|
settings->parameters.italics = description.italic;
|
|
|
|
settings->parameters.bold = description.bold;
|
|
|
|
settings->parameters.underline = description.underline;
|
|
|
|
settings->parameters.use_hinting = description.hinting;
|
|
|
|
}
|
|
|
|
|
|
|
|
return(success);
|
|
|
|
}
|
|
|
|
|
|
|
|
API_EXPORT Face_Description
|
|
|
|
Get_Face_Description(Application_Links *app, Face_ID id)
|
2017-11-21 00:35:35 +00:00
|
|
|
/*
|
|
|
|
DOC_PARAM(id, The face slot from which to read a description. If zero gets default values.)
|
|
|
|
DOC(Fills out the values of a Face_Description struct, which includes all the information that determines the appearance of the face. If the id does not specify a valid face the description will be invalid. An invalid description has a zero length string in it's font.name field (i.e. description.font.name[0] == 0), and a valid description always contains a non-zero length string in the font.name field (i.e. description.font.name[0] != 0)
|
|
|
|
|
|
|
|
If the input id is zero, the description returned will be invalid, but the pt_size and hinting fields will reflect the default values for those fields as specified on the command line. The default values, if unspecified, are pt_size=16 and hinting=false. Note that the id of zero is reserved and is never a valid face.)
|
|
|
|
DOC_RETURN(Returns a Face_Description that is valid if the id references a valid face slot and is filled with the description of the face. Otherwise returns an invalid Face_Description.)
|
|
|
|
DOC_SEE(Face_Description)
|
|
|
|
*/
|
2017-11-20 23:31:57 +00:00
|
|
|
{
|
2016-10-25 02:45:34 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
2017-03-29 16:32:06 +00:00
|
|
|
System_Functions *system = cmd->system;
|
2016-10-25 02:45:34 +00:00
|
|
|
|
2017-11-20 23:31:57 +00:00
|
|
|
Face_Description description = {0};
|
|
|
|
if (id != 0){
|
|
|
|
Font_Pointers font = system->font.get_pointers_by_id(id);
|
|
|
|
if (font.valid){
|
|
|
|
font_pointers_to_face_description(font, &description);
|
|
|
|
Assert(description.font.name[0] != 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
Models *models = cmd->models;
|
|
|
|
description.pt_size = models->settings.font_size;
|
|
|
|
description.hinting = models->settings.use_hinting;
|
|
|
|
}
|
2017-03-29 16:32:06 +00:00
|
|
|
|
2017-11-20 23:31:57 +00:00
|
|
|
return(description);
|
|
|
|
}
|
|
|
|
|
|
|
|
API_EXPORT Face_ID
|
|
|
|
Get_Face_ID(Application_Links *app, Buffer_Summary *buffer)
|
2017-11-21 00:35:35 +00:00
|
|
|
/*
|
|
|
|
DOC_PARAM(buffer, The buffer from which to get a face id. If NULL gets global face id.)
|
|
|
|
DOC(Retrieves a face id if buffer is a valid Buffer_Summary. If buffer is set to NULL, the parameter is ignored and the global default face is returned.)
|
|
|
|
DOC_RETURN(On success a valid Face_ID, otherwise returns zero.)
|
|
|
|
*/
|
2017-11-20 23:31:57 +00:00
|
|
|
{
|
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
|
|
|
|
Face_ID id = 0;
|
|
|
|
if (buffer != 0){
|
|
|
|
Editing_File *file = imp_get_file(cmd, buffer);
|
|
|
|
if (file != 0){
|
|
|
|
id = file->settings.font_id;
|
2016-10-25 02:45:34 +00:00
|
|
|
}
|
|
|
|
}
|
2017-11-20 23:31:57 +00:00
|
|
|
else{
|
|
|
|
Models *models = cmd->models;
|
|
|
|
id = models->global_font_id;
|
|
|
|
}
|
2016-10-25 02:45:34 +00:00
|
|
|
|
2017-11-20 23:31:57 +00:00
|
|
|
return(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
API_EXPORT Face_ID
|
|
|
|
Try_Create_New_Face(Application_Links *app, Face_Description *description)
|
2017-11-21 00:35:35 +00:00
|
|
|
/*
|
|
|
|
DOC_PARAM(description, A description of the new face to try to create.)
|
|
|
|
DOC(Attempts to create a new face and configure it with the provided description. This call can fail for a number of reasons:
|
|
|
|
|
|
|
|
- If the description's font field is not one of the available fonts no face is created.
|
|
|
|
|
|
|
|
- If the specified font cannot actually be loaded by the 4coder font system no face is created.
|
|
|
|
|
|
|
|
- If the specified font with the specified configuration is too large or too small no face is created.
|
|
|
|
|
|
|
|
Note, not all fonts will support all styles. The fields for italic, bold, underline, and hinting, are only requests that the system try to apply these configurations, but if any cannot be done the face will still be created but without the unsupported configurations. 4coder does not try to simulate the effects of missing styles.)
|
|
|
|
DOC_RETURN(Returns a new valid face id if the font system successfully instanatiates the new face, otherwise returns zero. Note that zero is a reserved id and is never a valid id.)
|
|
|
|
DOC_SEE(Face_Description)
|
|
|
|
*/
|
2017-11-20 23:31:57 +00:00
|
|
|
{
|
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
System_Functions *system = cmd->system;
|
|
|
|
|
|
|
|
Face_ID id = 0;
|
|
|
|
Font_Settings settings;
|
|
|
|
if (face_description_to_settings(system, *description, &settings)){
|
|
|
|
id = system->font.face_allocate_and_init(&settings);
|
|
|
|
}
|
|
|
|
|
|
|
|
return(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
API_EXPORT bool32
|
|
|
|
Try_Modify_Face(Application_Links *app, Face_ID id, Face_Description *description)
|
2017-11-21 00:35:35 +00:00
|
|
|
/*
|
|
|
|
DOC_PARAM(id, The id of the face slot to try to modify.)
|
|
|
|
DOC_PARAM(description, The new description for the face slot to use.)
|
|
|
|
DOC(Attempts to modify the face in a particular face slot. If successful all buffers using the face will continue using the same face slot, and will therefore change appearance to the new configuration of the face slot.
|
|
|
|
|
|
|
|
This call can fail for all the same reasons that try_create_new_face can fail, and the same rules about failure to apply specific styles also apply. If the call does fail, the original configuration of the face slot stays in place. A valid face slot should never become invalid except by releasing it.
|
|
|
|
|
|
|
|
Performance Warning: Modifying a face slot should only be done a couple of times per frame in most cases. Not only does this call reconfigure a slot, it also recomputes the layout for all buffers that use this face slot.)
|
|
|
|
DOC_RETURN(Returns true on success and false on failure.)
|
|
|
|
DOC_SEE(try_create_new_face)
|
|
|
|
*/
|
2017-11-20 23:31:57 +00:00
|
|
|
{
|
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
System_Functions *system = cmd->system;
|
|
|
|
|
|
|
|
bool32 success = false;
|
|
|
|
Font_Settings settings;
|
|
|
|
if (face_description_to_settings(system, *description, &settings)){
|
|
|
|
Models *models = cmd->models;
|
|
|
|
if (alter_font(system, models, id, &settings)){
|
|
|
|
success = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return(success);
|
|
|
|
}
|
|
|
|
|
|
|
|
API_EXPORT bool32
|
|
|
|
Try_Release_Face(Application_Links *app, Face_ID id, Face_ID replacement_id)
|
2017-11-21 00:35:35 +00:00
|
|
|
/*
|
|
|
|
DOC_PARAM(id, The id of the face slot to release.)
|
|
|
|
DOC_PARAM(replacement_id, Optional. Specifies what buffers that were using id should switch to after the release.)
|
|
|
|
DOC(Attempts to release the slot referred to by id. If successful all buffers using the face will switch to using a new valid face, and will therefore change appearance to the new face slot. If replacement_id refers to a valid face slot, it will be used for the new slot, otherwise the slot is chosen arbitrarily out of the remaining valid faces.
|
|
|
|
|
|
|
|
This call can fail if the id does not name a valid face slot, or if there is only one face slot left in the system.
|
|
|
|
|
|
|
|
Performance Warning: Releasing a face slot should only be done a couple of times per frame in most cases. Not only does it release all the resources used by the slot, it also recomputes the layout for all buffers that used the released slot. If no buffers use the slots that are released, it is generally okay to use it more frequently.)
|
|
|
|
DOC_RETURN(Returns true on success and zero on failure.)
|
|
|
|
*/
|
2017-11-20 23:31:57 +00:00
|
|
|
{
|
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
System_Functions *system = cmd->system;
|
|
|
|
Models *models = cmd->models;
|
|
|
|
|
|
|
|
bool32 success = false;
|
|
|
|
if (release_font(system, models, id, replacement_id)){
|
|
|
|
success = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return(success);
|
|
|
|
}
|
|
|
|
|
|
|
|
API_EXPORT int32_t
|
|
|
|
Get_Available_Font_Count(Application_Links *app)
|
2017-11-21 00:35:35 +00:00
|
|
|
/*
|
|
|
|
DOC(An available font is a font that the 4coder font system detected on initialization. Available fonts either come from the font folder in the same path as the 4ed executable, or from the system fonts. Attempting to load fonts not in returned by available fonts will likely fail, but is permitted. Available fonts are not updated after initialization. Just because a font is returned by the available font system does not necessarily mean that it can be loaded.)
|
|
|
|
DOC_RETURN(Returns the number of available fonts that the user can query.)
|
|
|
|
*/
|
2017-11-20 23:31:57 +00:00
|
|
|
{
|
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
System_Functions *system = cmd->system;
|
|
|
|
i32 count = system->font.get_loadable_count();
|
|
|
|
return(count);
|
|
|
|
}
|
|
|
|
|
|
|
|
API_EXPORT Available_Font
|
|
|
|
Get_Available_Font(Application_Links *app, int32_t index)
|
2017-11-21 00:35:35 +00:00
|
|
|
/*
|
|
|
|
DOC_PARAM(index, The index of the available font to retrieve. Must be in the range [0,count-1] where count is the value returned by get_available_font_count.)
|
|
|
|
DOC_RETURN(Returns a valid Available_Font if index is in the required range. Otherwise returns an invalid Available_Font. An Available_Font is valid if and only if it's name field contains a string with a non-zero length (i.e. font.name[0] != 0))
|
|
|
|
DOC_SEE(get_available_font_count)
|
|
|
|
*/
|
2017-11-20 23:31:57 +00:00
|
|
|
{
|
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
System_Functions *system = cmd->system;
|
|
|
|
|
|
|
|
Available_Font available = {0};
|
|
|
|
Font_Loadable_Description description = {0};
|
|
|
|
system->font.get_loadable(index, &description);
|
|
|
|
if (description.valid){
|
|
|
|
memcpy(available.name, description.display_name, description.display_len);
|
|
|
|
available.in_local_font_folder = description.stub.in_font_folder;
|
|
|
|
}
|
|
|
|
|
|
|
|
return(available);
|
2016-10-25 02:45:34 +00:00
|
|
|
}
|
|
|
|
|
2016-06-27 15:52:58 +00:00
|
|
|
API_EXPORT void
|
2016-10-08 20:20:49 +00:00
|
|
|
Set_Theme_Colors(Application_Links *app, Theme_Color *colors, int32_t count)
|
|
|
|
/*
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_PARAM(colors, The colors pointer provides an array of color structs pairing differet style tags to color codes.)
|
|
|
|
DOC_PARAM(count, The count parameter specifies the number of Theme_Color structs in the colors array.)
|
2017-03-29 16:32:06 +00:00
|
|
|
DOC(For each struct in the array, the slot in the main color pallet specified by the struct's tag is set to the color code in the struct. If the tag value is invalid no change is made to the color pallet.)
|
2017-02-20 21:05:42 +00:00
|
|
|
DOC_SEE(Theme_Color)
|
2016-06-24 19:33:37 +00:00
|
|
|
*/{
|
2016-06-13 18:54:26 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
2018-03-24 21:43:57 +00:00
|
|
|
Style *style = &cmd->models->styles.styles[0];
|
2016-06-23 23:11:09 +00:00
|
|
|
Theme_Color *theme_color = colors;
|
2018-03-24 21:43:57 +00:00
|
|
|
for (i32 i = 0; i < count; ++i, ++theme_color){
|
|
|
|
int_color *color = style_index_by_tag(&style->main, theme_color->tag);
|
|
|
|
if (color != 0){
|
2016-07-02 14:15:15 +00:00
|
|
|
*color = theme_color->color | 0xFF000000;
|
|
|
|
}
|
2016-06-13 18:54:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-27 15:52:58 +00:00
|
|
|
API_EXPORT void
|
2016-10-08 20:20:49 +00:00
|
|
|
Get_Theme_Colors(Application_Links *app, Theme_Color *colors, int32_t count)
|
|
|
|
/*
|
2016-06-24 19:33:37 +00:00
|
|
|
DOC_PARAM(colors, an array of color structs listing style tags to get color values for)
|
|
|
|
DOC_PARAM(count, the number of color structs in the colors array)
|
2017-02-20 21:05:42 +00:00
|
|
|
DOC(For each struct in the array, the color field of the struct is filled with the color from the slot in the main color pallet specified by the tag. If the tag value is invalid the color is filled with black.)
|
|
|
|
DOC_SEE(Theme_Color)
|
2016-06-24 19:33:37 +00:00
|
|
|
*/{
|
2016-06-14 19:00:03 +00:00
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
2018-03-24 21:43:57 +00:00
|
|
|
Style *style = &cmd->models->styles.styles[0];
|
2016-06-23 23:11:09 +00:00
|
|
|
Theme_Color *theme_color = colors;
|
2018-03-24 21:43:57 +00:00
|
|
|
for (i32 i = 0; i < count; ++i, ++theme_color){
|
|
|
|
u32 *color = style_index_by_tag(&style->main, theme_color->tag);
|
|
|
|
if (color != 0){
|
2016-06-14 19:00:03 +00:00
|
|
|
theme_color->color = *color | 0xFF000000;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
theme_color->color = 0xFF000000;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-07-02 14:15:15 +00:00
|
|
|
API_EXPORT int32_t
|
2016-10-08 20:20:49 +00:00
|
|
|
Directory_Get_Hot(Application_Links *app, char *out, int32_t capacity)
|
|
|
|
/*
|
2017-11-21 21:47:40 +00:00
|
|
|
DOC_PARAM(out, On success this character buffer is filled with the 4coder 'hot directory'.)
|
|
|
|
DOC_PARAM(capacity, Specifies the capacity in bytes of the of the out buffer.)
|
|
|
|
DOC(4coder has a concept of a 'hot directory' which is the directory most recently accessed in the GUI. Whenever the GUI is opened it shows the hot directory. In the future this will be deprecated and eliminated in favor of more flexible hot directories created and controlled in the custom layer.)
|
2018-03-24 10:06:45 +00:00
|
|
|
DOC_RETURN(This call returns the length of the hot directory string whether or not it was successfully copied into the output buffer. The call is successful if and only if capacity is greater than or equal to the return size.)
|
2017-06-20 20:37:45 +00:00
|
|
|
DOC_SEE(directory_set_hot)
|
2016-06-27 15:52:58 +00:00
|
|
|
*/{
|
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
Hot_Directory *hot = &cmd->models->hot_directory;
|
|
|
|
hot_directory_clean_end(hot);
|
2018-03-24 10:06:45 +00:00
|
|
|
if (capacity > 0){
|
|
|
|
i32 copy_max = capacity - 1;
|
|
|
|
if (copy_max > hot->string.size){
|
|
|
|
copy_max = hot->string.size;
|
|
|
|
}
|
|
|
|
memcpy(out, hot->string.str, copy_max);
|
|
|
|
out[copy_max] = 0;
|
2016-12-24 21:09:53 +00:00
|
|
|
}
|
2016-06-27 15:52:58 +00:00
|
|
|
return(hot->string.size);
|
|
|
|
}
|
|
|
|
|
2017-06-20 20:37:45 +00:00
|
|
|
API_EXPORT bool32
|
|
|
|
Directory_Set_Hot(Application_Links *app, char *str, int32_t len)
|
|
|
|
/*
|
|
|
|
DOC_PARAM(str, The new value of the hot directory. This does not need to be a null terminated string.)
|
|
|
|
DOC_PARAM(len, The length of str in bytes.)
|
|
|
|
DOC_RETURN(Returns non-zero on success.)
|
|
|
|
DOC(4coder has a concept of a 'hot directory' which is the directory most recently accessed in the GUI. Whenever the GUI is opened it shows the hot directory. In the future this will be deprecated and eliminated in favor of more flexible directories controlled on the custom side.)
|
|
|
|
DOC_SEE(directory_get_hot)
|
|
|
|
*/{
|
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
Hot_Directory *hot = &cmd->models->hot_directory;
|
|
|
|
b32 success = false;
|
|
|
|
if (len < hot->string.memory_size){
|
|
|
|
hot_directory_set(cmd->system, hot, make_string(str, len));
|
|
|
|
success = true;
|
|
|
|
}
|
|
|
|
return(success);
|
|
|
|
}
|
|
|
|
|
2016-06-27 15:52:58 +00:00
|
|
|
API_EXPORT File_List
|
2016-10-08 20:20:49 +00:00
|
|
|
Get_File_List(Application_Links *app, char *dir, int32_t len)
|
|
|
|
/*
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_PARAM(dir, This parameter specifies the directory whose files will be enumerated in the returned list; it need not be null terminated.)
|
|
|
|
DOC_PARAM(len, This parameter the length of the dir string.)
|
2017-02-10 18:02:17 +00:00
|
|
|
DOC_RETURN(This call returns a File_List struct containing pointers to the names of the files in the specified directory. The File_List returned should be passed to free_file_list when it is no longer in use.)
|
2017-06-05 21:48:49 +00:00
|
|
|
DOC_SEE(File_List)
|
2016-06-27 15:52:58 +00:00
|
|
|
*/{
|
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
System_Functions *system = cmd->system;
|
2017-02-10 18:02:17 +00:00
|
|
|
Partition *part = &cmd->models->mem.part;
|
2016-06-27 15:52:58 +00:00
|
|
|
File_List result = {};
|
2017-02-10 18:02:17 +00:00
|
|
|
Temp_Memory temp = begin_temp_memory(part);
|
|
|
|
String str = make_string_terminated(part, dir, len);
|
2017-02-12 06:01:01 +00:00
|
|
|
system->set_file_list(&result, str.str, 0, 0, 0);
|
2017-02-10 18:02:17 +00:00
|
|
|
end_temp_memory(temp);
|
2016-06-27 15:52:58 +00:00
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
API_EXPORT void
|
2016-10-08 20:20:49 +00:00
|
|
|
Free_File_List(Application_Links *app, File_List list)
|
|
|
|
/*
|
2016-07-02 14:15:15 +00:00
|
|
|
DOC_PARAM(list, This parameter provides the file list to be freed.)
|
|
|
|
DOC(After this call the file list passed in should not be read or written to.)
|
2017-06-05 21:48:49 +00:00
|
|
|
DOC_SEE(File_List)
|
2016-06-27 15:52:58 +00:00
|
|
|
*/{
|
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
System_Functions *system = cmd->system;
|
2017-02-12 06:01:01 +00:00
|
|
|
system->set_file_list(&list, 0, 0, 0, 0);
|
2016-06-27 15:52:58 +00:00
|
|
|
}
|
|
|
|
|
2016-10-27 23:45:41 +00:00
|
|
|
API_EXPORT void
|
2017-04-15 21:47:23 +00:00
|
|
|
Set_GUI_Up_Down_Keys(Application_Links *app, Key_Code up_key, Key_Modifier up_key_modifier, Key_Code down_key, Key_Modifier down_key_modifier)
|
2016-11-02 03:27:51 +00:00
|
|
|
/*
|
|
|
|
DOC_PARAM(up_key, the code of the key that should be interpreted as an up key)
|
2017-04-15 21:47:23 +00:00
|
|
|
DOC_PARAM(up_key_modifier, the modifier for the key that should be interpreted as an up key)
|
2016-11-02 03:27:51 +00:00
|
|
|
DOC_PARAM(down_key, the code of the key that should be interpreted as a down key)
|
2017-04-15 21:47:23 +00:00
|
|
|
DOC_PARAM(down_key_modifier, the modifier for the key that should be interpreted as a down key)
|
2016-11-02 03:27:51 +00:00
|
|
|
|
|
|
|
DOC(This is a temporary ad-hoc solution to allow some customization of the behavior of the built in GUI. There is a high chance that it will be removed and not replaced at some point, so it is not recommended that it be heavily used.) */
|
2016-10-27 23:45:41 +00:00
|
|
|
{
|
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
Models *models = cmd->models;
|
|
|
|
models->user_up_key = up_key;
|
2017-04-15 21:47:23 +00:00
|
|
|
models->user_up_key_modifier = up_key_modifier;
|
2016-10-27 23:45:41 +00:00
|
|
|
models->user_down_key = down_key;
|
2017-04-15 21:47:23 +00:00
|
|
|
models->user_down_key_modifier = down_key_modifier;
|
2016-10-27 23:45:41 +00:00
|
|
|
}
|
|
|
|
|
2017-01-23 06:19:43 +00:00
|
|
|
API_EXPORT void*
|
2017-03-23 19:16:39 +00:00
|
|
|
Memory_Allocate(Application_Links *app, int32_t size)
|
2017-01-23 06:19:43 +00:00
|
|
|
/*
|
|
|
|
DOC_PARAM(size, The size in bytes of the block that should be returned.)
|
|
|
|
DOC(This calls to a low level OS allocator which means it is best used for infrequent, large allocations. The size of the block must be remembered if it will be freed or if it's mem protection status will be changed.)
|
|
|
|
DOC_SEE(memory_free)
|
|
|
|
*/{
|
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
System_Functions *system = cmd->system;
|
|
|
|
void *result = system->memory_allocate(size);
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
API_EXPORT bool32
|
2017-03-23 19:16:39 +00:00
|
|
|
Memory_Set_Protection(Application_Links *app, void *ptr, int32_t size, Memory_Protect_Flags flags)
|
2017-01-23 06:19:43 +00:00
|
|
|
/*
|
|
|
|
DOC_PARAM(ptr, The base of the block on which to set memory protection flags.)
|
|
|
|
DOC_PARAM(size, The size that was originally used to allocate this block.)
|
|
|
|
DOC_PARAM(flags, The new memory protection flags.)
|
|
|
|
DOC(This call sets the memory protection flags of a block of memory that was previously allocate by memory_allocate.)
|
|
|
|
DOC_SEE(memory_allocate)
|
|
|
|
DOC_SEE(Memory_Protect_Flags)
|
|
|
|
*/{
|
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
System_Functions *system = cmd->system;
|
|
|
|
bool32 result = system->memory_set_protection(ptr, size, flags);
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
API_EXPORT void
|
2017-03-23 19:16:39 +00:00
|
|
|
Memory_Free(Application_Links *app, void *ptr, int32_t size)
|
2017-01-23 06:19:43 +00:00
|
|
|
/*
|
|
|
|
DOC_PARAM(mem, The base of a block to free.)
|
|
|
|
DOC_PARAM(size, The size that was originally used to allocate this block.)
|
|
|
|
DOC(This call frees a block of memory that was previously allocated by memory_allocate.)
|
|
|
|
DOC_SEE(memory_allocate)
|
|
|
|
*/{
|
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
System_Functions *system = cmd->system;
|
|
|
|
system->memory_free(ptr, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
API_EXPORT bool32
|
|
|
|
File_Exists(Application_Links *app, char *filename, int32_t len)
|
|
|
|
/*
|
|
|
|
DOC_PARAM(filename, This parameter specifies the full path to a file; it need not be null terminated.)
|
|
|
|
DOC_PARAM(len, This parameter specifies the length of the filename string.)
|
|
|
|
DOC_RETURN(This call returns non-zero if and only if the file exists.)
|
|
|
|
*/{
|
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
System_Functions *system = cmd->system;
|
|
|
|
bool32 result = system->file_exists(filename, len);
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
API_EXPORT bool32
|
|
|
|
Directory_CD(Application_Links *app, char *dir, int32_t *len, int32_t capacity, char *rel_path, int32_t rel_len)
|
|
|
|
/*
|
|
|
|
DOC_PARAM(dir, This parameter provides a character buffer that stores a directory; it need not be null terminated.)
|
|
|
|
DOC_PARAM(len, This parameter specifies the length of the dir string.)
|
|
|
|
DOC_PARAM(capacity, This parameter specifies the maximum size of the dir string.)
|
|
|
|
DOC_PARAM(rel_path, This parameter specifies the path to change to, may include '.' or '..'; it need not be null terminated.)
|
|
|
|
DOC_PARAM(rel_len, This parameter specifies the length of the rel_path string.)
|
|
|
|
DOC_RETURN(This call returns non-zero if the call succeeds.)
|
|
|
|
DOC(
|
2017-11-11 18:03:14 +00:00
|
|
|
This call succeeds if the new directory exists and it fits inside the dir buffer. If the call succeeds the dir buffer is filled with the new directory and len is overwritten with the length of the new string in the buffer.
|
2017-01-23 06:19:43 +00:00
|
|
|
|
|
|
|
For instance if dir contains "C:/Users/MySelf" and rel is "Documents" the buffer will contain "C:/Users/MySelf/Documents" and len will contain the length of that string. This call can also be used with rel set to ".." to traverse to parent folders.
|
|
|
|
)*/{
|
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
System_Functions *system = cmd->system;
|
|
|
|
bool32 result = system->directory_cd(dir, len, capacity, rel_path, rel_len);
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
API_EXPORT int32_t
|
|
|
|
Get_4ed_Path(Application_Links *app, char *out, int32_t capacity)
|
|
|
|
/*
|
|
|
|
DOC_PARAM(out, This parameter provides a character buffer that receives the path to the 4ed executable file.)
|
|
|
|
DOC_PARAM(capacity, This parameter specifies the maximum capacity of the out buffer.)
|
|
|
|
DOC_RETURN(This call returns non-zero on success.)
|
|
|
|
*/{
|
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
System_Functions *system = cmd->system;
|
|
|
|
int32_t result = system->get_4ed_path(out, capacity);
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO(allen): add a "shown but auto-hides on timer" setting here.
|
|
|
|
API_EXPORT void
|
|
|
|
Show_Mouse_Cursor(Application_Links *app, Mouse_Cursor_Show_Type show)
|
|
|
|
/*
|
|
|
|
DOC_PARAM(show, This parameter specifies the new state of the mouse cursor.)
|
|
|
|
DOC_SEE(Mouse_Cursor_Show_Type)
|
|
|
|
*/{
|
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
System_Functions *system = cmd->system;
|
|
|
|
system->show_mouse_cursor(show);
|
|
|
|
}
|
|
|
|
|
2017-07-18 22:09:16 +00:00
|
|
|
API_EXPORT bool32
|
|
|
|
Set_Fullscreen(Application_Links *app, bool32 full_screen)
|
2017-01-23 06:19:43 +00:00
|
|
|
/*
|
2017-07-18 22:09:16 +00:00
|
|
|
DOC_PARAM(full_screen, The new value of the global full_screen setting.)
|
2017-07-18 22:34:57 +00:00
|
|
|
DOC(This call tells 4coder to set the full_screen mode. The change to full screen mode does not take effect until the end of the current frame. But is_fullscreen does report the new state.)
|
2017-01-23 06:19:43 +00:00
|
|
|
*/{
|
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
System_Functions *system = cmd->system;
|
2017-07-18 22:09:16 +00:00
|
|
|
bool32 success = system->set_fullscreen(full_screen);
|
|
|
|
if (!success){
|
2017-07-18 22:34:57 +00:00
|
|
|
print_message(app, literal("ERROR: Failed to go fullscreen.\n"));
|
2017-01-23 06:19:43 +00:00
|
|
|
}
|
2017-07-18 22:09:16 +00:00
|
|
|
return(success);
|
2017-01-23 06:19:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
API_EXPORT bool32
|
|
|
|
Is_Fullscreen(Application_Links *app)
|
|
|
|
/*
|
2017-11-30 16:39:35 +00:00
|
|
|
DOC(This call returns true if the 4coder is in full screen mode. This call takes toggles that have already occured this frame into account. So it may return true even though the frame has not ended and actually put 4coder into full screen. If it returns true though, 4coder will definitely be full screen by the beginning of the next frame if the state is not changed.)
|
2017-01-23 06:19:43 +00:00
|
|
|
*/{
|
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
System_Functions *system = cmd->system;
|
|
|
|
bool32 result = system->is_fullscreen();
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
API_EXPORT void
|
|
|
|
Send_Exit_Signal(Application_Links *app)
|
|
|
|
/*
|
2017-11-30 16:39:35 +00:00
|
|
|
DOC(This call sends a signal to 4coder to attempt to exit. If there are unsaved files this triggers a dialogue ensuring you're okay with closing.)
|
2017-01-23 06:19:43 +00:00
|
|
|
*/{
|
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
|
|
|
System_Functions *system = cmd->system;
|
|
|
|
system->send_exit_signal();
|
|
|
|
}
|
|
|
|
|
2017-11-30 16:39:35 +00:00
|
|
|
API_EXPORT void
|
2017-11-30 23:25:49 +00:00
|
|
|
Set_Window_Title(Application_Links *app, char *title)
|
2017-11-30 16:39:35 +00:00
|
|
|
/*
|
|
|
|
DOC_PARAM(title, A null terminated string indicating the new title for the 4coder window.)
|
|
|
|
DOC(Sets 4coder's window title to the specified title string.)
|
|
|
|
*/{
|
|
|
|
Command_Data *cmd = (Command_Data*)app->cmd_context;
|
2017-11-30 19:02:37 +00:00
|
|
|
Models *models = cmd->models;
|
|
|
|
models->has_new_title = true;
|
|
|
|
String dst = make_string_cap(models->title_space, 0, models->title_capacity);
|
|
|
|
append(&dst, title);
|
|
|
|
terminate_with_null(&dst);
|
2017-11-30 16:39:35 +00:00
|
|
|
}
|
|
|
|
|
2016-06-13 18:54:26 +00:00
|
|
|
// BOTTOM
|
|
|
|
|