Problem: Vim intro screen shows register message (after v9.1.1893)
Solution: Remove the register message, registering is no longer useful
and possible.
fixes: #18933closes: #18934
Signed-off-by:
Signed-off-by: Christian Brabandt <cb@256bit.org>
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: #17403closes: #17928
Signed-off-by: Yee Cheng Chin <ychin.git@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
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: #17928fixes: #17897
Signed-off-by: Yee Cheng Chin <ychin.git@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
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.
Problem: GTK GUI: Buffer menu does not handle unicode correctly
Solution: Get rid of the BMHash() function (SUN Haitao)
fixes: #17403closes: #17405
Signed-off-by: SUN Haitao <sunhaitao@devtaste.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
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.
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>
* 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
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.
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)
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.
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.
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
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.
Problem: :confirm does not work properly for a terminal buffer.
Solution: Handle :confirm for a terminal buffer differently. (Yee Cheng
Chin, closes#11312)
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.
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.
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.
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
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.
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.
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