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 3A97E1381F3 for ; Tue, 10 Sep 2013 06:36:42 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 9A4C1E09B3; Tue, 10 Sep 2013 06:36:38 +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 9D56CE099F for ; Tue, 10 Sep 2013 06:36:37 +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 879BE33EC1B for ; Tue, 10 Sep 2013 06:36:36 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id B93E9E5460 for ; Tue, 10 Sep 2013 06:36:34 +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: <1378738518.b474c18106323db3d7dfe867c7598defe3f2ddd9.yamakuzure@gentoo> Subject: [gentoo-commits] proj/ufed:master commit in: / X-VCS-Repository: proj/ufed X-VCS-Files: ufed-curses-checklist.c ufed-curses-globals.c ufed-curses-globals.h ufed-curses.c ufed.pl.in X-VCS-Directories: / X-VCS-Committer: yamakuzure X-VCS-Committer-Name: Sven Eden X-VCS-Revision: b474c18106323db3d7dfe867c7598defe3f2ddd9 X-VCS-Branch: master Date: Tue, 10 Sep 2013 06:36:34 +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: eab70864-6858-4559-9ba1-fca5805671c1 X-Archives-Hash: c5d3d1fe52e6021d8370f223ef2a0200 commit: b474c18106323db3d7dfe867c7598defe3f2ddd9 Author: Sven Eden gmx net> AuthorDate: Mon Sep 9 14:55:18 2013 +0000 Commit: Sven Eden gmx de> CommitDate: Mon Sep 9 14:55:18 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/ufed.git;a=commit;h=b474c181 Added prefixing of predefined configuration values and added read-only-mode as the first in use. When read-only-mode is set, the interface now changes both header lines to other colors and to show the user that flags are not saved. --- ufed-curses-checklist.c | 18 ++++++++++++++++++ ufed-curses-globals.c | 2 ++ ufed-curses-globals.h | 2 ++ ufed-curses.c | 19 +++++++++++++++---- ufed.pl.in | 6 +++++- 5 files changed, 42 insertions(+), 5 deletions(-) diff --git a/ufed-curses-checklist.c b/ufed-curses-checklist.c index 003fc9a..4a12968 100644 --- a/ufed-curses-checklist.c +++ b/ufed-curses-checklist.c @@ -51,6 +51,24 @@ static char *getline(FILE *fp) if(fgets(lineBuf, size, fp) == NULL) return NULL; else { + + /* See to configuration bytes if not read already */ + if (!configDone) { + /* Byte 1: Whether read-only-mode is set or not */ + if ( '0' != lineBuf[0] ) + ro_mode = true; + + configDone = true; + + /* Remove the leading bytes transporting configuration values */ + char *oldLine = lineBuf; + lineBuf = malloc(size); + if (NULL == lineBuf) + ERROR_EXIT(-1, "Can not allocate %lu bytes for line buffer\n", sizeof(char) * size); + memcpy(lineBuf, oldLine + 1, size - 1); + free(oldLine); + } /* End of having to read configuration bytes */ + char *p = strchr(lineBuf, '\n'); if(p != NULL) { *p = '\0'; diff --git a/ufed-curses-globals.c b/ufed-curses-globals.c index ad9b66d..8c348d0 100644 --- a/ufed-curses-globals.c +++ b/ufed-curses-globals.c @@ -8,7 +8,9 @@ #include "ufed-curses-types.h" int bottomline = 0; +bool configDone = false; int minwidth = 0; +int ro_mode = false; int topline = 0; eMask e_mask = eMask_unmasked; eOrder e_order = eOrder_left; diff --git a/ufed-curses-globals.h b/ufed-curses-globals.h index 514563e..54f2cf2 100644 --- a/ufed-curses-globals.h +++ b/ufed-curses-globals.h @@ -11,6 +11,7 @@ #include "ufed-curses-types.h" extern int bottomline; +extern bool configDone; extern eMask e_mask; extern eOrder e_order; extern eScope e_scope; @@ -18,6 +19,7 @@ extern eState e_state; extern char* fayt; extern sListStats listStats; extern int minwidth; +extern bool ro_mode; extern int topline; extern sWindow window[wCount]; diff --git a/ufed-curses.c b/ufed-curses.c index 1948f99..6870e66 100644 --- a/ufed-curses.c +++ b/ufed-curses.c @@ -339,8 +339,14 @@ void drawTop(bool withSep) WINDOW* w = win(Top); char buf[COLS + 1]; - wattrset(w, COLOR_PAIR(1) | A_BOLD); - sprintf(buf, "%-*.*s", wWidth(Top), wWidth(Top), "Gentoo USE flags editor " PACKAGE_VERSION); + if (ro_mode) { + wattrset(w, COLOR_PAIR(4) | A_BOLD | A_REVERSE); + sprintf(buf, "%-*.*s", wWidth(Top), wWidth(Top), + "(RO) Gentoo USE flags editor " PACKAGE_VERSION " (RO)"); + } else { + wattrset(w, COLOR_PAIR(1) | A_BOLD); + sprintf(buf, "%-*.*s", wWidth(Top), wWidth(Top), "Gentoo USE flags editor " PACKAGE_VERSION); + } mvwaddstr(w, 0, 0, buf); /// REMOVEME: Stop wasting space @@ -352,8 +358,13 @@ void drawTop(bool withSep) mvwaddch(w, 1, wWidth(Top)-1, ACS_URCORNER); waddch(w, ACS_VLINE); - wattrset(w, COLOR_PAIR(3)); - sprintf(buf, " %-*.*s ", wWidth(Top)-4, wWidth(Top)-4, subtitle); + if (ro_mode) { + wattrset(w, COLOR_PAIR(4) | A_REVERSE); + sprintf(buf, " READ-ONLY MODE! %-*.*s READ-ONLY MODE! ", wWidth(Top)-36, wWidth(Top)-36, subtitle); + } else { + wattrset(w, COLOR_PAIR(3)); + sprintf(buf, " %-*.*s ", wWidth(Top)-4, wWidth(Top)-4, subtitle); + } waddstr(w, buf); wattrset(w, COLOR_PAIR(2) | A_BOLD); waddch(w, ACS_VLINE); diff --git a/ufed.pl.in b/ufed.pl.in index a922109..17ffd8e 100644 --- a/ufed.pl.in +++ b/ufed.pl.in @@ -119,7 +119,11 @@ sub flags_dialog { # Now let the interface know of the result if (open my $fh, '>&=', $iwrite) { binmode( $fh, ":encoding(ISO-8859-1)" ); - print $fh $outTxt; + + # Fixed config: + # byte 1: Read only 0/1 + # Rest: The flags configuration + print $fh "$Portage::ro_mode$outTxt"; close $fh; } else { die "Couldn't let interface know of flags\n";