From patchwork Wed Jul 8 00:11:43 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geoff Levand X-Patchwork-Id: 29552 Return-Path: X-Original-To: patchwork-incoming@bilbo.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id 71829B709B for ; Wed, 8 Jul 2009 10:20:14 +1000 (EST) Received: by ozlabs.org (Postfix) id D2264DE12A; Wed, 8 Jul 2009 10:19:24 +1000 (EST) Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id CF7F1DDDA0 for ; Wed, 8 Jul 2009 10:19:24 +1000 (EST) X-Original-To: cbe-oss-dev@ozlabs.org Delivered-To: cbe-oss-dev@ozlabs.org Received: from hera.kernel.org (hera.kernel.org [140.211.167.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B9B5BDDF36; Wed, 8 Jul 2009 10:18:13 +1000 (EST) Received: from hera.kernel.org (IDENT:U2FsdGVkX19p79HQTyRJjxxjpWg/CgtEWkH/f0BzOkM@localhost [127.0.0.1]) by hera.kernel.org (8.14.2/8.14.2) with ESMTP id n680I5Cl026455 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 8 Jul 2009 00:18:05 GMT Received: (from geoff@localhost) by hera.kernel.org (8.14.2/8.13.1/Submit) id n680I5hS026454; Wed, 8 Jul 2009 00:18:05 GMT Message-Id: <20090708001135.552313066@am.sony.com> User-Agent: quilt/0.47-1 Date: Tue, 07 Jul 2009 17:11:43 -0700 From: Geoff Levand To: Jeremy Kerr In-Reply-To: <20090708001134.934244536@am.sony.com> References: <20090708001134.934244536@am.sony.com> Content-Disposition: inline; filename=ked-fix-backspace.diff X-Virus-Scanned: ClamAV 0.93.3/9541/Tue Jul 7 17:31:53 2009 on hera.kernel.org X-Virus-Status: Clean X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00, UNPARSEABLE_RELAY autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on hera.kernel.org X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.0 (hera.kernel.org [127.0.0.1]); Wed, 08 Jul 2009 00:18:06 +0000 (UTC) Cc: cbe-oss-dev@ozlabs.org Subject: [Cbe-oss-dev] [patch 09/31] petitboot: Fix ked backspace X-BeenThere: cbe-oss-dev@ozlabs.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Discussion about Open Source Software for the Cell Broadband Engine List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: cbe-oss-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org Errors-To: cbe-oss-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org Fix a bug in the ked editor field backspace logic. Stop deleting chars when cursor reaches front of feild buffer. Signed-off-by: Geoff Levand --- ui/ncurses/nc-ked.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) --- a/ui/ncurses/nc-ked.c +++ b/ui/ncurses/nc-ked.c @@ -48,12 +48,15 @@ static struct ked *ked_from_arg(void *ar * @req: An ncurses request or char to send to form_driver(). */ -static void ked_move_cursor(struct ked *ked, int req) +static int ked_move_cursor(struct ked *ked, int req) { + int result; + wchgat(ked->scr.sub_ncw, 1, ked_attr_field_selected, 0, 0); - form_driver(ked->ncf, req); + result = form_driver(ked->ncf, req); wchgat(ked->scr.sub_ncw, 1, ked->attr_cursor, 0, 0); wrefresh(ked->scr.main_ncw); + return result; } /** @@ -93,12 +96,15 @@ static void ked_insert_mode_tog(struct k * @req: An ncurses request to send to form_driver(). */ -static void ked_move_field(struct ked *ked, int req) +static int ked_move_field(struct ked *ked, int req) { + int result; + set_field_back(current_field(ked->ncf), ked_attr_field_normal); - form_driver(ked->ncf, req); + result = form_driver(ked->ncf, req); set_field_back(current_field(ked->ncf), ked_attr_field_selected); ked_move_cursor(ked, REQ_END_FIELD); + return result; } static int ked_post(struct nc_scr *scr) @@ -187,12 +193,15 @@ static void ked_process_key(struct nc_sc while (1) { int c = getch(); + if (c == ERR) + return; + + /* DBGS("%d (%o)\n", c, c); */ + switch (c) { default: ked_move_cursor(ked, c); - break; - case ERR: - return; + break; /* hot keys */ case 2: { /* CTRL-B */ @@ -252,8 +261,8 @@ static void ked_process_key(struct nc_sc ked_move_cursor(ked, REQ_RIGHT_CHAR); break; case KEY_BACKSPACE: - ked_move_cursor(ked, REQ_LEFT_CHAR); - ked_move_cursor(ked, REQ_DEL_CHAR); + if (ked_move_cursor(ked, REQ_LEFT_CHAR) == E_OK) + ked_move_cursor(ked, REQ_DEL_CHAR); break; case KEY_DC: ked_move_cursor(ked, REQ_DEL_CHAR);