Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support coloring with multiline span #6

Closed
apstndb opened this issue Jan 19, 2025 · 4 comments
Closed

Support coloring with multiline span #6

apstndb opened this issue Jan 19, 2025 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@apstndb
Copy link

apstndb commented Jan 19, 2025

AFAIU, readline.Highlight is applied as per-line basis.

go-multiline-ny/main.go

Lines 399 to 403 in bb1bd51

colSeq := highlightToColoring(
m.lines[i],
m.LineEditor.ResetColor,
m.LineEditor.DefaultColor,
m.LineEditor.Highlight)

But, there is a syntax like multiline comments and multiline literals.(This examples uses ```...``` as multiline string literal, and /* ... */ as multiline comment)

Image
  • FindAllStringIndex() method only receives a single line, so multiline pattern won't be matched.
  • Some times, coloring will be broken.

Of course, I know using multi-line patterns in readline is a rare case and difficult to implement, but ideally I'd be happy if go-multiline-ny supported it.

@hymkor hymkor self-assigned this Jan 19, 2025
@hymkor hymkor added the enhancement New feature or request label Jan 19, 2025
@hymkor
Copy link
Owner

hymkor commented Jan 19, 2025

Thank you for trying the new feature so quickly.

But, there is a syntax like multiline comments and multiline literals

I understand your concern. However, it is difficult to implement it right away, because there are some technical challenges, and I currently have no clear ideas on how to solve them.

Therefore, I will treat it as a long-term task. I hope you don't mind waiting for a while.

@apstndb
Copy link
Author

apstndb commented Jan 20, 2025

Thank you for replying!

It is sufficient that it has been filed as an open issue, so it is fine if it takes a long time to resolve as it is a long term issue.

@hymkor
Copy link
Owner

hymkor commented Jan 21, 2025

In Release v0.19.0 · hymkor/go-multiline-ny, multi-line syntax highlighting to allow color changes across line boundaries is supported.

This feature is enabled with updating update the code to assign values to the fields as shown below

  • var ed multiline
  • ed.LineEditor.Highlight = ... to ed.Highlight = ...
  • ed.LineEditor.ResetColor = ... to ed.ResetColor = ...
  • ed.LineEditor.DefaultColor = ... to ed.DefaultColor = ...

(*Editor).Read creates new instances by wrapping those in ed.Highlight with its internal class and sets them into ed.LineEditor.Highlight.

Image

Since it is difficult to handle regions enclosed by """ and " simultaneously using regular expressions alone, I am using ```instead of """. I believe this issue can be resolved in your client (spanner-mycli) since it uses a customized type instead of regular expressions.

The source file of the example is https://github.com/hymkor/go-multiline-ny/blob/fa092b68055ea896fee0bf81768a148ac760b8f2/examples/example.go

@apstndb
Copy link
Author

apstndb commented Jan 22, 2025

Thank you for fast fixing!
I tried the update and it seems to work fine!

@apstndb apstndb closed this as completed Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants