stripped config menu and menu menu, added AltGr setting to API

master
Allen Webster 2017-05-14 19:42:16 -04:00
parent 7abf4de36f
commit f30bd14777
7 changed files with 48 additions and 85 deletions

View File

@ -1,4 +1,5 @@
struct Application_Links; struct Application_Links;
#define GLOBAL_SET_SETTING_SIG(n) bool32 n(Application_Links *app, Global_Setting_ID setting, int32_t value)
#define EXEC_COMMAND_SIG(n) bool32 n(Application_Links *app, Command_ID command_id) #define EXEC_COMMAND_SIG(n) bool32 n(Application_Links *app, Command_ID command_id)
#define EXEC_SYSTEM_COMMAND_SIG(n) bool32 n(Application_Links *app, View_Summary *view, Buffer_Identifier buffer, char *path, int32_t path_len, char *command, int32_t command_len, Command_Line_Interface_Flag flags) #define EXEC_SYSTEM_COMMAND_SIG(n) bool32 n(Application_Links *app, View_Summary *view, Buffer_Identifier buffer, char *path, int32_t path_len, char *command, int32_t command_len, Command_Line_Interface_Flag flags)
#define CLIPBOARD_POST_SIG(n) void n(Application_Links *app, int32_t clipboard_id, char *str, int32_t len) #define CLIPBOARD_POST_SIG(n) void n(Application_Links *app, int32_t clipboard_id, char *str, int32_t len)
@ -72,6 +73,7 @@ struct Application_Links;
#define TOGGLE_FULLSCREEN_SIG(n) void n(Application_Links *app) #define TOGGLE_FULLSCREEN_SIG(n) void n(Application_Links *app)
#define IS_FULLSCREEN_SIG(n) bool32 n(Application_Links *app) #define IS_FULLSCREEN_SIG(n) bool32 n(Application_Links *app)
#define SEND_EXIT_SIGNAL_SIG(n) void n(Application_Links *app) #define SEND_EXIT_SIGNAL_SIG(n) void n(Application_Links *app)
typedef GLOBAL_SET_SETTING_SIG(Global_Set_Setting_Function);
typedef EXEC_COMMAND_SIG(Exec_Command_Function); typedef EXEC_COMMAND_SIG(Exec_Command_Function);
typedef EXEC_SYSTEM_COMMAND_SIG(Exec_System_Command_Function); typedef EXEC_SYSTEM_COMMAND_SIG(Exec_System_Command_Function);
typedef CLIPBOARD_POST_SIG(Clipboard_Post_Function); typedef CLIPBOARD_POST_SIG(Clipboard_Post_Function);
@ -147,6 +149,7 @@ typedef IS_FULLSCREEN_SIG(Is_Fullscreen_Function);
typedef SEND_EXIT_SIGNAL_SIG(Send_Exit_Signal_Function); typedef SEND_EXIT_SIGNAL_SIG(Send_Exit_Signal_Function);
struct Application_Links{ struct Application_Links{
#if defined(ALLOW_DEP_4CODER) #if defined(ALLOW_DEP_4CODER)
Global_Set_Setting_Function *global_set_setting;
Exec_Command_Function *exec_command; Exec_Command_Function *exec_command;
Exec_System_Command_Function *exec_system_command; Exec_System_Command_Function *exec_system_command;
Clipboard_Post_Function *clipboard_post; Clipboard_Post_Function *clipboard_post;
@ -221,6 +224,7 @@ Toggle_Fullscreen_Function *toggle_fullscreen;
Is_Fullscreen_Function *is_fullscreen; Is_Fullscreen_Function *is_fullscreen;
Send_Exit_Signal_Function *send_exit_signal; Send_Exit_Signal_Function *send_exit_signal;
#else #else
Global_Set_Setting_Function *global_set_setting_;
Exec_Command_Function *exec_command_; Exec_Command_Function *exec_command_;
Exec_System_Command_Function *exec_system_command_; Exec_System_Command_Function *exec_system_command_;
Clipboard_Post_Function *clipboard_post_; Clipboard_Post_Function *clipboard_post_;
@ -303,6 +307,7 @@ void *current_coroutine;
int32_t type_coroutine; int32_t type_coroutine;
}; };
#define FillAppLinksAPI(app_links) do{\ #define FillAppLinksAPI(app_links) do{\
app_links->global_set_setting_ = Global_Set_Setting;\
app_links->exec_command_ = Exec_Command;\ app_links->exec_command_ = Exec_Command;\
app_links->exec_system_command_ = Exec_System_Command;\ app_links->exec_system_command_ = Exec_System_Command;\
app_links->clipboard_post_ = Clipboard_Post;\ app_links->clipboard_post_ = Clipboard_Post;\
@ -377,6 +382,7 @@ app_links->toggle_fullscreen_ = Toggle_Fullscreen;\
app_links->is_fullscreen_ = Is_Fullscreen;\ app_links->is_fullscreen_ = Is_Fullscreen;\
app_links->send_exit_signal_ = Send_Exit_Signal;} while(false) app_links->send_exit_signal_ = Send_Exit_Signal;} while(false)
#if defined(ALLOW_DEP_4CODER) #if defined(ALLOW_DEP_4CODER)
static inline bool32 global_set_setting(Application_Links *app, Global_Setting_ID setting, int32_t value){return(app->global_set_setting(app, setting, value));}
static inline bool32 exec_command(Application_Links *app, Command_ID command_id){return(app->exec_command(app, command_id));} static inline bool32 exec_command(Application_Links *app, Command_ID command_id){return(app->exec_command(app, command_id));}
static inline bool32 exec_system_command(Application_Links *app, View_Summary *view, Buffer_Identifier buffer, char *path, int32_t path_len, char *command, int32_t command_len, Command_Line_Interface_Flag flags){return(app->exec_system_command(app, view, buffer, path, path_len, command, command_len, flags));} static inline bool32 exec_system_command(Application_Links *app, View_Summary *view, Buffer_Identifier buffer, char *path, int32_t path_len, char *command, int32_t command_len, Command_Line_Interface_Flag flags){return(app->exec_system_command(app, view, buffer, path, path_len, command, command_len, flags));}
static inline void clipboard_post(Application_Links *app, int32_t clipboard_id, char *str, int32_t len){(app->clipboard_post(app, clipboard_id, str, len));} static inline void clipboard_post(Application_Links *app, int32_t clipboard_id, char *str, int32_t len){(app->clipboard_post(app, clipboard_id, str, len));}
@ -451,6 +457,7 @@ static inline void toggle_fullscreen(Application_Links *app){(app->toggle_fullsc
static inline bool32 is_fullscreen(Application_Links *app){return(app->is_fullscreen(app));} static inline bool32 is_fullscreen(Application_Links *app){return(app->is_fullscreen(app));}
static inline void send_exit_signal(Application_Links *app){(app->send_exit_signal(app));} static inline void send_exit_signal(Application_Links *app){(app->send_exit_signal(app));}
#else #else
static inline bool32 global_set_setting(Application_Links *app, Global_Setting_ID setting, int32_t value){return(app->global_set_setting_(app, setting, value));}
static inline bool32 exec_command(Application_Links *app, Command_ID command_id){return(app->exec_command_(app, command_id));} static inline bool32 exec_command(Application_Links *app, Command_ID command_id){return(app->exec_command_(app, command_id));}
static inline bool32 exec_system_command(Application_Links *app, View_Summary *view, Buffer_Identifier buffer, char *path, int32_t path_len, char *command, int32_t command_len, Command_Line_Interface_Flag flags){return(app->exec_system_command_(app, view, buffer, path, path_len, command, command_len, flags));} static inline bool32 exec_system_command(Application_Links *app, View_Summary *view, Buffer_Identifier buffer, char *path, int32_t path_len, char *command, int32_t command_len, Command_Line_Interface_Flag flags){return(app->exec_system_command_(app, view, buffer, path, path_len, command, command_len, flags));}
static inline void clipboard_post(Application_Links *app, int32_t clipboard_id, char *str, int32_t len){(app->clipboard_post_(app, clipboard_id, str, len));} static inline void clipboard_post(Application_Links *app, int32_t clipboard_id, char *str, int32_t len){(app->clipboard_post_(app, clipboard_id, str, len));}

View File

@ -81,10 +81,6 @@ ENUM(uint64_t, Command_ID){
/* DOC(cmdid_open_color_tweaker opens the theme editing GUI.) */ /* DOC(cmdid_open_color_tweaker opens the theme editing GUI.) */
cmdid_open_color_tweaker, cmdid_open_color_tweaker,
/* DOC(cmdid_open_config opens the configuration menu.) */
cmdid_open_config,
/* DOC(cmdid_open_menu opens the top level menu. ) */
cmdid_open_menu,
/* DOC(cmdid_open_debug opens the debug information viewer mode.) */ /* DOC(cmdid_open_debug opens the debug information viewer mode.) */
cmdid_open_debug, cmdid_open_debug,
@ -136,29 +132,30 @@ ENUM(int32_t, Wrap_Indicator_Mode){
WrapIndicator_Show_At_Wrap_Edge, WrapIndicator_Show_At_Wrap_Edge,
}; };
/* DOC(A Global_Setting_ID names a setting.) */
ENUM(int32_t, Global_Setting_ID){
/* DOC(GlobalSetting_Null is not a valid setting, it is reserved to detect errors.) */
GlobalSetting_Null,
/* DOC(When GlobalSetting_LAltLCtrlIsAltGr is enabled, keyboard layouts with AltGr will also interpret the left alt and control keys as AltGr. If you do not use a keyboard with AltGr you should have this turned off. This setting is only relevant on Windows and has no effect on other systems.) */
GlobalSetting_LAltLCtrlIsAltGr,
};
/* DOC(A Buffer_Setting_ID names a setting in a buffer.) */ /* DOC(A Buffer_Setting_ID names a setting in a buffer.) */
ENUM(int32_t, Buffer_Setting_ID){ ENUM(int32_t, Buffer_Setting_ID){
/* DOC(BufferSetting_Null is not a valid setting, it is reserved to detect errors.) */ /* DOC(BufferSetting_Null is not a valid setting, it is reserved to detect errors.) */
BufferSetting_Null, BufferSetting_Null,
/* DOC(The BufferSetting_Lex setting is used to determine whether to store C++ tokens /* DOC(The BufferSetting_Lex setting is used to determine whether to store C++ tokens from with the buffer.) */
from with the buffer.) */
BufferSetting_Lex, BufferSetting_Lex,
/* DOC(The BufferSetting_LexWithoutStrings tells the system to treat string and character marks as identifiers instead of strings. This settings does nothing if the buffer does not have lexing turned on.) */ /* DOC(The BufferSetting_LexWithoutStrings tells the system to treat string and character marks as identifiers instead of strings. This settings does nothing if the buffer does not have lexing turned on.) */
BufferSetting_LexWithoutStrings, BufferSetting_LexWithoutStrings,
/* DOC(The BufferSetting_WrapLine setting is used to determine whether a buffer prefers /* DOC(The BufferSetting_WrapLine setting is used to determine whether a buffer prefers to be viewed with wrapped lines, individual views can be set to override this value after being tied to the buffer.) */
to be viewed with wrapped lines, individual views can be set to override this value after
being tied to the buffer.) */
BufferSetting_WrapLine, BufferSetting_WrapLine,
/* DOC(The BufferSetting_WrapPosition setting determines after how many pixels /* DOC(The BufferSetting_WrapPosition setting determines after how many pixels a line will wrap. A view set's this value from the global default value when the view is created. This value cannot be set to less than 48, any value passed below 48 will cause the position to be set to 48. This is a potentially expensive operation because the wrap positions of the file have to be reindexed. For best behavior try to only set this setting once per frame, if possible.) */
a line will wrap. A view set's this value from the global default value
when the view is created. This value cannot be set to less than 48, any value passed
below 48 will cause the position to be set to 48. This is a potentially expensive
operation because the wrap positions of the file have to be reindexed. For
best behavior try to only set this setting once per frame, if possible.) */
BufferSetting_WrapPosition, BufferSetting_WrapPosition,
/* DOC(The BufferSetting_MinimumBaseWrapPosition setting is used to increase the with in pixels allotted to a line for wrapping, by setting a minimum position away from the base of the line. The base of a line is always 0, or the left hand side of the view, in text files. In code files the base of a line is the amount the line is shifted to the right due to brace nesting. This setting allows for deeply nested code to remain readable by ensuring lines deep in the nesting get some minimum base width which may be more wrapping space than the non base adjusted wrap position would have allowed. In any case where the (default wrapping position) is greater than (the base + minimum base position), the larger ) the default will still be used. */ /* DOC(The BufferSetting_MinimumBaseWrapPosition setting is used to increase the with in pixels allotted to a line for wrapping, by setting a minimum position away from the base of the line. The base of a line is always 0, or the left hand side of the view, in text files. In code files the base of a line is the amount the line is shifted to the right due to brace nesting. This setting allows for deeply nested code to remain readable by ensuring lines deep in the nesting get some minimum base width which may be more wrapping space than the non base adjusted wrap position would have allowed. In any case where the (default wrapping position) is greater than (the base + minimum base position), the larger ) the default will still be used. */
@ -167,12 +164,10 @@ ENUM(int32_t, Buffer_Setting_ID){
/* DOC(The BufferSetting_WrapIndicator setting is used to specify how wrapped lines should be marked so the user can see that they have been wrapped. The value should be one of the values in the Wrap_Indicator_Mode enum.) DOC_SEE(Wrap_Indicator_Mode) */ /* DOC(The BufferSetting_WrapIndicator setting is used to specify how wrapped lines should be marked so the user can see that they have been wrapped. The value should be one of the values in the Wrap_Indicator_Mode enum.) DOC_SEE(Wrap_Indicator_Mode) */
BufferSetting_WrapIndicator, BufferSetting_WrapIndicator,
/* DOC(The BufferSetting_MapID setting specifies the id of the command map that should be /* DOC(The BufferSetting_MapID setting specifies the id of the command map that should be active when a buffer is active.) */
active when a buffer is active.) */
BufferSetting_MapID, BufferSetting_MapID,
/* DOC(The BufferSetting_Eol setting specifies how line ends should be saved to the backing file. /* DOC(The BufferSetting_Eol setting specifies how line ends should be saved to the backing file. A 1 indicates dos endings "\r\n" and a 0 indicates nix endings "\n".) */
A 1 indicates dos endings "\r\n" and a 0 indicates nix endings "\n".) */
BufferSetting_Eol, BufferSetting_Eol,
/* DOC(The BufferSetting_Unimportant setting marks a buffer so that its dirty state will be forced to stay at DirtyState_UpToDate when the buffer is edited or when the buffer's paired file, if it has one, is edited.) */ /* DOC(The BufferSetting_Unimportant setting marks a buffer so that its dirty state will be forced to stay at DirtyState_UpToDate when the buffer is edited or when the buffer's paired file, if it has one, is edited.) */
@ -181,9 +176,7 @@ ENUM(int32_t, Buffer_Setting_ID){
/* DOC(The BufferSetting_ReadOnly setting marks a buffer so that it can only be returned from buffer access calls that include an AccessProtected flag. By convention this means that edit commands that should not be applied to read only buffers will not edit this buffer.) */ /* DOC(The BufferSetting_ReadOnly setting marks a buffer so that it can only be returned from buffer access calls that include an AccessProtected flag. By convention this means that edit commands that should not be applied to read only buffers will not edit this buffer.) */
BufferSetting_ReadOnly, BufferSetting_ReadOnly,
/* DOC(The BufferSetting_VirtualWhitespace settings enables virtual whitespace on a buffer. /* DOC(The BufferSetting_VirtualWhitespace settings enables virtual whitespace on a buffer. Text buffers with virtual whitespace will set the indentation of every line to zero. Buffers with lexing enabled will use virtual white space to present the code with appealing indentation.) */
Text buffers with virtual whitespace will set the indentation of every line to zero.
Buffers with lexing enabled will use virtual white space to present the code with appealing indentation.) */
BufferSetting_VirtualWhitespace, BufferSetting_VirtualWhitespace,
}; };

View File

@ -946,14 +946,6 @@ CUSTOM_COMMAND_SIG(open_color_tweaker){
exec_command(app, cmdid_open_color_tweaker); exec_command(app, cmdid_open_color_tweaker);
} }
CUSTOM_COMMAND_SIG(open_config){
exec_command(app, cmdid_open_config);
}
CUSTOM_COMMAND_SIG(open_menu){
exec_command(app, cmdid_open_menu);
}
CUSTOM_COMMAND_SIG(open_debug){ CUSTOM_COMMAND_SIG(open_debug){
exec_command(app, cmdid_open_debug); exec_command(app, cmdid_open_debug);
} }

View File

@ -483,9 +483,6 @@ CUSTOM_COMMAND_SIG(execute_arbitrary_command){
else if(match_ss(bar.string, make_lit_string("close all code"))){ else if(match_ss(bar.string, make_lit_string("close all code"))){
exec_command(app, close_all_code); exec_command(app, close_all_code);
} }
else if (match_ss(bar.string, make_lit_string("open menu"))){
exec_command(app, cmdid_open_menu);
}
else if (match_ss(bar.string, make_lit_string("dos lines")) || else if (match_ss(bar.string, make_lit_string("dos lines")) ||
match_ss(bar.string, make_lit_string("dosify"))){ match_ss(bar.string, make_lit_string("dosify"))){
exec_command(app, eol_dosify); exec_command(app, eol_dosify);

12
4ed.cpp
View File

@ -473,16 +473,6 @@ COMMAND_DECL(open_color_tweaker){
view_show_theme(view); view_show_theme(view);
} }
COMMAND_DECL(open_config){
USE_VIEW(view);
view_show_GUI(view, VUI_Config);
}
COMMAND_DECL(open_menu){
USE_VIEW(view);
view_show_GUI(view, VUI_Menu);
}
COMMAND_DECL(open_debug){ COMMAND_DECL(open_debug){
USE_VIEW(view); USE_VIEW(view);
view_show_GUI(view, VUI_Debug); view_show_GUI(view, VUI_Debug);
@ -585,8 +575,6 @@ setup_command_table(){
SET(kill_buffer); SET(kill_buffer);
SET(open_color_tweaker); SET(open_color_tweaker);
SET(open_config);
SET(open_menu);
SET(open_debug); SET(open_debug);
#undef SET #undef SET
} }

View File

@ -162,6 +162,32 @@ imp_get_view(Command_Data *cmd, View_Summary *view){
return(vptr); return(vptr);
} }
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);
}
API_EXPORT bool32 API_EXPORT bool32
Exec_Command(Application_Links *app, Command_ID command_id) Exec_Command(Application_Links *app, Command_ID command_id)
/* /*

View File

@ -125,8 +125,6 @@ enum View_UI{
VUI_None, VUI_None,
VUI_Theme, VUI_Theme,
VUI_Interactive, VUI_Interactive,
VUI_Menu,
VUI_Config,
VUI_Debug VUI_Debug
}; };
@ -4649,44 +4647,6 @@ step_file_view(System_Functions *system, View *view, View *active_view, Input_Su
} }
else{ else{
switch (view->showing_ui){ switch (view->showing_ui){
case VUI_Menu:
{
String message = make_lit_string("Menu");
String empty_string = {0};
GUI_id id = {0};
id.id[1] = VUI_Menu;
gui_do_text_field(target, message, empty_string);
id.id[0] = 0;
message = make_lit_string("Theme");
if (gui_do_fixed_option(target, id, message, 0)){
view_show_theme(view);
}
id.id[0] = 1;
message = make_lit_string("Config");
if (gui_do_fixed_option(target, id, message, 0)){
view_show_GUI(view, VUI_Config);
}
}break;
case VUI_Config:
{
String message = make_lit_string("Config");
String empty_string = {0};
GUI_id id = {0};
id.id[1] = VUI_Config;
gui_do_text_field(target, message, empty_string);
id.id[0] = 0;
message = make_lit_string("Left Ctrl + Left Alt = AltGr");
if (gui_do_fixed_option_checkbox(target, id, message, 0, (b8)models->settings.lctrl_lalt_is_altgr)){
models->settings.lctrl_lalt_is_altgr = !models->settings.lctrl_lalt_is_altgr;
}
}break;
case VUI_Theme: case VUI_Theme:
{ {
if (view != active_view){ if (view != active_view){