Page 1 of 1

Is this possible in a plugin?

Posted: Fri 28 Mar, 2014 07:37
by pepak
Hi! I would like to provide some functionality in my plugins, but I rather suspect they are impossible to implement without writing a completely new FAR editor. But perhaps someone can suggest a way which would make this possible:

1) Virtual wrap: The plugin AutoWrap makes it possible to wrap lines at a certain column, but it does it by inserting a hard EOL in the file. I would prefer a virtual wrap, where the lines are only wrapped for "visual purposes" but in fact the existence or non-existence of the wrap does not change the file itself. The only way I can think of would be marking a line as "continuing" or "normal", and then at EE_CLOSE (or possibly EE_SAVE) reinterpreting the file according to the flag. But there doesn't seem any way to add a user-defined flag to a particular line. Or is there?

2) Filter: I would like to be able to choose a (possibly non-continuous) selection of lines and only display these lines in the editor. The user could make any changes he liked with them, then exit the filter mode and the lines would be applied to the original file. I could probably do that by opening a new editor with just the selected lines, then on close of this new editor the selected lines would be deleted in the old editor and the lines from the new editor would be added to the old one. But that seems rather ugly, with a great possibility of failure. Am I overlooking something?

Thanks.

Re: Is this possible in a plugin?

Posted: Fri 28 Mar, 2014 12:03
by HaRT
Virtual wrap and code folding are among most wanted features missing from the internal editor and were requested/discussed in the Russian part of the forum multiple times. Unfortunately, they are extremely hard to fit into the existing implementation.

I don't know if one can attach arbitrary user data to an editor string easily in order to analyze it upon saving but I have two ideas:
A. FAR1 used to have 4 EOL types: Dos/Windows (CR LF), Unix (LF), Mac (CR) and Undefined. The latter was being used when plugins (e.g. ExeFilt) inserted lines and didn't care which type of EOL to use. One could use Visualizer to see those. If it's the same in FAR3, a virtual wrap plugin could potentially use those Undefined EOLs to mark virtual linebreaks.
B. In a regular situation any editor plugin can setup color regions for any parts of text. Potentially, those can be (ab)used as arbitrary custom data containers.
8)

Re: Is this possible in a plugin?

Posted: Fri 28 Mar, 2014 12:09
by pepak
I will certainly look into the color regions. That could possibly work, if Colorer doesn't interfere.

Re: Is this possible in a plugin?

Posted: Fri 28 Mar, 2014 12:27
by HaRT
pepak wrote:I will certainly look into the color regions. That could possibly work, if Colorer doesn't interfere.
In FAR3 coloring plugins don't interfere.
How are you going to prevent color changes resulting from your custom data?

BTW, if FAR3 still supports Undefined EOLs, they would be very nice for virtual wrap, as we're getting their visualization for free.
On the other hand, it you succeed in using the color regions, you might easily (and optionally) highlight those line-breaks yourself.

Re: Is this possible in a plugin?

Posted: Fri 28 Mar, 2014 12:40
by pepak
HaRT wrote:How are you going to prevent color changes resulting from your custom data?
I will know, or possibly give up, after I study the coloring options in the documentation.

Re: Is this possible in a plugin?

Posted: Sat 29 Mar, 2014 09:18
by ccaid
1) there IS the plugin: EditWrap
discussion was in Russian part of the forum. this plugin is not ideal but it's better than nothing. it's a far2 plugin so needed Far3Wrap to be used under far3