Is this possible in a plugin?

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

Is this possible in a plugin?

Post by pepak » Fri 28 Mar, 2014 07:37

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: 8118
Joined: Tue 30 Aug, 2005 17:21
Location: Санкт-Петербург
Has thanked: 68 times
Been thanked: 107 times

Re: Is this possible in a plugin?

Post by HaRT » Fri 28 Mar, 2014 12:03

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: 330
Joined: Sun 13 Jul, 2008 11:18
Has thanked: 3 times
Been thanked: 9 times

Re: Is this possible in a plugin?

Post by pepak » Fri 28 Mar, 2014 12:09

I will certainly look into the color regions. That could possibly work, if Colorer doesn't interfere.

User avatar
HaRT
Moderator
Posts: 8118
Joined: Tue 30 Aug, 2005 17:21
Location: Санкт-Петербург
Has thanked: 68 times
Been thanked: 107 times

Re: Is this possible in a plugin?

Post by HaRT » Fri 28 Mar, 2014 12:27

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: 330
Joined: Sun 13 Jul, 2008 11:18
Has thanked: 3 times
Been thanked: 9 times

Re: Is this possible in a plugin?

Post by pepak » Fri 28 Mar, 2014 12:40

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: 805
Joined: Fri 12 Jun, 2009 16:04
Has thanked: 9 times
Been thanked: 5 times

Re: Is this possible in a plugin?

Post by ccaid » Sat 29 Mar, 2014 09:18

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”