project command lister switched over to new variable system
parent
46ecbc1afe
commit
8940b29ab1
|
@ -577,6 +577,7 @@ prj_version_1_to_version_2(Application_Links *app, Config *parsed, Project *proj
|
|||
String_ID relative_id = vars_save_string(str8_lit("relative"));
|
||||
String_ID true_id = vars_save_string(str8_lit("true"));
|
||||
String_ID false_id = vars_save_string(str8_lit("false"));
|
||||
String_ID commands_id = vars_save_string(str8_lit("commands"));
|
||||
|
||||
String_ID out_id = vars_save_string(str8_lit("out"));
|
||||
String_ID footer_panel_id = vars_save_string(str8_lit("footer_panel"));
|
||||
|
@ -596,7 +597,7 @@ prj_version_1_to_version_2(Application_Links *app, Config *parsed, Project *proj
|
|||
|
||||
vars_new_variable(proj_var, project_name_id, vars_save_string(project->name));
|
||||
|
||||
// load paterns
|
||||
// NOTE(allen): Load Pattern
|
||||
struct PatternVars{
|
||||
String_ID id;
|
||||
Match_Pattern_List list;
|
||||
|
@ -622,7 +623,7 @@ prj_version_1_to_version_2(Application_Links *app, Config *parsed, Project *proj
|
|||
}
|
||||
}
|
||||
|
||||
// load paths
|
||||
// NOTE(allen): Load Paths
|
||||
{
|
||||
Variable_Handle load_paths = vars_new_variable(proj_var, load_paths_id);
|
||||
Variable_Handle os_var = vars_new_variable(load_paths, os_id);
|
||||
|
@ -637,13 +638,14 @@ prj_version_1_to_version_2(Application_Links *app, Config *parsed, Project *proj
|
|||
}
|
||||
}
|
||||
|
||||
// commands
|
||||
// NOTE(allen): Commands
|
||||
{
|
||||
Variable_Handle cmd_list_var = vars_new_variable(proj_var, commands_id);
|
||||
i32 count = project->command_array.count;
|
||||
Project_Command *cmd = project->command_array.commands;
|
||||
for (i32 i = 0; i < count; i += 1, cmd += 1){
|
||||
String_Const_u8 cmd_name = prj_sanitize_string(scratch, cmd->name);
|
||||
Variable_Handle cmd_var = vars_new_variable(proj_var, vars_save_string(cmd_name));
|
||||
Variable_Handle cmd_var = vars_new_variable(cmd_list_var, vars_save_string(cmd_name));
|
||||
vars_new_variable(cmd_var, os_id, vars_save_string(cmd->cmd));
|
||||
vars_new_variable(cmd_var, out_id, vars_save_string(cmd->out));
|
||||
vars_new_variable(cmd_var, footer_panel_id, cmd->footer_panel?true_id:false_id);
|
||||
|
@ -652,7 +654,7 @@ prj_version_1_to_version_2(Application_Links *app, Config *parsed, Project *proj
|
|||
}
|
||||
}
|
||||
|
||||
// fkey_commands
|
||||
// NOTE(allen): FKey Commands
|
||||
{
|
||||
Variable_Handle fkeys_var = vars_new_variable(proj_var, fkey_command_id);
|
||||
for (i32 i = 0; i < 16; i += 1){
|
||||
|
@ -669,7 +671,7 @@ prj_version_1_to_version_2(Application_Links *app, Config *parsed, Project *proj
|
|||
}
|
||||
}
|
||||
|
||||
return(proj_var);
|
||||
return(proj_var);
|
||||
}
|
||||
|
||||
function String_Const_u8
|
||||
|
@ -733,9 +735,10 @@ prj_exec_command(Application_Links *app, Variable_Handle cmd_var){
|
|||
buffer_id = buffer_identifier(string_u8_litexpr("*dump*"));
|
||||
}
|
||||
|
||||
Variable_Handle parent = vars_parent(cmd_var);
|
||||
String_Const_u8 project_dir = prj_path_from_project(scratch, parent);
|
||||
exec_system_command(app, view, buffer_id, project_dir, cmd, flags);
|
||||
Variable_Handle command_list_var = vars_parent(cmd_var);
|
||||
Variable_Handle prj_var = vars_parent(command_list_var);
|
||||
String_Const_u8 prj_dir = prj_path_from_project(scratch, prj_var);
|
||||
exec_system_command(app, view, buffer_id, prj_dir, cmd, flags);
|
||||
if (set_fancy_font){
|
||||
set_fancy_compilation_buffer_font(app);
|
||||
}
|
||||
|
@ -745,8 +748,9 @@ prj_exec_command(Application_Links *app, Variable_Handle cmd_var){
|
|||
function Variable_Handle
|
||||
prj_command_from_name(Application_Links *app, String_Const_u8 cmd_name){
|
||||
Scratch_Block scratch(app);
|
||||
String_ID cmd_name_id = vars_save_string(cmd_name);
|
||||
Variable_Handle cmd = def_get_config_var(cmd_name_id);
|
||||
// TODO(allen): fallback for multiple stages of reading
|
||||
Variable_Handle cmd_list = def_get_config_var(vars_save_string_lit("commands"));
|
||||
Variable_Handle cmd = vars_read_key(cmd_list, vars_save_string(cmd_name));
|
||||
return(cmd);
|
||||
}
|
||||
|
||||
|
@ -961,7 +965,9 @@ CUSTOM_DOC("Changes 4coder's hot directory to the root directory of the currentl
|
|||
Scratch_Block scratch(app);
|
||||
Variable_Handle prj_var = vars_read_key(vars_get_root(), vars_save_string_lit("prj_config"));
|
||||
String_Const_u8 prj_dir = prj_path_from_project(scratch, prj_var);
|
||||
set_hot_directory(app, prj_dir);
|
||||
if (prj_dir.size > 0){
|
||||
set_hot_directory(app, prj_dir);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////
|
||||
|
@ -1318,6 +1324,38 @@ CUSTOM_DOC("Queries the user for several configuration options and initializes a
|
|||
|
||||
///////////////////////////////
|
||||
|
||||
function Variable_Handle
|
||||
prj_cmd_from_user(Application_Links *app, Variable_Handle prj_var, String_Const_u8 query){
|
||||
Scratch_Block scratch(app);
|
||||
Lister_Block lister(app, scratch);
|
||||
lister_set_query(lister, query);
|
||||
lister_set_default_handlers(lister);
|
||||
|
||||
Variable_Handle cmd_list_var = vars_read_key(prj_var, vars_save_string_lit("commands"));
|
||||
String_ID os_id = vars_save_string_lit(OS_NAME);
|
||||
|
||||
for (Variable_Handle cmd = vars_first_child(cmd_list_var);
|
||||
!vars_is_nil(cmd);
|
||||
cmd = vars_next_sibling(cmd)){
|
||||
Variable_Handle os_cmd = vars_read_key(cmd, os_id);
|
||||
if (!vars_is_nil(os_cmd)){
|
||||
String_Const_u8 cmd_name = vars_key_from_var(scratch, cmd);
|
||||
String_Const_u8 os_cmd_str = vars_string_from_var(scratch, os_cmd);
|
||||
lister_add_item(lister, cmd_name, os_cmd_str, cmd.ptr, 0);
|
||||
}
|
||||
}
|
||||
|
||||
Variable_Handle result = vars_get_nil();
|
||||
Lister_Result l_result = run_lister(app, lister);
|
||||
if (!l_result.canceled){
|
||||
if (l_result.user_data != 0){
|
||||
result.ptr = (Variable*)l_result.user_data;
|
||||
}
|
||||
}
|
||||
|
||||
return(result);
|
||||
}
|
||||
|
||||
function Variable_Handle
|
||||
get_project_command_from_user(Application_Links *app, Project *project, String_Const_u8 query){
|
||||
Variable_Handle result = vars_get_nil();
|
||||
|
@ -1349,13 +1387,12 @@ get_project_command_from_user(Application_Links *app, Project *project, String_C
|
|||
CUSTOM_COMMAND_SIG(project_command_lister)
|
||||
CUSTOM_DOC("Open a lister of all commands in the currently loaded project.")
|
||||
{
|
||||
if (current_project.loaded){
|
||||
Variable_Handle proj_cmd =
|
||||
get_project_command_from_user(app, ¤t_project, string_u8_litexpr("Command:"));
|
||||
if (!vars_is_nil(proj_cmd)){
|
||||
prj_exec_command(app, proj_cmd);
|
||||
}
|
||||
Variable_Handle prj_var = vars_read_key(vars_get_root(), vars_save_string_lit("prj_config"));
|
||||
Variable_Handle prj_cmd = prj_cmd_from_user(app, prj_var, string_u8_litexpr("Command:"));
|
||||
if (!vars_is_nil(prj_cmd)){
|
||||
prj_exec_command(app, prj_cmd);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// BOTTOM
|
||||
|
|
|
@ -295,7 +295,7 @@ static Command_Metadata fcoder_metacmd_table[250] = {
|
|||
{ PROC_LINKS(click_set_cursor_if_lbutton, 0), false, "click_set_cursor_if_lbutton", 27, "If the mouse left button is pressed, sets the cursor position to the mouse position.", 84, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 243 },
|
||||
{ PROC_LINKS(click_set_mark, 0), false, "click_set_mark", 14, "Sets the mark position to the mouse position.", 45, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 256 },
|
||||
{ PROC_LINKS(clipboard_record_clip, 0), false, "clipboard_record_clip", 21, "In response to a new clipboard contents events, saves the new clip onto the clipboard history", 93, "W:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 7 },
|
||||
{ PROC_LINKS(close_all_code, 0), false, "close_all_code", 14, "Closes any buffer with a filename ending with an extension configured to be recognized as a code file type.", 107, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 778 },
|
||||
{ PROC_LINKS(close_all_code, 0), false, "close_all_code", 14, "Closes any buffer with a filename ending with an extension configured to be recognized as a code file type.", 107, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 782 },
|
||||
{ PROC_LINKS(close_build_panel, 0), false, "close_build_panel", 17, "If the special build panel is open, closes it.", 46, "W:\\4ed\\code\\custom\\4coder_build_commands.cpp", 44, 175 },
|
||||
{ PROC_LINKS(close_panel, 0), false, "close_panel", 11, "Closes the currently active panel if it is not the only panel open.", 67, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 674 },
|
||||
{ PROC_LINKS(command_documentation, 0), true, "command_documentation", 21, "Prompts the user to select a command then loads a doc buffer for that item", 74, "W:\\4ed\\code\\custom\\4coder_docs.cpp", 34, 190 },
|
||||
|
@ -371,7 +371,7 @@ static Command_Metadata fcoder_metacmd_table[250] = {
|
|||
{ PROC_LINKS(list_all_locations_of_type_definition_of_identifier, 0), false, "list_all_locations_of_type_definition_of_identifier", 51, "Reads a token or word under the cursor and lists all locations of strings that appear to define a type whose name matches it.", 125, "W:\\4ed\\code\\custom\\4coder_search.cpp", 36, 224 },
|
||||
{ PROC_LINKS(list_all_substring_locations, 0), false, "list_all_substring_locations", 28, "Queries the user for a string and lists all case-sensitive substring matches found in all open buffers.", 103, "W:\\4ed\\code\\custom\\4coder_search.cpp", 36, 174 },
|
||||
{ PROC_LINKS(list_all_substring_locations_case_insensitive, 0), false, "list_all_substring_locations_case_insensitive", 45, "Queries the user for a string and lists all case-insensitive substring matches found in all open buffers.", 105, "W:\\4ed\\code\\custom\\4coder_search.cpp", 36, 186 },
|
||||
{ PROC_LINKS(load_project, 0), false, "load_project", 12, "Looks for a project.4coder file in the current directory and tries to load it. Looks in parent directories until a project file is found or there are no more parents.", 167, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 807 },
|
||||
{ PROC_LINKS(load_project, 0), false, "load_project", 12, "Looks for a project.4coder file in the current directory and tries to load it. Looks in parent directories until a project file is found or there are no more parents.", 167, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 811 },
|
||||
{ PROC_LINKS(load_theme_current_buffer, 0), false, "load_theme_current_buffer", 25, "Parse the current buffer as a theme file and add the theme to the theme list. If the buffer has a .4coder postfix in it's name, it is removed when the name is saved.", 165, "W:\\4ed\\code\\custom\\4coder_config.cpp", 36, 1561 },
|
||||
{ PROC_LINKS(load_themes_default_folder, 0), false, "load_themes_default_folder", 26, "Loads all the theme files in the default theme folder.", 54, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 535 },
|
||||
{ PROC_LINKS(load_themes_hot_directory, 0), false, "load_themes_hot_directory", 25, "Loads all the theme files in the current hot directory.", 55, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 547 },
|
||||
|
@ -414,8 +414,8 @@ static Command_Metadata fcoder_metacmd_table[250] = {
|
|||
{ PROC_LINKS(multi_paste_interactive_quick, 0), false, "multi_paste_interactive_quick", 29, "Paste multiple lines from the clipboard history, controlled by inputing the number of lines to paste", 100, "W:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 380 },
|
||||
{ PROC_LINKS(music_start, 0), false, "music_start", 11, "Starts the music.", 17, "W:\\4ed\\code\\custom\\4coder_examples.cpp", 38, 213 },
|
||||
{ PROC_LINKS(music_stop, 0), false, "music_stop", 10, "Stops the music.", 16, "W:\\4ed\\code\\custom\\4coder_examples.cpp", 38, 232 },
|
||||
{ PROC_LINKS(open_all_code, 0), false, "open_all_code", 13, "Open all code in the current directory. File types are determined by extensions. An extension is considered code based on the extensions specified in 4coder.config.", 164, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 787 },
|
||||
{ PROC_LINKS(open_all_code_recursive, 0), false, "open_all_code_recursive", 23, "Works as open_all_code but also runs in all subdirectories.", 59, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 796 },
|
||||
{ PROC_LINKS(open_all_code, 0), false, "open_all_code", 13, "Open all code in the current directory. File types are determined by extensions. An extension is considered code based on the extensions specified in 4coder.config.", 164, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 791 },
|
||||
{ PROC_LINKS(open_all_code_recursive, 0), false, "open_all_code_recursive", 23, "Works as open_all_code but also runs in all subdirectories.", 59, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 800 },
|
||||
{ PROC_LINKS(open_file_in_quotes, 0), false, "open_file_in_quotes", 19, "Reads a filename from surrounding '\"' characters and attempts to open the corresponding file.", 94, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1576 },
|
||||
{ PROC_LINKS(open_in_other, 0), false, "open_in_other", 13, "Interactively opens a file in the other panel.", 46, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 2059 },
|
||||
{ PROC_LINKS(open_long_braces, 0), false, "open_long_braces", 16, "At the cursor, insert a '{' and '}' separated by a blank line.", 62, "W:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 46 },
|
||||
|
@ -436,9 +436,9 @@ static Command_Metadata fcoder_metacmd_table[250] = {
|
|||
{ PROC_LINKS(profile_disable, 0), false, "profile_disable", 15, "Prevent 4coder's self profiler from gathering new profiling information.", 72, "W:\\4ed\\code\\custom\\4coder_profile.cpp", 37, 219 },
|
||||
{ PROC_LINKS(profile_enable, 0), false, "profile_enable", 14, "Allow 4coder's self profiler to gather new profiling information.", 65, "W:\\4ed\\code\\custom\\4coder_profile.cpp", 37, 212 },
|
||||
{ PROC_LINKS(profile_inspect, 0), true, "profile_inspect", 15, "Inspect all currently collected profiling information in 4coder's self profiler.", 80, "W:\\4ed\\code\\custom\\4coder_profile_inspect.cpp", 45, 886 },
|
||||
{ PROC_LINKS(project_command_lister, 0), false, "project_command_lister", 22, "Open a lister of all commands in the currently loaded project.", 62, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1349 },
|
||||
{ PROC_LINKS(project_fkey_command, 0), false, "project_fkey_command", 20, "Run an 'fkey command' configured in a project.4coder file. Determines the index of the 'fkey command' by which function key or numeric key was pressed to trigger the command.", 175, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 932 },
|
||||
{ PROC_LINKS(project_go_to_root_directory, 0), false, "project_go_to_root_directory", 28, "Changes 4coder's hot directory to the root directory of the currently loaded project. With no loaded project nothing hapepns.", 125, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 958 },
|
||||
{ PROC_LINKS(project_command_lister, 0), false, "project_command_lister", 22, "Open a lister of all commands in the currently loaded project.", 62, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1387 },
|
||||
{ PROC_LINKS(project_fkey_command, 0), false, "project_fkey_command", 20, "Run an 'fkey command' configured in a project.4coder file. Determines the index of the 'fkey command' by which function key or numeric key was pressed to trigger the command.", 175, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 936 },
|
||||
{ PROC_LINKS(project_go_to_root_directory, 0), false, "project_go_to_root_directory", 28, "Changes 4coder's hot directory to the root directory of the currently loaded project. With no loaded project nothing hapepns.", 125, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 962 },
|
||||
{ PROC_LINKS(query_replace, 0), false, "query_replace", 13, "Queries the user for two strings, and incrementally replaces every occurence of the first string with the second string.", 120, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1282 },
|
||||
{ PROC_LINKS(query_replace_identifier, 0), false, "query_replace_identifier", 24, "Queries the user for a string, and incrementally replace every occurence of the word or token found at the cursor with the specified string.", 140, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1303 },
|
||||
{ PROC_LINKS(query_replace_selection, 0), false, "query_replace_selection", 23, "Queries the user for a string, and incrementally replace every occurence of the string found in the selected range with the specified string.", 141, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 1319 },
|
||||
|
@ -477,10 +477,10 @@ static Command_Metadata fcoder_metacmd_table[250] = {
|
|||
{ PROC_LINKS(set_mark, 0), false, "set_mark", 8, "Sets the mark to the current position of the cursor.", 52, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 115 },
|
||||
{ PROC_LINKS(set_mode_to_notepad_like, 0), false, "set_mode_to_notepad_like", 24, "Sets the edit mode to Notepad like.", 35, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 499 },
|
||||
{ PROC_LINKS(set_mode_to_original, 0), false, "set_mode_to_original", 20, "Sets the edit mode to 4coder original.", 38, "W:\\4ed\\code\\custom\\4coder_default_framework.cpp", 47, 493 },
|
||||
{ PROC_LINKS(setup_build_bat, 0), false, "setup_build_bat", 15, "Queries the user for several configuration options and initializes a new build batch script.", 92, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1301 },
|
||||
{ PROC_LINKS(setup_build_bat_and_sh, 0), false, "setup_build_bat_and_sh", 22, "Queries the user for several configuration options and initializes a new build batch script.", 92, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1313 },
|
||||
{ PROC_LINKS(setup_build_sh, 0), false, "setup_build_sh", 14, "Queries the user for several configuration options and initializes a new build shell script.", 92, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1307 },
|
||||
{ PROC_LINKS(setup_new_project, 0), false, "setup_new_project", 17, "Queries the user for several configuration options and initializes a new 4coder project with build scripts for every OS.", 120, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1294 },
|
||||
{ PROC_LINKS(setup_build_bat, 0), false, "setup_build_bat", 15, "Queries the user for several configuration options and initializes a new build batch script.", 92, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1307 },
|
||||
{ PROC_LINKS(setup_build_bat_and_sh, 0), false, "setup_build_bat_and_sh", 22, "Queries the user for several configuration options and initializes a new build batch script.", 92, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1319 },
|
||||
{ PROC_LINKS(setup_build_sh, 0), false, "setup_build_sh", 14, "Queries the user for several configuration options and initializes a new build shell script.", 92, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1313 },
|
||||
{ PROC_LINKS(setup_new_project, 0), false, "setup_new_project", 17, "Queries the user for several configuration options and initializes a new 4coder project with build scripts for every OS.", 120, "W:\\4ed\\code\\custom\\4coder_project_commands.cpp", 46, 1300 },
|
||||
{ PROC_LINKS(show_filebar, 0), false, "show_filebar", 12, "Sets the current view to show it's filebar.", 43, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 697 },
|
||||
{ PROC_LINKS(show_scrollbar, 0), false, "show_scrollbar", 14, "Sets the current view to show it's scrollbar.", 45, "W:\\4ed\\code\\custom\\4coder_base_commands.cpp", 43, 683 },
|
||||
{ PROC_LINKS(show_the_log_graph, 0), true, "show_the_log_graph", 18, "Parses *log* and displays the 'log graph' UI", 44, "W:\\4ed\\code\\custom\\4coder_log_parser.cpp", 40, 991 },
|
||||
|
|
Loading…
Reference in New Issue