expose 4ed module path in custom API
parent
cc91b72883
commit
e07ec779cb
|
@ -358,6 +358,7 @@ struct Application_Links;
|
||||||
|
|
||||||
// File system navigation
|
// File system navigation
|
||||||
#define DIRECTORY_GET_HOT_SIG(n) int n(Application_Links *app, char *out, int capacity)
|
#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 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 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)
|
#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
|
// File system navigation
|
||||||
typedef DIRECTORY_GET_HOT_SIG(Directory_Get_Hot_Function);
|
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 FILE_EXISTS_SIG(File_Exists_Function);
|
||||||
typedef DIRECTORY_CD_SIG(Directory_CD_Function);
|
typedef DIRECTORY_CD_SIG(Directory_CD_Function);
|
||||||
typedef GET_FILE_LIST_SIG(Get_File_List_Function);
|
typedef GET_FILE_LIST_SIG(Get_File_List_Function);
|
||||||
|
@ -507,6 +509,7 @@ struct Application_Links{
|
||||||
|
|
||||||
// File system navigation
|
// File system navigation
|
||||||
Directory_Get_Hot_Function *directory_get_hot;
|
Directory_Get_Hot_Function *directory_get_hot;
|
||||||
|
Get_4ed_Path_Function *get_4ed_path;
|
||||||
File_Exists_Function *file_exists;
|
File_Exists_Function *file_exists;
|
||||||
Directory_CD_Function *directory_cd;
|
Directory_CD_Function *directory_cd;
|
||||||
Get_File_List_Function *get_file_list;
|
Get_File_List_Function *get_file_list;
|
||||||
|
|
1
4ed.cpp
1
4ed.cpp
|
@ -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->clear_parameters = external_clear_parameters;
|
||||||
|
|
||||||
app_links->directory_get_hot = external_directory_get_hot;
|
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->file_exists = system->file_exists;
|
||||||
app_links->directory_cd = system->directory_cd;
|
app_links->directory_cd = system->directory_cd;
|
||||||
app_links->get_file_list = external_get_file_list;
|
app_links->get_file_list = external_get_file_list;
|
||||||
|
|
|
@ -2365,7 +2365,6 @@ get_line_indentation_marks(Partition *part, Buffer *buffer, Cpp_Token_Stack toke
|
||||||
switch(token->type){
|
switch(token->type){
|
||||||
case CPP_TOKEN_BRACE_OPEN:
|
case CPP_TOKEN_BRACE_OPEN:
|
||||||
case CPP_TOKEN_BRACE_CLOSE:
|
case CPP_TOKEN_BRACE_CLOSE:
|
||||||
case CPP_TOKEN_PARENTHESE_OPEN:
|
|
||||||
goto out_of_loop;
|
goto out_of_loop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -212,9 +212,10 @@ struct System_Functions{
|
||||||
System_File_Track *file_track;
|
System_File_Track *file_track;
|
||||||
System_File_Untrack *file_untrack;
|
System_File_Untrack *file_untrack;
|
||||||
|
|
||||||
// file system navigation (4coder_custom.h): 2
|
// file system navigation (4coder_custom.h): 3
|
||||||
File_Exists_Function *file_exists;
|
File_Exists_Function *file_exists;
|
||||||
Directory_CD_Function *directory_cd;
|
Directory_CD_Function *directory_cd;
|
||||||
|
Get_4ed_Path_Function *get_4ed_path;
|
||||||
|
|
||||||
// clipboard: 1
|
// clipboard: 1
|
||||||
System_Post_Clipboard *post_clipboard;
|
System_Post_Clipboard *post_clipboard;
|
||||||
|
|
|
@ -313,13 +313,23 @@ void experiment_extension(Bind_Helper *context){
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#define SETTINGS_FILE ".4coder_settings"
|
||||||
HOOK_SIG(experimental_start_hook){
|
HOOK_SIG(experimental_start_hook){
|
||||||
my_start(app);
|
my_start(app);
|
||||||
|
|
||||||
FILE *file = fopen(".4coder_settings", "rb");
|
|
||||||
char theme_name[128];
|
char theme_name[128];
|
||||||
char font_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){
|
if (file){
|
||||||
fscanf(file, "%127s\n%127s", theme_name, font_name);
|
fscanf(file, "%127s\n%127s", theme_name, font_name);
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
#include "4ed_internal.h"
|
#include "4ed_internal.h"
|
||||||
#include "system_shared.h"
|
#include "system_shared.h"
|
||||||
|
|
||||||
#define FPS 30
|
#define FPS 60
|
||||||
#define frame_useconds (1000000 / FPS)
|
#define frame_useconds (1000000 / FPS)
|
||||||
|
|
||||||
// TODO(allen): Do we still need all of these? I've abandoned the
|
// 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);
|
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
|
internal
|
||||||
Sys_Post_Clipboard_Sig(system_post_clipboard){
|
Sys_Post_Clipboard_Sig(system_post_clipboard){
|
||||||
if (OpenClipboard(win32vars.window_handle)){
|
if (OpenClipboard(win32vars.window_handle)){
|
||||||
|
@ -1124,6 +1136,7 @@ Win32LoadSystemCode(){
|
||||||
|
|
||||||
win32vars.system->file_exists = system_file_exists;
|
win32vars.system->file_exists = system_file_exists;
|
||||||
win32vars.system->directory_cd = system_directory_cd;
|
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->post_clipboard = system_post_clipboard;
|
||||||
win32vars.system->time = system_time;
|
win32vars.system->time = system_time;
|
||||||
|
|
Loading…
Reference in New Issue