Angus Leeming wrote: > Alfredo Braunstein wrote: > >> John Levon wrote: >> >>> On Thu, Oct 30, 2003 at 01:08:25PM +0100, Alfredo Braunstein wrote: >>> >>>> In which situations you think we need it to remain valid? >>> >>> I don't understand. Clearly, search and replace, spellcheck, merge >>> changes all need a static iterator position whilst things change >>> around them ... >> >> >> Is not "around", you know exactly *where*, don't you?. >> >> I.e for instance, if you replace the selection (a pair of >> "PosIterators" or Cursors), the first one remains valid and that's >> all we need. (that includes S&R and spellcheck) >> >> In general: put an iterator in the first position of your mangling, >> and that will remain valid... >> >> [Btw, this is AndrÃ's argument IIUC] > > Help me through this, I'm getting confused. Here is my document: > > "The quick brown fox jumped over the |lazy dog." > > The position of the global cursor is indicated by '|'. Internally, I > imagine that this cursor contains a (valid) PosIterator. > > I wish to find "brown": > PosIterator pos = search_for(buffer, "brown"); > > I now wish to replace "brown" with "red". How do I do so to ensure > that the global cursor remains valid?
AndrÃ's solution is to modify only things under the global cursor. I.e, before the change put the global cursor in "pos", and then change "lazy" into "brown". The global cursor will remain valid, pointing to the "b" in brown. Alfredo