nano-devel
[Top][All Lists]
Advanced

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

Re: [Nano-devel] [PATCH] Pipe selected text to external tool


From: David Ramsey
Subject: Re: [Nano-devel] [PATCH] Pipe selected text to external tool
Date: Sun, 18 Feb 2018 12:34:24 -0600

Marco Diego Aurélio Mesquita:
> So, is it better to introduce a new undo type?
>
> Can you give some hints/tips/advice on how to do it?

I can help you with what I know of the existing code regarding undo
types or other things, but, keep in mind, I don't understand the undo
code all that well.  Adding undo support to indent/unindent was the most
complex thing I did with it.  And what code I added was very much
modeled after the already existing undo support for comment/uncomment,
which mostly did what I needed (adding or removing text from every line
in a block of text).

The code for undoing indent/unindent is close to what's needed (more so
than undoing comment/uncomment, because it doesn't have to deal with the
PREFLIGHT undo type), but won't actually work here in one important
aspect: it assumes that the number of lines in the block of text will
remain the same even after the lines are changed.  In the case of piping
selected text or justifying/unjustifying, there's no guarantee of this.

> From what I see in do_cut_text_void, it looks like it is possible to
> remove text without disturbing undo. The read_file function has a
> parameter specific to not disturb undo. How should the new undo type
> be implemented? Should a add_undo be called before removing text and
> update_undo after insertion or should there be an intermediate update
> between both calls?

Hmmm.  I'll have to think about it.  Still, since you've mentioned
read_file(), there's another bit of existing code similar to what you're
trying to do, that involves using read_file() indirectly.

Look in text.c's do_alt_speller(), when the user runs the alternate
spell checker on selected text.  The original text is piped to a
temporary file, the file is run through the alternate spell checker, the
original selected text is thrown out, and the spell-checked file is
inserted in the same place.  Note, however, that alternate spell-check
in all forms is impossible to undo, so if you were using this code as a
base, you'd have to add it (which is why I didn't bring it up before; it
leads to the same original problem).



reply via email to

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