summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorQball Cow <qball@gmpclient.org>2014-05-14 19:51:48 +0200
committerQball Cow <qball@gmpclient.org>2014-05-14 19:51:48 +0200
commitde5187bb0148f5c68cfe8e0668887edf54d8a12b (patch)
treedc2821aec08a5efd6835e1a4962d816590e9acc1 /source
parenta925e59653b37cc8bdd83eb2404df262488d0e92 (diff)
Add small arrows indicating more pages. (to be updated later)
Diffstat (limited to 'source')
-rw-r--r--source/rofi.c28
-rw-r--r--source/run-dialog.c12
-rw-r--r--source/textbox.c27
3 files changed, 48 insertions, 19 deletions
diff --git a/source/rofi.c b/source/rofi.c
index 59c70bad..c489b0f6 100644
--- a/source/rofi.c
+++ b/source/rofi.c
@@ -808,6 +808,19 @@ Window main_window = None;
GC gc = NULL;
#include "textbox.h"
+inline char *menu_set_arrow_text(int filtered_lines, int selected, int max_lines)
+{
+ int page = (filtered_lines > 0)? selected/max_lines:0;
+ int npages = (filtered_lines > 0)? ((filtered_lines+max_lines-1)/max_lines):1;
+ if( page != 0 && page != (npages-1)) {
+ return "⇵";
+ } else if (page != 0) {
+ return "↑";
+ } else if (page != (npages-1)) {
+ return "↓";
+ }
+ return " ";
+}
void menu_draw ( textbox *text,
textbox **boxes,
@@ -1044,13 +1057,22 @@ MenuReturn menu ( char **lines, char **input, char *prompt, Time *time, int *shi
}
// search text input
+ textbox *arrowbox = textbox_create ( box, TB_AUTOHEIGHT | TB_AUTOWIDTH,
+ (config.padding),
+ (config.padding),
+ 0, 0,
+ config.menu_font, config.menu_fg, config.menu_bg,
+ "W", NULL);
+
textbox *text = textbox_create ( box, TB_AUTOHEIGHT | TB_EDITABLE,
( config.padding ),
( config.padding ),
- element_width, 1,
+ element_width-arrowbox->w, 1,
config.menu_font, config.menu_fg, config.menu_bg,
( input != NULL ) ? *input : "", prompt );
+ textbox_move ( arrowbox, w-config.padding-arrowbox->w, config.padding);
textbox_show ( text );
+ textbox_show ( arrowbox );
int line_height = text->font->ascent + text->font->descent;
@@ -1184,6 +1206,8 @@ MenuReturn menu ( char **lines, char **input, char *prompt, Time *time, int *shi
}
menu_draw ( text, boxes, max_lines, num_lines, &last_offset, selected, filtered );
+ textbox_text( arrowbox, menu_set_arrow_text(filtered_lines, selected, max_lines));
+ textbox_draw( arrowbox );
// Why do we need the specian -1?
if ( config.wmode == VERTICAL && max_lines > 0)
@@ -1396,6 +1420,8 @@ MenuReturn menu ( char **lines, char **input, char *prompt, Time *time, int *shi
}
menu_draw ( text, boxes, max_lines, num_lines, &last_offset, selected, filtered );
+ textbox_text( arrowbox, menu_set_arrow_text(filtered_lines, selected, max_lines));
+ textbox_draw( arrowbox );
}
}
diff --git a/source/run-dialog.c b/source/run-dialog.c
index 1fca28da..e28b307e 100644
--- a/source/run-dialog.c
+++ b/source/run-dialog.c
@@ -59,18 +59,6 @@ static inline int execsh ( const char *cmd, int run_in_term )
return execlp ( "/bin/sh", "sh", "-c", cmd, NULL );
}
-#define RUN_DIALOG_NAME_LENGTH 256
-typedef struct _element
-{
- long int index;
- char name[RUN_DIALOG_NAME_LENGTH];
-}element;
-static int element_sort_func ( const void *ea, const void *eb )
-{
- element *a = *(element * *) ea;
- element *b = *(element * *) eb;
- return b->index - a->index;
-}
// execute sub-process
static pid_t exec_cmd ( const char *cmd, int run_in_term )
{
diff --git a/source/textbox.c b/source/textbox.c
index 00c4fe08..e1349377 100644
--- a/source/textbox.c
+++ b/source/textbox.c
@@ -39,7 +39,7 @@
#include "rofi.h"
#include "textbox.h"
-#define SIDE_MARGIN 3
+#define SIDE_MARGIN 2
extern Display *display;
@@ -133,6 +133,15 @@ void textbox_text ( textbox *tb, char *text )
textbox_extents ( tb );
}
+void textbox_move (textbox *tb, int x, int y)
+{
+ if ( x != tb->x || y != tb->y )
+ {
+ tb->x = x;
+ tb->y = y;
+ XMoveResizeWindow ( display, tb->window, tb->x, tb->y, tb->w, tb->h );
+ }
+}
// within the parent. handled auto width/height modes
void textbox_moveresize ( textbox *tb, int x, int y, int w, int h )
{
@@ -143,7 +152,14 @@ void textbox_moveresize ( textbox *tb, int x, int y, int w, int h )
if ( tb->flags & TB_AUTOWIDTH )
{
- w = tb->extents.width;
+ if(w > 1)
+ {
+ w = MIN(w, tb->extents.width+2*SIDE_MARGIN);
+ }
+ else
+ {
+ w = tb->extents.width+2*SIDE_MARGIN;
+ }
}
if ( x != tb->x || y != tb->y || w != tb->w || h != tb->h )
@@ -259,12 +275,10 @@ void textbox_draw ( textbox *tb )
// calc full input text width
// Calculate the right size, so no characters are cut off.
// TODO: Check performance of this.
- while ( 1 )
- {
+ do{
XftTextExtentsUtf8 ( display, tb->font, ( unsigned char * ) line, length, &extents );
line_width = extents.width;
-
- if ( line_width < ( tb->w - 2 * SIDE_MARGIN ) )
+ if ( line_width <= ( tb->w - 2 * SIDE_MARGIN ) )
{
break;
}
@@ -274,6 +288,7 @@ void textbox_draw ( textbox *tb )
;
}
}
+ while ( line_width >0 );
int x = SIDE_MARGIN, y = tb->font->ascent;