aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile6
-rw-r--r--README.md6
-rw-r--r--config.h2
-rw-r--r--font.c2
-rw-r--r--graphics.c76
-rwxr-xr-xswenu-path.sh6
-rwxr-xr-xswenu-run.sh2
7 files changed, 59 insertions, 41 deletions
diff --git a/Makefile b/Makefile
index 9f8c0f2..fcd9772 100644
--- a/Makefile
+++ b/Makefile
@@ -53,9 +53,13 @@ clean:
install: all
install -m 755 ./$(BIN) $(PREFIX)/usr/bin
+ install -m 755 ./swenu-run $(PREFIX)/usr/bin
+ install -m 755 ./swenu-path $(PREFIX)/usr/bin
uninstall:
- rm -rf $(PREFIX)/usr/bin/$(BIN)
+ rm -f $(PREFIX)/usr/bin/$(BIN)
+ rm -f $(PREFIX)/usr/bin/swenu-run
+ rm -f $(PREFIX)/usr/bin/swenu-path
run: all
./swenu-run.sh
diff --git a/README.md b/README.md
index 7f874fc..e98da4f 100644
--- a/README.md
+++ b/README.md
@@ -6,14 +6,14 @@ To build: `make`
## Todo -
- [x] "selection"
- [x] figure out whats going on with stderr and exit code
+- [X] fancy highlights
+- [X] scrolling
+- [X] special mode if there is no stdin
- [ ] unicode
- [ ] fuzzy filter and sort filtering by match %
- [ ] cursor
-- [ ] fancy highlights
-- [ ] scrolling
- [ ] kerning
- [ ] config file
- [ ] emacs keybindings
-- [ ] special mode if there is no stdin
- [ ] input fluff
- [ ] "prompt"
diff --git a/config.h b/config.h
index 494ae97..36c21ee 100644
--- a/config.h
+++ b/config.h
@@ -3,7 +3,7 @@
#include <stdint.h>
-static const uint32_t min_width = 600;
+static const uint32_t min_width = 500;
static const uint32_t font_size = 15;
#endif
diff --git a/font.c b/font.c
index c67e427..9b0ba48 100644
--- a/font.c
+++ b/font.c
@@ -66,7 +66,7 @@ bool freetype_init(client_state* state, const char* file) {
}
state->load_flags = FT_LOAD_RENDER;
state->line_height = state->ft_face->size->metrics.height >> 6;
- state->horizontal_spacing = state->line_height / 2.0f;
+ state->horizontal_spacing = state->line_height;
return true;
}
diff --git a/graphics.c b/graphics.c
index 448b225..c2a0405 100644
--- a/graphics.c
+++ b/graphics.c
@@ -154,7 +154,12 @@ void render_frame(client_state *state) {
else { input_width = state->width / 3.0f; }
// draw input buffer
- glScissor(0, input_y, input_width - state->horizontal_spacing / 2.0f, state->line_height);
+ if (array_size(state->filtered_items) != 0) {
+ glScissor(0, input_y, input_width - state->horizontal_spacing / 2.0f, state->line_height);
+ }
+ else {
+ glScissor(0, 0, state->width, state->height);
+ }
glBindVertexArray(state->input_buffer_grafix.vao);
glUniform2f(state->offset_uniform, state->horizontal_spacing / 2.0f, input_y - state->atlas.vert_shift);
glDrawElements(GL_TRIANGLES, state->input_buffer_grafix.num_elements, GL_UNSIGNED_INT, 0);
@@ -165,35 +170,39 @@ void render_frame(client_state *state) {
glScissor(0, 0, state->width, input_y);
start = input_y - state->line_height + state->scroll;
- // calc scroll
- float selected_bot = start - state->filtered_items[state->selected_filtered_item].offset;
- float selected_top = selected_bot + state->line_height;
- if (selected_bot < 0) {
- state->scroll -= selected_bot;
- start -= selected_bot;
- }
- float diff = selected_top - input_y;
- if (diff > 0) {
- state->scroll -= diff;
- start -= diff;
+ if (array_size(state->filtered_items) != 0) {
+ // calc scroll
+ float selected_bot = start - state->filtered_items[state->selected_filtered_item].offset;
+ float selected_top = selected_bot + state->line_height;
+ if (selected_bot < 0) {
+ state->scroll -= selected_bot;
+ start -= selected_bot;
+ }
+ float diff = selected_top - input_y;
+ if (diff > 0) {
+ state->scroll -= diff;
+ start -= diff;
+ }
}
} else {
glScissor(input_width, 0, state->width, state->line_height);
start = input_width + state->scroll;
- // calc scroll
- item_display_t* selected = &state->filtered_items[state->selected_filtered_item];
- float selected_left = start + selected->offset;
- float selected_right = selected_left + selected->item->pixel_len + state->horizontal_spacing;
- float diff = selected_right - state->width;
- if (diff > 0) {
- state->scroll -= diff;
- start -= diff;
- }
- diff = selected_left - input_width;
- if (diff < 0) {
- state->scroll -= diff;
- start -= diff;
+ if (array_size(state->filtered_items) != 0) {
+ // calc scroll
+ item_display_t* selected = &state->filtered_items[state->selected_filtered_item];
+ float selected_left = start + selected->offset;
+ float selected_right = selected_left + selected->item->pixel_len + state->horizontal_spacing;
+ float diff = selected_right - state->width;
+ if (diff > 0) {
+ state->scroll -= diff;
+ start -= diff;
+ }
+ diff = selected_left - input_width;
+ if (diff < 0) {
+ state->scroll -= diff;
+ start -= diff;
+ }
}
}
@@ -214,9 +223,22 @@ void render_frame(client_state *state) {
glBindVertexArray(item->text_buffer.vao);
glUniform2f(state->offset_uniform, x + state->horizontal_spacing / 2.0f, y - state->atlas.vert_shift);
- if (i == state->selected_filtered_item) glUniform3f(state->color_uniform, 0.0f, 0.4f, 0.8f);
+ if (i == state->selected_filtered_item) {
+ glUniform3f(state->color_uniform, 1.0f, 1.0f, 1.0f);
+ glScissor(x, y, ((state->lines > 0) ? state->width : item->pixel_len + state->horizontal_spacing), state->line_height);
+ glClearColor(0.0f, 0.4f, 0.8f, 1.0);
+ glClear(GL_COLOR_BUFFER_BIT);
+ }
glDrawElements(GL_TRIANGLES, item->text_buffer.num_elements, GL_UNSIGNED_INT, 0);
- if (i == state->selected_filtered_item) glUniform3f(state->color_uniform, 1.0f, 1.0f, 1.0f);
+ if (i == state->selected_filtered_item) {
+ glUniform3f(state->color_uniform, 1.0f, 1.0f, 1.0f);
+ if (state->lines > 0) {
+ glScissor(0, 0, state->width, input_y);
+ }
+ else {
+ glScissor(input_width, 0, state->width, state->line_height);
+ }
+ }
}
// present screen
diff --git a/swenu-path.sh b/swenu-path.sh
deleted file mode 100755
index a720d5c..0000000
--- a/swenu-path.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/sh
-
-IFS=:
-for dir in $PATH; do
- [ -e ${dir} ] && find ${dir} -executable -printf '%f\n'
-done | sort -u
diff --git a/swenu-run.sh b/swenu-run.sh
deleted file mode 100755
index 956fe64..0000000
--- a/swenu-run.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-./swenu-path.sh | ./swenu "$@" | ${SHELL:-"/bin/sh"} &