From patchwork Sun Jul 23 23:37:17 2006 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Udo Richter X-Patchwork-Id: 12362 Received: from mail.gmx.net ([213.165.64.21]) by www.linuxtv.org with smtp (Exim 4.50) id 1G4nY5-0007g5-IJ for vdr@linuxtv.org; Mon, 24 Jul 2006 01:39:49 +0200 Received: (qmail invoked by alias); 23 Jul 2006 23:39:19 -0000 Received: from p548A3FD4.dip0.t-ipconnect.de (EHLO [192.168.73.1]) [84.138.63.212] by mail.gmx.net (mp020) with SMTP; 24 Jul 2006 01:39:19 +0200 X-Authenticated: #1417946 Message-ID: <44C4082D.1070201@gmx.de> Date: Mon, 24 Jul 2006 01:37:17 +0200 From: Udo Richter User-Agent: Thunderbird 2.0a1 (Windows/20060722) MIME-Version: 1.0 To: VDR Mailing List X-Y-GMX-Trusted: 0 Subject: [vdr] [Patch] Cannot delete last char in insert mode X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: VDR Mailing List List-Id: VDR Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 23 Jul 2006 23:39:49 -0000 Status: O X-Status: X-Keywords: X-UID: 10198 Hi list, I've fixed a small editing bug: For menu string edit items, when in insert mode, its impossible to delete the last character of the string. Steps to reproduce: - Go into some edit field: [A]BCDEF - Switch to insert mode : []ABCDEF - Move into the string : ABC[]DEF - Press yellow key : ABC[]EF - Press yellow key : ABC[]F - Press yellow key : ABC[]F - nothing happens. This doesn't happen if you move the cursor to the end once, as this will insert a blind space: ABCDEF[]_ The attached patch fixes this in one possible way: It deletes the last char, but keeps the cursor position by inserting a whitespace: ABC[]F -> ABC[]_ Without the whitespace, the cursor would have to move in an ugly way: ABC[]F -> AB[]C -> A[]B -> []A -> []_ The implementation requires another quirk: To do the delete-towards-left at the end of the string, just as the overwrite mode does, the delete key behaves differently if it deletes a final whitespace: Instead of deleting the whitespace, the second last char is deleted: ABC[]F -> ABC[]_ -> AB[]_ -> A[]_ -> []_ Cheers, Udo --- vdr-1.4.1-2-orig/menuitems.c 2006-07-24 00:24:25.176897944 +0200 +++ vdr-1.4.1/menuitems.c 2006-07-24 01:19:52.383818056 +0200 @@ -395,6 +399,16 @@ if (strlen(value) > 1) { if (!insert || pos < int(strlen(value)) - 1) memmove(value + pos, value + pos + 1, strlen(value) - pos); + else if (insert && pos == int(strlen(value)) - 1) { + // in insert mode, deleting the last char replaces it with whitespace to keep cursor pos + if (value[pos] != ' ' || pos < 1) + value[pos] = ' '; + else { + // unless the last char is already a whitespace + value[pos-1] = ' '; + value[pos] = 0; + } + } // reduce position, if we removed the last character if (pos == int(strlen(value))) pos--;