expose 4ed module path in custom API

master
Allen Webster 2016-05-16 22:22:57 -04:00
parent cc91b72883
commit e07ec779cb
6 changed files with 31 additions and 4 deletions

View File

@ -358,6 +358,7 @@ struct Application_Links;
// File system navigation
#define DIRECTORY_GET_HOT_SIG(n) int n(Application_Links *app, char *out, int capacity)
#define GET_4ED_PATH_SIG(n) int n(Application_Links *app, char *out, int capacity)
#define FILE_EXISTS_SIG(n) int n(Application_Links *app, char *filename, int len)
#define DIRECTORY_CD_SIG(n) int n(Application_Links *app, char *dir, int *len, int capacity, char *rel_path, int rel_len)
#define GET_FILE_LIST_SIG(n) File_List n(Application_Links *app, char *dir, int len)
@ -442,6 +443,7 @@ extern "C"{
// File system navigation
typedef DIRECTORY_GET_HOT_SIG(Directory_Get_Hot_Function);
typedef GET_4ED_PATH_SIG(Get_4ed_Path_Function);
typedef FILE_EXISTS_SIG(File_Exists_Function);
typedef DIRECTORY_CD_SIG(Directory_CD_Function);
typedef GET_FILE_LIST_SIG(Get_File_List_Function);
@ -507,6 +509,7 @@ struct Application_Links{
// File system navigation
Directory_Get_Hot_Function *directory_get_hot;
Get_4ed_Path_Function *get_4ed_path;
File_Exists_Function *file_exists;
Directory_CD_Function *directory_cd;
Get_File_List_Function *get_file_list;

View File

@ -2557,6 +2557,7 @@ app_links_init(System_Functions *system, Application_Links *app_links, void *dat
app_links->clear_parameters = external_clear_parameters;
app_links->directory_get_hot = external_directory_get_hot;
app_links->get_4ed_path = system->get_4ed_path;
app_links->file_exists = system->file_exists;
app_links->directory_cd = system->directory_cd;
app_links->get_file_list = external_get_file_list;

View File

@ -2365,7 +2365,6 @@ get_line_indentation_marks(Partition *part, Buffer *buffer, Cpp_Token_Stack toke
switch(token->type){
case CPP_TOKEN_BRACE_OPEN:
case CPP_TOKEN_BRACE_CLOSE:
case CPP_TOKEN_PARENTHESE_OPEN:
goto out_of_loop;
}
}

View File

@ -212,9 +212,10 @@ struct System_Functions{
System_File_Track *file_track;
System_File_Untrack *file_untrack;
// file system navigation (4coder_custom.h): 2
// file system navigation (4coder_custom.h): 3
File_Exists_Function *file_exists;
Directory_CD_Function *directory_cd;
Get_4ed_Path_Function *get_4ed_path;
// clipboard: 1
System_Post_Clipboard *post_clipboard;

View File

@ -313,13 +313,23 @@ void experiment_extension(Bind_Helper *context){
#include <stdio.h>
#define SETTINGS_FILE ".4coder_settings"
HOOK_SIG(experimental_start_hook){
my_start(app);
FILE *file = fopen(".4coder_settings", "rb");
char theme_name[128];
char font_name[128];
FILE *file = fopen(SETTINGS_FILE, "rb");
if (!file){
char module_path[512];
int len;
len = app->get_4ed_path(app, module_path, 448);
memcpy(module_path+len, SETTINGS_FILE, sizeof(SETTINGS_FILE));
file = fopen(module_path, "rb");
}
if (file){
fscanf(file, "%127s\n%127s", theme_name, font_name);

View File

@ -43,7 +43,7 @@
#include "4ed_internal.h"
#include "system_shared.h"
#define FPS 30
#define FPS 60
#define frame_useconds (1000000 / FPS)
// TODO(allen): Do we still need all of these? I've abandoned the
@ -582,6 +582,18 @@ DIRECTORY_CD_SIG(system_directory_cd){
return(result);
}
GET_4ED_PATH_SIG(system_get_4ed_path){
String str = make_string(out, 0, capacity);
i32 result = 0;
i32 size = GetModuleFileName(0, out, capacity);
if (size < capacity-1){
str.size = size;
remove_last_folder(&str);
result = str.size;
}
return(result);
}
internal
Sys_Post_Clipboard_Sig(system_post_clipboard){
if (OpenClipboard(win32vars.window_handle)){
@ -1124,6 +1136,7 @@ Win32LoadSystemCode(){
win32vars.system->file_exists = system_file_exists;
win32vars.system->directory_cd = system_directory_cd;
win32vars.system->get_4ed_path = system_get_4ed_path;
win32vars.system->post_clipboard = system_post_clipboard;
win32vars.system->time = system_time;