205 Commits

Author SHA1 Message Date
Yee Cheng Chin
644db087e5 Merge remote-tracking branch 'vim/master' 2025-12-31 22:17:11 -08:00
Christian Brabandt
ca12f62d0a patch 9.1.1989: Vim intro screen shows register message
Problem:  Vim intro screen shows register message (after v9.1.1893)
Solution: Remove the register message, registering is no longer useful
          and possible.

fixes:  #18933
closes: #18934

Signed-off-by:
Signed-off-by: Christian Brabandt <cb@256bit.org>
2025-12-16 20:39:31 +01:00
Yee Cheng Chin
70df8b31f3 Merge remote-tracking branch 'vim/master' 2025-08-12 06:43:22 -07:00
Yee Cheng Chin
8f9de4991e patch 9.1.1623: Buffer menu does not handle unicode names correctly
Problem:  Buffer menu does not handle unicode names correctly
          (after v9.1.1622)
Solution: Fix the BMHash() function (Yee Cheng Chin)

The Buffers menu uses a BMHash() function to generate a sortable number
to be used for the menu index. It used a naive (and incorrect) way of
encoding multiple ASCII values into a single integer, but assumes each
character to be only in the ASCII 32-96 range. This means if we use
non-ASCII file names (e.g. Unicode values like CJK or emojis) we get
integer underflow and overflow, causing the menu index to wrap around.
Vim's GUI implementations internally use a signed 32-bit integer for the
`gui_mch_add_menu_item()` function and so we need to make sure the menu
index is in the (0, 2^31-1) range.

To do this, if the file name starts with a non-ASCII value, we just use
the first character's value and set the high bit so it sorts after the
other ASCII ones. Otherwise, we just take the first 5 characters, and
use 5 bit for each character to encode a 30-bit number that can be
sorted.

This means Unicode file names won't be sorted beyond the first
character. This is likely going to be fine as there are lots of ways to
query buffers.

related: #17403
closes: #17928

Signed-off-by: Yee Cheng Chin <ychin.git@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2025-08-10 10:09:38 +02:00
Yee Cheng Chin
cda0d17f59 patch 9.1.1622: Patch v9.1.1432 causes performance regressions
Problem:  Patch v9.1.1432 causes performance regressions
Solution: Revert "patch 9.1.1432: GTK GUI: Buffer menu does not handle
          unicode correctly" (Yee Cheng Chin).

This reverts commit 08896dd330.

The previous change to support Unicode characters properly in the
buffers menu resorted to removing all buffer menus and re-add the
buffers after doing a sort, per each buffer addition. This was quite
slow because if Vim is trying to load in multiple buffers at once (e.g.
when loading a session) this scales in O(n^2) and Vim can freeze for
dozens of seconds when adding a few hundred buffers.

related: #17405
related: #17928
fixes: #17897

Signed-off-by: Yee Cheng Chin <ychin.git@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2025-08-10 10:05:29 +02:00
Yee Cheng Chin
5e0c33363e Merge remote-tracking branch 'vim/master'
Additional test fixes:
- test_macvim:
  - remove check.vim import which is now done automatically
- test_gui:
  - Test_Buffers_Menu add conditional check to not run the
    LoadBufferMenu autocmd since in MacVim we don't use it.
  - Test_scrollbars remove go-k from the guioptions, due to MacVim's
    implementation being async compared to normal GVim. May need to
    revisit this in the future.

Also fix code indentation for MacVim-specific code to pass the new
Test_indent_of_source_files() test in test_codestyle.vim.
2025-07-22 16:34:55 -07:00
SUN Haitao
08896dd330 patch 9.1.1432: GTK GUI: Buffer menu does not handle unicode correctly
Problem:  GTK GUI: Buffer menu does not handle unicode correctly
Solution: Get rid of the BMHash() function (SUN Haitao)

fixes: #17403
closes: #17405

Signed-off-by: SUN Haitao <sunhaitao@devtaste.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2025-06-04 21:25:31 +02:00
Yee Cheng Chin
b860e88aef Merge remote-tracking branch 'vim/master' 2024-10-15 14:19:44 -07:00
h-east
a4205471ad runtime(misc): Use consistent "Vim script" spelling
References: https://groups.google.com/g/vim_dev/c/3Z5yM8KER2w/m/wAqws0QSEAAJ

closes: #15863

Signed-off-by: h-east <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
2024-10-13 19:16:42 +02:00
Yee Cheng Chin
fa83ca5cb1 Allow launching MacVim in clean defaults, add menu to open clean Vim
Now support a `-IgnoreUserDefaults 1` flag that can be passed to MacVim
at launch, which would cause MacVim to open with the default settings
instead of whatever the user has previously set. This only works by
overriding the MacVim-specific application defaults, and won't affect
Sparkle settings and other macOS native ones.

Also add a new menu item / macaction to open a new Vim window in clean
mode (which would prevent loading in vimrc and plugins). It works by
launching Vim using a `--clean` flag. The alt menu would open a clean
Vim window without using defaults.vim as well for the most vanilla Vim.

Currently only added Chinese/Japanese translations for the menu items.
Users who want other languages to be localized will need to file a pull
request themselves.

This feature is useful for users, but the main reason is to serve as a
pre-requisite for adding XCTest test cases to MacVim and needing a way
to launch it in a clean and predictable way.
2023-10-26 09:44:38 -07:00
Yee Cheng Chin
4b6110fa32 Merge remote-tracking branch 'vim/master' 2023-08-31 16:23:30 -07:00
Yee Cheng Chin
c50fd2fdde Merge remote-tracking branch 'vim/master'
Local fixes:
- Fix usage of `replace_termcodes` which added an additional parameter
  upstream.
2023-08-23 15:28:24 -07:00
Christian Brabandt
e059fae100 runtime(menu): define shortcut for File->Open Tab (#12895)
Seems missing as noted by Antonio Giovanni Colombo. So add it and use
the 'T' as shortcut, which does not seem to be used in the File dialog.

Verified on Windows.

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Antonio Giovanni Colombo <azc100@gmail.com>
2023-08-23 17:07:55 +01:00
Christian Brabandt
e978b4534a Farewell to Bram and dedicate upcoming Vim 9.1 to him (#12749)
* Dedicate upcoming Vim 9.1 to Bram

Also replace in a few more places Brams email address and mention new
maintainers.

* Remove Bram from any Maintainer role

* runtime: Align Header

* it's mailing list not mailinglist
2023-08-13 10:33:05 +02:00
Yee Cheng Chin
07336ac22b Add "What's New" page to show release notes after update to new version
Currently when a user uses Sparkle updater to update, they will see the
release notes beforehand. However, if they are updating across multiple
versions, they only see the latest one. Also, if they are using
automatic update, they will not see the release notes page. Users who
get MacVim from Homebrew or manually building from source also do not
see the release notes as those mechanisms are driven from command line.
This makes it harder to communicate new features and announcements to
these users.

Add a new "What's New" page that will be automatically shown whenever
the user has updated to a new version of MacVim. The last version of
MacVIm is tracked by the MMLastUsedBundleVersion value previously added
in #1357, which allows us to detect such update no matter what
installation method was used and display a dialog box. Other than
opening at launch, the user can also open it in the Help menu, and
there's an option to make it not open at launch if it's annoying to
the user.

The release notes is served by http://macvim.org/ (done in
https://github.com/macvim-dev/macvim-dev.github.io/pull/1) so we don't
have to bundle it locally and it makes it easier to update them. MacVim
will know the request a range of release notes (if updating across
multiple versions at once) so that all new versions will be visible.

Also, fix it so that both Sparkle updater and the new What's New page
will properly be shown on top of the new MacVim window that gets opened
when MacVim is launched. Previously when we get a new update, Sparkle
frequently gets hid behind the editor window.
2023-07-08 05:29:39 -07:00
Yee Cheng Chin
519b052cb6 Merge remote-tracking branch 'vim/master' 2023-06-05 09:27:03 -07:00
Bram Moolenaar
b7398fe41c Update runtime files 2023-05-14 18:50:25 +01:00
Yee Cheng Chin
55fb47f684 Merge remote-tracking branch 'vim/master' 2022-12-10 17:58:16 -05:00
Bram Moolenaar
86b4816766 Update runtime files 2022-12-06 18:20:10 +00:00
Yee Cheng Chin
4b008ec2d9 Merge remote-tracking branch 'vim/master' 2022-12-04 19:21:20 -05:00
Bram Moolenaar
502e91756e patch 9.0.0960: error when using the "Spelling / Find More Languages" menu
Problem:    Error when using the "Tools / Spelling / Find More Languages"
            menu.
Solution:   Remove "<SID>".  Reset "g:menutrans_set_lang_to" when 'encoding'
            changes. (closes #11625)
2022-11-27 16:18:33 +00:00
Bram Moolenaar
8b336a6614 patch 9.0.0959: error when using the "File Settings / Text Width" menu
Problem:    Error when using the "File Settings / Text Width" menu.
Solution:   Use str2nr(). (closes #11624)
2022-11-27 15:51:46 +00:00
Yee Cheng Chin
59eb760a80 Add zoomLeft: / zoomRight: / macOS 13 Stage Manager actions
New zoomLeft/Right actions let the user easily pin the MacVim window to
the left/right of the screen using the private APIs _zoomLeft: /
_zoomRight:. This is similar to Windows' Aero Snap mode, and the
functionality has been in macOS since 10.15. Unfortunately there isn't a
public API for calling this.

Note that this could already be done if the user went to the Keyboard
settings and added a shortcut key to the Window -> "Move Window to Right
Side of Screen" menu, but I doubt a lot of people do that, and it's
nicer to have script-level control of this. The other likely option
users would have adopted is to use a third-party tool. This change
mostly makes it possible to easily snap the windows without needing to
use them.

Also, add new macOS 13 Ventura hooks for interfacing with Stage Manager.
Expose the `_removeWindowFromStageManagerSet:`, which is the private API
behind the new "Remove Window from Set" menu item, which removes the
window from a mixed application set in Stage Manager. Similar to
_zoomLeft:, this is a UI-only feature, and hence no public API is
avaialble. Also, expose the collections API so that we can call
join/unjoinAllStageManagerSets: to have MacVim windows float among all
Stage Manager sets, which is useful for windows that need to show up
next to other windows (e.g. a copy-and-paste scratchpad file).

Also add a new separator to the Window menu because macOS injects all
the window/Stage Manager related menu items right after the "Zoom" item,
and it kind of expects a separator to be right after it for the new
items to be categorized right.
2022-10-30 23:13:58 -07:00
Yee Cheng Chin
d14f9a76cf Fix popup test failure, and clean up MacVim error codes
Fix failure in Test_popup_command. The test assumes a certain PopUp menu
layout but we recently added a new "Look Up" menu item. Make sure the
test removes those non-standard menu items before progressing the test.

Also, while we are at it, make sure the showdefinition() command will
fail when not in GUI mode so it doesn't queue up the command queue.
Also, convert the E??? error codes to proper error codes (and using a
postfix "-M" to make sure they don't conflict with future Vim error
codes) so they can be looked up in documentation.
2022-10-27 22:51:44 -07:00
Yee Cheng Chin
d8a4dcbe89 Add Vim script support and a popup menu for data lookup
Add a new Vim script function `showdefinition()` that allows Vim script
to call back to macOS's data lookup feature and show the definition /
URL preview / etc for any text, at a designated row/col position. If the
row/col are not provided this function will just show it at the cursor.

Also, add a new autoload/macvim.vim for utility functions to call
showdefinition() for selected texts and the word under cursor. Make a
new right-click popup menu "Look Up" call that when there are selected
texts in visual mode to make the lookup functionality easier to access
for users without a trackpad (since Ctrl-Cmd-D is a little obscure and
unwieldy to use). For the utility functions, it was a little hard to
determine how to get the text under visual selection without yanking (we
don't want to pollute the register here), and just implemented a
function to take care of all the edge cases including visual/block/line
modes and selection=exclusive. It could be useful in other situations.

As a side refactor, change the message handler in MacVim from if/else to
switch case. In optimized builds, they both essentially optimize to the
same thing, but for debug builds, the if/else statements have to step
through one by one, and switch case just makes more sense for a giant
message ID lookup like this.

Part of Epic #1311
2022-10-14 19:32:50 -07:00
Yee Cheng Chin
f8462bd3b4 Add File.Close support for terminal which also makes it work for Cmd-W
Since Vim upstream added support for `:confirm q` for terminals, we can
now get our File.Close menu to work properly for them as well. This also
means Cmd-W (which is bound to that menu item) works too.

Also just add validateMenuItem: for MMAppController even if we are just
returning YES. This makes it semantically clearer and is easier to
debug.
2022-10-09 13:20:47 -07:00
Yee Cheng Chin
09d44aa8c5 Merge remote-tracking branch 'vim/master' 2022-10-09 13:02:50 -07:00
Yee Cheng Chin
15b314ffbb patch 9.0.0708: :confirm does not work properly for a terminal buffer
Problem:    :confirm does not work properly for a terminal buffer.
Solution:   Handle :confirm for a terminal buffer differently.  (Yee Cheng
            Chin, closes #11312)
2022-10-09 18:53:32 +01:00
Yee Cheng Chin
622a45e8a2 Merge pull request #1267 from ychin/fix-macvim-disable-install-menus
Fix did_install_default_menus not working with MacVim
2022-08-09 00:04:11 -07:00
Yee Cheng Chin
ac0153c8f3 Fix did_install_default_menus not working with MacVim
The `macaction` blocks were previously not respecting the
`did_install_default_menus` setting. If you set it to 1 in your vimrc,
MacVim would throw startup errors about macmenu not finding the menu
items it expected to. Move the `macaction` setup to the correct place so
they would only be called if `did_install_default_menus` is not 1.

Close #1231. Originally pull request by @jpetrie.
2022-08-08 17:53:37 -07:00
Yee Cheng Chin
ea193e8b5d Fix vimtutor menu not working
Previously, the "Help.Vim Tutor" menu was using `:!vimtutor -g &`, but a
change in Vim (v8.2.3502) broke that behavior, as the whole script will
get terminated as soon as `:!` finishes running. Fix that to use `:call
system('vimtutor -g &')` instead, since that still works. See
https://github.com/vim/vim/issues/8951 for more discussions.
2022-08-05 21:07:33 -07:00
ichizok
ae7aaf1460 Merge remote-tracking branch 'vim/master' 2022-03-10 13:02:18 +09:00
Bram Moolenaar
1588bc8ebe Update runtime files 2022-03-08 21:35:07 +00:00
ichizok
85ab5ac55c Merge remote-tracking branch 'vim/master' 2022-02-24 09:19:26 +09:00
Bram Moolenaar
2007dd49f5 patch 8.2.4455: accepting one and zero for second sort() argument is strange
Problem:    Accepting one and zero for the second sort() argument is strange.
Solution:   Disallow using one and zero in Vim9 script.
2022-02-23 13:17:47 +00:00
ichizok
4cb9532be0 Merge remote-tracking branch 'vim/master' 2022-02-12 12:32:24 +09:00
Bram Moolenaar
9da17d7c57 Update runtime files 2022-02-09 21:50:44 +00:00
ichizok
8292705ac1 Merge remote-tracking branch 'vim/master' 2022-02-07 11:43:18 +09:00
Bram Moolenaar
3e79c97c18 Update runtime files; use compiled functions 2022-02-04 19:48:06 +00:00
ichizok
912f6bad92 Merge remote-tracking branch 'vim/master' 2021-12-27 09:08:40 +09:00
Bram Moolenaar
fa3b72348d Update runtime files 2021-12-24 13:18:38 +00:00
Yee Cheng Chin
6128cf912b Remove fade-to-black animation for native/custom fullscreen
For native fullscreen, simply remove the custom animation as it doesn't
look good and doesn't look native. This was added back when resizing the
window rapidly would result in artifacts, but they should have all been
fixed. As such, no need to hide everything under a black fade.

For custom fullscreen, make it so that if `MMFullScreenFadeTime` is set
to 0 (which is now the default), the fading animation will simply not be
drawn as it simply flickers. Since it now defaults to 0, the user will
have to manually set this back to 0.25 to get the old functionality,
which is ok as it's somewhat a legacy feature anyway and there shouldn't
be any flickering now during the transition.

Also, update documentation on full-screen to provide more info on native
vs custom, and clean up old outdated texts.

Misc driveby fixes related to full screen:
- Robustify the Touch Bar full screen button to listen to `OptionSet`
  event which is more robust than relying on `VimResized`, which also
  didn't work when 'fuoptions' is set to nothing.
- Make MacVim handle the DidFailToEnter/ExitFullScreen events better.
  These events could fire when using native full screen while the user
  is e.g. switching space. We need to make sure to properly update the
  states when these two events happen and let Vim know what the current
  `'fullscreen'` state is so both sides are synced.
- Fix up the preferences pane's full screen buttons to not trigger
  fontPropertiesChanged which was a mistake due to copy-and-paste in
  Interface Builder.

See:
- #292 / #289 which implemented the fade effect.
2021-02-07 21:32:33 -08:00
Yee Cheng Chin
ccdf468588 Add "Release Notes" to Help menu similar to a lot of other apps
Also add translations for the new entry.
2020-12-09 05:50:42 -08:00
Yee Cheng Chin
99e9e4143e Turn on Vim menu translations and add MacVim-specific ones
Remove langmenu=none from the MacVim vimrc to enable Vim's menu
translations.

Menu cleanups:
- Remove Emoji character picker menu item as macOS already adds it
  automatically to Edit menu. No need to do that ourselves.
- Rename some menus to fit macOS more and so we can use an official
  Apple translations (e.g. Select Next Tab renamed to "Show Next Tab").

Also, modify extract-specific-localised-strings.swift for MacVim. This
sets up only the locales we need, and add a new mode to generate Vim
menu translations and can be toggled using a command-line parameter.

Vim menu translations
--------------------
Vim already has menu translations, but need to add translations for
MacVim-specific menus. Add menu translations for MacVim in a new
subfolder. Each locale has two new translation files: one with Apple
official translations extracted using the script, and the other one with
custom translations (they were mostly done by referencing existing
translations, e.g. "About MacVim").  Also added a README to try to make
it clear what's going on.
- Not all menu items are translated yet. There are a couple left (e.g.
  "Toggle Full Screen" and "Stay in Front") but for it's good for now,
  and we can add those translations in later.

MacVim xib translations
--------------------
Convert MainMenu.xib to Base localization and add per-locale strings
files. The top parts are the manually translated strings (well, mostly
from guessworks with help from Google translte), and the bottom parts
are the Apple official ones coming from the script. This mostly affects
the menu that's shown when no Vim instance is opened, and also the main
app menu called "MacVim". Other menu items when there is a window opened
use the Vim menu translations instead.

Other MacVim GUI items like preference pane are currently not localized
as those would likely need someone to go through and actually manually
translate them, and it would be tricky to keep them up to date if we
make changes, which happens from time to time.

Locales
--------------------
- No MacVim translations (Apple didn't have official translations for
  them):
    - af_af.latin1
    - eo.utf-8
    - is_is.utf-8
    - sl_si.utf-8
    - sr_rs.utf-8
- Added MacVim translations:
    - ca_es
    - cs_cz
    - da
    - de_de
    - es_es
    - fi_fi
    - fr_fr
    - hu_hu
    - it_it
    - ja
    - ko_kr
    - nl_nl
    - no_no
    - pl_pl
    - pt_br
    - pt_pt
    - ru_ru
    - sv_se
    - tr_tr
    - zh_cn
    - zh_tw

Close #776
2020-10-02 17:54:17 -07:00
Yee Cheng Chin
6dc1510930 Merge remote-tracking branch 'vim/master' 2020-09-28 12:58:15 -07:00
Bram Moolenaar
b45cd36bd9 patch 8.2.1768: cannot use the help menu from a terminal window
Problem:    Cannot use the help menu from a terminal window.
Solution:   Add ":tlnoremenu" commands. (Yee Cheng Chin, closes #7023)
2020-09-28 21:41:49 +02:00
Yee Cheng Chin
fcd5797563 Bundle vimtutor with MacVim and provide Help menu item to open it
MacVim has previously not included vimtutor, meaning the user had to
obtain it elsewhere. Change the build scripts to copy it over to the app
bundle so that it's under MacVim.app/Contents/bin just like `mvim` etc.

Also, provide a Help menu item to open vimtutor. The menu action will
also make sure to override the PATH first to prevent accidentally
opening other installed MacVim/Vim versions since vimtutor works by
searching PATH instead of explicitly passing in the Vim executable path.

Also, make all Help menu items work in terminal mode as well as an easy
fix.
2020-09-26 02:29:34 -07:00
Yee Cheng Chin
e13d237836 Touch Bar add submenu/title/emoji picker support
Can now specify submenus. E.g. TouchBar.Debugger.Run. When trying to
create a submenu it will first create a popover item and then only
create the NSButton at the leaf.

- Unfortunatley macOS currently can't do multiple levels of submenus (the
  API will allow it, but it doesn't really work), presumably for
  usability concerns. Limit it to only one level of nesting for now.

Add ability to set a title on a Touch Bar button, using `tmenu`. This
allows us to override the displayed button name, and when an icon is
specified the override name will still be shown alongside the icon.

Add emoji picker support, and add it to the list of default Touch Bar
menus. Only enable it in modes where the user is typing (insert,
command, terminal, etc).

Fixed up the internal implementation of Touch Bar management so it's
easier to add metadata to it now.

Also, add documentation.

TODO:

- Using `tmenu` after `amenu` doesn't really work (unless it's specified
  in vimrc). This is because MacVim hasn't implemented
  `gui_mch_menu_set_tip`. Should fix it by adding support for it. For
  now, the user can just call `tmenu` before `amenu`.
- Disabling menus currently just hides the menu. Since the user can
  already do `aunmenu` to hide, should change the disable behavior to
  show the button but disabled instead, similar to how toolbars and
  normal menus work.
2020-09-08 02:35:53 -07:00
Yee Cheng Chin
0b58aa150f Add terminal menu mappings for new tab/tab next/full screen menus
Vim terminals use tlmenu to specify menu items and the normal `amenu`
doesn't work. This causes functionality such as toggling full screen and
going to next/prev tab to not work in terminal mode. Fix that by adding
the proper tlmenu mapping to the appropriate items.

Fix #1045
2020-08-11 22:05:23 -07:00
ichizok
4d306060eb Merge remote-tracking branch 'vim/master' 2020-06-19 14:17:00 +09:00