pyscripter / SynEdit

SynEdit is a syntax highlighting edit control, not based on the Windows common controls.
26 stars 11 forks source link

Finer control of special chars shown. #89

Closed pyscripter closed 4 months ago

pyscripter commented 4 months ago

Currently when eoShowSpecialChars is in Options, SynEdit shows whitespace (space + Tabs), control characters and EOL symbols. I personally do not find the EOL symbols useful. The proposal is to have finer control over what is drawn. This involves,

  1. Dropping the option eoShowSpecialChars
  2. Introducing a new property VisibleSpecialChars
type
  TSynSpecialChars = (scWhitespace, scControlChars, scEOL);
  TSynVisibleSpecialChars = set of TSynSpecialChars;

  property VisibleSpecialChars: TSynVisibleSpecialChars

This is a breaking change

DGH2112 commented 4 months ago

I'm okay with this change.

m-matsubara commented 4 months ago

I thought it was wonderful. But the colors don't seem to be correct in comments or string literals.

image

m-matsubara commented 4 months ago

It seems like the caret is out of place... (Font is Consolas)

image

pyscripter commented 4 months ago

It is up to the highlighter to determine the color. Within code they might be painted with an Error Attribute to indicate a syntax error. In strings and comments they are part of them and should be painted accordingly. Most highlighters consider control characters as whitespace.

pyscripter commented 4 months ago

It seems like the caret is out of place...

I will look into it.

m-matsubara commented 4 months ago

It is up to the highlighter to determine the color. Within code they might be painted with an Error Attribute to indicate a syntax error. In strings and comments they are part of them and should be painted accordingly. Most highlighters consider control characters as whitespace.

got it. To be honest, I think it would be better if control characters were displayed in different colors, but I respect that idea.

pyscripter commented 4 months ago

I have fixed the cursor positioning error in https://github.com/pyscripter/SynEdit/commit/2760affb659b143b9511fed47921a4c1d783847c. Could you please test it.

There is still a slight issue when the font style is [fsBold, fsItalic] and you have many graphical unicode characters (control chars, emojis) on the same line. But this is highly uncommon. I will leave that for another day.