From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 1DCDD1389F1 for ; Wed, 13 Feb 2013 09:23:37 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id F1ACEE0495; Wed, 13 Feb 2013 09:23:30 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 3CEACE0495 for ; Wed, 13 Feb 2013 09:23:30 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 1472233E58F for ; Wed, 13 Feb 2013 09:23:29 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id A18F2E4090 for ; Wed, 13 Feb 2013 09:23:27 +0000 (UTC) From: "Sven Eden" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sven Eden" Message-ID: <1360745093.9af992c041f7f05b6dc0e5d61804c6a2414b73b4.yamakuzure@gentoo> Subject: [gentoo-commits] proj/ufed:master commit in: / X-VCS-Repository: proj/ufed X-VCS-Files: ufed-curses.c X-VCS-Directories: / X-VCS-Committer: yamakuzure X-VCS-Committer-Name: Sven Eden X-VCS-Revision: 9af992c041f7f05b6dc0e5d61804c6a2414b73b4 X-VCS-Branch: master Date: Wed, 13 Feb 2013 09:23:27 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 9a5a7cb9-743b-49ca-a091-9600f68572df X-Archives-Hash: a5a6750bd8fccd9cfd3655615d60eff0 commit: 9af992c041f7f05b6dc0e5d61804c6a2414b73b4 Author: Sven Eden gmx de> AuthorDate: Wed Feb 13 08:44:53 2013 +0000 Commit: Sven Eden gmx de> CommitDate: Wed Feb 13 08:44:53 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/ufed.git;a=commit;h=9af992c0 Changed the drawing of the key help to look more like buttons. Even if ncurses is installed without gpm support, this should make reading which key does what a lot easier. --- ufed-curses.c | 63 +++++++++++++++++++++++++++----------------------------- 1 files changed, 30 insertions(+), 33 deletions(-) diff --git a/ufed-curses.c b/ufed-curses.c index f8680bb..78427ac 100644 --- a/ufed-curses.c +++ b/ufed-curses.c @@ -73,6 +73,7 @@ void initcurses() { init_pair(3, COLOR_BLACK, COLOR_WHITE); init_pair(4, COLOR_RED, COLOR_WHITE); init_pair(5, COLOR_BLUE, COLOR_WHITE); + init_pair(6, COLOR_BLACK, COLOR_CYAN); #ifdef NCURSES_MOUSE_VERSION mousemask(BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED | BUTTON1_PRESSED | BUTTON1_RELEASED, NULL); #endif @@ -111,54 +112,50 @@ static void checktermsize() { */ void drawBottom(bool withSep) { - WINDOW* w = win(Bottom); + WINDOW* w = win(Bottom); + int bWidth = wWidth(Bottom); wattrset(w, COLOR_PAIR(2) | A_BOLD); mvwaddch(w, 0, 0, ACS_VLINE); wattrset(w, COLOR_PAIR(3)); waddch(w, ' '); waddch(w, ACS_LLCORNER); - whline(w, ACS_HLINE, wWidth(Bottom)-6); + whline(w, ACS_HLINE, bWidth - 6); if (withSep) { mvwaddch(w, 0, minwidth + 3, ACS_BTEE); // Before state mvwaddch(w, 0, minwidth + 7, ACS_BTEE); // Between state and scope mvwaddch(w, 0, minwidth + 10, ACS_BTEE); // After scope } - mvwaddch(w, 0, wWidth(Bottom)-3, ACS_LRCORNER); + mvwaddch(w, 0, bWidth - 3, ACS_LRCORNER); waddch(w, ' '); wattrset(w, COLOR_PAIR(2) | A_BOLD); - waddch(w, ACS_VLINE); + waddch (w, ACS_VLINE); // Right vline on line 0 + waddch (w, ACS_VLINE); // Left vline on line 1 + whline (w, ' ', bWidth - 2); // Blank line (filled with keys later) + mvwaddch(w, 1, bWidth - 1, ACS_VLINE); // Right vline on line 1 + mvwaddch(w, 2, 0, ACS_LLCORNER); // lower left corner on line 2 + whline (w, ACS_HLINE, bWidth - 2); // bottom line + mvwaddch(w, 2, bWidth - 1, ACS_LRCORNER); // lower right corner on line 2 - waddch(w, ACS_VLINE); - wattrset(w, COLOR_PAIR(3)); if (keys) { - char buf[COLS + 1]; - char *p = buf; - const sKey* key; - const size_t maxAdr = (const size_t)(buf+wWidth(Bottom)-3); - *p++ = ' '; - for(key=keys; key->key!='\0'; key++) { - size_t n = maxAdr - (size_t)p; - if(n > key->length) - n = key->length; - memcpy(p, key->descr, n); - p += n; - if ((size_t)p == maxAdr) - break; - *p++ = ' '; + const sKey* key = keys; + int pos = 2; + int len = 0; + + while ((pos < (bWidth - 2)) && (key->key != '\0')) { + len = strlen(key->descr); + if (len > (bWidth - 2 - pos)) + len = bWidth - 2 - pos; + if (key->key > 0) + wattrset(w, COLOR_PAIR(6)); + else + wattrset(w, COLOR_PAIR(3)); + mvwaddnstr(w, 1, pos, key->descr, len); + pos += len + 1; + ++key; } - memset(p, ' ', maxAdr + 1 - (size_t)p); - buf[wWidth(Bottom)-2] = '\0'; - waddstr(w, buf); - } else - whline(w, ' ', wWidth(Bottom) - 3); - - wattrset(w, COLOR_PAIR(2) | A_BOLD); - waddch(w, ACS_VLINE); + } - waddch(w, ACS_LLCORNER); - whline(w, ACS_HLINE, wWidth(Bottom)-2); - mvwhline(w, 2, wWidth(Bottom)-1, ACS_LRCORNER, 1); wnoutrefresh(w); } @@ -626,12 +623,12 @@ int maineventloop( for(key = keys; key->key!='\0'; key++) { if( (key->key > 0) && ((size_t)x < key->length)) { event.x -= x; - wattrset(win(Bottom), COLOR_PAIR(3) | A_BOLD | A_REVERSE); + wattrset(win(Bottom), COLOR_PAIR(6) | A_BOLD | A_REVERSE); mvwaddstr(win(Bottom), event.y, event.x, key->descr); wmove(win(Bottom), event.y, event.x); wrefresh(win(Bottom)); usleep(100000); - wattrset(win(Bottom), COLOR_PAIR(3)); + wattrset(win(Bottom), COLOR_PAIR(6)); waddstr(win(Bottom), key->descr); wnoutrefresh(win(Bottom)); c = key->key;