Define number of completion items

This commit is contained in:
Moritz Lipp 2010-07-04 10:25:11 +02:00
parent ab2288b241
commit 2f027ed1ad
2 changed files with 26 additions and 8 deletions

View file

@ -1,12 +1,13 @@
/* settings */ /* settings */
int default_width = 800; int default_width = 800;
int default_height = 600; int default_height = 600;
float zoom_step = 10; float zoom_step = 10;
float zoom_min = 10; float zoom_min = 10;
float zoom_max = 400; float zoom_max = 400;
float scroll_step = 40; float scroll_step = 40;
float transparency = 0.4; float transparency = 0.4;
float smooth_scrolling = 0.0; float smooth_scrolling = 0.0;
int n_completion_items = 15;
/* completion */ /* completion */
static const char FORMAT_COMMAND[] = "<b>%s</b>"; static const char FORMAT_COMMAND[] = "<b>%s</b>";
@ -206,6 +207,7 @@ Setting settings[] = {
{"inputbar_fgcolor", &(inputbar_fgcolor), 's', FALSE, TRUE, "Inputbar foreground color"}, {"inputbar_fgcolor", &(inputbar_fgcolor), 's', FALSE, TRUE, "Inputbar foreground color"},
{"labels", &(Zathura.Global.enable_labelmode), 'b', FALSE, TRUE, "Allow label mode"}, {"labels", &(Zathura.Global.enable_labelmode), 'b', FALSE, TRUE, "Allow label mode"},
{"list_printer_command", &(list_printer_command), 's', FALSE, FALSE, "Command to list printers"}, {"list_printer_command", &(list_printer_command), 's', FALSE, FALSE, "Command to list printers"},
{"n_completion_items", &(n_completion_items), 'i', FALSE, FALSE, "Number of completion items"},
{"notification_e_bgcolor", &(notification_e_bgcolor), 's', FALSE, TRUE, "Notification (error) background color"}, {"notification_e_bgcolor", &(notification_e_bgcolor), 's', FALSE, TRUE, "Notification (error) background color"},
{"notification_e_fgcolor", &(notification_e_fgcolor), 's', FALSE, TRUE, "Notification (error) foreground color"}, {"notification_e_fgcolor", &(notification_e_fgcolor), 's', FALSE, TRUE, "Notification (error) foreground color"},
{"notification_w_bgcolor", &(notification_w_bgcolor), 's', FALSE, TRUE, "Notification (warning) background color"}, {"notification_w_bgcolor", &(notification_w_bgcolor), 's', FALSE, TRUE, "Notification (warning) background color"},

View file

@ -8,6 +8,7 @@
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <libgen.h> #include <libgen.h>
#include <math.h>
#include <poppler/glib/poppler.h> #include <poppler/glib/poppler.h>
#include <cairo.h> #include <cairo.h>
@ -2478,6 +2479,21 @@ isc_completion(Argument* argument)
setCompletionRowColor(results, HIGHLIGHT, current_item); setCompletionRowColor(results, HIGHLIGHT, current_item);
/* hide other items */
int uh = ceil(n_completion_items / 2);
int lh = floor(n_completion_items / 2);
for(i = 0; i < n_items; i++)
{
if((i >= (current_item - lh) && (i <= current_item + uh)) ||
(i < n_completion_items && current_item < lh) ||
(i >= (n_items - n_completion_items) && (current_item >= (n_items - uh)))
)
gtk_widget_show(rows[i].row);
else
gtk_widget_hide(rows[i].row);
}
if(command_mode) if(command_mode)
temp = g_strconcat(":", rows[current_item].command, NULL); temp = g_strconcat(":", rows[current_item].command, NULL);
else else