mihnita / ansi-econsole

Eclipse plugin that understands ANSI escape sequences to color the Eclipse console output.

Home Page:http://www.mihai-nita.net/java/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

copy/paste without escape characters doesn't seem to work anymore

martinlippert opened this issue · comments

Looks like the standard copy feature to quickly pull text from the console view excluding the escape sequences (see #19) doesn't work anymore (as someone reported here: spring-projects/sts4#667)

Tested, confirmed (at least on macOS)

Thanks Martin.

Meantime I've confirmed it on Windows and Linux.
I have a fix, committed.
Will do a release soon.

Awesome, thanks for the quick turnaround, much appreciated.

Any updates on this? Is there already a release available that includes this?

commented

Thank you, Mihai for the awesome plugin and Martin for fixing. Any good news on release date?

commented

As a temporal quick-and-dirty solution until the new version of the plugin is released, I replaced the file AnsiConsolePageParticipant.class in the net.mihai-nita.ansicon.plugin_1.4.4.202102040736.jar inside Eclipse with the new version from the main branch (which contains the fix). Copying without escape sequences does work now.

Tested with Eclipse 2021-06 and 2021-09. Compiled with AdoptOpenJDK-11.0.11+9.
Perhaps can be useful for someone.

Just replace the two jar files inside Eclipse plugins folder with the attached ones: net.mihai-nita.ansicon.plugin_1.4.4.202102040736.patched.zip (extract them from zip since GitHub doesn't support uploading of jar files). Only one file (AnsiConsolePageParticipant) has been replaced in the jars, all others are untouched. The source-jar is just for the sake of completeness.

commented

Hmm... Strange behavior with this patch. Having some output in the Ansi Console and clicking Ctrl+C on a selected text in any other Eclipse view (e.g. code editor, commit details in history) will copy the whole content of the console (or whatever is selected there) into clipboard.

Copying via "Copy" entry from the context menu (as opposed to Ctrl+C shortcut) works properly in other views, but copies with escape characters from Ansi Console.

commented

My next try is to define a CopyWithoutEscapesHandler (analogous to existing CopyWithEscapesHandler but calling AnsiClipboardUtils.textToClipboard() with true parameter to remove escapes) and bind it to the button "Copy text without escapes" on the console toolbar. Not as convenient as using keyboard shortcuts, but at least I can now copy text from console without escapes.

A proper solution from my pov would be intercepting copying operation in the Console (and only there) if the AnsiConsole plugin is activated.

Released

commented

Unfortunately, the copying without escape characters (color codes) is not working in Eclipse 2022-09 (where ANSI Console is a default part of Eclipse). In the plugin v1.4.5 and Eclipse 2022-06, it was nicely working. How can we fix that?

@elab I would recommend to raise this as an enhancement request or bug against https://github.com/eclipse-platform/eclipse.platform.debug

Explaining why this does not work anymore, and the fact that it was intentional, not an accident

When I've integrated this to Eclipse they discovered that some of the things I was doing were not quite OK.
For example I was intercepting the standard copy to do a "copy without escapes"

They argued (fair enough) that people who install this plugin are people interested in it, and care about its features.
They are free to uninstall it if they don't like it.
And it is clear who's at fault :-)

But doing something like that in the standard Eclipse, for everybody, goes against the Eclipse UX guidelines.
(same complaints about other things I was doing, like adding icons on the console toolbar).

All valid, I am not complaining :-)


How to fix it

  1. You can copy using Ctrl+Insert instead of Ctrl+C (Command instead of Ctrl on MacOS)

That hotkey is in fact very old Copy hotkey (still works as Copy in standard OS widgets).

  1. If you want a different hotkey (Ctrl+Shift+C, or whatever) you can configure it

The Enable/Disable and Copy (with/without escapes) are standard Eclipse commands and you can assign whatever hotkeys yoo want.
Preferences -- General -- Keys and search for ANSI.

  1. File a bug / feature request as Martin suggested.

For the default copy behavior discussion during the integration see eclipse-platform/eclipse.platform.debug#57

Reading it again, it was not so much about strictly "don't hijack the standard copy", but mostly a mixture of technical limitations / my lack of knowledge.
The context menu "Copy" in the console didn't show the "Ctrl+C" binding anymore.
And I didn't know how to really replace that command, instead of just "steal the hotkey"

So I don't want to blame it on others...

I expect there will be some fine-tunning for the next few Eclipse versions...
Feedback from users (like you :-) would greatly help with the direction of these changes.