Skip to content
Myr

main: only display as many matches that fit in the window

Before adoption: this commit came in with the history the project adopted, so no landing records it.

This is a temporary stop-gap solution, until we have implemented scrolling.

authored by Daniel Eklöf · committed by Daniel Eklöf · parent c347f47 · Browse files · 2 files+23 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+23 added−5 removed

  • other:+23 added−5 removed

2 files+23 added−5 removed

modified:main.c+23 added-4 removed
99 unmodified lines
100 uint32_t key;101 } repeat;102};103104/* Window size */105static const int width = 500;106static const int height = 300;107108/* From render */109//static const double x_margin = 20;110static const double y_margin = 4;111static const double border_size = 1;112113static int max_matches;114115static void refresh(const struct context *c);116static void update_matches(struct context *c);117118static void
669 unmodified lines
788update_matches(struct context *c)789{790 /* Nothing entered; all programs found matches */791 if (strlen(c->prompt.text) == 0) {784 c->match_count = tll_length(c->applications);792793 size_t i = 0;794 tll_foreach(c->applications, it) {795 c->matches[i++] = (struct match){796 .application = &it->item, .start_title = -1, .start_comment = -1};797 if (i >= max_matches)798 break;799 }800792 assert(c->selected < c->match_count);801 c->match_count = i;802803 if (c->selected >= c->match_count && c->selected > 0)804 c->selected = c->match_count - 1;805 return;806 }807808 tll(struct match) _matches = tll_init();
22 unmodified lines
831 .start_comment = start_comment}));832 }833834 size_t i = 0;823 c->match_count = tll_length(_matches);824 tll_foreach(_matches, it)835 tll_foreach(_matches, it) {836 c->matches[i++] = it->item;837 if (i >= max_matches)838 break;839 }840 c->match_count = i;841842 tll_free(_matches);843844 if (c->selected >= c->match_count && c->selected > 0)
97 unmodified lines
942943 LOG_DBG("height: %f, ascent: %f, descent: %f",944 fextents.height, fextents.ascent, fextents.descent);945946 const double line_height = 2 * y_margin + fextents.height;947 max_matches = (height - 2 * border_size - line_height) / line_height;948 LOG_DBG("max matches: %d", max_matches);949950 //find_programs();951 xdg_find_programs(fextents.height, &c.applications);952 c.matches = malloc(tll_length(c.applications) * sizeof(c.matches[0]));953 update_matches(&c);
200 unmodified lines
modified:render.c-1 removed
253 unmodified lines
254 cairo_paint(buf->cairo);255 cairo_restore(buf->cairo);256 }257258 /* TODO: use theme */258 cur_x += row_height;259260 /* Application title */261 render_match_text(
25 unmodified lines