From 4e2e9f00ec0c67a577639df399fef9851c3ae78d Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Sun, 7 Mar 2021 11:31:56 -0500 Subject: resizable build window --- README.md | 9 +++++++++ main.c | 27 ++++++++++++++++++++++++++- ted.h | 3 +++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a638c43..9617975 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,15 @@ The extensions section is fairly self-explanatory. To reset your ted configuration to the default settings, delete your ted.cfg file (`~/.local/share/ted/ted.cfg` on Linux, `C:\Users\\AppData\Local\ted\ted.cfg` on Windows) or move it somewhere else. +### Tips + +- Even if you don't want to change anything with ted, it's a good idea to look at the config file to see all of the +keyboard shortcuts! +- You can use Ctrl+f for "find", but if you want to search for something across multiple files, you can do +Ctrl+! (run shell command), then run `grep -n search_term *.py`, for example (on Windows, you will need to have +cygwin or something in your PATH for this to work). The `-n` ensures that +ted can jump to the results, just like jumping to build errors. + ### IDE-like features If you are working in a compiled language, like C, you can press F4 to compile your code. The default is to run `make` in diff --git a/main.c b/main.c index 1fe6266..3bfd5f0 100644 --- a/main.c +++ b/main.c @@ -791,7 +791,32 @@ int main(int argc, char **argv) { } if (ted->build_shown) { float y2 = y; - y -= 0.3f * ted->window_height; + y -= ted->build_output_height * ted->window_height; + if (ted->build_output_height == 0) { + // hasn't been initialized yet + ted->build_output_height = 0.25f; + } + if (ted->resizing_build_output) { + if (ted->mouse_state & SDL_BUTTON_LMASK) { + // resize it + ted->build_output_height = clampf((y2 - ted->mouse_pos.y) / ted->window_height, 0.05f, 0.8f); + } else { + // stop resizing build output + ted->resizing_build_output = false; + } + ted->cursor = ted->cursor_resize_v; + } else { + Rect gap = rect4(x1, y - padding, x2, y); + for (uint i = 0; i < ted->nmouse_clicks[SDL_BUTTON_LEFT]; ++i) { + if (rect_contains_point(gap, ted->mouse_clicks[SDL_BUTTON_LEFT][i])) { + // start resizing build output + ted->resizing_build_output = true; + } + } + if (rect_contains_point(gap, ted->mouse_pos)) { + ted->cursor = ted->cursor_resize_v; + } + } build_frame(ted, x1, y, x2, y2); y -= padding; } diff --git a/ted.h b/ted.h index 586fcd9..3628c54 100644 --- a/ted.h +++ b/ted.h @@ -309,6 +309,9 @@ typedef struct Ted { // points to a selector if any is open, otherwise NULL. Selector *selector_open; + + float build_output_height; // what % of the screen the build output takes up + bool resizing_build_output; Process build_process; // When we read the stdout from the build process, the tail end of the read could be an -- cgit v1.2.3