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 strikethrough/underdouble/underdashed/underdotted styles #1287

Merged
merged 1 commit into from
Sep 15, 2022

Conversation

ychin
Copy link
Member

@ychin ychin commented Sep 15, 2022

Add support for all the missing text styles for MacVim for Vim parity.

For strikethrough, this needed to be done as a second pass to make sure they get drawn on top of the text. This is necessary because currently the logic buffers texts up before dispatching them later in a line, so it's just easier to loop through the line a second time if we detected strikethrough. For the strikethrough position, we simply use the half of xheight which seems to work best in looking good.

For underdouble, the logic is a little tricky because sometimes we don't have space below the line. When that's the case, simply draw the second line on top of the first line.

For underdotted, need to do something smart to space out the dots. When the width is divisible by 2, they get spaced out evenly. If they are not, try to make it work if divisible by 3. If that's not the case, we just readjust the size of dot/gap a little bit to make it fit, even though now we have non-integer sizes (from experimentation, the antialising works well enough that it's not too jarring).

Also fix rendering of undercurl to work for double-width characters as well.

Note that underdouble/underdotted/underdashed are not supported in regular gVim yet, and so I had to add the ifdef for those in gui.c. These may cause merge conflicts later which should be easily resolved.

Known issue 1: Note that currently underline is not respecting the font's underline thickness and position. We always use a thickness of 1 pt, and hard-code a 0.4*descent position, which are not great. Thickness in particular should scale with the font size. They should be fixed in a future commit.

Known issue 2: There are some current clipping bugs in the renderer. This is because the line height returned by NSLayoutManager is sometimes smaller than ascent+descent+leading, and MMCoreTextView for some reason takes the ceil(descent) (presumably to make the rendering grid-aligned). This should be fixed later.

Fix #1034

Add support for all the missing text styles for MacVim for Vim parity.

For strikethrough, this needed to be done as a second pass to make sure
they get drawn on top of the text. This is necessary because currently
the logic buffers texts up before dispatching them later in a line, so
it's just easier to loop through the line a second time if we detected
strikethrough. For the strikethrough position, we simply use the half of
xheight which seems to work best in looking good.

For underdouble, the logic is a little tricky because sometimes we don't
have space below the line. When that's the case, simply draw the second
line on top of the first line.

For underdotted, need to do something smart to space out the dots. When
the width is divisible by 2, they get spaced out evenly. If they are
not, try to make it work if divisible by 3. If that's not the case, we
just readjust the size of dot/gap a little bit to make it fit, even
though now we have non-integer sizes (from experimentation, the
antialising works well enough that it's not too jarring).

Also fix rendering of undercurl to work for double-width characters as
well.

Note that underdouble/underdotted/underdashed are not supported in
regular gVim yet, and so I had to add the ifdef for those in gui.c.
These may cause merge conflicts later which should be easily resolved.

Known issue 1: Note that currently underline is not respecting the
font's underline thickness and position. We always use a thickness of 1
pt, and hard-code a 0.4*descent position, which are not great. Thickness
in particular should scale with the font size. They should be fixed in a
future commit.

Known issue 2: There are some current clipping bugs in the renderer.
This is because the line height returned by NSLayoutManager is sometimes
smaller than ascent+descent+leading, *and* MMCoreTextView for some
reason takes the `ceil(descent)` (presumably to make the rendering
grid-aligned). This should be fixed later.

Fix macvim-dev#1034
@ychin ychin added Renderer Text rendering issues, including CoreText renderer Vim Parity Issues related to MacVim support of core Vim features. labels Sep 15, 2022
@ychin ychin added this to the Release 174 milestone Sep 15, 2022
@ychin ychin merged commit fa37c18 into macvim-dev:master Sep 15, 2022
@ychin ychin deleted the support-strikethrough branch September 15, 2022 04:07
ychin added a commit that referenced this pull request Sep 15, 2022
Updated to Vim 9.0.472.

Announcements
====================

Sponsors
--------------------

MacVim now allows you to sponsor the team! Any amount would be
appreciated and it is of course optional. See the announcement (#1271)
for more details.

Supporting old versions of macOS (10.12 or below)
--------------------

Currently, macOS supports macOS 10.9 or above. However, this is getting
harder to do so as time goes on (e.g. the latest Xcode doesn't support
building for it). In the near future, MacVim will mostly target 10.13
(High Sierra) or above, with 10.9 - 10.12 as legacy support. Visit this
discussion (#1288) if you would be affected and would like to know more.

Features
====================

Resizing MacVim new options
--------------------

You can now smoothly drag and resize MacVim without having it
constrained to fixed multiples of the text size, by setting the
"Smoothly resizes window" under General preference pane. This also
allows MacVim to behave better when used with third-party tools (e.g.
BetterSnapTool) to snap it to one side of the screen. #1276

The command line can now be pinned to the bottom of the window with a
setting (under Appearance preference pane). This makes it look better
aligned when using smooth resizing, or in other situations where the
window size is not a direct multiples of Vim's text size (e.g. full
screen or guioption+=k). #1280

New supported text styles
--------------------

Vim highlight groups `strikethrough`, `underdouble`, `underdotted`,
`underdashed` are now supported. #1287

New Vim features
--------------------

Virtual text allows you to place custom texts to be displayed inline for
diagnostic information and more (e.g. build errors, CSS color preview).
See `:help virtual-text` for more information.

The default color schemes (e.g. desert) are now fixed to look correct
again.

Misc options and commands:
- `set nosplitscroll` lets you preserve the windows' scroll positions
  when splitting. (v9.0.0445)
- `:defer` allows you to clean up in a function. (v9.0.0370)
- `:echowindow` allows you to echo a message to a floating popup message
  window instead of to the command line. (v9.0.0321)

Fixes
====================

- Fixed non-native full screen not working well with the notch on newer
  MacBook's when set to not show menu bar. You can also use
  `MMNonNativeFullScreenSafeAreaBehavior` to force MacVim to use the
  notch area as well if you don't mind some content being obscured. #1261
- Fixed bad interaction when two settings ("Open untitled window: never"
  and "After last window closes: Quit MacVim") are set together. #1257
- Fixed the bundled Vim tutor not working when launching from the Help
  menu #1265.
- Fix crashing on launch under macOS 10.9. #1212
- Fixed potential crash when switching appearance mode in MacVim
  preferences. #1270
- Korean localized menus no longer throw a syntax error on launch. #1278
- `did_install_default_menus` should work in MacVim now. #1267

General
====================

Sparkle (updater for MacVim) is now updated to 1.27.1 (#1284), and we no
longer use DSA keys for signing updates (#1285) as we are using EdDSA
already.

Scripting
====================

- Scripting languages versions:
    - Python is now built against 3.10, up from 3.9.

Compatibility
====================

Requires macOS 10.9 or above.

Script interfaces have compatibility with these versions:

- Lua 5.4
- Perl 5.18
- Python2 2.7
- Python3 3.10
- Ruby 3.1
ychin added a commit to ychin/macvim that referenced this pull request Sep 28, 2022
This was previously broken by macvim-dev#1287 as I did not update the new
constants' values.

Fix macvim-dev#1296
ychin added a commit to ychin/macvim that referenced this pull request Sep 28, 2022
This was previously broken by macvim-dev#1287 as I did not update the new
constants' values.

Also, make strikethrough work in it.

The non-CoreText renderer is essentially deprecated and will be removed
in near future, but for now just fix up the straggling bugs since this
is easy to do so.

Fix macvim-dev#1296
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Renderer Text rendering issues, including CoreText renderer Vim Parity Issues related to MacVim support of core Vim features.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Highlight feature "gui=strikethrough" does not display strikethrough text.
1 participant