2016-02-01 05:03:42 +00:00
|
|
|
/*
|
|
|
|
* Bind helper struct and functions
|
|
|
|
*/
|
|
|
|
|
2016-06-28 19:48:12 +00:00
|
|
|
#ifndef FCODER_HELPER_H
|
|
|
|
#define FCODER_HELPER_H
|
|
|
|
|
2016-02-01 05:03:42 +00:00
|
|
|
struct Bind_Helper{
|
|
|
|
Binding_Unit *cursor, *start, *end;
|
|
|
|
Binding_Unit *header, *group;
|
|
|
|
int write_total;
|
|
|
|
int error;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define BH_ERR_NONE 0
|
|
|
|
#define BH_ERR_MISSING_END 1
|
|
|
|
#define BH_ERR_MISSING_BEGIN 2
|
|
|
|
#define BH_ERR_OUT_OF_MEMORY 3
|
|
|
|
|
|
|
|
inline void
|
|
|
|
copy(char *dest, const char *src, int len){
|
|
|
|
for (int i = 0; i < len; ++i){
|
|
|
|
*dest++ = *src++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline Binding_Unit*
|
|
|
|
write_unit(Bind_Helper *helper, Binding_Unit unit){
|
|
|
|
Binding_Unit *p = 0;
|
|
|
|
helper->write_total += sizeof(*p);
|
|
|
|
if (helper->error == 0 && helper->cursor != helper->end){
|
|
|
|
p = helper->cursor++;
|
|
|
|
*p = unit;
|
|
|
|
}
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline char*
|
|
|
|
write_inline_string(Bind_Helper *helper, char *value, int len){
|
|
|
|
char *dest = 0;
|
|
|
|
helper->write_total += len;
|
|
|
|
if (helper->error == 0){
|
|
|
|
dest = (char*)helper->cursor;
|
|
|
|
int cursor_advance = len + sizeof(*helper->cursor) - 1;
|
|
|
|
cursor_advance /= sizeof(*helper->cursor);
|
|
|
|
cursor_advance *= sizeof(*helper->cursor);
|
|
|
|
helper->cursor += cursor_advance;
|
|
|
|
if (helper->cursor < helper->end){
|
|
|
|
copy(dest, value, len);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
helper->error = BH_ERR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return dest;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline Bind_Helper
|
|
|
|
begin_bind_helper(void *data, int size){
|
|
|
|
Bind_Helper result;
|
|
|
|
|
|
|
|
result.header = 0;
|
|
|
|
result.group = 0;
|
|
|
|
result.write_total = 0;
|
|
|
|
result.error = 0;
|
|
|
|
|
|
|
|
result.cursor = (Binding_Unit*)data;
|
|
|
|
result.start = result.cursor;
|
|
|
|
result.end = result.start + size / sizeof(*result.cursor);
|
|
|
|
|
|
|
|
Binding_Unit unit;
|
|
|
|
unit.type = unit_header;
|
|
|
|
unit.header.total_size = sizeof(*result.header);
|
|
|
|
result.header = write_unit(&result, unit);
|
|
|
|
result.header->header.user_map_count = 0;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
2016-05-19 13:29:38 +00:00
|
|
|
begin_map_(Bind_Helper *helper, int mapid, int replace){
|
2016-02-01 05:03:42 +00:00
|
|
|
if (helper->group != 0 && helper->error == 0) helper->error = BH_ERR_MISSING_END;
|
|
|
|
if (!helper->error && mapid < mapid_global) ++helper->header->header.user_map_count;
|
|
|
|
|
|
|
|
Binding_Unit unit;
|
|
|
|
unit.type = unit_map_begin;
|
|
|
|
unit.map_begin.mapid = mapid;
|
2016-05-19 13:29:38 +00:00
|
|
|
unit.map_begin.replace = replace;
|
2016-02-01 05:03:42 +00:00
|
|
|
helper->group = write_unit(helper, unit);
|
|
|
|
helper->group->map_begin.bind_count = 0;
|
|
|
|
}
|
|
|
|
|
2016-05-19 13:29:38 +00:00
|
|
|
inline void
|
|
|
|
begin_map(Bind_Helper *helper, int mapid){
|
|
|
|
begin_map_(helper, mapid, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
|
|
|
restart_map(Bind_Helper *helper, int mapid){
|
|
|
|
begin_map_(helper, mapid, 1);
|
|
|
|
}
|
|
|
|
|
2016-02-01 05:03:42 +00:00
|
|
|
inline void
|
|
|
|
end_map(Bind_Helper *helper){
|
|
|
|
if (helper->group == 0 && helper->error == 0) helper->error = BH_ERR_MISSING_BEGIN;
|
|
|
|
helper->group = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
2016-02-24 05:16:08 +00:00
|
|
|
bind(Bind_Helper *helper, short code, unsigned char modifiers, int cmdid){
|
2016-02-01 05:03:42 +00:00
|
|
|
if (helper->group == 0 && helper->error == 0) helper->error = BH_ERR_MISSING_BEGIN;
|
|
|
|
if (!helper->error) ++helper->group->map_begin.bind_count;
|
|
|
|
|
|
|
|
Binding_Unit unit;
|
|
|
|
unit.type = unit_binding;
|
|
|
|
unit.binding.command_id = cmdid;
|
2016-02-24 05:16:08 +00:00
|
|
|
unit.binding.code = code;
|
|
|
|
unit.binding.modifiers = modifiers;
|
2016-02-01 05:03:42 +00:00
|
|
|
|
|
|
|
write_unit(helper, unit);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
2016-02-24 05:16:08 +00:00
|
|
|
bind(Bind_Helper *helper, short code, unsigned char modifiers, Custom_Command_Function *func){
|
2016-02-01 05:03:42 +00:00
|
|
|
if (helper->group == 0 && helper->error == 0) helper->error = BH_ERR_MISSING_BEGIN;
|
|
|
|
if (!helper->error) ++helper->group->map_begin.bind_count;
|
|
|
|
|
|
|
|
Binding_Unit unit;
|
|
|
|
unit.type = unit_callback;
|
|
|
|
unit.callback.func = func;
|
2016-02-24 05:16:08 +00:00
|
|
|
unit.callback.code = code;
|
|
|
|
unit.callback.modifiers = modifiers;
|
2016-02-01 05:03:42 +00:00
|
|
|
|
|
|
|
write_unit(helper, unit);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
|
|
|
bind_vanilla_keys(Bind_Helper *helper, int cmdid){
|
|
|
|
bind(helper, 0, 0, cmdid);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
2016-02-23 03:56:15 +00:00
|
|
|
bind_vanilla_keys(Bind_Helper *helper, Custom_Command_Function *func){
|
|
|
|
bind(helper, 0, 0, func);
|
2016-02-01 05:03:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
|
|
|
bind_vanilla_keys(Bind_Helper *helper, unsigned char modifiers, int cmdid){
|
|
|
|
bind(helper, 0, modifiers, cmdid);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
2016-02-23 03:56:15 +00:00
|
|
|
bind_vanilla_keys(Bind_Helper *helper, unsigned char modifiers, Custom_Command_Function *func){
|
|
|
|
bind(helper, 0, modifiers, func);
|
2016-02-01 05:03:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
|
|
|
inherit_map(Bind_Helper *helper, int mapid){
|
|
|
|
if (helper->group == 0 && helper->error == 0) helper->error = BH_ERR_MISSING_BEGIN;
|
|
|
|
if (!helper->error && mapid < mapid_global) ++helper->header->header.user_map_count;
|
|
|
|
|
|
|
|
Binding_Unit unit;
|
|
|
|
unit.type = unit_inherit;
|
|
|
|
unit.map_inherit.mapid = mapid;
|
|
|
|
|
|
|
|
write_unit(helper, unit);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
2016-03-07 05:13:20 +00:00
|
|
|
set_hook(Bind_Helper *helper, int hook_id, Hook_Function *func){
|
2016-02-01 05:03:42 +00:00
|
|
|
Binding_Unit unit;
|
|
|
|
unit.type = unit_hook;
|
|
|
|
unit.hook.hook_id = hook_id;
|
2016-03-04 21:32:50 +00:00
|
|
|
unit.hook.func = (void*) func;
|
2016-02-01 05:03:42 +00:00
|
|
|
|
|
|
|
write_unit(helper, unit);
|
|
|
|
}
|
|
|
|
|
2016-06-23 23:11:09 +00:00
|
|
|
inline void
|
|
|
|
set_open_file_hook(Bind_Helper *helper, Open_File_Hook_Function *func){
|
|
|
|
Binding_Unit unit;
|
|
|
|
unit.type = unit_hook;
|
|
|
|
unit.hook.hook_id = _hook_open_file;
|
|
|
|
unit.hook.func = (void*) func;
|
|
|
|
|
|
|
|
write_unit(helper, unit);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
|
|
|
set_new_file_hook(Bind_Helper *helper, Open_File_Hook_Function *func){
|
|
|
|
Binding_Unit unit;
|
|
|
|
unit.type = unit_hook;
|
|
|
|
unit.hook.hook_id = _hook_new_file;
|
|
|
|
unit.hook.func = (void*) func;
|
|
|
|
|
|
|
|
write_unit(helper, unit);
|
|
|
|
}
|
|
|
|
|
2016-06-29 18:23:14 +00:00
|
|
|
inline void
|
|
|
|
set_command_caller(Bind_Helper *helper, Command_Caller_Hook_Function *func){
|
|
|
|
Binding_Unit unit;
|
|
|
|
unit.type = unit_hook;
|
|
|
|
unit.hook.hook_id = _hook_command_caller;
|
|
|
|
unit.hook.func = (void*) func;
|
|
|
|
|
|
|
|
write_unit(helper, unit);
|
|
|
|
}
|
|
|
|
|
2016-06-29 19:11:37 +00:00
|
|
|
inline void
|
|
|
|
set_input_filter(Bind_Helper *helper, Input_Filter_Function *func){
|
|
|
|
Binding_Unit unit;
|
|
|
|
unit.type = unit_hook;
|
|
|
|
unit.hook.hook_id = _hook_input_filter;
|
|
|
|
unit.hook.func = (void*) func;
|
|
|
|
|
|
|
|
write_unit(helper, unit);
|
|
|
|
}
|
|
|
|
|
2016-03-04 06:06:11 +00:00
|
|
|
inline void
|
|
|
|
set_scroll_rule(Bind_Helper *helper, Scroll_Rule_Function *func){
|
|
|
|
Binding_Unit unit;
|
|
|
|
unit.type = unit_hook;
|
|
|
|
unit.hook.hook_id = _hook_scroll_rule;
|
2016-03-04 21:32:50 +00:00
|
|
|
unit.hook.func = (void*) func;
|
2016-03-04 06:06:11 +00:00
|
|
|
|
|
|
|
write_unit(helper, unit);
|
|
|
|
}
|
|
|
|
|
2016-05-07 17:25:45 +00:00
|
|
|
inline int
|
2016-02-01 05:03:42 +00:00
|
|
|
end_bind_helper(Bind_Helper *helper){
|
2016-05-07 17:25:45 +00:00
|
|
|
int result;
|
2016-02-01 05:03:42 +00:00
|
|
|
if (helper->header){
|
|
|
|
helper->header->header.total_size = (int)(helper->cursor - helper->start);
|
|
|
|
helper->header->header.error = helper->error;
|
|
|
|
}
|
2016-05-07 17:25:45 +00:00
|
|
|
result = helper->write_total;
|
|
|
|
return(result);
|
2016-02-01 05:03:42 +00:00
|
|
|
}
|
|
|
|
|
2016-02-25 12:12:09 +00:00
|
|
|
inline Range
|
2016-03-03 04:10:45 +00:00
|
|
|
get_range(View_Summary *view){
|
2016-02-25 12:12:09 +00:00
|
|
|
Range range;
|
2016-02-26 17:40:51 +00:00
|
|
|
range = make_range(view->cursor.pos, view->mark.pos);
|
2016-02-25 12:12:09 +00:00
|
|
|
return(range);
|
|
|
|
}
|
|
|
|
|
2016-05-12 02:15:54 +00:00
|
|
|
struct Buffer_Rect{
|
|
|
|
int char0,line0;
|
|
|
|
int char1,line1;
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifndef Swap
|
2016-05-12 17:41:52 +00:00
|
|
|
#define Swap(T,a,b) do{ T t = a; a = b; b = t; } while(0)
|
2016-05-12 02:15:54 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
inline Buffer_Rect
|
|
|
|
get_rect(View_Summary *view){
|
|
|
|
Buffer_Rect rect;
|
|
|
|
|
|
|
|
rect.char0 = view->mark.character;
|
|
|
|
rect.line0 = view->mark.line;
|
|
|
|
|
|
|
|
rect.char1 = view->cursor.character;
|
|
|
|
rect.line1 = view->cursor.line;
|
|
|
|
|
|
|
|
if (rect.line0 > rect.line1){
|
2016-05-12 17:41:52 +00:00
|
|
|
Swap(int, rect.line0, rect.line1);
|
2016-05-12 02:15:54 +00:00
|
|
|
}
|
|
|
|
if (rect.char0 > rect.char1){
|
2016-05-12 17:41:52 +00:00
|
|
|
Swap(int, rect.char0, rect.char1);
|
2016-05-12 02:15:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return(rect);
|
|
|
|
}
|
|
|
|
|
2016-02-23 03:56:15 +00:00
|
|
|
inline void
|
2016-02-26 06:26:26 +00:00
|
|
|
exec_command(Application_Links *app, Command_ID id){
|
2016-06-13 16:56:33 +00:00
|
|
|
app->exec_command(app, id);
|
2016-02-23 03:56:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
2016-02-26 06:26:26 +00:00
|
|
|
exec_command(Application_Links *app, Custom_Command_Function *func){
|
|
|
|
func(app);
|
2016-02-23 03:56:15 +00:00
|
|
|
}
|
|
|
|
|
2016-06-29 18:23:14 +00:00
|
|
|
inline void
|
|
|
|
exec_command(Application_Links *app, Generic_Command cmd){
|
|
|
|
if (cmd.cmdid < cmdid_count){
|
|
|
|
exec_command(app, cmd.cmdid);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
exec_command(app, cmd.command);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-26 17:40:51 +00:00
|
|
|
inline void
|
2016-06-20 20:34:48 +00:00
|
|
|
active_view_to_line(Application_Links *app, unsigned int access, int line_number){
|
2016-03-03 04:10:45 +00:00
|
|
|
View_Summary view;
|
2016-06-20 20:34:48 +00:00
|
|
|
view = app->get_active_view(app, access);
|
2016-02-26 17:40:51 +00:00
|
|
|
|
|
|
|
// NOTE(allen|a3.4.4): We don't have to worry about whether this is a valid line number.
|
2016-02-29 03:35:19 +00:00
|
|
|
// When it's not possible to place a cursor at the position for whatever reason it will set the
|
|
|
|
// cursor to a nearby valid position.
|
2016-02-26 17:40:51 +00:00
|
|
|
app->view_set_cursor(app, &view, seek_line_char(line_number, 0), 1);
|
|
|
|
}
|
|
|
|
|
2016-03-05 08:10:43 +00:00
|
|
|
inline View_Summary
|
|
|
|
get_first_view_with_buffer(Application_Links *app, int buffer_id){
|
|
|
|
View_Summary result = {};
|
|
|
|
View_Summary test = {};
|
2016-06-20 20:34:48 +00:00
|
|
|
|
2016-06-28 22:58:50 +00:00
|
|
|
if (buffer_id != 0){
|
|
|
|
unsigned int access = AccessAll;
|
|
|
|
for(test = app->get_view_first(app, access);
|
|
|
|
test.exists;
|
|
|
|
app->get_view_next(app, &test, access)){
|
|
|
|
|
|
|
|
Buffer_Summary buffer = app->get_buffer(app, test.buffer_id, access);
|
|
|
|
|
|
|
|
if(buffer.buffer_id == buffer_id){
|
|
|
|
result = test;
|
|
|
|
break;
|
|
|
|
}
|
2016-03-05 08:10:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2016-02-27 19:33:42 +00:00
|
|
|
inline int
|
|
|
|
key_is_unmodified(Key_Event_Data *key){
|
|
|
|
char *mods = key->modifiers;
|
|
|
|
int unmodified = !mods[MDFR_CONTROL_INDEX] && !mods[MDFR_ALT_INDEX];
|
|
|
|
return(unmodified);
|
|
|
|
}
|
|
|
|
|
2016-02-27 22:23:40 +00:00
|
|
|
static int
|
2016-02-27 23:33:30 +00:00
|
|
|
query_user_general(Application_Links *app, Query_Bar *bar, int force_number){
|
2016-02-27 22:23:40 +00:00
|
|
|
User_Input in;
|
|
|
|
int success = 1;
|
|
|
|
int good_character = 0;
|
|
|
|
|
|
|
|
// NOTE(allen|a3.4.4): It will not cause an *error* if we continue on after failing to.
|
|
|
|
// start a query bar, but it will be unusual behavior from the point of view of the
|
|
|
|
// user, if this command starts intercepting input even though no prompt is shown.
|
|
|
|
// This will only happen if you have a lot of bars open already or if the current view
|
|
|
|
// doesn't support query bars.
|
2016-02-27 23:33:30 +00:00
|
|
|
if (app->start_query_bar(app, bar, 0) == 0) return 0;
|
2016-02-27 22:23:40 +00:00
|
|
|
|
|
|
|
while (1){
|
|
|
|
// NOTE(allen|a3.4.4): This call will block until the user does one of the input
|
|
|
|
// types specified in the flags. The first set of flags are inputs you'd like to intercept
|
|
|
|
// that you don't want to abort on. The second set are inputs that you'd like to cause
|
|
|
|
// the command to abort. If an event satisfies both flags, it is treated as an abort.
|
|
|
|
in = app->get_user_input(app, EventOnAnyKey, EventOnEsc | EventOnButton);
|
|
|
|
|
|
|
|
// NOTE(allen|a3.4.4): The responsible thing to do on abort is to end the command
|
|
|
|
// without waiting on get_user_input again.
|
|
|
|
if (in.abort){
|
|
|
|
success = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
good_character = 0;
|
|
|
|
if (key_is_unmodified(&in.key)){
|
|
|
|
if (force_number){
|
|
|
|
if (in.key.character >= '0' && in.key.character <= '9'){
|
|
|
|
good_character = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
if (in.key.character != 0){
|
|
|
|
good_character = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-03-26 08:06:41 +00:00
|
|
|
|
2016-02-29 03:35:19 +00:00
|
|
|
// NOTE(allen|a3.4.4): All we have to do to update the query bar is edit our
|
|
|
|
// local Query_Bar struct! This is handy because it means our Query_Bar
|
|
|
|
// is always correct for typical use without extra work updating the bar.
|
2016-02-27 22:23:40 +00:00
|
|
|
if (in.type == UserInputKey){
|
|
|
|
if (in.key.keycode == '\n' || in.key.keycode == '\t'){
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (in.key.keycode == key_back){
|
2016-03-26 08:06:41 +00:00
|
|
|
if (bar->string.size > 0){
|
|
|
|
--bar->string.size;
|
|
|
|
}
|
2016-02-27 22:23:40 +00:00
|
|
|
}
|
|
|
|
else if (good_character){
|
2016-02-27 23:33:30 +00:00
|
|
|
append(&bar->string, in.key.character);
|
2016-02-27 22:23:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return(success);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int
|
2016-02-27 23:33:30 +00:00
|
|
|
query_user_string(Application_Links *app, Query_Bar *bar){
|
|
|
|
int success = query_user_general(app, bar, 0);
|
2016-02-27 22:23:40 +00:00
|
|
|
return(success);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int
|
2016-02-27 23:33:30 +00:00
|
|
|
query_user_number(Application_Links *app, Query_Bar *bar){
|
|
|
|
int success = query_user_general(app, bar, 1);
|
2016-02-27 22:23:40 +00:00
|
|
|
return(success);
|
|
|
|
}
|
2016-03-05 08:10:43 +00:00
|
|
|
|
|
|
|
inline String empty_string() {String Result = {}; return(Result);}
|
2016-05-31 01:22:55 +00:00
|
|
|
|
|
|
|
inline Buffer_Summary
|
2016-06-20 20:34:48 +00:00
|
|
|
get_active_buffer(Application_Links *app, unsigned int access){
|
|
|
|
View_Summary view = app->get_active_view(app, access);
|
|
|
|
Buffer_Summary buffer = app->get_buffer(app, view.buffer_id, access);
|
2016-05-31 01:22:55 +00:00
|
|
|
return(buffer);
|
|
|
|
}
|
|
|
|
|
2016-07-10 05:49:11 +00:00
|
|
|
inline char
|
|
|
|
buffer_get_char(Application_Links *app, Buffer_Summary *buffer, int pos){
|
|
|
|
char result = 0;
|
|
|
|
app->buffer_read_range(app, buffer, pos, pos+1, &result);
|
2016-05-31 01:22:55 +00:00
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2016-06-13 16:56:33 +00:00
|
|
|
inline Buffer_Identifier
|
|
|
|
buffer_identifier(char *str, int len){
|
|
|
|
Buffer_Identifier identifier;
|
|
|
|
identifier.name = str;
|
|
|
|
identifier.name_len = len;
|
|
|
|
identifier.id = 0;
|
|
|
|
return(identifier);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline Buffer_Identifier
|
|
|
|
buffer_identifier(int id){
|
|
|
|
Buffer_Identifier identifier;
|
|
|
|
identifier.name = 0;
|
|
|
|
identifier.name_len = 0;
|
|
|
|
identifier.id = id;
|
|
|
|
return(identifier);
|
|
|
|
}
|
|
|
|
|
2016-06-17 03:31:15 +00:00
|
|
|
static int
|
|
|
|
view_open_file(Application_Links *app, View_Summary *view,
|
|
|
|
char *filename, int filename_len, int do_in_background){
|
|
|
|
int result = false;
|
2016-06-20 20:34:48 +00:00
|
|
|
Buffer_Summary buffer = app->get_buffer_by_name(app, filename, filename_len, AccessProtected|AccessHidden);
|
2016-06-17 03:31:15 +00:00
|
|
|
if (buffer.exists){
|
2016-07-03 20:03:19 +00:00
|
|
|
if (!do_in_background){
|
2016-07-04 04:04:39 +00:00
|
|
|
if (view){
|
|
|
|
app->view_set_buffer(app, view, buffer.buffer_id, 0);
|
|
|
|
}
|
2016-07-03 20:03:19 +00:00
|
|
|
}
|
2016-06-17 03:31:15 +00:00
|
|
|
result = true;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
buffer = app->create_buffer(app, filename, filename_len, do_in_background);
|
|
|
|
if (!do_in_background){
|
|
|
|
if (buffer.exists){
|
2016-07-04 04:04:39 +00:00
|
|
|
if (view){
|
|
|
|
app->view_set_buffer(app, view, buffer.buffer_id, 0);
|
|
|
|
result = true;
|
|
|
|
}
|
2016-06-17 03:31:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return(result);
|
|
|
|
}
|
|
|
|
|
2016-06-28 19:48:12 +00:00
|
|
|
#endif
|