summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-03-02 18:29:41 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-03-02 18:29:41 -0500
commitdd349c6c7e0eba659afc2149fd214f9972826052 (patch)
tree3fb212c34d31fbc9e6ee4415be9218448a45fc2f
parent68066ad410368b0e5d66d7fa983bea882eba1eb6 (diff)
:open-config
-rw-r--r--command.c5
-rw-r--r--command.h4
-rw-r--r--main.c8
-rw-r--r--ted.h1
4 files changed, 13 insertions, 5 deletions
diff --git a/command.c b/command.c
index e2673a6..b0b9df3 100644
--- a/command.c
+++ b/command.c
@@ -215,6 +215,11 @@ void command_execute(Ted *ted, Command c, i64 argument) {
case CMD_PASTE:
if (buffer) buffer_paste(buffer);
break;
+ case CMD_OPEN_CONFIG: {
+ char local_config_filename[TED_PATH_MAX];
+ strbuf_printf(local_config_filename, "%s" PATH_SEPARATOR_STR TED_CFG, ted->local_data_dir);
+ ted_open_file(ted, local_config_filename);
+ } break;
case CMD_COMMAND_SELECTOR:
menu_open(ted, MENU_COMMAND_SELECTOR);
break;
diff --git a/command.h b/command.h
index 2fc1688..cfbe2d9 100644
--- a/command.h
+++ b/command.h
@@ -44,10 +44,11 @@ ENUM_U16 {
CMD_SAVE, // save current buffer
CMD_SAVE_AS,
CMD_SAVE_ALL, // save all open buffers with unsaved changes
- CMD_COMMAND_SELECTOR,
CMD_NEW,
CMD_UNDO,
CMD_REDO,
+ CMD_COMMAND_SELECTOR,
+ CMD_OPEN_CONFIG,
CMD_QUIT,
CMD_COPY,
@@ -128,6 +129,7 @@ static CommandName const command_names[] = {
{"save-all", CMD_SAVE_ALL},
{"quit", CMD_QUIT},
{"command-selector", CMD_COMMAND_SELECTOR},
+ {"open-config", CMD_OPEN_CONFIG},
{"undo", CMD_UNDO},
{"redo", CMD_REDO},
{"copy", CMD_COPY},
diff --git a/main.c b/main.c
index 70b36d0..849645b 100644
--- a/main.c
+++ b/main.c
@@ -1,5 +1,4 @@
// @TODO:
-// - :open-config
// - test on BSD
// - completion
@@ -396,9 +395,9 @@ int main(int argc, char **argv) {
{
// copy global config to local config
char local_config_filename[TED_PATH_MAX];
- strbuf_printf(local_config_filename, "%s" PATH_SEPARATOR_STR "ted.cfg", ted->local_data_dir);
+ strbuf_printf(local_config_filename, "%s" PATH_SEPARATOR_STR TED_CFG, ted->local_data_dir);
char global_config_filename[TED_PATH_MAX];
- strbuf_printf(global_config_filename, "%s" PATH_SEPARATOR_STR "ted.cfg", ted->global_data_dir);
+ strbuf_printf(global_config_filename, "%s" PATH_SEPARATOR_STR TED_CFG, ted->global_data_dir);
if (!fs_file_exists(local_config_filename)) {
if (fs_file_exists(global_config_filename)) {
if (!copy_file(global_config_filename, local_config_filename)) {
@@ -417,7 +416,8 @@ int main(int argc, char **argv) {
}
if (ted->search_cwd) {
- config_read(ted, "ted.cfg");
+ // read config in cwd
+ config_read(ted, TED_CFG);
}
}
diff --git a/ted.h b/ted.h
index ddbedc8..b9edc0b 100644
--- a/ted.h
+++ b/ted.h
@@ -1,5 +1,6 @@
#define TED_PATH_MAX 256
#define TED_UNTITLED "Untitled" // what to call untitled buffers
+#define TED_CFG "ted.cfg" // config filename
#define TEXT_SIZE_MIN 6
#define TEXT_SIZE_MAX 70