Is this possible in a plugin?

A place where plug-in developers can share their knowledge and experience.
Post Reply
pepak
Posts: 604
Joined: Sun 13 Jul, 2008 11:18
Has thanked: 17 times
Been thanked: 54 times

Is this possible in a plugin?

Post 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.
User avatar
HaRT
Moderator
Posts: 10822
Joined: Tue 30 Aug, 2005 17:21
Has thanked: 221 times
Been thanked: 358 times

Re: Is this possible in a plugin?

Post 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)
Фар есть инструмент, а не нянька. © 2009 DrKnS
pepak
Posts: 604
Joined: Sun 13 Jul, 2008 11:18
Has thanked: 17 times
Been thanked: 54 times

Re: Is this possible in a plugin?

Post by pepak »

I will certainly look into the color regions. That could possibly work, if Colorer doesn't interfere.
User avatar
HaRT
Moderator
Posts: 10822
Joined: Tue 30 Aug, 2005 17:21
Has thanked: 221 times
Been thanked: 358 times

Re: Is this possible in a plugin?

Post 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.
Фар есть инструмент, а не нянька. © 2009 DrKnS
pepak
Posts: 604
Joined: Sun 13 Jul, 2008 11:18
Has thanked: 17 times
Been thanked: 54 times

Re: Is this possible in a plugin?

Post 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.
ccaid
Posts: 908
Joined: Fri 12 Jun, 2009 16:04
Has thanked: 24 times
Been thanked: 6 times

Re: Is this possible in a plugin?

Post 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
Фар делают добрые люди
Post Reply

Return to “Plug-In Developers”