From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by 10.42.224.197 with SMTP id ip5cs209086icb; Tue, 22 Feb 2011 09:27:02 -0800 (PST) Received: by 10.229.188.1 with SMTP id cy1mr2262656qcb.110.1298395621726; Tue, 22 Feb 2011 09:27:01 -0800 (PST) Return-Path: Received: from rubyforge.org (rubyforge.org [205.234.109.19]) by mx.google.com with ESMTP id v6si13349927qcq.165.2011.02.22.09.27.01; Tue, 22 Feb 2011 09:27:01 -0800 (PST) Received-SPF: pass (google.com: domain of sup-devel-bounces@rubyforge.org designates 205.234.109.19 as permitted sender) client-ip=205.234.109.19; Authentication-Results: mx.google.com; spf=pass (google.com: domain of sup-devel-bounces@rubyforge.org designates 205.234.109.19 as permitted sender) smtp.mail=sup-devel-bounces@rubyforge.org; dkim=neutral (body hash did not verify) header.i=@gmail.com Received: from rubyforge.org (rubyforge.org [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id 2B7B43C8047; Tue, 22 Feb 2011 12:27:01 -0500 (EST) Received: from mail-ew0-f50.google.com (mail-ew0-f50.google.com [209.85.215.50]) by rubyforge.org (Postfix) with ESMTP id 5D3AB185835A for ; Tue, 22 Feb 2011 12:02:00 -0500 (EST) Received: by ewy26 with SMTP id 26so1636318ewy.23 for ; Tue, 22 Feb 2011 09:02:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:content-type:subject:from:to:in-reply-to :references:date:message-id:user-agent:content-transfer-encoding; bh=+h0w9fQYnpAJnuUxJLKfUUg8nrvfH5DZw5/rMGuqai8=; b=fBXIl0SIRPw8F6at76nkMciZlB/ellEJMHgePb1nqIaekuzhIFdiAS3gngcXajBqc7 Fo3UzQiedPQIxm0+X9ToFPyUd3WbuqFiXVJiYM8xTp7XemTkNRGNGb0u0ofhDMBqbUAK dRZRdDmQiL5zMxTBeGFHUiPf80QED+wQqscOo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=content-type:subject:from:to:in-reply-to:references:date:message-id :user-agent:content-transfer-encoding; b=fhleXTbGapVv7FkGCSW7YaNJFGm4SMrS1gboqdqTeHPEkCG0YcGuvglPtMtKEBDeiZ yKoxUoAtyaBaANnYjZICywvUYcdiWyHGOtHgmwQ440D69k0B2v5bHdwNrD+bZid1Mzed Gw6iAE53D2DqbbUG6bIu/TsGo6uPDxjBRj2PE= Received: by 10.14.29.77 with SMTP id h53mr3234592eea.18.1298394093571; Tue, 22 Feb 2011 09:01:33 -0800 (PST) Received: from localhost (cpc12-cmbg15-2-0-cust81.5-4.cable.virginmedia.com [86.30.247.82]) by mx.google.com with ESMTPS id t50sm6134860eeh.6.2011.02.22.09.01.31 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 22 Feb 2011 09:01:32 -0800 (PST) From: Hamish To: sup-devel In-reply-to: <1298251460-sup-4333@whisper> References: <1298251460-sup-4333@whisper> Date: Tue, 22 Feb 2011 17:01:29 +0000 Message-Id: <1298393768-sup-7839@whisper> User-Agent: Sup/git Subject: Re: [sup-devel] [BRANCH] Ctrl-W behaviour X-BeenThere: sup-devel@rubyforge.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: Sup developer discussion List-Id: Sup developer discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: sup-devel-bounces@rubyforge.org Errors-To: sup-devel-bounces@rubyforge.org Excerpts from Hamish's message of Mon Feb 21 01:29:20 +0000 2011: > I use Ctrl-W when deleting labels from a thread, and it's been a minor > annoyance that this is slightly broken - when there is a space before > the cursor, Ctrl-W will just delete the space, and you need to press > Ctrl-W a second time to delete the word aswell. This is not how I'm used > to it working in vim or on the command line. I've now merged this into next. I forgot to put the patches in email last night, so I've put the branch diff at the end of this email. Hamish Downer diff --git a/lib/sup/textfield.rb b/lib/sup/textfield.rb index a3d002a..343e450 100644 --- a/lib/sup/textfield.rb +++ b/lib/sup/textfield.rb @@ -120,6 +120,9 @@ class TextField nop Ncurses::Form::REQ_BEG_FIELD when ?\C-w.ord + while action = remove_extra_space + Ncurses::Form.form_driver @form, action + end Ncurses::Form.form_driver @form, Ncurses::Form::REQ_PREV_CHAR Ncurses::Form.form_driver @form, Ncurses::Form::REQ_DEL_WORD when Ncurses::KEY_UP, Ncurses::KEY_DOWN @@ -167,6 +170,40 @@ private end end + def remove_extra_space + return nil unless @field + + Ncurses::Form.form_driver @form, Ncurses::Form::REQ_VALIDATION + x = Ncurses.curx + v = @field.field_buffer(0).gsub(/^\s+|\s+$/, "") + v_index = x - @question.length + + # at start of line + if v_index < 1 + nil + ## cursor <= end of text + elsif v_index < v.length + # is the character before the cursor a space? + if v[v_index-1] == ?\s + # if there is a non-space char under cursor then go back + if v[v_index] != ?\s + Ncurses::Form::REQ_PREV_CHAR + # otherwise delete the space + else + Ncurses::Form::REQ_DEL_PREV + end + else + nil + end + elsif v_index == v.length + # at end of string, with non-space before us + nil + else + # trailing spaces + Ncurses::Form::REQ_PREV_CHAR + end + end + def set_cursed_value v @field.set_field_buffer 0, v end _______________________________________________ Sup-devel mailing list Sup-devel@rubyforge.org http://rubyforge.org/mailman/listinfo/sup-devel