From: "Sven Eden" <sven.eden@gmx.de>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/ufed:master commit in: /
Date: Wed, 16 Jan 2013 12:56:44 +0000 (UTC) [thread overview]
Message-ID: <1358323549.dc50feb37e84cf3dec29eac69143d7e625734cf3.yamakuzure@gentoo> (raw)
commit: dc50feb37e84cf3dec29eac69143d7e625734cf3
Author: Sven Eden <sven.eden <AT> gmx <DOT> de>
AuthorDate: Wed Jan 16 08:05:49 2013 +0000
Commit: Sven Eden <sven.eden <AT> gmx <DOT> de>
CommitDate: Wed Jan 16 08:05:49 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/ufed.git;a=commit;h=dc50feb3
Added filtering of now transported masked flags. These are not shown, yet,
because of the filter being turned off by default. A key to toggle the
filtering of masked flags is not implemented, yet.
With this commit ufed should not do anything different than in the past.
---
ufed-curses-checklist.c | 69 +++++++++++++++++++++++++++++---------------
ufed-curses.c | 73 +++++++++++++++++++++++++++++++++-------------
ufed-curses.h | 5 +++
3 files changed, 103 insertions(+), 44 deletions(-)
diff --git a/ufed-curses-checklist.c b/ufed-curses-checklist.c
index 50dc1b4..b43ecac 100644
--- a/ufed-curses-checklist.c
+++ b/ufed-curses-checklist.c
@@ -11,6 +11,41 @@
#include "ufed-curses-help.h"
+/* internal types */
+struct flag {
+ struct item item;
+ char *name;
+ char on;
+ char *state;
+ char *descr[FLEXIBLE_ARRAY_MEMBER];
+};
+
+
+/* internal members */
+static struct flag *flags;
+static int descriptionleft;
+static char *fayt;
+static struct item **faytsave;
+
+#define mkKey(x) x, sizeof(x)-1
+static const struct key keys[] = {
+ { '?', mkKey("Help (?)") },
+ { '\n', mkKey("Save (Return/Enter)") },
+ { '\033', mkKey("Cancel (Esc)") },
+ { '\0', mkKey("") }
+};
+#undef mkKey
+
+
+/* internal prototypes */
+static void free_flags(void);
+
+
+/* external members */
+enum mask showMasked = show_unmasked; //!< Set whether to show masked, unmasked or both flags
+
+
+/* static functions */
static char *getline(FILE *fp) {
size_t size;
char *result;
@@ -45,22 +80,14 @@ static char *getline(FILE *fp) {
}
size += size/2;
}
+ return NULL; // never reached.
}
-static struct flag {
- struct item item;
- char *name;
- char on;
- char *state;
- char *descr[FLEXIBLE_ARRAY_MEMBER];
-} *flags;
-static int descriptionleft;
-
-static void free_flags(void);
static void read_flags(void) {
FILE *input = fdopen(3, "r");
char *line;
int y=0;
+
if(input==NULL)
exit(-1);
atexit(&free_flags);
@@ -89,23 +116,29 @@ static void read_flags(void) {
minwidth = name.end-name.start+11;
flag->name = &line[name.start];
+ /* check and save current flag setting from configuration */
line[on.end] = '\0';
+ flag->item.isMasked = false;
if(!strcmp(&line[on.start], "on"))
flag->on = '+';
else if(!strcmp(&line[on.start], "off"))
flag->on = '-';
else if(!strcmp(&line[on.start], "def"))
flag->on = ' ';
- else if(!strcmp(&line[on.start], "msk"))
+ else if(!strcmp(&line[on.start], "msk")) {
flag->on = 'm';
+ flag->item.isMasked = true;
+ }
else
exit(-1);
+ /* check and set flag state */
line[state.end] = '\0';
if(state.end-state.start != 4)
exit(-1);
flag->state = &line[state.start];
+ /* check and set flag item height */
flag->item.height = ndescr;
{ int i; for(i=0; i<ndescr; i++) {
flag->descr[i] = getline(input);
@@ -113,6 +146,7 @@ static void read_flags(void) {
y += ndescr;
+ /* Save flag in our linked list */
if(flags==NULL) {
flag->item.prev = (struct item *) flag;
flag->item.next = (struct item *) flag;
@@ -147,14 +181,6 @@ static void free_flags(void) {
}
}
-static const struct key keys[] = {
-#define key(x) x, sizeof(x)-1
- { '?', key("Help (?)") },
- { '\n', key("Save (Return/Enter)") },
- { '\033', key("Cancel (Esc)") },
- { '\0', key("") }
-#undef key
-};
static void drawflag(struct item *item, bool highlight) {
struct flag *flag = (struct flag *) item;
@@ -182,7 +208,7 @@ static void drawflag(struct item *item, bool highlight) {
? flag->state[1] : ' '
: flag->on,
flag->on == ' ' ? ')' : ']',
- /* distance and name being masked or not */
+ /* distance and name */
minwidth-11, flag->name,
/* current selection state */
flag->state);
@@ -214,9 +240,6 @@ static void drawflag(struct item *item, bool highlight) {
wnoutrefresh(win(List));
}
-static char *fayt;
-static struct item **faytsave;
-
static int callback(struct item **currentitem, int key) {
if(*fayt!='\0' && key!=KEY_BACKSPACE && (key==' ' || key!=(unsigned char) key || !isprint(key))) {
*fayt = '\0';
diff --git a/ufed-curses.c b/ufed-curses.c
index 14b41e3..65c4ba8 100644
--- a/ufed-curses.c
+++ b/ufed-curses.c
@@ -6,6 +6,7 @@
#include <unistd.h>
#include <locale.h>
+/* internal types */
struct window window[wCount] = {
{ NULL, 0, 0, 5, 0 }, /* Top */
{ NULL, 5, 0, -8, 3 }, /* Left */
@@ -16,15 +17,22 @@ struct window window[wCount] = {
{ NULL, -3, 0, 3, 0 }, /* Bottom */
};
-static const char *subtitle;
+/* internal members */
+static const char *subtitle;
static const struct key *keys;
-
static struct item *items, *currentitem;
+
+
+/* external members */
int topy, minwidth;
+extern enum mask showMasked;
+/* internal prototypes */
static void checktermsize(void);
+
+/* internal functions */
void initcurses(void) {
setlocale(LC_CTYPE, "");
initscr();
@@ -71,19 +79,35 @@ static void checktermsize(void) {
static void (*drawitem)(struct item *, bool);
void drawitems(void) {
- struct item *item;
- int y;
+ struct item *item = currentitem;
+ int y = item->top - topy;
- item = currentitem;
- while((y=item->top-topy) > 0)
+ /* move to the top of the displayed list */
+ for ( ; (y > 0) && item; y = item->top - topy)
item = item->prev;
+ /* advance in the list if the top item would be a masked
+ * flag that is to be filtered out.
+ * This is needed in two situations. First at the very start
+ * of the program and second whenever the filtering is
+ * toggled. The latter resets the list position to guarantee
+ * a valid display.
+ */
+ if ((show_unmasked == showMasked) && item->isMasked) {
+ while (item && item->isMasked) {
+ if (currentitem == item)
+ currentitem = item->next;
+ topy += item->height;
+ item = item->next;
+ }
+ }
+
for(;;) {
if(item!=currentitem)
(*drawitem)(item, FALSE);
y += item->height;
item = item->next;
- if(y>=wHeight(List))
+ if(y >= wHeight(List))
break;
if(item==items) {
char buf[wWidth(List)];
@@ -221,9 +245,9 @@ static void draw(void) {
void scrollcurrent(void) {
if(currentitem->top < topy)
- topy = max(currentitem->top, currentitem->top+currentitem->height-wHeight(List));
- else if(currentitem->top+currentitem->height > topy+wHeight(List))
- topy = min(currentitem->top+currentitem->height-wHeight(List), currentitem->top);
+ topy = max(currentitem->top, currentitem->top + currentitem->height - wHeight(List));
+ else if( (currentitem->top + currentitem->height) > (topy + wHeight(List)))
+ topy = min(currentitem->top + currentitem->height - wHeight(List), currentitem->top);
else
return;
drawitems();
@@ -267,6 +291,7 @@ bool yesno(const char *prompt) {
break;
#endif
}
+ return FALSE;
}
int maineventloop(
@@ -313,7 +338,8 @@ int maineventloop(
if(c==KEY_MOUSE) {
MEVENT event;
if(getmouse(&event)==OK) {
- if(mousekey != ERR && event.bstate & (BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED | BUTTON1_RELEASED)) {
+ if( (mousekey != ERR)
+ && (event.bstate & (BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED | BUTTON1_RELEASED)) ) {
cbreak();
mousekey = ERR;
if(!(event.bstate & (BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED)))
@@ -344,8 +370,8 @@ int maineventloop(
(*drawitem)(currentitem, TRUE);
}
} else if(wmouse_trafo(win(Scrollbar), &event.y, &event.x, FALSE)) {
- if(event.bstate & (BUTTON1_PRESSED | BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED)
- && event.y < wHeight(Scrollbar)-1) {
+ if( (event.bstate & (BUTTON1_PRESSED | BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED))
+ && (event.y < wHeight(Scrollbar)-1) ) {
halfdelay(1);
#define SIM(key) \
@@ -371,8 +397,6 @@ int maineventloop(
for(;;) {
c = getch();
switch(c) {
- default:
- goto check_key;
case ERR:
continue;
case KEY_MOUSE:
@@ -393,14 +417,17 @@ int maineventloop(
wrefresh(win(List));
}
}
+ break;
+ default:
+ goto check_key;
}
break;
}
}
}
} else if(wmouse_trafo(win(Bottom), &event.y, &event.x, FALSE)) {
- if(event.bstate & (BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED)
- && event.y == 1) {
+ if( (event.bstate & (BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED))
+ && (event.y == 1) ) {
const struct key *key;
int x = event.x;
if(x < 2)
@@ -437,11 +464,13 @@ int maineventloop(
switch(c) {
case KEY_UP:
- if(currentitem->top<topy) {
+ if(currentitem->top < topy ) {
(*drawitem)(currentitem, FALSE);
topy--;
(*drawitem)(currentitem, TRUE);
- } else if(currentitem!=items || topy>currentitem->top) {
+ } else if( (currentitem!=items || topy>currentitem->top)
+ && ( !currentitem->prev->isMasked
+ || (show_unmasked != showMasked)) ) {
(*drawitem)(currentitem, FALSE);
currentitem = currentitem->prev;
scrollcurrent();
@@ -450,11 +479,13 @@ int maineventloop(
break;
case KEY_DOWN:
- if(currentitem->top+currentitem->height>topy+wHeight(List)) {
+ if( (currentitem->top + currentitem->height) > (topy + wHeight(List)) ) {
(*drawitem)(currentitem, FALSE);
topy++;
(*drawitem)(currentitem, TRUE);
- } else if(currentitem->next!=items) {
+ } else if( (currentitem->next != items)
+ && ( currentitem->next->isMasked
+ || (show_masked != showMasked)) ){
(*drawitem)(currentitem, FALSE);
currentitem = currentitem->next;
scrollcurrent();
diff --git a/ufed-curses.h b/ufed-curses.h
index 8730d36..7a97c3e 100644
--- a/ufed-curses.h
+++ b/ufed-curses.h
@@ -5,14 +5,19 @@
#include <curses.h>
enum win { Top, Left, List, Input, Scrollbar, Right, Bottom, wCount };
+enum mask { show_unmasked, show_both, show_masked };
+
struct window {
WINDOW *win;
const int top, left, height, width;
};
+
struct item {
struct item *prev, *next;
int top, height;
+ bool isMasked;
};
+
struct key {
char key;
const char *descr;
next reply other threads:[~2013-01-16 12:56 UTC|newest]
Thread overview: 238+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-16 12:56 Sven Eden [this message]
-- strict thread matches above, loose matches on Subject: below --
2020-11-07 14:25 [gentoo-commits] proj/ufed:master commit in: / Sven Eden
2020-05-02 8:38 Ulrich Müller
2019-09-27 6:42 Sven Eden
2019-09-27 6:39 Sven Eden
2019-09-24 17:57 Sven Eden
2019-09-24 17:56 Sven Eden
2019-04-07 15:17 David Seifert
2019-04-07 13:56 David Seifert
2019-04-07 13:19 David Seifert
2019-04-07 13:19 David Seifert
2019-04-07 13:19 David Seifert
2019-04-07 13:19 David Seifert
2019-04-07 13:19 David Seifert
2015-02-12 15:47 Sven Eden
2015-02-11 9:03 Sven Eden
2014-11-10 9:59 Sven Eden
2014-10-28 11:43 Sven Eden
2014-02-26 10:26 Sven Eden
2014-02-26 10:26 Sven Eden
2014-02-26 10:26 Sven Eden
2014-02-26 10:26 Sven Eden
2014-02-26 10:26 Sven Eden
2014-02-26 10:26 Sven Eden
2014-02-25 8:18 Sven Eden
2014-02-25 8:18 Sven Eden
2014-02-25 8:18 Sven Eden
2014-02-25 8:18 Sven Eden
2013-11-25 21:43 Sven Eden
2013-11-25 21:43 Sven Eden
2013-11-25 21:43 Sven Eden
2013-11-25 21:43 Sven Eden
2013-11-25 21:43 Sven Eden
2013-09-20 8:30 Sven Eden
2013-09-20 8:30 Sven Eden
2013-09-20 8:30 Sven Eden
2013-09-20 8:30 Sven Eden
2013-09-20 8:30 Sven Eden
2013-09-20 8:30 Sven Eden
2013-09-20 8:30 Sven Eden
2013-09-20 8:30 Sven Eden
2013-09-20 8:30 Sven Eden
2013-09-20 8:30 Sven Eden
2013-09-20 8:30 Sven Eden
2013-09-20 8:30 Sven Eden
2013-09-20 8:30 Sven Eden
2013-09-20 8:30 Sven Eden
2013-09-20 8:30 Sven Eden
2013-09-20 8:30 Sven Eden
2013-09-20 8:30 Sven Eden
2013-09-20 8:30 Sven Eden
2013-09-20 8:30 Sven Eden
2013-09-20 8:30 Sven Eden
2013-09-20 8:30 Sven Eden
2013-09-20 8:30 Sven Eden
2013-09-20 8:30 Sven Eden
2013-09-20 8:30 Sven Eden
2013-09-20 8:30 Sven Eden
2013-09-11 7:09 Sven Eden
2013-09-11 6:31 Sven Eden
2013-09-11 6:04 Sven Eden
2013-09-11 6:04 Sven Eden
2013-09-11 6:04 Sven Eden
2013-09-11 6:04 Sven Eden
2013-09-11 6:04 Sven Eden
2013-09-11 6:04 Sven Eden
2013-09-11 6:04 Sven Eden
2013-09-11 6:04 Sven Eden
2013-09-11 6:04 Sven Eden
2013-09-11 6:04 Sven Eden
2013-09-11 6:04 Sven Eden
2013-09-11 6:04 Sven Eden
2013-09-11 6:04 Sven Eden
2013-09-11 6:04 Sven Eden
2013-09-11 6:04 Sven Eden
2013-09-11 6:04 Sven Eden
2013-09-11 6:04 Sven Eden
2013-09-11 6:04 Sven Eden
2013-09-11 6:04 Sven Eden
2013-09-11 6:04 Sven Eden
2013-09-11 6:04 Sven Eden
2013-09-11 6:04 Sven Eden
2013-09-10 12:37 Sven Eden
2013-09-10 6:36 Sven Eden
2013-09-10 6:36 Sven Eden
2013-09-10 6:36 Sven Eden
2013-09-10 6:36 Sven Eden
2013-09-10 6:36 Sven Eden
2013-09-10 6:36 Sven Eden
2013-09-10 6:36 Sven Eden
2013-07-22 9:34 Sven Eden
2013-07-22 6:09 Sven Eden
2013-07-22 6:09 Sven Eden
2013-04-09 7:22 Sven Eden
2013-04-09 7:22 Sven Eden
2013-04-09 7:22 Sven Eden
2013-04-08 7:18 Sven Eden
2013-04-03 13:39 Sven Eden
2013-03-05 16:53 Sven Eden
2013-03-05 16:49 Sven Eden
2013-03-05 16:49 Sven Eden
2013-03-05 16:49 Sven Eden
2013-03-05 16:49 Sven Eden
2013-03-05 16:49 Sven Eden
2013-02-21 10:02 Sven Eden
2013-02-19 15:16 Sven Eden
2013-02-19 13:34 Sven Eden
2013-02-18 7:22 Sven Eden
2013-02-15 8:36 Sven Eden
2013-02-15 8:36 Sven Eden
2013-02-15 8:36 Sven Eden
2013-02-14 8:35 Sven Eden
2013-02-14 8:35 Sven Eden
2013-02-14 8:35 Sven Eden
2013-02-13 9:23 Sven Eden
2013-02-13 9:23 Sven Eden
2013-02-13 9:23 Sven Eden
2013-02-13 9:23 Sven Eden
2013-02-13 9:23 Sven Eden
2013-02-12 10:51 Sven Eden
2013-02-12 10:51 Sven Eden
2013-02-12 9:01 Sven Eden
2013-02-12 9:01 Sven Eden
2013-02-12 9:01 Sven Eden
2013-02-12 9:01 Sven Eden
2013-02-12 9:01 Sven Eden
2013-02-12 9:01 Sven Eden
2013-02-12 9:01 Sven Eden
2013-02-12 9:01 Sven Eden
2013-02-12 9:01 Sven Eden
2013-02-12 9:01 Sven Eden
2013-02-12 9:01 Sven Eden
2013-02-12 9:01 Sven Eden
2013-02-12 9:01 Sven Eden
2013-02-12 9:01 Sven Eden
2013-02-12 9:01 Sven Eden
2013-02-12 9:01 Sven Eden
2013-02-12 9:01 Sven Eden
2013-02-12 9:01 Sven Eden
2013-02-12 9:01 Sven Eden
2013-02-12 9:01 Sven Eden
2013-02-12 9:01 Sven Eden
2013-02-12 9:01 Sven Eden
2013-02-06 9:09 Sven Eden
2013-02-06 9:09 Sven Eden
2013-02-05 18:06 Paul Varner
2013-02-05 13:53 Sven Eden
2013-02-05 13:53 Sven Eden
2013-02-05 11:24 Sven Eden
2013-02-03 14:32 Sven Eden
2013-02-03 14:32 Sven Eden
2013-02-03 14:32 Sven Eden
2013-02-03 14:32 Sven Eden
2013-02-03 14:32 Sven Eden
2013-02-02 20:49 Sven Eden
2013-02-02 10:11 Sven Eden
2013-02-02 9:47 Sven Eden
2013-02-02 9:47 Sven Eden
2013-02-02 9:47 Sven Eden
2013-02-01 21:12 Sven Eden
2013-02-01 21:12 Sven Eden
2013-02-01 21:12 Sven Eden
2013-02-01 16:04 Sven Eden
2013-02-01 15:55 Sven Eden
2013-02-01 15:26 Sven Eden
2013-02-01 14:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-01-24 10:15 Sven Eden
2013-01-24 10:15 Sven Eden
2013-01-24 10:15 Sven Eden
2013-01-24 10:15 Sven Eden
2013-01-24 10:15 Sven Eden
2013-01-23 14:44 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-16 13:43 Sven Eden
2013-01-16 12:56 Sven Eden
2013-01-16 12:56 Sven Eden
2013-01-16 12:56 Sven Eden
2013-01-16 12:56 Sven Eden
2013-01-16 12:56 Sven Eden
2013-01-08 11:02 Sven Eden
2013-01-02 8:47 Sven Eden
2013-01-02 8:01 Sven Eden
2013-01-02 8:01 Sven Eden
2012-11-20 17:31 Paul Varner
2012-11-20 17:25 Paul Varner
2012-10-23 16:13 Paul Varner
2012-10-23 16:13 Paul Varner
2012-10-23 16:13 Paul Varner
2012-10-23 16:01 Paul Varner
2012-10-22 20:42 Paul Varner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1358323549.dc50feb37e84cf3dec29eac69143d7e625734cf3.yamakuzure@gentoo \
--to=sven.eden@gmx.de \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox