SublimeANSI icon indicating copy to clipboard operation
SublimeANSI copied to clipboard

Edit text in ansi view

Open jakkubu opened this issue 8 years ago • 3 comments

What do you think about adding editing possibilities to ANSI view?

The biggest issue is to change view back to plain text, since now it's done by simply reverting history.

jakkubu avatar Apr 16 '16 18:04 jakkubu

@jakkubu Actually I have played around with this idea in the past; effectively we want to "hide" the ansi escape codes rather than delete them. Unfortunately I wasn't able to get the sublime.HIDDEN region option to work as I was hoping; is seem to hide only the formatting applied to the escape codes, not the the actual escape code themselves.

Another option is to use view.fold(region) to hide the escape codes. This does actually work, however replaces the escape codes with the fold icon; maybe we could disable the fold marker somehow?

matt1003 avatar Apr 18 '16 22:04 matt1003

@matt1003 yeah, I also was playing with this. There are couple options:

  1. Parse regions to codes.
  2. Save the codes in region key
  3. Save codes somewhere else
  4. Make two syntax - ANSI reader and ANSI editor with folded regions.

As I understand ANSI colour codes don't require to have first BG or FG, which means that two sequences may produce the same colour output. This means that after parsing colour (1st option) back to codes we may have different file. Which is unexpected for user.

For 2nd option we can use region key as holder of exact code. This solves above issue, but we still are loosing codes after restarting sublime.

The 4th option solves the problem with codes lost after restart for editor syntax. However it doesn't look good.

So I think that there are two nice options, but I don't figure out how to implement them:

  • hide fold icon (as you suggested)
  • save regions for sublime restart and use key as exact ANSI code holder

jakkubu avatar Apr 19 '16 09:04 jakkubu

You can do this just by creating this keybind:

[
    {
      "keys": ["ctrl+f5"],
      "command": "ansi"
    },
]

evandrocoan avatar Jul 10 '19 22:07 evandrocoan