[1156] in BarnOwl Developers

home help back first fref pref prev next nref lref last post

[D-O-H] r1103 - trunk/owl

daemon@ATHENA.MIT.EDU (nelhage@MIT.EDU)
Thu Oct 29 18:13:36 2009

Resent-From: nelhage@mit.edu
Resent-To: barnowl-dev-mtg@charon.mit.edu
X-Original-To: nelhage@nelhage.com
To: dirty-owl-hackers@MIT.EDU
From: nelhage@MIT.EDU
Reply-to: dirty-owl-hackers@MIT.EDU
Date: Wed, 20 Aug 2008 02:16:30 -0400 (EDT)

Author: nelhage
Date: 2008-08-20 02:16:30 -0400 (Wed, 20 Aug 2008)
New Revision: 1103

Modified:
   trunk/owl/editwin.c
Log:
editwin.c: Don't make owl_editwin_insert_char increase e->bufflen twice

This seems to fix at least some cases of the editwin becoming confused
and causing text entry to not work quite right (often manifesting as a
trailing '.' on a line by itself not sending a zephyr)


Modified: trunk/owl/editwin.c
===================================================================
--- trunk/owl/editwin.c	2008-08-10 21:38:44 UTC (rev 1102)
+++ trunk/owl/editwin.c	2008-08-20 06:16:30 UTC (rev 1103)
@@ -329,18 +329,22 @@
 void _owl_editwin_insert_bytes(owl_editwin *e, int n) /*noproto*/
 {
   int i, z;
-  
+
   if ((e->bufflen + n) > (e->allocated - 5)) {
     _owl_editwin_addspace(e);
   }
 
-  e->bufflen += n;
-  e->buff[e->bufflen] = '\0';
-  
   z = _owl_editwin_get_index_from_xy(e);
-  for (i = e->bufflen - 1; i > z; i--) {
-    e->buff[i] = e->buff[i - n];
+
+  if(z != e->bufflen) {
+    for (i = e->bufflen + n - 1; i > z; i--) {
+      e->buff[i] = e->buff[i - n];
+    }
   }
+
+  e->bufflen += n;
+  e->buff[e->bufflen] = '\0';
+
 }
 
 
@@ -425,19 +429,13 @@
   }
 
   /* shift all the other characters right */
-  if (z != e->bufflen) {
-    _owl_editwin_insert_bytes(e, len);
-  }
+  _owl_editwin_insert_bytes(e, len);
 
   /* insert the new character */
   for(i = 0; i < len; i++) {
     e->buff[z + i] = tmp[i];
   }
 
-  /* housekeeping */
-  e->bufflen += len;
-  e->buff[e->bufflen] = '\0';
-  
   /* advance the cursor */
   z += len;
   _owl_editwin_set_xy_by_index(e, z);


home help back first fref pref prev next nref lref last post