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

Feat: Undercurl #1390

Closed
benjamin-kirkbride opened this issue Jul 18, 2023 · 11 comments
Closed

Feat: Undercurl #1390

benjamin-kirkbride opened this issue Jul 18, 2023 · 11 comments

Comments

@benjamin-kirkbride
Copy link
Contributor

An undercurl is a type of styling applied to text or code to signify a particular state or issue. It's often used to highlight syntax errors, warnings, or typos in your code. It's typically represented as a wavy line, similar to a curly underline, beneath the code or text.

For instance, if you've made a syntax mistake in your code, the IDE might display an undercurl beneath the problematic section to alert you to the issue. The color of the undercurl could vary to indicate the severity of the issue, with red typically used for errors, and yellow for warnings.

Hovering the mouse cursor on undercurled text will show a tooltip with information and possibly buttons/links that can be clicked.

This is a very helpful feature, because it assists programmers in detecting defects in the early stages, allowing them to resolve problems during coding without having to first execute the code to discover the issues.

Linters are what provide undercurl and can specifically include:

  • spellcheckers / grammar checkers
  • type checkers
  • syntax error detection
  • too-long-line detection

In VSCode, it looks like this:
image

Things to note:

  • the first two lines are distinct linters showing essentially the same issue, but playing nicely together
  • the same tooltip "modal" that displays intellisense also shows the cause of the undercurl

It is unclear if and to what extent tkinter supports undercurl:

https://stackoverflow.com/questions/65437742/how-to-do-custom-underlining-in-tkinter-text-widgets

https://stackoverflow.com/questions/61506470/is-it-possible-to-have-a-red-squiggly-line-appear-under-words-in-a-tkinter-text/61604625#61604625

@rdbende
Copy link
Collaborator

rdbende commented Jul 18, 2023

I'm not sure if you're aware of it, or this is a different feature, but Porcupine already has support for underlines, if you enable the underlines plugin. The urls plugin uses it to underline clickable links in the code, and the langserver plugin to show the location of errors/warnings returned by flake8 for example, and it also provides such tooltips on hover.

image
image

Can't capture the hover tooltips for some reason.


As for the squiggly line, I tried to implement it once with a bitmap as bgstipple, but it's a hack, and it had all kinds of problems when selecting text.

@benjamin-kirkbride
Copy link
Contributor Author

Gotcha, I haven't used Porcupine with a version of Python that works with the langserver 😅 (#1300)

I would like to be able to register arbitrary linters to use the underline feature, and also to have them automatically refresh on save (also autoformat on save).

Some of this will likely come with #1342

@rdbende
Copy link
Collaborator

rdbende commented Jul 18, 2023

Gotcha, I haven't used Porcupine with a version of Python that works with the langserver 😅 (#1300)

I downgraded my Porcupine venv just because of that :))

@Moosems
Copy link
Contributor

Moosems commented Jul 18, 2023

The way this look would be done is through bgstipple's and though they are supported on Windows and Linux, they are very much not supported on Mac. I remember someone once make a TIP on the Tcl/Tk to add it and had been working on it but it hasn't received any attention in quite some time.

@Moosems
Copy link
Contributor

Moosems commented Jul 18, 2023

Gotcha, I haven't used Porcupine with a version of Python that works with the langserver 😅 (#1300)

What Python version are you using 🙂?

@benjamin-kirkbride
Copy link
Contributor Author

3.11

@Moosems
Copy link
Contributor

Moosems commented Jul 18, 2023

Does 3.11 not work with the langserver? I use 3.11 too.

@benjamin-kirkbride
Copy link
Contributor Author

#1300

@Moosems
Copy link
Contributor

Moosems commented Jul 18, 2023

image

Why is the underline cut off by the long line marker 😄?

@rdbende
Copy link
Collaborator

rdbende commented Jul 18, 2023

Why is the underline cut off by the long line marker 😄?

That underline is the too long line warning that flake8 outputs

What Python version are you using 🙂?

I use 3.11 too, but I also have 3.8, 3.9 and 3.10 installed. I use Porcupine in a 3.10 venv.

@Akuli
Copy link
Owner

Akuli commented Jul 19, 2023

I would like to be able to register arbitrary linters to use the underline feature...

Already supported.

...and also to have them automatically refresh on save (also autoformat on save).

This too is already possible (search for <<BeforeSave>> / <<AfterSave>>), though it has nothing to do with squiggles/underlines and IMO shouldn't have anything to do with them. For example, langservers usually refresh whenever they're ready, regardless of whether the file is saved or not.

As for the squiggly line, I tried to implement it once

I have tried it too and it was a similar experience. I had trouble changing the color of the squiggle.

Since everyone has had trouble with implementing squiggles, I think there's nothing we can really do here :)

@Akuli Akuli closed this as not planned Won't fix, can't repro, duplicate, stale Jul 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants