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 C7338198002 for ; Tue, 5 Mar 2013 16:50:02 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 4D316E06B7; Tue, 5 Mar 2013 16:50:01 +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 CEC51E06BF for ; Tue, 5 Mar 2013 16:50:00 +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 D832533DF31 for ; Tue, 5 Mar 2013 16:49:59 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 73CA1E42E2 for ; Tue, 5 Mar 2013 16:49:58 +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: <1362466693.85458024ce090ca1c7a8c0093156f1f4abb3bc7a.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: 85458024ce090ca1c7a8c0093156f1f4abb3bc7a X-VCS-Branch: master Date: Tue, 5 Mar 2013 16:49:58 +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: 10752f86-5781-461b-a7c5-c82471f99669 X-Archives-Hash: 110c95c51a4f26019c17cd14c56e9b69 commit: 85458024ce090ca1c7a8c0093156f1f4abb3bc7a Author: Sven Eden gmx de> AuthorDate: Tue Mar 5 06:58:13 2013 +0000 Commit: Sven Eden gmx de> CommitDate: Tue Mar 5 06:58:13 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/ufed.git;a=commit;h=85458024 Added rendering and mouse event handling for two lines of keys --- ufed-curses.c | 50 ++++++++++++++++++++++++++++++++------------------ 1 files changed, 32 insertions(+), 18 deletions(-) diff --git a/ufed-curses.c b/ufed-curses.c index cf97d0c..1948f99 100644 --- a/ufed-curses.c +++ b/ufed-curses.c @@ -143,17 +143,27 @@ void drawBottom(bool withSep) if (keys) { const sKey* key = keys; int pos = 2; + int row = 0; int len = 0; - while ((pos < (bWidth - 2)) && (key->key != '\0')) { + while (key->key != '\0') { + if (row != key->row) { + row = key->row; + pos = 2; + } + 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); + + if (pos < (bWidth - 2)) { + 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, row + 1, pos, key->descr, len); + } pos += len + 1; ++key; } @@ -622,14 +632,21 @@ int maineventloop( } // End of having a scrollbar } else if(wmouse_trafo(win(Bottom), &event.y, &event.x, FALSE)) { if( (event.bstate & (BUTTON1_CLICKED | BUTTON1_DOUBLE_CLICKED)) - && (event.y == 1) ) { - const sKey* key; - int x = event.x; - if(x < 2) + && (event.y >= 1) && (event.y <= 2)) { + const sKey* key = keys; + int x = event.x; + int y = event.y; + if((x < 2) || (y < 1) || (y > 2)) continue; x -= 2; - for(key = keys; key->key!='\0'; key++) { - if( (key->key > 0) && ((size_t)x < key->length)) { + --y; + + // Forward to second row if y is 1 + for ( ; y > key->row; key++) ; + + // Check key + for ( ; (key->row == y) && (x >= 0) && (key->key != '\0'); key++) { + if ((key->key > 0) && ((size_t)x < key->length) ) { event.x -= x; wattrset(win(Bottom), COLOR_PAIR(6) | A_BOLD | A_REVERSE); mvwaddstr(win(Bottom), event.y, event.x, key->descr); @@ -642,10 +659,7 @@ int maineventloop( c = key->key; goto check_key; } - x -= key->length; - if(x == 0) - break; - x--; + x -= key->length + 1; } } }