[comp.windows.x] xedit is brain-damaged

gustav@arp.anu.oz.au (Zdzislaw Meglicki) (02/01/90)

Xedit's search and replace function is brain-damaged and can lead
to a disaster. This is what has happened to one of my users.
While working on a TeX document he found that instead of using
\~ he has used just ~ in several places. He therefore typed CTRL-S
to get the search-replace window and asked xedit to search for ~ and
replace it with \~. Xedit then did the following thing: it would
find the first occurrence of ~, then it would convert it to \~,
then it would position the insert cursor in front of \~, would find
~ again (the same one!), would put a second \ in front of ~, and
so ad infinitum. No way to stop the stupid thing without killing
the window! The solution is, of course, to make sure that the insert
point is placed after the replaced string, not in front of it.
If anyone has a quick fix to this one, please, reply to the net
and/or to:

	gustav@arp.anu.oz.au
	Gustav Meglicki, Automated Reasoning Project,
	The Australian National University,
	GPO Box 4, Canberra, ACT, 2601, Australia

kit@EXPO.LCS.MIT.EDU (Chris D. Peterson) (02/02/90)

Brain damaged?  Perhaps a bit buggy, but brain damaged? :-)

>  Xedit then did the following thing: it would
> find the first occurrence of ~, then it would convert it to \~,
> then it would position the insert cursor in front of \~, would find
> ~ again (the same one!), would put a second \ in front of ~, and
> so ad infinitum.

In any case, you have found a real bug in the Text widget, here is an
"unofficial" patch to ``lib/Xaw/TextPop.c'' that will solve your problem.


						Chris D. Peterson     
						MIT X Consortium 

Net:	 kit@expo.lcs.mit.edu
Phone:   (617) 253 - 9608	
Address: MIT - Room NE43-213

-----  cut here  -----------

*** /tmp/,RCSt1002877       Thu Feb  1 16:19:51 1990
--- lib/Xaw/TextPop.c Thu Feb  1 15:38:27 1990
***************
*** 949,954
        return(FALSE);
      }

      if (once_only)
        if (show_current)
      break;

--- 949,959 -----
        return(FALSE);
      }

+     if (dir == XawsdRight)
+       XawTextSetInsertionPoint( tw, pos + replace.length);
+     else
+       XawTextSetInsertionPoint( tw, pos);
+
      if (once_only)
        if (show_current)
      break;
***************
*** 958,968
        }
      count++;
    }
-
-   if (dir == XawsdRight)
-     XawTextSetInsertionPoint( tw, pos + replace.length);
-   else
-     XawTextSetInsertionPoint( tw, pos);

    if (replace.length == 0)
      XawTextUnsetSelection(tw);

--- 963,968 -----
        }
      count++;
    }

    if (replace.length == 0)
      XawTextUnsetSelection(tw);