1 |
commit: 85458024ce090ca1c7a8c0093156f1f4abb3bc7a |
2 |
Author: Sven Eden <sven.eden <AT> gmx <DOT> de> |
3 |
AuthorDate: Tue Mar 5 06:58:13 2013 +0000 |
4 |
Commit: Sven Eden <sven.eden <AT> gmx <DOT> de> |
5 |
CommitDate: Tue Mar 5 06:58:13 2013 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/ufed.git;a=commit;h=85458024 |
7 |
|
8 |
Added rendering and mouse event handling for two lines of keys |
9 |
|
10 |
--- |
11 |
ufed-curses.c | 50 ++++++++++++++++++++++++++++++++------------------ |
12 |
1 files changed, 32 insertions(+), 18 deletions(-) |
13 |
|
14 |
diff --git a/ufed-curses.c b/ufed-curses.c |
15 |
index cf97d0c..1948f99 100644 |
16 |
--- a/ufed-curses.c |
17 |
+++ b/ufed-curses.c |
18 |
@@ -143,17 +143,27 @@ void drawBottom(bool withSep) |
19 |
if (keys) { |
20 |
const sKey* key = keys; |
21 |
int pos = 2; |
22 |
+ int row = 0; |
23 |
int len = 0; |
24 |
|
25 |
- while ((pos < (bWidth - 2)) && (key->key != '\0')) { |
26 |
+ while (key->key != '\0') { |
27 |
+ if (row != key->row) { |
28 |
+ row = key->row; |
29 |
+ pos = 2; |
30 |
+ } |
31 |
+ |
32 |
len = strlen(key->descr); |
33 |
- if (len > (bWidth - 2 - pos)) |
34 |
- len = bWidth - 2 - pos; |
35 |
- if (key->key > 0) |
36 |
- wattrset(w, COLOR_PAIR(6)); |
37 |
- else |
38 |
- wattrset(w, COLOR_PAIR(3)); |
39 |
- mvwaddnstr(w, 1, pos, key->descr, len); |
40 |
+ |
41 |
+ if (pos < (bWidth - 2)) { |
42 |
+ if (len > (bWidth - 2 - pos)) |
43 |
+ len = bWidth - 2 - pos; |
44 |
+ if (key->key > 0) |
45 |
+ wattrset(w, COLOR_PAIR(6)); |
46 |
+ else |
47 |
+ wattrset(w, COLOR_PAIR(3)); |
48 |
+ |
49 |
+ mvwaddnstr(w, row + 1, pos, key->descr, len); |
50 |
+ } |
51 |
pos += len + 1; |
52 |
++key; |
53 |
} |
54 |
@@ -622,14 +632,21 @@ int maineventloop( |
55 |
} // End of having a scrollbar |
56 |
} else if(wmouse_trafo(win(Bottom), &event.y, &event.x, FALSE)) { |
57 |
if( (event.bstate & (BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED)) |
58 |
- && (event.y == 1) ) { |
59 |
- const sKey* key; |
60 |
- int x = event.x; |
61 |
- if(x < 2) |
62 |
+ && (event.y >= 1) && (event.y <= 2)) { |
63 |
+ const sKey* key = keys; |
64 |
+ int x = event.x; |
65 |
+ int y = event.y; |
66 |
+ if((x < 2) || (y < 1) || (y > 2)) |
67 |
continue; |
68 |
x -= 2; |
69 |
- for(key = keys; key->key!='\0'; key++) { |
70 |
- if( (key->key > 0) && ((size_t)x < key->length)) { |
71 |
+ --y; |
72 |
+ |
73 |
+ // Forward to second row if y is 1 |
74 |
+ for ( ; y > key->row; key++) ; |
75 |
+ |
76 |
+ // Check key |
77 |
+ for ( ; (key->row == y) && (x >= 0) && (key->key != '\0'); key++) { |
78 |
+ if ((key->key > 0) && ((size_t)x < key->length) ) { |
79 |
event.x -= x; |
80 |
wattrset(win(Bottom), COLOR_PAIR(6) | A_BOLD | A_REVERSE); |
81 |
mvwaddstr(win(Bottom), event.y, event.x, key->descr); |
82 |
@@ -642,10 +659,7 @@ int maineventloop( |
83 |
c = key->key; |
84 |
goto check_key; |
85 |
} |
86 |
- x -= key->length; |
87 |
- if(x == 0) |
88 |
- break; |
89 |
- x--; |
90 |
+ x -= key->length + 1; |
91 |
} |
92 |
} |
93 |
} |