GCIC search/replace algorithm

Mike Stramba <[email protected]>
Newsgroups gmane.comp.emulators.hercules390.vm
Message-ID <[email protected]>
Roc,

I have no experience in writing an editor, and haven't looked at your
editor code yet .. :)

But maybe my ideas will spark further discussion / thoughts.

You also didn't mention *undo*  :) ....  a feature that eventually
would be very nice ;), again I haven't looked at your code, so don't
know if what I propose below is already implemented.

Any editing of the file now (insert delete .. etc), can already be
looked at as sort of a "search / replace", and if that's the case,
then adding a REP(LACE) command might be easy(ier).

My idea is to maintain a linked list or other table where any changes
to the file are kept, regardless of search / replace .. user input ..
DD, CC .. MM .. whatever.

Then the display is updated with a combination of the original buffer
/ file and any changes that have occured at the current displayed
position.

Sounds complex, even as I write the description ;)

A look through Source forge .. other public source for editors, might
yield some other ideas

Mike


On 8/8/10, Rocky <[email protected]> wrote:
>
> Need an algorythm for the search/replace routine.
>
> Anybody have any experience with this or a well thought out sugestion.
>
> Issue is:
>
> We probably need a trunc command to tell us where to stop shifting
> We need to know what to do if we find an impossibe situation
>
> My ideas is
>
> String2 replaces string1
>
> If string 2 is shorter than string1 than pad with blanks and don't touch
> anything else in the record.
>
> Same if string2 is equal in length to string1 without the padding
>
> If string 2 is greater it begins to get complicated.
>
> My thoughts are:
>
> If there are enough blanks immediately adjacent then use them as long as you
> leave at least one blank
>
> if not enough blanks then find the first place that there are two  blanks to
> the right of the insert and shift up to 1 blank and then continue.
>
> Cannot eliminate blanks that are between Quotes "" or ' '
> Cannot shift past the trunc setting
>
> that is sort of the idea that I have but does anybody have some serious
> thoughts on how to do this, or what the proper algorytm should be.
>
> Not a simple routine. The things we take for granted in x-edit or ispf edit
> are not all that simple.
>
> What is the proper logic?  Not the kind of routine that I want to write more
> than once.
>
> Roc
>
>
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.