summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--command.c5
-rw-r--r--command.h2
-rw-r--r--main.c8
-rw-r--r--menu.c8
-rw-r--r--ted.cfg1
-rw-r--r--ted.h2
7 files changed, 25 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 4728941..5894f73 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@ ALL_CFLAGS=$(CFLAGS) -Wall -Wextra -Wshadow -Wconversion -Wpedantic -pedantic -s
-Wno-unused-function -Wno-fixed-enum-extension -Wimplicit-fallthrough -Wno-format-truncation -Wno-unknown-warning-option
LIBS=-lSDL2 -lGL -ldl -lm libpcre2-32.a -Ipcre2-10.36/build
DEBUG_CFLAGS=$(ALL_CFLAGS) -DDEBUG -O0 -g
-RELEASE_CFLAGS=$(ALL_CFLAGS) -O3
+RELEASE_CFLAGS=$(ALL_CFLAGS) -O3 -g
PROFILE_CFLAGS=$(ALL_CFLAGS) -O3 -g -DPROFILE=1
GLOBAL_DATA_DIR=/usr/share/ted
LOCAL_DATA_DIR=/home/`logname`/.local/share/ted
diff --git a/command.c b/command.c
index 274d8c8..e2673a6 100644
--- a/command.c
+++ b/command.c
@@ -215,7 +215,10 @@ void command_execute(Ted *ted, Command c, i64 argument) {
case CMD_PASTE:
if (buffer) buffer_paste(buffer);
break;
-
+ case CMD_COMMAND_SELECTOR:
+ menu_open(ted, MENU_COMMAND_SELECTOR);
+ break;
+
case CMD_TEXT_SIZE_INCREASE: {
i64 new_text_size = settings->text_size + argument;
if (new_text_size >= TEXT_SIZE_MIN && new_text_size <= TEXT_SIZE_MAX) {
diff --git a/command.h b/command.h
index ad5034c..2fc1688 100644
--- a/command.h
+++ b/command.h
@@ -44,6 +44,7 @@ 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,
@@ -126,6 +127,7 @@ static CommandName const command_names[] = {
{"save-as", CMD_SAVE_AS},
{"save-all", CMD_SAVE_ALL},
{"quit", CMD_QUIT},
+ {"command-selector", CMD_COMMAND_SELECTOR},
{"undo", CMD_UNDO},
{"redo", CMD_REDO},
{"copy", CMD_COPY},
diff --git a/main.c b/main.c
index ec4ffc3..8f1c298 100644
--- a/main.c
+++ b/main.c
@@ -461,6 +461,10 @@ int main(int argc, char **argv) {
strcpy(config_err, ted->error);
ted_clearerr(ted); // clear the error so later things (e.g. loading font) don't detect an error
}
+
+ if (ted->search_cwd) {
+ config_read(ted, "ted.cfg");
+ }
}
@@ -530,6 +534,7 @@ int main(int argc, char **argv) {
}
line_buffer_create(&ted->find_buffer, ted);
line_buffer_create(&ted->replace_buffer, ted);
+ line_buffer_create(&ted->argument_buffer, ted);
buffer_create(&ted->build_buffer, ted);
{
@@ -903,7 +908,7 @@ int main(int argc, char **argv) {
i32 ms_wait = (i32)((frame_end_noswap - frame_start) * 1000);
if (ms_wait > 0) {
ms_wait -= 1; // give swap an extra ms to make sure it's actually vsynced
- SDL_Delay(ms_wait);
+ SDL_Delay((u32)ms_wait);
}
SDL_GL_SwapWindow(window);
PROFILE_TIME(frame_end);
@@ -945,6 +950,7 @@ int main(int argc, char **argv) {
buffer_free(&ted->find_buffer);
buffer_free(&ted->replace_buffer);
buffer_free(&ted->build_buffer);
+ buffer_free(&ted->argument_buffer);
text_font_free(ted->font);
text_font_free(ted->font_bold);
settings_free(&ted->settings);
diff --git a/menu.c b/menu.c
index 19053ab..79b597e 100644
--- a/menu.c
+++ b/menu.c
@@ -26,6 +26,10 @@ static void menu_close(Ted *ted) {
case MENU_GOTO_LINE:
buffer_clear(&ted->line_buffer);
break;
+ case MENU_COMMAND_SELECTOR:
+ buffer_clear(&ted->line_buffer);
+ buffer_clear(&ted->argument_buffer);
+ break;
}
ted->menu = MENU_NONE;
ted->selector_open = NULL;
@@ -66,6 +70,10 @@ static void menu_open(Ted *ted, Menu menu) {
case MENU_GOTO_LINE:
ted_switch_to_buffer(ted, &ted->line_buffer);
break;
+ case MENU_COMMAND_SELECTOR:
+ ted_switch_to_buffer(ted, &ted->line_buffer);
+ buffer_insert_char_at_cursor(&ted->argument_buffer, '1');
+ break;
}
}
diff --git a/ted.cfg b/ted.cfg
index b149ac6..a76c899 100644
--- a/ted.cfg
+++ b/ted.cfg
@@ -95,6 +95,7 @@ Ctrl+Shift+f = :find-replace
Ctrl+c = :copy
Ctrl+x = :cut
Ctrl+v = :paste
+Ctrl+Shift+p = :command-selector
# tabs
Ctrl+w = :tab-close
diff --git a/ted.h b/ted.h
index 8a6893d..cb2f35c 100644
--- a/ted.h
+++ b/ted.h
@@ -169,6 +169,7 @@ ENUM_U16 {
MENU_ASK_RELOAD, // prompt about whether to reload file which has ben changed by another program
MENU_GOTO_DEFINITION,
MENU_GOTO_LINE,
+ MENU_COMMAND_SELECTOR
} ENUM_U16_END(Menu);
typedef struct {
@@ -257,6 +258,7 @@ typedef struct Ted {
TextBuffer find_buffer; // use for "find" term in find/find+replace
TextBuffer replace_buffer; // "replace" for find+replace
TextBuffer build_buffer; // buffer for build output (view only)
+ TextBuffer argument_buffer; // used for command selector
double error_time; // time error box was opened (in seconds -- see time_get_seconds)
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"