nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nano-devel] The undo feature


From: Erik Lundin
Subject: Re: [Nano-devel] The undo feature
Date: Wed, 29 Oct 2014 18:02:36 +0100

> Erik,
> 
> You must be overlooking the while loops in do_redo and do_undo for the
> cases SPLIT_BEGIN and SPLIT_END.  If the position of the linked list
> of undo objects ends up in the middle of SPLIT_BEGIN and SPLIT_END
> then something terrible has gone wrong.  The scenario will not happen,
> you do not need to worry about this.
> 
> You only need to create an undo type for your function. something
> similar to the SPLIT_BEGIN and SPIT_END pair.  You can then string
> together functions that have already been developed and tested.
> 
> --Mark Majeres

Mark, 

Following your suggestions on the whitespace to tabs function on 5 rows
that each have 16 spaces would look like this:
 
SPLIT_BEGIN
16x UNDO(DEL)
1x UNDO(ADD)
16x UNDO(DEL)
1x UNDO(ADD)
16x UNDO(DEL)
1x UNDO(ADD)
16x UNDO(DEL)
1x UNDO(ADD)
16x UNDO(DEL)
1x UNDO(ADD)
SPLIT_END
 
The deletion and addition of data is in this case linked to a single
change. There has to be even more markers to mark where one change
begins and ends and where the set starts and ends. I don't think this is
the optimal way of doing this.
 
Another example is the search+replace all with newlines (which i think
it should support).
 
The text:
1. foo bar foo
2. foo bar foo
3. foo bar foo
4. foo bar foo
5. foo bar foo
 
If you search for "bar" and replace it with "\nthis\nis\nnewlines\n",
there would have to be a lot of complicated calculations on where the
add_undo(ENTER) should be placed etc. And what about search+replace with
submatches? Example: Replace "([a-z])(ar)" with "\n$1\ngo$2\n\n"

-- 
Erik Lundin <address@hidden>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]