summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md8
-rw-r--r--config.c3
-rw-r--r--main.c2
-rw-r--r--syntax.c2
-rw-r--r--ted.cfg5
-rw-r--r--ted.h37
6 files changed, 36 insertions, 21 deletions
diff --git a/README.md b/README.md
index bee145e..ff9d651 100644
--- a/README.md
+++ b/README.md
@@ -77,6 +77,14 @@ it clear it's a command. Colors are formatted like `#rgb`, `#rgba`, `#rrggbb` or
blue, and alpha (transparency/opacity). You can use a [color picker](https://www.google.com/search?q=color+picker) to help you out.
The extensions section is fairly self-explanatory.
+You can set settings for specific programming languages like this:
+
+```
+[HTML.core]
+# set tab width for HTML files to 2
+tab-width = 2
+```
+
To reset your ted configuration to the default settings, delete your ted.cfg file (`~/.local/share/ted/ted.cfg` on Linux,
`C:\Users\<your user name>\AppData\Local\ted\ted.cfg` on Windows) or move it somewhere else.
diff --git a/config.c b/config.c
index aa09444..3cd64de 100644
--- a/config.c
+++ b/config.c
@@ -371,6 +371,7 @@ void config_read(Ted *ted, char const *filename, int pass) {
switch (section) {
case SECTION_CORE:
case SECTION_COLORS:
+ case SECTION_KEYBOARD:
break;
default:
config_err(cfg, "%s settings cannot be configured for individual languages.",
@@ -431,7 +432,7 @@ void config_read(Ted *ted, char const *filename, int pass) {
case SECTION_KEYBOARD: {
// lines like Ctrl+Down = 10 :down
u32 key_combo = config_parse_key_combo(cfg, key);
- KeyAction *action = &ted->key_actions[key_combo];
+ KeyAction *action = &settings->key_actions[key_combo];
llong argument = 1;
if (isdigit(*value)) {
// read the argument
diff --git a/main.c b/main.c
index 7a6731e..60bc230 100644
--- a/main.c
+++ b/main.c
@@ -688,7 +688,7 @@ int main(int argc, char **argv) {
(u32)((modifier & (KMOD_LSHIFT|KMOD_RSHIFT)) != 0) << KEY_MODIFIER_SHIFT_BIT |
(u32)((modifier & (KMOD_LALT|KMOD_RALT)) != 0) << KEY_MODIFIER_ALT_BIT;
if (key_combo < KEY_COMBO_COUNT) {
- KeyAction *action = &ted->key_actions[key_combo];
+ KeyAction *action = &ted_active_settings(ted)->key_actions[key_combo];
if (action->command) {
command_execute(ted, action->command, action->argument);
}
diff --git a/syntax.c b/syntax.c
index bef3ea9..97d0554 100644
--- a/syntax.c
+++ b/syntax.c
@@ -7,7 +7,7 @@
// returns the language this string is referring to, or LANG_NONE if it's invalid.
Language language_from_str(char const *str) {
for (int i = 0; i < LANG_COUNT; ++i) {
- if (streq(language_names[i].name, str))
+ if (strcmp_case_insensitive(language_names[i].name, str) == 0)
return language_names[i].lang;
}
return LANG_NONE;
diff --git a/ted.cfg b/ted.cfg
index ab7344b..6b30ff9 100644
--- a/ted.cfg
+++ b/ted.cfg
@@ -231,3 +231,8 @@ Config = .cfg
Javascript = .js
Java = .java
Go = .go
+
+
+# You can add language-specific settings like this:
+# [HTML.core]
+# tab-width = 2
diff --git a/ted.h b/ted.h
index b7ecf19..1ee8525 100644
--- a/ted.h
+++ b/ted.h
@@ -112,6 +112,24 @@ ENUM_U8 {
#define SYNTAX_CODE SYNTAX_PREPROCESSOR // for markdown
#define SYNTAX_LINK SYNTAX_CONSTANT // for markdown
+
+#define SCANCODE_COUNT 0x120 // SDL scancodes should be less than this value.
+// a "key combo" is some subset of {control, shift, alt} + some key.
+#define KEY_COMBO_COUNT (SCANCODE_COUNT << 3)
+#define KEY_MODIFIER_CTRL_BIT 0
+#define KEY_MODIFIER_SHIFT_BIT 1
+#define KEY_MODIFIER_ALT_BIT 2
+#define KEY_MODIFIER_CTRL ((u32)1<<KEY_MODIFIER_CTRL_BIT)
+#define KEY_MODIFIER_SHIFT ((u32)1<<KEY_MODIFIER_SHIFT_BIT)
+#define KEY_MODIFIER_ALT ((u32)1<<KEY_MODIFIER_ALT_BIT)
+// ctrl+alt+c is encoded as SDL_SCANCODE_C << 3 | KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT
+
+typedef struct KeyAction {
+ u32 line_number; // config line number where this was set
+ Command command; // this will be 0 (COMMAND_UNKNOWN) if there's no action for the key
+ i64 argument;
+} KeyAction;
+
typedef struct {
float cursor_blink_time_on, cursor_blink_time_off;
u32 colors[COLOR_COUNT];
@@ -135,25 +153,9 @@ typedef struct {
char build_default_command[256];
// [i] = comma-separated string of file extensions for language i, or NULL for none
char *language_extensions[LANG_COUNT];
+ KeyAction key_actions[KEY_COMBO_COUNT];
} Settings;
-#define SCANCODE_COUNT 0x120 // SDL scancodes should be less than this value.
-// a "key combo" is some subset of {control, shift, alt} + some key.
-#define KEY_COMBO_COUNT (SCANCODE_COUNT << 3)
-#define KEY_MODIFIER_CTRL_BIT 0
-#define KEY_MODIFIER_SHIFT_BIT 1
-#define KEY_MODIFIER_ALT_BIT 2
-#define KEY_MODIFIER_CTRL ((u32)1<<KEY_MODIFIER_CTRL_BIT)
-#define KEY_MODIFIER_SHIFT ((u32)1<<KEY_MODIFIER_SHIFT_BIT)
-#define KEY_MODIFIER_ALT ((u32)1<<KEY_MODIFIER_ALT_BIT)
-// ctrl+alt+c is encoded as SDL_SCANCODE_C << 3 | KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT
-
-typedef struct KeyAction {
- u32 line_number; // config line number where this was set
- Command command; // this will be 0 (COMMAND_UNKNOWN) if there's no action for the key
- i64 argument;
-} KeyAction;
-
// a position in the buffer
typedef struct {
u32 line;
@@ -320,7 +322,6 @@ typedef struct Ted {
TextBuffer argument_buffer; // used for command selector
double error_time; // time error box was opened (in seconds -- see time_get_seconds)
double cursor_error_time; // time which the cursor error animation started (cursor turns red, e.g. when there's no autocomplete suggestion)
- KeyAction key_actions[KEY_COMBO_COUNT];
bool search_cwd; // should the working directory be searched for files? set to true if the executable isn't "installed"
bool quit; // if set to true, the window will close next frame. NOTE: this doesn't check for unsaved changes!!
bool find; // is the find or find+replace menu open?