summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-03-07 11:31:56 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-03-07 11:31:56 -0500
commit4e2e9f00ec0c67a577639df399fef9851c3ae78d (patch)
treeae9a2031d3628d857e4caf02f5a91a43858ea447
parent0ccd4de98d9f432053552edde65691888b564fdf (diff)
resizable build window
-rw-r--r--README.md9
-rw-r--r--main.c27
-rw-r--r--ted.h3
3 files changed, 38 insertions, 1 deletions
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\<your user name>\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