Compare commits

...

128 Commits

Author SHA1 Message Date
Bjorn Winckler 9716d0b66f Snapshot 30 2008-06-08 16:54:26 +02:00
Bjorn Winckler 428d1b4412 Window cycling hardcoded to keycode 50
Window cycling is hardcoded to happen when the Cmd key is pressed with
the key whose keycode = 50.  Having window cycling in the "Window" menu
means that window cycling stops working when the keyboard layout is
changed.  Thus revert back to the old way of dealing with this since it
seems to work better.
2008-06-08 16:35:43 +02:00
Bjorn Winckler bf70f82498 Snapshot 29 2008-06-08 14:21:16 +02:00
Bjorn Winckler 89d9e60b8a Add 'rightleft' support to ATSUI renderer 2008-06-07 15:36:07 +02:00
Bjorn Winckler 0ea7546c7c Add 'mousehide' option support 2008-06-07 15:35:25 +02:00
Bjorn Winckler 321fdf61aa Ensure processCommandQueueDidFinish: gets called if exception is raised 2008-06-07 14:33:05 +02:00
Bjorn Winckler 2fa74c01aa Use -[NSScreen visibleFrame] to get full-screen max dimensions
This fixes a bug where the window dimensions were not restored after
leaving full-screen (with 'maxvert' fu-option set).
2008-06-07 14:30:52 +02:00
Bjorn Winckler c4222c6ebb Don't delay loading "Buffers" menu
This avoids a flickering menu each time a new editor window is opened.
2008-06-07 12:42:47 +02:00
Bjorn Winckler 1f538dc364 Set title for separator items to ensure valid descriptors 2008-06-06 23:32:26 +02:00
Bjorn Winckler 9471224d0b Give Vim processes some time to terminate before MacVim does
This should stop MacVim from beeping when Cmd-q is pressed.
2008-06-06 22:46:13 +02:00
Bjorn Winckler 1d83527039 Pass 'rl' option in "DrawCursor" message 2008-06-06 22:31:21 +02:00
Bjorn Winckler 7752431b82 Ensure "Services" menu is empty when creating new main menu
MMVimController uses a copy of the "MacVim" menu that is defined inside
MainMenu.nib instead of getting it from the default main menu.  This
ensures that the "Services" menu is initially empty for each new
MMVimController.  Without this the setKeyEquivalent: call would fail if
the key equivalent already was in a "Services" menu item (e.g. <D-F> and
<D-L> would fail).
2008-06-06 21:20:55 +02:00
Bjorn Winckler 2ac28f887e Edit->Font->Bigger/Smaller validates properly
Fixes bug where the above items were enabled even when all windows were
minimized.
2008-06-06 17:47:54 +02:00
Bjorn Winckler 9c517cb4e9 Don't draw control chars in MMTextStorage
It can happen that MMTextStorage is asked to draw characters from the
"Control Characters" set (e.g. when :shell is invoked).  This would
cause internal errors in MMTextStorage so when control chars are
detected, simply draw blanks instead.
2008-06-06 14:24:49 +02:00
Bjorn Winckler 3915c6afc6 Catch exceptions in processCommandQueue: 2008-06-06 14:22:49 +02:00
Bjorn Winckler a4569d06ac Do not set key equivalent when 'mac_key == 0' 2008-06-06 14:16:10 +02:00
Bjorn Winckler cb120a21cf Validate performClose: in MMWindow and MMFullscreenWindow
Failing to validate would cause the "Close" menu item to be disabled in
full-screen.
2008-06-05 23:13:40 +02:00
Bjorn Winckler 7070fd3f76 Update help on menus 2008-06-05 21:27:02 +02:00
Bjorn Winckler 9f1b770ee6 Add "Cycle Through Windows" to default "Windows" menu
This ensures that Cmd-` works for all windows.  Also changed its
alternate to read "Cycle Backwards Through Windows".  Note that the
default "Windows" menu does not contain the alternate since Interface
Builder turned Cmd-Shift-` into Cmd-~ which is no longer a valid
alternate.
2008-06-05 20:52:30 +02:00
Bjorn Winckler ebf10927c7 Ignore "Recent Files" when no "File" menu is found 2008-06-05 20:24:36 +02:00
Bjorn Winckler e18186c461 Pass key equivalents to default main menu after main menu
This is so that the key equivalents set up in the default main menu will
work even when the system gvimrc files hasn't been sourced.  This is
useful e.g. when "-u NONE -U NONE" is passed as arguments resulting in
the default Vim menus being used.
2008-06-05 20:19:32 +02:00
Bjorn Winckler af279d2477 Update MMAppController top level information 2008-06-04 21:53:05 +02:00
Bjorn Winckler 8c442b7b28 Merge upstream 2008-06-04 21:36:00 +02:00
vimboss 4c6ed9759c updated for version 7.1-311 2008-06-04 19:35:35 +00:00
Bjorn Winckler d98e291038 Set windows menu even if it is nil 2008-06-04 21:21:28 +02:00
Bjorn Winckler 092e0cc894 Add support for popup menus 2008-06-04 21:17:05 +02:00
vimboss b904b019b8 updated for version 7.1-310 2008-06-04 17:37:34 +00:00
Bjorn Winckler c0159b8fdf Default menu "MacVim Help" item opens help window maximized 2008-06-04 19:08:52 +02:00
Bjorn Winckler 11ec93a03a Add "Minimize All" and "Zoom All" items to "Windows" menu 2008-06-04 19:03:33 +02:00
Bjorn Winckler c2f8b396de Add "Cycle Through Windows" to Windows menu (remove <D-`> hack) 2008-06-04 18:45:45 +02:00
Bjorn Winckler fa15736b2b Hook up "MacVim Help" on default main menu 2008-06-04 18:25:08 +02:00
Bjorn Winckler d1a9e08f94 Add standard menus to default main menu 2008-06-04 18:17:23 +02:00
vimboss 9d2727c56f updated for version 7.1-309 2008-06-04 13:28:18 +00:00
vimboss ce9c112020 updated for version 7.1-308 2008-06-04 12:29:14 +00:00
vimboss 0e2ddfca38 updated for version 7.1-307 2008-06-04 11:35:26 +00:00
vimboss 1f7de911ba updated for version 7.1-306 2008-06-04 09:00:32 +00:00
Bjorn Winckler f6ab5cbc03 Use default menu when no window open, fix 'Recent Files' menu 2008-06-03 23:15:18 +02:00
Bjorn Winckler 44d7e60b06 Change heuristic for finding "Services" menu 2008-06-02 18:44:59 +02:00
Bjorn Winckler 0e37f590ab Use -[NSApp setMainMenu:] to update main menu 2008-06-01 21:28:18 +02:00
Bjorn Winckler a0f684e003 Add autoenabling for menus 2008-06-01 15:57:21 +02:00
Bjorn Winckler f54c3100e9 Menu removal functionality added 2008-06-01 14:30:00 +02:00
Bjorn Winckler a588fc3e33 Use menu descriptors instead of tags to locate menu items 2008-05-31 21:47:30 +02:00
vimboss 039f611554 updated for version 7.1-305 2008-05-29 20:41:57 +00:00
vimboss 3a4682c9dd updated for version 7.1-304 2008-05-29 19:47:13 +00:00
Nico Weber fdc64858c5 Wrap user-visible strings in NSLocalizedString() 2008-05-29 17:01:44 +02:00
vimboss 45a9151fc6 updated for version 7.1-303 2008-05-29 13:36:10 +00:00
vimboss b9241163d8 updated for version 7.1-302 2008-05-28 20:02:48 +00:00
Bjorn Winckler defa7bd098 Insert mode cursor respects 'rightleft' option
When 'rl' is enabled the insert mode cursor is drawn on the right-hand
side of a cell.
2008-05-28 21:16:27 +02:00
vimboss 6bfab82aca updated for version 7.1-301 2008-05-28 17:02:46 +00:00
vimboss 64959e3177 updated for version 7.1-300 2008-05-28 15:32:20 +00:00
vimboss 2eee45eb39 updated for version 7.1-299 2008-05-28 14:49:58 +00:00
Nico Weber 8d051eef4e Make QuickLook work with .vim files 2008-05-27 17:40:55 +02:00
Bjorn Winckler 7f449520a5 Patch a memory leak
The 'vimState' instance variable in MMVimController is now released on
dealloc.
2008-05-25 21:59:39 +02:00
Bjorn Winckler 07831f45b2 Snapshot 28 2008-05-25 20:22:58 +02:00
Bjorn Winckler 9a69ad0d62 Open and save dialogs track the Vim pwd
Open and save dialogs will open up at the present working directory of
the key Vim process.  This can be disabled by setting the user default
"MMDialogsTrackPwd" to 0.  If disabled, these dialogs always open up at
the last location browsed to (which is the default OS X behaviour).
2008-05-25 19:22:12 +02:00
Bjorn Winckler be6ecb5d92 Set 'backspace' in the system vimrc
Add "indent,eol,start" to the 'backspace' option in $VIM/vimrc to make
the delete key behave in a more familiar way to new users.  The help
file has been update to point out this non-standard behaviour.
2008-05-25 13:35:08 +02:00
Bjorn Winckler 138be9d567 Improve "Edit" menu support in dialogs
The Edit menu items cut/copy/paste/select all/undo/redo are wired to
send the appropriate action messages (now possible with :macmenu
command) so that they may work with dialogs.  However, to make this work
100%, menus must first autoenable (which they currently do not).  This
will be addressed in a future patch.
2008-05-20 16:12:52 +02:00
Bjorn Winckler 0430474168 Coerce MacVim to work with LCC
The LCC (Logitech Control Center) comes with an input manager which
registers its own root object with the default NSConnection.  MacVim
uses the root object of the default connection to vend the frontend
object, so LCC would cause MacVim to never open any new windows.

To work around this problem the default connection is no longer used in
MacVim, instead a new connection is created and this connection is used
to vend the frontend object instead.
2008-05-20 14:40:57 +02:00
Bjorn Winckler 0f1ee64746 Fix bug in :macmenu
Menu item not found lead to bad memory access.
2008-05-19 21:34:55 +02:00
Bjorn Winckler d08cc220fd Add "File.Save All" menu item
This patch serves the secondary purpose of showing off the new feature
of being able to specify alternate menu items using the new :macmenu
command.  When the "File" menu is revealed either the "Save All" or the
"Save" item is displayed, depending on whether Alt is held or not.
2008-05-19 20:08:52 +02:00
Bjorn Winckler 04d9ab21b0 Bind "File.Close" to ":conf q"
With the introduction of ":macmenu" it is possible to bind "File.Close"
to ":conf q" and at the same time have it send the "performClose:"
action.

This patch reverts back to using ":conf q" since there were problems
with "File.Close" in conjunction with bindings to <C-\>.
2008-05-19 19:28:20 +02:00
Bjorn Winckler 9c7523e944 Change ":macmenukey" to ":macmenu"
The new command allows better control over menus with ability to specify
key equivalent, action, and wheter menu item is an alternate.  These are
specified as "key=value" pairs to allow future expansion.  The help
files have also been rewritten to reflect this change.
2008-05-19 19:09:05 +02:00
Bjorn Winckler 030d0d07ec Update help which referred to Carbon version
In particular, state that MacVim does not source $VIMRUNTIME/macmap.vim.
2008-05-19 17:40:02 +02:00
Bjorn Winckler 0578f14843 Appcast points to fixed snapshot 27 2008-05-13 19:38:58 +02:00
Bjorn Winckler 11274e43c4 Merge upstream 2008-05-12 18:00:00 +02:00
Bjorn Winckler ebfad47ec6 Snapshot 27
The 'make-snapshot.sh' script has been updated to run on Leopard with
Perl support (TCL support is disabled for now).
2008-05-11 17:54:22 +02:00
Bjorn Winckler 48e6f325d6 Update credits 2008-05-11 16:22:01 +02:00
vimboss e899e2dfc7 updated for version 7.1-298 2008-05-10 19:39:08 +00:00
Bjorn Winckler 1bc466c774 Move "Recent Files" menu 2008-05-10 16:11:43 +02:00
Bjorn Winckler f08c899208 Add files opened/saved from :browse to "Recent Files" menu 2008-05-10 16:07:58 +02:00
Bjorn Winckler 31bd050607 Avoid "dropping DO message ..." warning when quitting
The warning was a result of sending a DO message from Vim and then
immediately exiting the process.  It is avoided by not sending any DO
messages while Vim is exiting.
2008-05-10 15:25:44 +02:00
Bjorn Winckler 2e6fb2ea53 Enable macvim color scheme to work with other Vim ports 2008-05-09 21:58:19 +02:00
Nico Weber 862da53932 Add "Recent Files" menu
The recent files menu will only remember files opened from Finder and
not files opened from within Vim (via :e etc.).  Recent files will also
be added to the "Recent Items" menu under the Apple menu.

(Patch by Nico Weber with some modifications by Bjorn Winckler.)
2008-05-09 21:41:39 +02:00
Bjorn Winckler 15763286bd Window no longer moves down on zoom 2008-05-09 15:05:31 +02:00
Bjorn Winckler fed823a238 Modifying 'antialias' in .[g]vimrc now works 2008-05-09 13:36:15 +02:00
Bjorn Winckler 5d5176aabf Cmd-w shows confirmation dialog when buffer modified 2008-05-09 13:27:03 +02:00
Enno Lübbers 19468d3117 Add background color option to 'fuopt' 2008-05-08 12:31:28 +02:00
Bjorn Winckler 0402b6b5c4 Merge upstream 2008-05-07 21:47:00 +02:00
vimboss b6932fb3ae updated for version 7.1-297 2008-05-07 19:46:51 +00:00
vimboss 22695b7f3b updated for version 7.1-296 2008-05-07 17:09:24 +00:00
vimboss bc8b62f3d9 updated for version 7.1-295 2008-05-07 15:40:33 +00:00
vimboss bd542602dd updated for version 7.1-294 2008-05-07 11:10:28 +00:00
Bjorn Winckler e5159c3b6a Snapshot 26 2008-04-11 22:54:48 +02:00
Bjorn Winckler b36829bcaa Add 'antialias' to list of non-standard options in help 2008-04-10 21:07:52 +02:00
Bjorn Winckler 07c344444b New MacVim icon 2008-04-10 20:57:46 +02:00
Bjorn Winckler bafcc3365d Merge upstream 2008-04-09 15:50:00 +02:00
vimboss 41ca0e5508 updated for version 7.1-293 2008-04-09 13:49:57 +00:00
vimboss 246dfc17f4 updated for version 7.1-292 2008-04-09 10:16:02 +00:00
Bjorn Winckler 9aae3ba3cc Fix initial window placement bug
The algorithm which determines the topmost window only searches through
visible windows.  The initial window placement bug was a result of this
algorithm returning the (invisible) window whose position was to be
determined.
2008-04-08 13:37:21 +02:00
Bjorn Winckler 0a54dd7370 Snapshot 25 2008-04-06 19:38:05 +02:00
Bjorn Winckler 6e8e20588d Only cascade from windows belonging to Vim process
This ensures that a newly opened window isn't cascaded from e.g. the
preferences panel.
2008-04-06 14:36:12 +02:00
Bjorn Winckler 296634f40e Make copy/paste respect block-wise selections
When text is copied inside Vim we put both the text and the motion type
on the pasteboard.  Text copied from outside Vim never contains the
motion type so we have to guess between line and character-wise motion
types in that case.
2008-04-05 15:24:25 +02:00
Bjorn Winckler 13d45e4ff9 Merge upstream
Conflicts:
	src/vim.h
2008-04-01 20:00:00 +01:00
vimboss 3e314dee6e updated for version 7.1-291 2008-04-01 18:59:07 +00:00
vimboss 779811f241 updated for version 7.1-290 2008-04-01 15:14:36 +00:00
vimboss 22017e1410 updated for version 7.1-289 2008-04-01 12:53:43 +00:00
vimboss af8ea2cc11 updated for version 7.1-288 2008-04-01 12:31:14 +00:00
vimboss ac3b778ddb updated for version 7.1-287 2008-04-01 11:12:09 +00:00
vimboss 1de2bc973a updated for version 7.1-286 2008-04-01 10:06:39 +00:00
Bjorn Winckler cdb8dc17ca Update :maca help, release actionDict 2008-03-26 20:41:00 +01:00
Bjorn Winckler b11e6ca3c9 Fix typo in help on :maca 2008-03-23 19:05:37 +01:00
Nico Weber 69c366f7ed Add command line completion to :macaction command
This enables the user to cycle through all actions by typing
":maca <Tab>" and then repeatedly hitting <Tab>.  The help on :maca was
also updated.

(Initial patch by Nico Weber with some changes by Bjorn Winckler.)
2008-03-23 18:48:24 +01:00
Nico Weber 7792c4e8ab Transparency setting not lost after leaving full-screen
Fixes bug where setting 'transp' while in full-screen and switching back
to windowed mode would result in the window being opaque.
2008-03-22 17:15:46 +01:00
Bjorn Winckler 3910f20697 Disable <D-?> key equivalent
The key equivalent is disabled for now since it only works on Tiger and
not on Leopard.
2008-03-22 14:19:23 +01:00
Bjorn Winckler 472eda54f6 Update Help menu
Add "MacVim Help" item with <D-?> key equivalent, as well as a
"MacVim Website" item which opens up the MacVim website in the user's
default browser.
2008-03-21 20:30:41 +01:00
vimboss c09ef35588 updated for version 7.1-285 2008-03-20 13:39:37 +00:00
vimboss bf90097520 updated for version 7.1-284 2008-03-20 12:23:49 +00:00
Bjorn Winckler 3292e01a82 Improve <D-w> behaviour
With this patch <D-w> works as follows:
- if in Ex-mode, exit by sending "^U:vi<CR>"
- if the command-line window is open, close it using CTRL-\_CTRL-N
- otherwise go to normal mode and add ":q<CR>" to the input buffer
2008-03-19 19:56:19 +01:00
Nico Weber ba210fdada Add full-screen options
When entering full-screen the 'fuoptions' option is used to determine
whether the vim view should maximize in the vertical and/or horizontal
directions.  The previous rows/columns are restored upon returning to
windowed mode.

The help docs for 'fullscreen' have been updated and docs for
'fuoptions' have been added.
2008-03-18 19:52:59 +01:00
Jjgod Jiang 2d57fac276 Support 'antialias' with default renderer
This provides some support for the 'antialias' option with the
NSTextView renderer.  However, some fonts seem to be unaffected by this
option.  In particular, Monaco of point sizes up to 10 always render
without antialiasing.
2008-03-16 21:53:35 +01:00
Jjgod Jiang 4868c3cb85 Support 'antialias' with ATSUI renderer
This commit adds support for the 'antialias' option with the ATSUI
renderer (the NSTextView renderer still uses System Preferences).  The
docs on 'antialias' have been updated.

Some changes to the code used by Carbon Vim is affected by this commit.
A feature flag FEAT_ANTIALIAS was added to support easy disabling of
'antialias' support.

(Patch by Jjgod Jiang with some modifications by Bjorn Winckler.)
2008-03-16 18:40:48 +01:00
vimboss d38abe1843 updated for version 7.1-283 2008-03-16 15:04:34 +00:00
vimboss 045cef0a51 updated for version 7.1-282 2008-03-16 13:54:13 +00:00
vimboss 560504f7ba updated for version 7.1-281 2008-03-16 12:09:58 +00:00
vimboss 4ba3129468 updated for version 7.1-280 2008-03-15 12:12:59 +00:00
vimboss 98cc0fee24 updated for version 7.1-279 2008-03-15 11:41:07 +00:00
Bjorn Winckler 26349fc938 Update credits 2008-03-15 12:03:32 +01:00
vimboss 52b5ee23fc updated for version 7.1-278 2008-03-12 20:48:13 +00:00
vimboss d97c301011 updated for version 7.1-277 2008-03-12 16:38:55 +00:00
vimboss 343bd24d2e updated for version 7.1-276 2008-03-12 16:27:00 +00:00
vimboss a58654a6b0 updated for version 7.1-275 2008-03-12 13:40:54 +00:00
vimboss af62299744 updated for version 7.1-274 2008-03-12 12:46:13 +00:00
vimboss 60cd2a75c1 updated for version 7.1-273 2008-03-12 12:17:28 +00:00
vimboss 2ef7f8c8a0 updated for version 7.1-272 2008-03-12 11:23:53 +00:00
vimboss f2282b0096 updated for version 7.1-271 2008-03-11 21:02:00 +00:00
vimboss 5d748c8f27 updated for version 7.1-270 2008-03-10 20:34:59 +00:00
vimboss b884eef376 updated for version 7.1-269 2008-03-09 15:45:53 +00:00
vimboss 49cb3f99b8 updated for version 7.1-268 2008-03-09 13:30:56 +00:00
103 changed files with 4576 additions and 1831 deletions
+1
View File
@@ -193,6 +193,7 @@ SRC_UNIX = \
src/vim_icon.xbm \
src/vim_mask.xbm \
src/vimtutor \
src/gvimtutor \
src/which.sh \
src/workshop.c \
src/workshop.h \
+22 -10
View File
@@ -1,6 +1,6 @@
" Vim autoload file for editing compressed files.
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last Change: 2007 May 10
" Last Change: 2008 May 29
" These functions are used by the gzip plugin.
@@ -73,8 +73,15 @@ fun gzip#read(cmd)
let empty = line("'[") == 1 && line("']") == line("$")
let tmp = tempname()
let tmpe = tmp . "." . expand("<afile>:e")
if exists('*fnameescape')
let tmp_esc = fnameescape(tmp)
let tmpe_esc = fnameescape(tmpe)
else
let tmp_esc = escape(tmp, ' ')
let tmpe_esc = escape(tmpe, ' ')
endif
" write the just read lines to a temp file "'[,']w tmp.gz"
execute "silent '[,']w " . escape(tmpe, ' ')
execute "silent '[,']w " . tmpe_esc
" uncompress the temp file: call system("gzip -dn tmp.gz")
call system(a:cmd . " " . s:escape(tmpe))
if !filereadable(tmp)
@@ -95,12 +102,12 @@ fun gzip#read(cmd)
setlocal nobin
if exists(":lockmarks")
if empty
execute "silent lockmarks " . l . "r ++edit " . tmp
execute "silent lockmarks " . l . "r ++edit " . tmp_esc
else
execute "silent lockmarks " . l . "r " . tmp
execute "silent lockmarks " . l . "r " . tmp_esc
endif
else
execute "silent " . l . "r " . tmp
execute "silent " . l . "r " . tmp_esc
endif
" if buffer became empty, delete trailing blank line
@@ -110,8 +117,8 @@ fun gzip#read(cmd)
endif
" delete the temp file and the used buffers
call delete(tmp)
silent! exe "bwipe " . tmp
silent! exe "bwipe " . tmpe
silent! exe "bwipe " . tmp_esc
silent! exe "bwipe " . tmpe_esc
endif
" Restore saved option values.
@@ -124,10 +131,15 @@ fun gzip#read(cmd)
" When uncompressed the whole buffer, do autocommands
if ok && empty
if &verbose >= 8
execute "doau BufReadPost " . expand("%:r")
if exists('*fnameescape')
let fname = fnameescape(expand("%:r"))
else
execute "silent! doau BufReadPost " . expand("%:r")
let fname = escape(expand("%:r"), " \t\n*?[{`$\\%#'\"|!<")
endif
if &verbose >= 8
execute "doau BufReadPost " . fname
else
execute "silent! doau BufReadPost " . fname
endif
endif
endfun
+12 -4
View File
@@ -1,7 +1,7 @@
" MacVim colorscheme
"
" Maintainer: Bjorn Winckler <bjorn.winckler@gmail.com>
" Last Change: 2007 Nov 17
" Last Change: 2008 May 9
"
" This is the default MacVim color scheme. It supports both light and dark
" backgrounds (see :h 'background').
@@ -50,7 +50,11 @@ hi TabLineFill gui=reverse
hi TabLineSel gui=bold
hi Title gui=bold guifg=DeepSkyBlue3
hi VertSplit gui=NONE guifg=DarkSlateGray guibg=Gray90
hi Visual guibg=MacSelectedTextBackgroundColor
if has("gui_macvim")
hi Visual guibg=MacSelectedTextBackgroundColor
else
hi Visual guibg=#72F7FF
endif
hi WarningMsg guifg=Firebrick2
" Syntax items (`:he group-name` -- more groups are available, these are just
@@ -101,7 +105,11 @@ else
hi DiffText gui=NONE guibg=Gold
hi LineNr guifg=#888888 guibg=#E6E6E6
hi MatchParen guifg=White guibg=MediumPurple1
hi Normal gui=NONE guifg=MacTextColor guibg=MacTextBackgroundColor
if has("gui_macvim")
hi Normal gui=NONE guifg=MacTextColor guibg=MacTextBackgroundColor
else
hi Normal gui=NONE guifg=Black guibg=White
endif
hi Search guibg=CadetBlue1 guifg=NONE
hi Statement gui=bold guifg=Maroon guibg=NONE
hi Todo gui=NONE guifg=DarkGreen guibg=PaleGreen1
@@ -115,7 +123,7 @@ endif
" Change the selection color on focus change (but only if the "macvim"
" colorscheme is active).
"
if !exists("s:augroups_defined")
if has("gui_macvim") && !exists("s:augroups_defined")
au FocusLost * if exists("colors_name") && colors_name == "macvim" | hi Visual guibg=MacSecondarySelectedControlColor | endif
au FocusGained * if exists("colors_name") && colors_name == "macvim" | hi Visual guibg=MacSelectedTextBackgroundColor | endif
+15 -1
View File
@@ -1,4 +1,4 @@
*eval.txt* For Vim version 7.1. Last change: 2008 Feb 20
*eval.txt* For Vim version 7.1. Last change: 2008 May 28
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1609,6 +1609,7 @@ finddir( {name}[, {path}[, {count}]])
String find directory {name} in {path}
findfile( {name}[, {path}[, {count}]])
String find file {name} in {path}
fnameescape( {fname}) String escape special characters in {fname}
fnamemodify( {fname}, {mods}) String modify file name
foldclosed( {lnum}) Number first line of fold at {lnum} if closed
foldclosedend( {lnum}) Number last line of fold at {lnum} if closed
@@ -2620,6 +2621,19 @@ findfile({name}[, {path}[, {count}]]) *findfile()*
< Searches from the directory of the current file upwards until
it finds the file "tags.vim".
fnameescape({string}) *fnameescape()*
Escape {string} for use as file name command argument. All
characters that have a special meaning, such as '%' and '|'
are escaped with a backslash.
For most systems the characters escaped are "". For systems
where a backslash appears in a filename, it depends on the
value of 'isfname'.
Example: >
:let fname = 'some str%nge|name'
:exe "edit " . fnameescape(fname)
< results in executing: >
edit some\ str\%nge\|name
fnamemodify({fname}, {mods}) *fnamemodify()*
Modify file name {fname} according to {mods}. {mods} is a
string of characters like it is used for file names on the
+94 -51
View File
@@ -1,4 +1,4 @@
*gui_mac.txt* For Vim version 7.1. Last change: 2008 Feb 05
*gui_mac.txt* For Vim version 7.1. Last change: 2008 May 25
VIM REFERENCE MANUAL by Bjorn Winckler
@@ -124,7 +124,7 @@ strings like "((3) of 2)" to appear in the window title.
*macvim-options*
These are the non-standard options that MacVim supports:
'fullscreen' 'toolbariconsize' 'transparency'
'fullscreen' 'fuoptions' 'toolbariconsize' 'transparency' 'antialias'
*macvim-find*
Whenever you search for something in Vim (e.g. using "/") the search query is
@@ -142,6 +142,11 @@ another in MacVim. Simply search for something in one window (using "/") then
switch to another (e.g. with <D-`>) and hit <D-g> and the search will be
repeated in the new window.
*macvim-backspace* *macvim-delete*
The 'backspace' option is set in the system vimrc to make the delete key
behave in a more familiar way to new users. If you dislike this non-default
behaviour, then add the line "set backspace&" to your "~/.vimrc" file.
==============================================================================
2. Starting MacVim *macvim-start*
@@ -220,7 +225,9 @@ as general information regarding Mac OS X user defaults.
Here is a list of relevant dictionary entries:
KEY VALUE ~
MMAtsuiRenderer enable ATSUI renderer [bool]
MMCellWidthMultiplier width of a normal glyph in em units [float]
MMDialogsTrackPwd open/save dialogs track the Vim pwd [bool]
MMLoginShellArgument login shell parameter [string]
MMLoginShellCommand which shell to use to launch Vim [string]
MMNoFontSubstitution disable automatic font substitution [bool]
@@ -309,49 +316,84 @@ than the default?) then post them to |vim_mac|.
==============================================================================
5. Menus *macvim-menus*
*:macm* *:macmenukey*
MacVim has a special way of binding keys to menu items that differs from other
Vim GUI ports. A menu binding is called a "key equivalent" in Mac OS X
terminology, this is displayed on the right side of a menu item. The
":macmenukey" command is used to set the key equivalent of a menu item. This
command takes two parameters, the first names the menu item to bind to, the
second gives the key combination. For example: >
:macmenukey File.New\ Tab <D-t>
This sets the key equivalent of the "New Tab" menu item under the "File" menu
to Cmd+t.
Menus in Mac OS X behave slightly different from other platforms. For that
reason two new commands have been added to Vim. To understand what these
commands do you must first understand how menus work on OS X.
Note that key equivalents:
* must contain the Cmd modifier flag (<D-...>)
* take precedence over normal mappings made with ":map"
* can only be modified during startup (e.g. in .gvimrc)
Each entry in a menu is called a "menu item". With each menu item is
associated: a title, a key equivalent and an action message. When a menu is
displayed the title is shown on the left and the key equivalent (if any) is
shown on the right. Key equivalents enable you to access a menu item using
the keyboard instead of having to use the mouse. When a menu item is clicked
it will send it's associated action message. Actions can be used to instruct
MacVim to paste some text (paste:), open a new window (newWindow:), etc.
Certain actions are standard throughout OS X which is why MacVim must be able
to set these for each menu item. (E.g. the menu item "Edit.Paste" must be
bound to the action "paste:" otherwise pasting won't work in dialogs since
that is the action that instructs them to paste something.)
It is possible to reset a key equivalent by calling :macmenukey with a menu
name but no key. This is so that the default key equivalents can be reset in
"~/.gvimrc". For example, if you would like to free up <D-s> (which is the
key equivalent of "File.Save") then add the following line to "~/.gvimrc": >
macmenukey File.Save
Now you can use :map to bind <D-s> to whatever you like.
Menus are configured using the |:macmenu| command and the |:macaction| command
can be used to send action messages.
It is not necessary to reset a key equivalent if all you want to do is to
change the key equivalent of a menu item. For example, say you want to use
<D-M-Right> as the key equivalent for "Next Tab", then add the following line
to "~/.gvimrc": >
macmenukey Window.Next\ Tab <D-M-Right>
<
*:maca* *:macaction*
It is typical for menu items in Cocoa applications to bind to Objective-C
selectors. To support this, MacVim introduces the ":macaction" command. This
command takes the name of an action message as its only parameter. (An action
message is an Objective-C message with "void" return type and a single
parameter of type "id".) For example, the "New Window" menu item on the
"File" menu is created in the following manner: >
:an 10.290 File.New\ Window :macaction newWindow:<CR>
:maca[ction] {action:} Send the message "action:" to the first responder.
The list of allowed actions can be seen by typing
:maca <C-d>
An attempt to send an action not listed here will
result in an error. This list is specified in a
property list file called |Actions.plist|.
Note 1: A menu item which is bound to ":macaction" will automatically be bound
to that action in all modes (as if ":an" was used). It is not possible to
bind to ":macaction" in one mode only.
Note 2: The action is "nil-targeted", which means it is passed down the first
responder chain.
*:macm* *:macmenu*
:mac[menu] {menu} {key}={arg} ...
Set Mac specific properties for {menu}. The
properties that can be set are:
action the action this menu sends
alt "yes" if alternate of previous menu
key the key equivalent of this menu
This command must be used in a startup file, for
example in "~/.gvimrc". It has no effect otherwise.
For convenience, a menu with "action=name:" which is
bound to <Nop> will act as if bound to
":maca name:<CR>". Thus, if "Menu.Item" is given by
:an Menu.Item <Nop>
:macm Menu.Item action=name:
then ":emenu Menu.Item" is equivalent to
":maca name:".
The key equivalent is specified with the <D-..>
syntax. Note that key equivalents must contain the
Cmd modifier flag (<D-...>), and they take precedence
over normal mappings.
Use the syntax "key=<nop>" to clear the key equivalent
of a menu. This can be used to free up a key
combination that is set in the system gvimrc so that
it may be mapped to using ":map".
Recognised values of "alt" are "0", "no", "1", and
"yes". The default is "no". An alternate menu must
have the same key equivalent as the previous menu,
except the modifier flags must differ. The alternate
menu is by default hidden and only shows up when the
modifier is held down.
Here are some examples on how to use these commands:
1. Create a menu item with title "New Window" under the "File" menu, with key
equivalent Cmd-n, which opens a new window when selected: >
:an 10.290 File.New\ Window <Nop>
:macm File.New\ Window action=newWindow: key=<D-n>
2. Change the key equivalent to cycle through tabs to Cmd-Left/Right: >
:macm Window.Previous\ Tab key=<D-Left>
:macm Window.Next\ Tab key=<D-Right>
3. Create a mapping in normal mode which closes the current tab/window: >
:map <C-w> :maca performClose:<CR>
>
The standard Vim menus are modified in "$VIM/gvimrc". Take a look at that
file for more examples on how to set up menus. Note: When no window is open a
minimal default menu is used. The default menu is set up in MainMenu.nib
which resides in "Resources/English.lproj/" folder inside the app bundle.
*Actions.plist*
Some action messages would not be suitable to call from within Vim, so there
@@ -360,29 +402,30 @@ application bundle) which contains all actions that may be called. The key in
this dictionary is the name of the action message (case sensitive), the value
is not used.
Hint: The |:macaction| command supports command-line completion so you can
enter ":maca<Space><C-d>" to see a list of all available actions.
Here is a random assortment of actions from Actions.plist which might be
useful.
useful.
Action Description ~
fileOpen: Show "File Open" dialog
findNext: Search forward using the "Find Pasteboard"
findPrevious: Search backward using the "Find Pasteboard"
fontSizeDown: Decrease font size
fontSizeUp: Increase font size
hide: Hide MacVim
miniaturizeAll: Minimize all windows to the dock
newWindow: Open a new (empty) window
orderFrontCharacterPalette: Show the the "Special Characters" dialog
orderFrontFontPanel: Show the Font panel
orderFrontPreferencePanel: Show the Preferences panel
performMiniaturize: Minimize window to the dock
performZoom: Zoom window (same as clicking the green blob)
selectNextWindow: Select next window (similar to <D-`>)
selectPreviousWindow: Select previous window (similar to <S-D-`>)
As an example, to map <C-z> to performZoom: you could do something like this: >
:map <silent> <C-z> :macaction performZoom:<CR>
A better way to map to performZoom: would be to set the key equivalent of the
menu item "Window.Zoom" to the above action. This can be done by adding the
following line to "~/.gvimrc": >
macmenukey Window.Zoom <D-C-z>
(Note that key equivalents must contain the 'D' flag.)
terminate: Quit MacVim
zoomAll: Zoom all windows
_cycleWindows: Select next window (similar to <D-`>)
_cycleWindowsBackwards: Select previous window (similar to <D-S-`>)
==============================================================================
6. Toolbar *macvim-toolbar*
+1 -1
View File
@@ -1289,7 +1289,7 @@ The commands are sorted on the non-optional part of their name.
|:move| :m[ove] move lines
|:mark| :ma[rk] set a mark
|:macation| :maca[ction] send action message
|:macmenukey| :macm[eyequiv] set key equivalent for menu item
|:macmenu| :macm[enu] set Mac specific properties for menu item
|:make| :mak[e] execute external command 'makeprg' and parse
error messages
|:map| :map show or enter a mapping
+80 -18
View File
@@ -1,4 +1,4 @@
*options.txt* For Vim version 7.1. Last change: 2007 Aug 10
*options.txt* For Vim version 7.1. Last change: 2008 Feb 24
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -666,17 +666,21 @@ A jump table for the options with a short description can be found at |Q_op|.
Standard Annex #11 (http://www.unicode.org/reports/tr11).
*'antialias'* *'anti'* *'noantialias'* *'noanti'*
'antialias' 'anti' boolean (default: off)
'antialias' 'anti' boolean (default off, on for MacVim)
global
{not in Vi}
{only available when compiled with Carbon GUI enabled
on Mac OS X}
This option only has an effect in the Carbon GUI version of Vim on Mac
OS X v10.2 or later. When on, Vim will use smooth ("antialiased")
fonts, which can be easier to read at certain sizes on certain
displays. Setting this option can sometimes cause problems if
'guifont' is set to its default (empty string).
Note: Antialiasing is handled automatically on MacVim.
{only available when compiled with GUI enabled on
Mac OS X}
This option only has an effect in the GUI version of Vim on Mac OS X
v10.2 or later. When on, Vim will use smooth ("antialiased") fonts,
which can be easier to read at certain sizes on certain displays.
Setting this option in the Carbon version can sometimes cause problems
if 'guifont' is set to its default (empty string).
Support for this option is not flawless in MacVim. In particular,
Monaco always seems to render not antialiased for point sizes up
to 10. The ATSUI renderer has better antialias support.
*'autochdir'* *'acd'* *'noautochdir'* *'noacd'*
'autochdir' 'acd' boolean (default off)
@@ -3046,16 +3050,74 @@ A jump table for the options with a short description can be found at |Q_op|.
'fullscreen' 'fu' boolean (default off)
global
{not in Vi}
{only available in the MacVim GUI}
When this option is set, the whole screen is covered by vim. Screen
{only in MacVim GUI}
When this option is set, the whole screen is covered by Vim. Screen
decorations drawn by the operating system (such as the dock or the
menu bar) are hidden. Most of vim's window chrome is hidden as well
(e.g. toolbar, title bar). The tab bar and scroll bars remains visible.
Most of the screen is black, only a 'columns' x 'lines' part of the
screen is covered by the actual vim control. The control is centered.
menu bar) are hidden. Most of Vim's window chrome is hidden as well
(e.g. toolbar, title bar). The tab bar and scroll bars remain visible.
Updates to the window position are ignored in fullscreen mode.
See 'fuoptions' for how Vim resizes and colors the background when
entering and leaving fullscreen mode.
XXX: Add fuenter/fuleave autocommands? You might want to display
a NERDTree or a Tlist only in fullscreen for example. Then again, this
could probably be in a sizechanged autocommand that triggers if the
size is above a certain threshold.
XXX: Think about how 'fullscreen' and 'transparency' should interact.
*'fuoptions'* *'fuopt'*
'fuoptions' 'fuopt' string (default "maxvert")
global
{not in Vi}
{only in MacVim GUI}
In fullscreen mode, most of the screen is black, only a part of the
screen is covered by the actual Vim control. The control is centered.
This option controls the size of the Vim control as well as the color
of the unused screen area.
value effect ~
maxvert When entering fullscreen, 'lines' is set to the maximum number
of lines fitting on the screen in fullscreen mode. When
leaving fullscreen, if 'lines' is still equal to the maximized
number of lines, it is restored to the value it had before
entering fullscreen.
maxhorz When entering fullscreen, 'columns' is set to the maximum number
of columns fitting on the screen in fullscreen mode. When
leaving fullscreen, if 'columns' is still equal to the maximized
number of columns, it is restored to the value it had before
entering fullscreen.
background:color
When entering fullscreen, 'color' defines the color of the part
of the screen that is not occupied by the Vim control. If
'color' is an 8-digit hexadecimal number preceded by '#',
it is interpreted as an explicit color value '#aarrggbb', with
one byte each for the alpha, red, green, and blue values.
Otherwise, 'color' is interpreted as a highlight group name,
and the fullscreen background is filled with that highlight
group's background color, as defined by the current color
scheme.
Examples:
Don't change size of Vim when entering fullscreen: >
:set fuoptions=
< Maximize Vim when entering fullscreen: >
:set fuoptions=maxvert,maxhorz
< Maximize Vim only vertically when entering fullscreen, and color the
background dark blue: >
:set fuoptions=maxvert,background:#FF003042
< Don't change the size of Vim when entering fullscreen, and color the
background like the current text background: >
:set fuoptions=background:Normal
<
XXX: what if the font size is changed? you probably never want to
restore the old 'lines' or 'columns' in that case.
XXX: Each time the Vim window resizes (for example due to font size
changes, re-maximize Vim to fullscreen?)
XXX: The approach doesn't restore vertical Vim size if fu is entered
without tabs and leaves with tabs (or the other way round).
*'gdefault'* *'gd'* *'nogdefault'* *'nogd'*
'gdefault' 'gd' boolean (default off)
global
@@ -4906,7 +4968,7 @@ A jump table for the options with a short description can be found at |Q_op|.
|autocmd-osfiletypes|
*'paragraphs'* *'para'*
'paragraphs' 'para' string (default "IPLPPPQPP LIpplpipbp")
'paragraphs' 'para' string (default "IPLPPPQPP TPHPLIPpLpItpplpipbp")
global
Specifies the nroff macros that separate paragraphs. These are pairs
of two letters (see |object-motions|).
+7 -3
View File
@@ -1,4 +1,4 @@
*os_mac.txt* For Vim version 7.1. Last change: 2006 Apr 30
*os_mac.txt* For Vim version 7.1. Last change: 2008 May 19
VIM REFERENCE MANUAL by Bram Moolenaar et al.
@@ -6,9 +6,13 @@
*mac* *Mac* *macintosh* *Macintosh*
This file documents the particularities of the Macintosh version of Vim.
This file documents the particularities of the Mac version of Vim. It was
written with the older Carbon version of Vim in mind. If you are using the
newer MacVim.app then please go to |macvim|. Some of the information here
does not apply to MacVim.app.
NOTE: This file is a bit outdated. You might find more useful info here:
NOTE: This file is a bit outdated. You might find more useful info on the old
Carbon version of Vim here:
http://macvim.org/
1. Filename Convention |mac-filename|
+1
View File
@@ -697,6 +697,7 @@ Short explanation of each option: *option-list*
'formatexpr' 'fex' expression used with "gq" command
'fsync' 'fs' whether to invoke fsync() after file write
'fullscreen' 'fu' let vim cover the whole screen (MacVim only)
'fuoptions' 'fuopt' controls how 'fullscreen' behaves (MacVim only)
'gdefault' 'gd' the ":substitute" flag 'g' is default on
'grepformat' 'gfm' format of 'grepprg' output
'grepprg' 'gp' program to use for ":grep"
+2 -1
View File
@@ -766,7 +766,8 @@ accordingly. Vim proceeds in this order:
Note that this file is ALWAYS read in 'compatible' mode, since the
automatic resetting of 'compatible' is only done later. Add a ":set
nocp" command if you like.
For the Macintosh the $VIMRUNTIME/macmap.vim is read.
For the Macintosh the $VIMRUNTIME/macmap.vim is read (not on
MacVim.app, this only applies to the older Carbon version).
*VIMINIT* *.vimrc* *_vimrc* *EXINIT* *.exrc* *_exrc*
c. Four places are searched for initializations. The first that exists
+2
View File
@@ -1177,6 +1177,8 @@ goes from 2.2 to 2.3. (Gordon Prieur)
Mac: When starting up Vim will load the $VIMRUNTIME/macmap.vim script to
define default command-key mappings. (mostly by Benji Fisher)
This only applies to the older Carbon version of Vim, MacVim.app does not
source this file.
Mac: Add the selection type to the clipboard, so that Block, line and
character selections can be used between two Vims. (Eckehard Berns)
+4 -1
View File
@@ -3,7 +3,7 @@
vimtutor \- the Vim tutor
.SH SYNOPSIS
.br
.B vimtutor [language]
.B vimtutor [-g] [language]
.SH DESCRIPTION
.B Vimtutor
starts the
@@ -18,6 +18,9 @@ is useful for people that want to learn their first
.B Vim
commands.
.PP
The optional argument -g starts vimtutor with gvim rather than vim, if the
GUI version of vim is available, or falls back to Vim if gvim is not found.
.PP
The optional [language] argument is the two-letter name of a language, like
"it" or "es".
If the [language] argument is missing, the language of the current locale will
+9 -6
View File
@@ -16,20 +16,23 @@ set cpo&vim
augroup filetypedetect
" Ignored extensions
if exists("*fnameescape")
au BufNewFile,BufRead ?\+.orig,?\+.bak,?\+.old,?\+.new,?\+.rpmsave,?\+.rpmnew
\ exe "doau filetypedetect BufRead " . expand("<afile>:r")
\ exe "doau filetypedetect BufRead " . fnameescape(expand("<afile>:r"))
au BufNewFile,BufRead *~
\ let s:name = expand("<afile>") |
\ let s:short = substitute(s:name, '\~$', '', '') |
\ if s:name != s:short && s:short != "" |
\ exe "doau filetypedetect BufRead " . s:short |
\ exe "doau filetypedetect BufRead " . fnameescape(s:short) |
\ endif |
\ unlet s:name |
\ unlet s:short
\ unlet s:name s:short
au BufNewFile,BufRead ?\+.in
\ if expand("<afile>:t") != "configure.in" |
\ exe "doau filetypedetect BufRead " . expand("<afile>:r") |
\ exe "doau filetypedetect BufRead " . fnameescape(expand("<afile>:r")) |
\ endif
elseif &verbose > 0
echomsg "Warning: some filetypes will not be recognized because this version of Vim does not have fnameescape()"
endif
" Pattern used to match file names which should not be inspected.
" Currently finds compressed files.
@@ -187,7 +190,7 @@ func! s:FTasmsyntax()
let head = " ".getline(1)." ".getline(2)." ".getline(3)." ".getline(4).
\" ".getline(5)." "
if head =~ '\sasmsyntax=\S\+\s'
let b:asmsyntax = substitute(head, '.*\sasmsyntax=\(\S\+\)\s.*','\1', "")
let b:asmsyntax = substitute(head, '.*\sasmsyntax=\([a-zA-Z0-9]\+\)\s.*','\1', "")
elseif ((head =~? '\.title') || (head =~? '\.ident') || (head =~? '\.macro') || (head =~? '\.subtitle') || (head =~? '\.library'))
let b:asmsyntax = "vmasm"
endif
+3 -2
View File
@@ -783,8 +783,9 @@ func! s:BMMunge(fname, bnum)
return name
endfunc
" When just starting Vim, load the buffer menu later
if has("vim_starting")
" When just starting Vim, load the buffer menu later. Don't do this for MacVim
" because it makes the menu flicker each time a new editor window is opened.
if has("vim_starting") && !has("gui_macvim")
augroup LoadBufferMenu
au! VimEnter * if !exists("no_buffers_menu") | call <SID>BMShow() | endif
au VimEnter * au! LoadBufferMenu
+8 -2
View File
@@ -1,7 +1,7 @@
" These commands create the option window.
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last Change: 2006 Oct 10
" Last Change: 2008 May 12
" If there already is an option window, jump to that one.
if bufwinnr("option-window") > 0
@@ -147,7 +147,7 @@ endwhile
" Open the window
new option-window
setlocal ts=15 tw=0
setlocal ts=15 tw=0 noro
" Insert help and a "set" command for each option.
call append(0, '" Each "set" line shows the current value of an option (on the left).')
@@ -350,6 +350,10 @@ call append("$", "lines\tnumber of lines in the display")
call append("$", " \tset lines=" . &lines)
call append("$", "lazyredraw\tdon't redraw while executing macros")
call <SID>BinOptionG("lz", &lz)
if has("reltime")
call append("$", "redrawtime\ttimeout for 'hlsearch' and :match highlighting in msec")
call append("$", " \tset rdt=" . &rdt)
endif
call append("$", "writedelay\tdelay in msec for each char written to the display")
call append("$", "\t(for debugging)")
call append("$", " \tset wd=" . &wd)
@@ -617,6 +621,8 @@ if has("gui")
call append("$", " \tset transparency=" . &transp)
call append("$", "fullscreen\tdisplay vim in fullscreen mode")
call <SID>BinOptionG("fullscreen", &fullscreen)
call append("$", "fuoptions\tcontrol how fullscreen mode should behave")
call <SID>OptionG("fuoptions", &fuoptions)
endif
endif
+42 -30
View File
@@ -1,6 +1,6 @@
" Vim plugin for showing matching parens
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last Change: 2008 Jan 06
" Last Change: 2008 Feb 27
" Exit quickly when:
" - this plugin was already loaded (or disabled)
@@ -34,7 +34,8 @@ function! s:Highlight_Matching_Pair()
endif
" Avoid that we remove the popup menu.
if pumvisible()
" Return when there are no colors (looks like the cursor jumps).
if pumvisible() || (&t_Co < 8 && !has("gui_running"))
return
endif
@@ -60,39 +61,13 @@ function! s:Highlight_Matching_Pair()
endif
" Figure out the arguments for searchpairpos().
" Restrict the search to visible lines with "stopline".
" And avoid searching very far (e.g., for closed folds and long lines)
" The "viewable" variables give a range in which we can scroll while keeping
" the cursor at the same position
" adjustedScrolloff accounts for very large numbers of scrolloff
let adjustedScrolloff = min([&scrolloff, (line('w$') - line('w0')) / 2])
let bottom_viewable = min([line('$'), c_lnum + &lines - adjustedScrolloff - 2])
let top_viewable = max([1, c_lnum-&lines+adjustedScrolloff + 2])
" one of these stoplines will be adjusted below, but the current values are
" minimal boundaries within the current window
let stoplinebottom = line('w$')
let stoplinetop = line('w0')
if i % 2 == 0
let s_flags = 'nW'
let c2 = plist[i + 1]
if has("byte_offset") && has("syntax_items") && &smc > 0
let stopbyte = min([line2byte("$"), line2byte(".") + col(".") + &smc * 2])
let stopline = min([bottom_viewable, byte2line(stopbyte)])
else
let stopline = min([bottom_viewable, c_lnum + 100])
endif
let stoplinebottom = stopline
else
let s_flags = 'nbW'
let c2 = c
let c = plist[i - 1]
if has("byte_offset") && has("syntax_items") && &smc > 0
let stopbyte = max([1, line2byte(".") + col(".") - &smc * 2])
let stopline = max([top_viewable, byte2line(stopbyte)])
else
let stopline = max([top_viewable, c_lnum - 100])
endif
let stoplinetop = stopline
endif
if c == '['
let c = '\['
@@ -111,10 +86,47 @@ function! s:Highlight_Matching_Pair()
\ '=~? "string\\|character\\|singlequote\\|comment"'
execute 'if' s_skip '| let s_skip = 0 | endif'
" Limit the search to lines visible in the window.
let stoplinebottom = line('w$')
let stoplinetop = line('w0')
if i % 2 == 0
let stopline = stoplinebottom
else
let stopline = stoplinetop
endif
try
" Limit the search time to 500 msec to avoid a hang on very long lines.
let [m_lnum, m_col] = searchpairpos(c, '', c2, s_flags, s_skip, stopline, 500)
" Limit the search time to 300 msec to avoid a hang on very long lines.
" This fails when a timeout is not supported.
let [m_lnum, m_col] = searchpairpos(c, '', c2, s_flags, s_skip, stopline, 300)
catch /E118/
" Can't use the timeout, restrict the stopline a bit more to avoid taking
" a long time on closed folds and long lines.
" The "viewable" variables give a range in which we can scroll while
" keeping the cursor at the same position.
" adjustedScrolloff accounts for very large numbers of scrolloff.
let adjustedScrolloff = min([&scrolloff, (line('w$') - line('w0')) / 2])
let bottom_viewable = min([line('$'), c_lnum + &lines - adjustedScrolloff - 2])
let top_viewable = max([1, c_lnum-&lines+adjustedScrolloff + 2])
" one of these stoplines will be adjusted below, but the current values are
" minimal boundaries within the current window
if i % 2 == 0
if has("byte_offset") && has("syntax_items") && &smc > 0
let stopbyte = min([line2byte("$"), line2byte(".") + col(".") + &smc * 2])
let stopline = min([bottom_viewable, byte2line(stopbyte)])
else
let stopline = min([bottom_viewable, c_lnum + 100])
endif
let stoplinebottom = stopline
else
if has("byte_offset") && has("syntax_items") && &smc > 0
let stopbyte = max([1, line2byte(".") + col(".") - &smc * 2])
let stopline = max([top_viewable, byte2line(stopbyte)])
else
let stopline = max([top_viewable, c_lnum - 100])
endif
let stoplinetop = stopline
endif
let [m_lnum, m_col] = searchpairpos(c, '', c2, s_flags, s_skip, stopline)
endtry
+1 -1
View File
@@ -24,7 +24,7 @@ gvimext.dll: gvimext.obj \
gvimext.obj: gvimext.h
.cpp.obj:
$(cc) $(cflags) -DFEAT_GETTEXT $(cvarsdll) $*.cpp
$(cc) $(cflags) -DFEAT_GETTEXT $(cvarsmt) $*.cpp
gvimext.res: gvimext.rc
$(rc) $(rcflags) $(rcvars) gvimext.rc
+10 -3
View File
@@ -82,9 +82,8 @@ To compile and debug Vim with the VC2003 Toolkit, you will also need
|ms-platform-sdk|, |dotnet-1.1-redist|, |dotnet-1.1-sdk|,
and |windbg-download|.
It's easier to download Visual C++ 2005 Express Edition, |msvc-2005-express|.
The advantage of the VC 2003 Toolkit is that it will be freely available
long after VC 2005 Express Edition stops being free in November 2006.
It's easier to download Visual C++ 2008 Express Edition, |msvc-2008-express|,
which is freely available in perpetuity.
The free Code::Blocks IDE works with the VC2003 Toolkit, as described at
http://wiki.codeblocks.org/index.php?title=Integrating_Microsoft_Visual_Toolkit_2003_with_Code::Blocks_IDE
@@ -152,6 +151,14 @@ Instructions for integrating the Platform SDK into VC Express:
http://msdn.microsoft.com/vstudio/express/visualc/usingpsdk/default.aspx
Visual C++ 2008 Express Edition *msvc-2008-express*
-------------------------------
Visual C++ 2008 Express Edition can be downloaded for free from:
http://msdn2.microsoft.com/en-us/express/default.aspx
This includes the IDE and the debugger. You can build Vim with Make_mvc.mak.
2. MinGW
========
+27 -1
View File
@@ -1,11 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>_cycleWindows:</key>
<string></string>
<key>_cycleWindowsBackwards:</key>
<string></string>
<key>addNewTab:</key>
<string></string>
<key>arrangeInFront:</key>
<string></string>
<key>clearRecentDocuments:</key>
<string></string>
<key>copy:</key>
<string></string>
<key>cut:</key>
<string></string>
<key>fileOpen:</key>
<string></string>
<key>findNext:</key>
@@ -24,27 +34,43 @@
<string></string>
<key>newWindow:</key>
<string></string>
<key>openWebsite:</key>
<string></string>
<key>orderFrontCharacterPalette:</key>
<string></string>
<key>orderFrontFontPanel:</key>
<string></string>
<key>orderFrontPreferencePanel:</key>
<string></string>
<key>paste:</key>
<string></string>
<key>performClose:</key>
<string></string>
<key>performMiniaturize:</key>
<string></string>
<key>performZoom:</key>
<string></string>
<key>recentFilesDummy:</key>
<string></string>
<key>redo:</key>
<string></string>
<key>selectAll:</key>
<string></string>
<key>selectNextWindow:</key>
<string></string>
<key>selectPreviousWindow:</key>
<string></string>
<key>showVimHelp:</key>
<string></string>
<key>terminate:</key>
<string></string>
<key>undo:</key>
<string></string>
<key>unhide:</key>
<string></string>
<key>unhideAllApplications:</key>
<string></string>
<key>zoomAll:</key>
<string></string>
</dict>
</plist>
+13 -12
View File
@@ -1,32 +1,33 @@
{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf440
{\fonttbl\f0\fswiss\fcharset77 Helvetica-Bold;\f1\fswiss\fcharset77 Helvetica;\f2\fswiss\fcharset77 Helvetica-Oblique;
}
{\rtf1\ansi\ansicpg1252\cocoartf949\cocoasubrtf270
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
\vieww9000\viewh8400\viewkind0
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural
\f0\b\fs24 \cf0 VIM - Vi IMproved
\f1\b0 \
\b0 \
\f2\i Bram Moolenaar et al.
\f1\i0 \
\i Bram Moolenaar et al.
\i0 \
\
\f0\b MacVim GUI\
\b MacVim GUI\
\f2\i\b0 Bj\'9arn Winckler\
\i\b0 Bj\'f6rn Winckler\
\f1\i0 \
\i0 \
with the help of:\
\f2\i Nico Weber\
\i Nico Weber\
George Harker\
Jjgod Jiang\
Tim Allen\
Chris Willmore\
Ben Schmidt\
Scott Renfro\
Enno L\'fcbbers\
\f1\i0 \
\i0 \
...and many others who have helped by reporting bugs etc.\
\
\
@@ -36,7 +37,7 @@ Toolbar icons from {\field{\*\fldinst{HYPERLINK "http://svn.gnome.org/viewvc/gno
\
Vim icons made by {\field{\*\fldinst{HYPERLINK "http://www.cs.princeton.edu/~mtwebb/vim_icon/vim_icons.html"}}{\fldrslt Matthew Webb}}.\
\
The default font in MacVim, DejaVu Sans Mono, is based on the Bitstream Vera\'aa and Arev fonts. Bitstream Vera\'aa is \'a9 2003 by Bitstream, Inc. Arev is \'a9 2006 by Tavmjong Bah. The DejaVu changes to these fonts are in the public domain.\
The default font in MacVim, DejaVu Sans Mono, is based on the Bitstream Vera\'99 and Arev fonts. Bitstream Vera\'99 is \'a9 2003 by Bitstream, Inc. Arev is \'a9 2006 by Tavmjong Bah. The DejaVu changes to these fonts are in the public domain.\
\
Thanks to Andy Matuschak for {\field{\*\fldinst{HYPERLINK "http://sparkle.andymatuschak.org/"}}{\fldrslt Sparkle}}.\
\
+20
View File
@@ -15,12 +15,20 @@
<string>id</string>
<key>newWindow</key>
<string>id</string>
<key>openWebsite</key>
<string>id</string>
<key>orderFrontPreferencePanel</key>
<string>id</string>
<key>selectNextWindow</key>
<string>id</string>
<key>selectPreviousWindow</key>
<string>id</string>
<key>showHelp</key>
<string>id</string>
<key>showVimHelp</key>
<string>id</string>
<key>zoomAll</key>
<string>id</string>
</dict>
<key>CLASS</key>
<string>MMAppController</string>
@@ -29,9 +37,21 @@
<key>SUPERCLASS</key>
<string>NSObject</string>
</dict>
<dict>
<key>CLASS</key>
<string>NSMenu</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSObject</string>
</dict>
<dict>
<key>ACTIONS</key>
<dict>
<key>_cycleWindows</key>
<string>id</string>
<key>_cycleWindowsBackwards</key>
<string>id</string>
<key>addNewTab</key>
<string>id</string>
</dict>
+2 -2
View File
@@ -10,10 +10,10 @@
<integer>5</integer>
<key>IBOpenObjects</key>
<array>
<integer>57</integer>
<integer>310</integer>
</array>
<key>IBSystem Version</key>
<string>9B18</string>
<string>9D34</string>
<key>targetFramework</key>
<string>IBCocoaFramework</string>
</dict>
Binary file not shown.
+30 -1
View File
@@ -4,6 +4,35 @@
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<!--
Both UTExportedTypeDeclarations (for Spotlight and QuickLook) and
CFBundleDocumentTypes seem to be required, even though they contain
more or less the same information:
http://lists.apple.com/archives/Spotlight-dev/2007/Jul/msg00019.html
-->
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.text</string>
<string>public.plain-text</string>
</array>
<key>UTTypeDescription</key>
<string>vim script file</string>
<key>UTTypeIdentifier</key>
<string>org.vim.vim</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>com.apple.ostype</key>
<string>TEXT</string>
<key>public.filename-extension</key>
<array>
<string>vim</string>
</array>
</dict>
</dict>
</array>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
@@ -545,7 +574,7 @@
<key>CFBundleSignature</key>
<string>VIMM</string>
<key>CFBundleVersion</key>
<string>24</string>
<string>30</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
+11 -2
View File
@@ -16,20 +16,29 @@
@interface MMAppController : NSObject <MMAppProtocol> {
NSConnection *connection;
NSMutableArray *vimControllers;
NSString *openSelectionString;
ATSFontContainerRef fontContainerRef;
NSMutableDictionary *pidArguments;
NSMenu *defaultMainMenu;
NSMenuItem *appMenuItemTemplate;
NSMenuItem *recentFilesMenuItem;
}
+ (MMAppController *)sharedInstance;
- (NSMenu *)defaultMainMenu;
- (NSMenuItem *)appMenuItemTemplate;
- (void)removeVimController:(id)controller;
- (void)windowControllerWillOpen:(MMWindowController *)windowController;
- (void)setMainMenu:(NSMenu *)mainMenu;
- (IBAction)newWindow:(id)sender;
- (IBAction)fileOpen:(id)sender;
- (IBAction)selectNextWindow:(id)sender;
- (IBAction)selectPreviousWindow:(id)sender;
- (IBAction)fontSizeUp:(id)sender;
- (IBAction)fontSizeDown:(id)sender;
- (IBAction)orderFrontPreferencePanel:(id)sender;
- (IBAction)openWebsite:(id)sender;
- (IBAction)showVimHelp:(id)sender;
- (IBAction)zoomAll:(id)sender;
@end
+351 -101
View File
@@ -13,7 +13,7 @@
* MMAppController is the delegate of NSApp and as such handles file open
* requests, application termination, etc. It sets up a named NSConnection on
* which it listens to incoming connections from Vim processes. It also
* coordinates all MMVimControllers.
* coordinates all MMVimControllers and takes care of the main menu.
*
* A new Vim process is started by calling launchVimProcessWithArguments:.
* When the Vim process is initialized it notifies the app controller by
@@ -24,6 +24,17 @@
* A Vim process started from the command line connects directly by sending the
* connectBackend:pid: message (launchVimProcessWithArguments: is never called
* in this case).
*
* The main menu is handled as follows. Each Vim controller keeps its own main
* menu. All menus except the "MacVim" menu are controlled by the Vim process.
* The app controller also keeps a reference to the "default main menu" which
* is set up in MainMenu.nib. When no editor window is open the default main
* menu is used. When a new editor window becomes main its main menu becomes
* the new main menu, this is done in -[MMAppController setMainMenu:].
* NOTE: Certain heuristics are used to find the "MacVim", "Windows", "File",
* and "Services" menu. If MainMenu.nib changes these heuristics may have to
* change as well. For specifics see the find... methods defined in the NSMenu
* category "MMExtras".
*/
#import "MMAppController.h"
@@ -41,6 +52,12 @@
static NSTimeInterval MMRequestTimeout = 5;
static NSTimeInterval MMReplyTimeout = 5;
static NSString *MMWebsiteString = @"http://code.google.com/p/macvim/";
// When terminating, notify Vim processes then sleep for these many
// microseconds.
static useconds_t MMTerminationSleepPeriod = 10000;
#pragma options align=mac68k
typedef struct
@@ -84,15 +101,24 @@ static int executeInLoginShell(NSString *path, NSArray *args);
- (void)passArguments:(NSDictionary *)args toVimController:(MMVimController*)vc;
@end
@interface NSMenu (MMExtras)
- (void)recurseSetAutoenablesItems:(BOOL)on;
@end
@interface NSNumber (MMExtras)
- (int)tag;
@end
@interface NSMenu (MMExtras)
- (int)indexOfItemWithAction:(SEL)action;
- (NSMenuItem *)itemWithAction:(SEL)action;
- (NSMenu *)findMenuContainingItemWithAction:(SEL)action;
- (NSMenu *)findWindowsMenu;
- (NSMenu *)findApplicationMenu;
- (NSMenu *)findServicesMenu;
- (NSMenu *)findFileMenu;
@end
@implementation MMAppController
@@ -122,6 +148,7 @@ static int executeInLoginShell(NSString *path, NSArray *args);
[NSNumber numberWithBool:NO], MMZoomBothKey,
@"", MMLoginShellCommandKey,
@"", MMLoginShellArgumentKey,
[NSNumber numberWithBool:YES], MMDialogsTrackPwdKey,
nil];
[[NSUserDefaults standardUserDefaults] registerDefaults:dict];
@@ -138,24 +165,30 @@ static int executeInLoginShell(NSString *path, NSArray *args);
vimControllers = [NSMutableArray new];
pidArguments = [NSMutableDictionary new];
// NOTE: Do not use the default connection since the Logitech Control
// Center (LCC) input manager steals and this would cause MacVim to
// never open any windows. (This is a bug in LCC but since they are
// unlikely to fix it, we graciously give them the default connection.)
connection = [[NSConnection alloc] initWithReceivePort:[NSPort port]
sendPort:nil];
[connection setRootObject:self];
[connection setRequestTimeout:MMRequestTimeout];
[connection setReplyTimeout:MMReplyTimeout];
// NOTE: When the user is resizing the window the AppKit puts the run
// loop in event tracking mode. Unless the connection listens to
// request in this mode, live resizing won't work.
[connection addRequestMode:NSEventTrackingRunLoopMode];
// NOTE! If the name of the connection changes here it must also be
// updated in MMBackend.m.
NSConnection *connection = [NSConnection defaultConnection];
NSString *name = [NSString stringWithFormat:@"%@-connection",
[[NSBundle mainBundle] bundleIdentifier]];
//NSLog(@"Registering connection with name '%@'", name);
if ([connection registerName:name]) {
[connection setRequestTimeout:MMRequestTimeout];
[connection setReplyTimeout:MMReplyTimeout];
[connection setRootObject:self];
// NOTE: When the user is resizing the window the AppKit puts the
// run loop in event tracking mode. Unless the connection listens
// to request in this mode, live resizing won't work.
[connection addRequestMode:NSEventTrackingRunLoopMode];
} else {
NSLog(@"WARNING: Failed to register connection with name '%@'",
if (![connection registerName:name]) {
NSLog(@"FATAL ERROR: Failed to register connection with name '%@'",
name);
[connection release]; connection = nil;
}
}
@@ -166,23 +199,65 @@ static int executeInLoginShell(NSString *path, NSArray *args);
{
//NSLog(@"MMAppController dealloc");
[connection release]; connection = nil;
[pidArguments release]; pidArguments = nil;
[vimControllers release]; vimControllers = nil;
[openSelectionString release]; openSelectionString = nil;
[recentFilesMenuItem release]; recentFilesMenuItem = nil;
[defaultMainMenu release]; defaultMainMenu = nil;
[appMenuItemTemplate release]; appMenuItemTemplate = nil;
[super dealloc];
}
#if MM_HANDLE_XCODE_MOD_EVENT
- (void)applicationWillFinishLaunching:(NSNotification *)notification
{
// Remember the default menu so that it can be restored if the user closes
// all editor windows.
defaultMainMenu = [[NSApp mainMenu] retain];
// Store a copy of the default app menu so we can use this as a template
// for all other menus. We make a copy here because the "Services" menu
// will not yet have been populated at this time. If we don't we get
// problems trying to set key equivalents later on because they might clash
// with items on the "Services" menu.
appMenuItemTemplate = [defaultMainMenu itemAtIndex:0];
appMenuItemTemplate = [appMenuItemTemplate copy];
// Set up the "Open Recent" menu. See
// http://lapcatsoftware.com/blog/2007/07/10/
// working-without-a-nib-part-5-open-recent-menu/
// and
// http://www.cocoabuilder.com/archive/message/cocoa/2007/8/15/187793
// for more information.
//
// The menu itself is created in MainMenu.nib but we still seem to have to
// hack around a bit to get it to work. (This has to be done in
// applicationWillFinishLaunching at the latest, otherwise it doesn't
// work.)
NSMenu *fileMenu = [defaultMainMenu findFileMenu];
if (fileMenu) {
int idx = [fileMenu indexOfItemWithAction:@selector(fileOpen:)];
if (idx >= 0 && idx+1 < [fileMenu numberOfItems])
recentFilesMenuItem = [fileMenu itemWithTitle:@"Open Recent"];
[[recentFilesMenuItem submenu] performSelector:@selector(_setMenuName:)
withObject:@"NSRecentDocumentsMenu"];
// Note: The "Recent Files" menu must be moved around since there is no
// -[NSApp setRecentFilesMenu:] method. We keep a reference to it to
// facilitate this move (see setMainMenu: below).
[recentFilesMenuItem retain];
}
#if MM_HANDLE_XCODE_MOD_EVENT
[[NSAppleEventManager sharedAppleEventManager]
setEventHandler:self
andSelector:@selector(handleXcodeModEvent:replyEvent:)
forEventClass:'KAHL'
andEventID:'MOD '];
}
#endif
}
- (void)applicationDidFinishLaunching:(NSNotification *)notification
{
@@ -259,6 +334,16 @@ static int executeInLoginShell(NSString *path, NSArray *args);
[arguments setObject:filenames forKey:@"filenames"];
[arguments setObject:[NSNumber numberWithBool:YES] forKey:@"openFiles"];
// Add file names to "Recent Files" menu.
int i, count = [filenames count];
for (i = 0; i < count; ++i) {
// Don't add files that are being edited remotely (using ODB).
if ([arguments objectForKey:@"remoteID"]) continue;
[[NSDocumentController sharedDocumentController]
noteNewRecentFilePath:[filenames objectAtIndex:i]];
}
if ((openInTabs && (vc = [self topmostVimController]))
|| (vc = [self findUntitledWindow])) {
// Open files in an already open window.
@@ -338,11 +423,16 @@ static int executeInLoginShell(NSString *path, NSArray *args);
if (modifiedBuffers) {
NSAlert *alert = [[NSAlert alloc] init];
[alert setAlertStyle:NSWarningAlertStyle];
[alert addButtonWithTitle:@"Quit"];
[alert addButtonWithTitle:@"Cancel"];
[alert setMessageText:@"Quit without saving?"];
[alert setInformativeText:@"There are modified buffers, "
"if you quit now all changes will be lost. Quit anyway?"];
[alert addButtonWithTitle:NSLocalizedString(@"Quit",
@"Dialog button")];
[alert addButtonWithTitle:NSLocalizedString(@"Cancel",
@"Dialog button")];
[alert setMessageText:NSLocalizedString(@"Quit without saving?",
@"Quit dialog with changed buffers, title")];
[alert setInformativeText:NSLocalizedString(
@"There are modified buffers, "
"if you quit now all changes will be lost. Quit anyway?",
@"Quit dialog with changed buffers, text")];
if ([alert runModal] != NSAlertFirstButtonReturn)
reply = NSTerminateCancel;
@@ -369,24 +459,35 @@ static int executeInLoginShell(NSString *path, NSArray *args);
if (numWindows > 1 || numTabs > 1) {
NSAlert *alert = [[NSAlert alloc] init];
[alert setAlertStyle:NSWarningAlertStyle];
[alert addButtonWithTitle:@"Quit"];
[alert addButtonWithTitle:@"Cancel"];
[alert setMessageText:@"Are you sure you want to quit MacVim?"];
[alert addButtonWithTitle:NSLocalizedString(@"Quit",
@"Dialog button")];
[alert addButtonWithTitle:NSLocalizedString(@"Cancel",
@"Dialog button")];
[alert setMessageText:NSLocalizedString(
@"Are you sure you want to quit MacVim?",
@"Quit dialog with no changed buffers, title")];
NSString *info = nil;
if (numWindows > 1) {
if (numTabs > numWindows)
info = [NSString stringWithFormat:@"There are %d windows "
"open in MacVim, with a total of %d tabs. Do you want "
"to quit anyway?", numWindows, numTabs];
info = [NSString stringWithFormat:NSLocalizedString(
@"There are %d windows open in MacVim, with a "
"total of %d tabs. Do you want to quit anyway?",
@"Quit dialog with no changed buffers, text"),
numWindows, numTabs];
else
info = [NSString stringWithFormat:@"There are %d windows "
"open in MacVim. Do you want to quit anyway?",
info = [NSString stringWithFormat:NSLocalizedString(
@"There are %d windows open in MacVim. "
"Do you want to quit anyway?",
@"Quit dialog with no changed buffers, text"),
numWindows];
} else {
info = [NSString stringWithFormat:@"There are %d tabs open "
"in MacVim. Do you want to quit anyway?", numTabs];
info = [NSString stringWithFormat:NSLocalizedString(
@"There are %d tabs open in MacVim. "
"Do you want to quit anyway?",
@"Quit dialog with no changed buffers, text"),
numTabs];
}
[alert setInformativeText:info];
@@ -406,6 +507,11 @@ static int executeInLoginShell(NSString *path, NSArray *args);
id vc;
while ((vc = [e nextObject]))
[vc sendMessage:TerminateNowMsgID data:nil];
// Give Vim processes a chance to terminate before MacVim. If they
// haven't terminated by the time applicationWillTerminate: is sent,
// they may be forced to quit (see below).
usleep(MMTerminationSleepPeriod);
}
return reply;
@@ -419,9 +525,9 @@ static int executeInLoginShell(NSString *path, NSArray *args);
andEventID:'MOD '];
#endif
// This will invalidate all connections (since they were spawned from the
// default connection).
[[NSConnection defaultConnection] invalidate];
// This will invalidate all connections (since they were spawned from this
// connection).
[connection invalidate];
// Send a SIGINT to all running Vim processes, so that they are sure to
// receive the connectionDidDie: notification (a process has to be checking
@@ -442,6 +548,24 @@ static int executeInLoginShell(NSString *path, NSArray *args);
[NSApp setDelegate:nil];
}
+ (MMAppController *)sharedInstance
{
// Note: The app controller is a singleton which is instantiated in
// MainMenu.nib where it is also connected as the delegate of NSApp.
id delegate = [NSApp delegate];
return [delegate isKindOfClass:self] ? (MMAppController*)delegate : nil;
}
- (NSMenu *)defaultMainMenu
{
return defaultMainMenu;
}
- (NSMenuItem *)appMenuItemTemplate
{
return appMenuItemTemplate;
}
- (void)removeVimController:(id)controller
{
//NSLog(@"%s%@", _cmd, controller);
@@ -451,31 +575,24 @@ static int executeInLoginShell(NSString *path, NSArray *args);
[vimControllers removeObject:controller];
if (![vimControllers count]) {
// Turn on autoenabling of menus (because no Vim is open to handle it),
// but do not touch the MacVim menu. Note that the menus must be
// enabled first otherwise autoenabling does not work.
NSMenu *mainMenu = [NSApp mainMenu];
int i, count = [mainMenu numberOfItems];
for (i = 1; i < count; ++i) {
NSMenuItem *item = [mainMenu itemAtIndex:i];
[item setEnabled:YES];
[[item submenu] recurseSetAutoenablesItems:YES];
}
// The last editor window just closed so restore the main menu back to
// its default state (which is defined in MainMenu.nib).
[self setMainMenu:defaultMainMenu];
}
}
- (void)windowControllerWillOpen:(MMWindowController *)windowController
{
NSPoint topLeft = NSZeroPoint;
NSWindow *keyWin = [NSApp keyWindow];
NSWindow *topWin = [[[self topmostVimController] windowController] window];
NSWindow *win = [windowController window];
if (!win) return;
// If there is a key window, cascade from it, otherwise use the autosaved
// window position (if any).
if (keyWin) {
NSRect frame = [keyWin frame];
// If there is a window belonging to a Vim process, cascade from it,
// otherwise use the autosaved window position (if any).
if (topWin) {
NSRect frame = [topWin frame];
topLeft = NSMakePoint(frame.origin.x, NSMaxY(frame));
} else {
NSString *topLeftString = [[NSUserDefaults standardUserDefaults]
@@ -485,7 +602,7 @@ static int executeInLoginShell(NSString *path, NSArray *args);
}
if (!NSEqualPoints(topLeft, NSZeroPoint)) {
if (keyWin)
if (topWin)
topLeft = [win cascadeTopLeftFromPoint:topLeft];
[win setFrameTopLeftPoint:topLeft];
@@ -503,6 +620,69 @@ static int executeInLoginShell(NSString *path, NSArray *args);
}
}
- (void)setMainMenu:(NSMenu *)mainMenu
{
if ([NSApp mainMenu] == mainMenu) return;
// If the new menu has a "Recent Files" dummy item, then swap the real item
// for the dummy. We are forced to do this since Cocoa initializes the
// "Recent Files" menu and there is no way to simply point Cocoa to a new
// item each time the menus are swapped.
NSMenu *fileMenu = [mainMenu findFileMenu];
if (recentFilesMenuItem && fileMenu) {
int dummyIdx =
[fileMenu indexOfItemWithAction:@selector(recentFilesDummy:)];
if (dummyIdx >= 0) {
NSMenuItem *dummyItem = [[fileMenu itemAtIndex:dummyIdx] retain];
[fileMenu removeItemAtIndex:dummyIdx];
NSMenu *recentFilesParentMenu = [recentFilesMenuItem menu];
int idx = [recentFilesParentMenu indexOfItem:recentFilesMenuItem];
if (idx >= 0) {
[[recentFilesMenuItem retain] autorelease];
[recentFilesParentMenu removeItemAtIndex:idx];
[recentFilesParentMenu insertItem:dummyItem atIndex:idx];
}
[fileMenu insertItem:recentFilesMenuItem atIndex:dummyIdx];
[dummyItem release];
}
}
// Now set the new menu. Notice that we keep one menu for each editor
// window since each editor can have its own set of menus. When swapping
// menus we have to tell Cocoa where the new "MacVim", "Windows", and
// "Services" menu are.
[NSApp setMainMenu:mainMenu];
// Setting the "MacVim" (or "Application") menu ensures that it is typeset
// in boldface. (The setAppleMenu: method used to be public but is now
// private so this will have to be considered a bit of a hack!)
NSMenu *appMenu = [mainMenu findApplicationMenu];
[NSApp performSelector:@selector(setAppleMenu:) withObject:appMenu];
NSMenu *servicesMenu = [mainMenu findServicesMenu];
[NSApp setServicesMenu:servicesMenu];
NSMenu *windowsMenu = [mainMenu findWindowsMenu];
if (windowsMenu) {
// Cocoa isn't clever enough to get rid of items it has added to the
// "Windows" menu so we have to do it ourselves otherwise there will be
// multiple menu items for each window in the "Windows" menu.
// This code assumes that the only items Cocoa add are ones which
// send off the action makeKeyAndOrderFront:. (Cocoa will not add
// another separator item if the last item on the "Windows" menu
// already is a separator, so we needen't worry about separators.)
int i, count = [windowsMenu numberOfItems];
for (i = count-1; i >= 0; --i) {
NSMenuItem *item = [windowsMenu itemAtIndex:i];
if ([item action] == @selector(makeKeyAndOrderFront:))
[windowsMenu removeItem:item];
}
}
[NSApp setWindowsMenu:windowsMenu];
}
- (IBAction)newWindow:(id)sender
{
[self launchVimProcessWithArguments:nil];
@@ -510,10 +690,17 @@ static int executeInLoginShell(NSString *path, NSArray *args);
- (IBAction)fileOpen:(id)sender
{
NSString *dir = nil;
BOOL trackPwd = [[NSUserDefaults standardUserDefaults]
boolForKey:MMDialogsTrackPwdKey];
if (trackPwd) {
MMVimController *vc = [self keyVimController];
if (vc) dir = [[vc vimState] objectForKey:@"pwd"];
}
NSOpenPanel *panel = [NSOpenPanel openPanel];
[panel setAllowsMultipleSelection:YES];
int result = [panel runModalForTypes:nil];
int result = [panel runModalForDirectory:dir file:nil types:nil];
if (NSOKButton == result)
[self application:NSApp openFiles:[panel filenames]];
}
@@ -561,23 +748,29 @@ static int executeInLoginShell(NSString *path, NSArray *args);
}
}
- (IBAction)fontSizeUp:(id)sender
{
[[NSFontManager sharedFontManager] modifyFont:
[NSNumber numberWithInt:NSSizeUpFontAction]];
}
- (IBAction)fontSizeDown:(id)sender
{
[[NSFontManager sharedFontManager] modifyFont:
[NSNumber numberWithInt:NSSizeDownFontAction]];
}
- (IBAction)orderFrontPreferencePanel:(id)sender
{
[[MMPreferenceController sharedPrefsWindowController] showWindow:self];
}
- (IBAction)openWebsite:(id)sender
{
[[NSWorkspace sharedWorkspace] openURL:
[NSURL URLWithString:MMWebsiteString]];
}
- (IBAction)showVimHelp:(id)sender
{
// Open a new window with the help window maximized.
[self launchVimProcessWithArguments:[NSArray arrayWithObjects:
@"-c", @":h gui_mac", @"-c", @":res", nil]];
}
- (IBAction)zoomAll:(id)sender
{
[NSApp makeWindowsPerform:@selector(performZoom:) inOrder:YES];
}
- (byref id <MMFrontendProtocol>)
connectBackend:(byref in id <MMBackendProtocol>)backend
pid:(int)pid
@@ -591,7 +784,8 @@ static int executeInLoginShell(NSString *path, NSArray *args);
setProtocolForProxy:@protocol(MMBackendProtocol)];
vc = [[[MMVimController alloc]
initWithBackend:backend pid:pid] autorelease];
initWithBackend:backend pid:pid]
autorelease];
if (![vimControllers count]) {
// The first window autosaves its position. (The autosaving
@@ -733,9 +927,10 @@ static int executeInLoginShell(NSString *path, NSArray *args);
- (MMVimController *)topmostVimController
{
NSArray *windows = [NSApp orderedWindows];
if ([windows count] > 0) {
NSWindow *window = [windows objectAtIndex:0];
// Find the topmost visible window which has an associated vim controller.
NSEnumerator *e = [[NSApp orderedWindows] objectEnumerator];
id window;
while ((window = [e nextObject]) && [window isVisible]) {
unsigned i, count = [vimControllers count];
for (i = 0; i < count; ++i) {
MMVimController *vc = [vimControllers objectAtIndex:i];
@@ -810,18 +1005,23 @@ static int executeInLoginShell(NSString *path, NSArray *args);
if (firstMissingFile) {
NSAlert *alert = [[NSAlert alloc] init];
[alert addButtonWithTitle:@"OK"];
[alert addButtonWithTitle:NSLocalizedString(@"OK",
@"Dialog button")];
NSString *text;
if ([files count] >= count-1) {
[alert setMessageText:@"File not found"];
text = [NSString stringWithFormat:@"Could not open file with "
"name %@.", firstMissingFile];
[alert setMessageText:NSLocalizedString(@"File not found",
@"File not found dialog, title")];
text = [NSString stringWithFormat:NSLocalizedString(
@"Could not open file with name %@.",
@"File not found dialog, text"), firstMissingFile];
} else {
[alert setMessageText:@"Multiple files not found"];
text = [NSString stringWithFormat:@"Could not open file with "
"name %@, and %d other files.", firstMissingFile,
count-[files count]-1];
[alert setMessageText:NSLocalizedString(@"Multiple files not found",
@"File not found dialog, title")];
text = [NSString stringWithFormat:NSLocalizedString(
@"Could not open file with name %@, and %d other files.",
@"File not found dialog, text"),
firstMissingFile, count-[files count]-1];
}
[alert setInformativeText:text];
@@ -953,6 +1153,8 @@ static int executeInLoginShell(NSString *path, NSArray *args);
// TODO: This is a moronic test...should query the Vim process if there
// are any open buffers or something like that instead.
NSString *title = [[[vc windowController] window] title];
// TODO: this will not work in a localized MacVim
if ([title hasPrefix:@"[No Name] - VIM"]) {
//NSLog(@"found untitled window");
return vc;
@@ -1059,28 +1261,6 @@ static int executeInLoginShell(NSString *path, NSArray *args);
@implementation NSMenu (MMExtras)
- (void)recurseSetAutoenablesItems:(BOOL)on
{
[self setAutoenablesItems:on];
int i, count = [self numberOfItems];
for (i = 0; i < count; ++i) {
NSMenuItem *item = [self itemAtIndex:i];
[item setEnabled:YES];
NSMenu *submenu = [item submenu];
if (submenu) {
[submenu recurseSetAutoenablesItems:on];
}
}
}
@end // NSMenu (MMExtras)
@implementation NSNumber (MMExtras)
- (int)tag
{
@@ -1091,6 +1271,77 @@ static int executeInLoginShell(NSString *path, NSArray *args);
@implementation NSMenu (MMExtras)
- (int)indexOfItemWithAction:(SEL)action
{
int i, count = [self numberOfItems];
for (i = 0; i < count; ++i) {
NSMenuItem *item = [self itemAtIndex:i];
if ([item action] == action)
return i;
}
return -1;
}
- (NSMenuItem *)itemWithAction:(SEL)action
{
int idx = [self indexOfItemWithAction:action];
return idx >= 0 ? [self itemAtIndex:idx] : nil;
}
- (NSMenu *)findMenuContainingItemWithAction:(SEL)action
{
// NOTE: We only look for the action in the submenus of 'self'
int i, count = [self numberOfItems];
for (i = 0; i < count; ++i) {
NSMenu *menu = [[self itemAtIndex:i] submenu];
NSMenuItem *item = [menu itemWithAction:action];
if (item) return menu;
}
return nil;
}
- (NSMenu *)findWindowsMenu
{
return [self findMenuContainingItemWithAction:
@selector(performMiniaturize:)];
}
- (NSMenu *)findApplicationMenu
{
// TODO: Just return [self itemAtIndex:0]?
return [self findMenuContainingItemWithAction:@selector(terminate:)];
}
- (NSMenu *)findServicesMenu
{
// NOTE! Our heuristic for finding the "Services" menu is to look for the
// second item before the "Hide MacVim" menu item on the "MacVim" menu.
// (The item before "Hide MacVim" should be a separator, but this is not
// important as long as the item before that is the "Services" menu.)
NSMenu *appMenu = [self findApplicationMenu];
if (!appMenu) return nil;
int idx = [appMenu indexOfItemWithAction: @selector(hide:)];
if (idx-2 < 0) return nil; // idx == -1, if selector not found
return [[appMenu itemAtIndex:idx-2] submenu];
}
- (NSMenu *)findFileMenu
{
return [self findMenuContainingItemWithAction:@selector(performClose:)];
}
@end // NSMenu (MMExtras)
static int
executeInLoginShell(NSString *path, NSArray *args)
{
@@ -1184,4 +1435,3 @@ executeInLoginShell(NSString *path, NSArray *args)
return pid;
}
+3 -1
View File
@@ -30,6 +30,7 @@ enum { MMMaxCellsPerChar = 2 };
NSImage *contentImage;
NSSize imageSize;
ATSUStyle atsuStyles[MMMaxCellsPerChar];
BOOL antialias;
}
- (id)initWithFrame:(NSRect)frame;
@@ -53,10 +54,11 @@ enum { MMMaxCellsPerChar = 2 };
//
// MMTextView methods
//
- (NSEvent *)lastMouseDownEvent;
- (void)setShouldDrawInsertionPoint:(BOOL)on;
- (void)setPreEditRow:(int)row column:(int)col;
- (void)hideMarkedTextField;
- (void)setMouseShape:(int)shape;
- (void)setAntialias:(BOOL)state;
//
// NSTextView methods
+113 -20
View File
@@ -27,6 +27,8 @@
#import "MMAtsuiTextView.h"
#import "MMVimController.h"
#import "MMWindowController.h"
#import "MMAppController.h"
#import "MacVim.h"
@@ -65,6 +67,8 @@ enum {
- (void)updateAtsuStyles;
- (void)dispatchKeyEvent:(NSEvent *)event;
- (void)sendKeyDown:(const char *)chars length:(int)len modifiers:(int)flags;
- (void)hideMouseCursor;
- (MMWindowController *)windowController;
- (MMVimController *)vimController;
@end
@@ -108,6 +112,10 @@ enum {
imageSize = NSZeroSize;
insetSize = NSZeroSize;
// NOTE: If the default changes to 'NO' then the intialization of
// p_antialias in option.c must change as well.
antialias = YES;
[self initAtsuStyles];
}
@@ -241,11 +249,6 @@ enum {
- (NSEvent *)lastMouseDownEvent
{
return nil;
}
- (void)setShouldDrawInsertionPoint:(BOOL)on
{
}
@@ -258,6 +261,15 @@ enum {
{
}
- (void)setMouseShape:(int)shape
{
}
- (void)setAntialias:(BOOL)state
{
antialias = state;
}
@@ -322,8 +334,7 @@ enum {
}
}
// TODO: Support 'mousehide' (check p_mh)
[NSCursor setHiddenUntilMouseMoves:YES];
[self hideMouseCursor];
// NOTE: 'string' is either an NSString or an NSAttributedString. Since we
// do not support attributes, simply pass the corresponding NSString in the
@@ -395,19 +406,25 @@ enum {
&& !(116 == [event keyCode] || 121 == [event keyCode]))
return NO;
// HACK! KeyCode 50 represent the key which switches between windows
// within an application (like Cmd+Tab is used to switch between
// applications). Return NO here, else the window switching does not work.
if ([event keyCode] == 50)
return NO;
// HACK! Let the main menu try to handle any key down event, before
// passing it on to vim, otherwise key equivalents for menus will
// effectively be disabled.
if ([[NSApp mainMenu] performKeyEquivalent:event])
return YES;
// HACK! KeyCode 50 represent the key which switches between windows
// within an application (like Cmd+Tab is used to switch between
// applications). Return NO here, else the window switching does not work.
//
// Will this hack work for all languages / keyboard layouts?
if ([event keyCode] == 50)
return NO;
// HACK! Give the default main menu a chance to handle the key down event.
// This is to ensure that the standard mappings (which are in the default
// main menu) are always available, also when the default Vim menus are
// used (these do not set any key equivalents!).
if ([[[MMAppController sharedInstance] defaultMainMenu]
performKeyEquivalent:event])
return YES;
// HACK! On Leopard Ctrl-key events end up here instead of keyDown:.
if (flags & NSControlKeyMask) {
@@ -713,6 +730,42 @@ enum {
[[self vimController] sendMessage:ScrollWheelMsgID data:data];
}
//
// NOTE: The menu items cut/copy/paste/undo/redo/select all/... must be bound
// to the same actions as in IB otherwise they will not work with dialogs. All
// we do here is forward these actions to the Vim process.
//
- (IBAction)cut:(id)sender
{
[[self windowController] vimMenuItemAction:sender];
}
- (IBAction)copy:(id)sender
{
[[self windowController] vimMenuItemAction:sender];
}
- (IBAction)paste:(id)sender
{
[[self windowController] vimMenuItemAction:sender];
}
- (IBAction)undo:(id)sender
{
[[self windowController] vimMenuItemAction:sender];
}
- (IBAction)redo:(id)sender
{
[[self windowController] vimMenuItemAction:sender];
}
- (IBAction)selectAll:(id)sender
{
[[self windowController] vimMenuItemAction:sender];
}
@end // MMAtsuiTextView
@@ -854,21 +907,34 @@ enum {
[data appendBytes:&len length:sizeof(int)];
[data appendBytes:chars length:len];
// TODO: Support 'mousehide' (check p_mh)
[NSCursor setHiddenUntilMouseMoves:YES];
[self hideMouseCursor];
//NSLog(@"%s len=%d chars=0x%x", _cmd, len, chars[0]);
[[self vimController] sendMessage:KeyDownMsgID data:data];
}
}
- (MMVimController *)vimController
- (void)hideMouseCursor
{
// Check 'mousehide' option
id mh = [[[self vimController] vimState] objectForKey:@"p_mh"];
if (mh && ![mh boolValue])
[NSCursor setHiddenUntilMouseMoves:NO];
else
[NSCursor setHiddenUntilMouseMoves:YES];
}
- (MMWindowController *)windowController
{
id windowController = [[self window] windowController];
if ([windowController isKindOfClass:[MMWindowController class]])
return (MMWindowController*)windowController;
return nil;
}
// TODO: Make sure 'windowController' is a MMWindowController before type
// casting.
return [(MMWindowController*)windowController vimController];
- (MMVimController *)vimController
{
return [[self windowController] vimController];
}
@end // MMAtsuiTextView (Private)
@@ -918,6 +984,9 @@ enum {
[contentImage unlockFocus];
}
#define atsu_style_set_bool(s, t, b) \
ATSUSetAttributes(s, 1, &t, &(sizeof(Boolean)), &&b);
- (void)drawString:(UniChar *)string length:(UniCharCount)length
atRow:(int)row column:(int)col cells:(int)cells
withFlags:(int)flags foregroundColor:(NSColor *)fg
@@ -929,6 +998,26 @@ enum {
ATSUStyle style = (flags & DRAW_WIDE) ? atsuStyles[1] : atsuStyles[0];
ATSUTextLayout layout;
// Font selection and rendering options for ATSUI
ATSUAttributeTag attribTags[3] = { kATSUQDBoldfaceTag,
kATSUQDItalicTag,
kATSUStyleRenderingOptionsTag };
ByteCount attribSizes[] = { sizeof(Boolean),
sizeof(Boolean),
sizeof(UInt32) };
Boolean useBold, useItalic;
UInt32 useAntialias;
ATSUAttributeValuePtr attribValues[3] = { &useBold, &useItalic,
&useAntialias };
useBold = (flags & DRAW_BOLD) ? true : false;
useItalic = (flags & DRAW_ITALIC) ? true : false;
useAntialias = antialias ? kATSStyleApplyAntiAliasing
: kATSStyleNoAntiAliasing;
ATSUSetAttributes(style, sizeof(attribValues) / sizeof(attribValues[0]),
attribTags, attribSizes, attribValues);
// NSLog(@"drawString: %d", length);
ATSUCreateTextLayout(&layout);
@@ -1038,6 +1127,10 @@ enum {
} else if (MMInsertionPointVertical == shape) {
int frac = (cellSize.width * percent + 99)/100;
rect.size.width = frac;
} else if (MMInsertionPointVerticalRight == shape) {
int frac = (cellSize.width * percent + 99)/100;
rect.origin.x += rect.size.width - frac;
rect.size.width = frac;
}
[color set];
+6 -10
View File
@@ -24,6 +24,7 @@
id frontendProxy;
NSDictionary *colorDict;
NSDictionary *sysColorDict;
NSDictionary *actionDict;
BOOL inputReceived;
BOOL tabBarVisible;
unsigned backgroundColor;
@@ -54,7 +55,9 @@
- (void)setSpecialColor:(int)color;
- (void)setDefaultColorsBackground:(int)bg foreground:(int)fg;
- (NSConnection *)connection;
- (NSDictionary *)actionDict;
- (void)queueMessage:(int)msgid properties:(NSDictionary *)props;
- (BOOL)checkin;
- (BOOL)openVimWindow;
- (void)clearAll;
@@ -82,15 +85,6 @@
saving:(int)saving;
- (int)presentDialogWithType:(int)type title:(char *)title message:(char *)msg
buttons:(char *)btns textField:(char *)txtfield;
- (void)addMenuWithTag:(int)tag parent:(int)parentTag name:(char *)name
atIndex:(int)index;
- (void)addMenuItemWithTag:(int)tag parent:(int)parentTag name:(char *)name
tip:(char *)tip icon:(char *)icon
keyEquivalent:(int)key modifiers:(int)mods
action:(NSString *)action atIndex:(int)index;
- (void)removeMenuItemWithTag:(int)tag;
- (void)enableMenuItemWithTag:(int)tag state:(int)enabled;
- (void)showPopupMenuWithName:(char *)name atMouseLocation:(BOOL)mouse;
- (void)showToolbar:(int)enable flags:(int)flags;
- (void)createScrollbarWithIdentifier:(long)ident type:(int)type;
- (void)destroyScrollbarWithIdentifier:(long)ident;
@@ -112,9 +106,11 @@
- (int)lookupColorWithKey:(NSString *)key;
- (BOOL)hasSpecialKeyWithValue:(NSString *)value;
- (void)enterFullscreen;
- (void)enterFullscreen:(int)fuoptions background:(int)bg;
- (void)leaveFullscreen;
- (void)setAntialias:(BOOL)antialias;
- (void)updateModifiedFlag;
- (void)registerServerWithName:(NSString *)name;
+71 -191
View File
@@ -51,10 +51,12 @@ static unsigned MMServerMax = 1000;
// TODO: Move to separate file.
static int eventModifierFlagsToVimModMask(int modifierFlags);
static int vimModMaskToEventModifierFlags(int mods);
static int eventModifierFlagsToVimMouseModMask(int modifierFlags);
static int eventButtonNumberToVimMouseButton(int buttonNumber);
static int specialKeyToNSKey(int key);
// In gui_macvim.m
vimmenu_T *menu_for_descriptor(NSArray *desc);
enum {
MMBlinkStateNone = 0,
@@ -76,7 +78,9 @@ static NSString *MMSymlinkWarningString =
@interface MMBackend (Private)
- (void)queueVimStateMessage;
- (void)processInputQueue;
- (void)handleInputEvent:(int)msgid data:(NSData *)data;
+ (NSDictionary *)specialKeys;
@@ -142,8 +146,12 @@ static NSString *MMSymlinkWarningString =
sysColorDict = [[NSDictionary dictionaryWithContentsOfFile:path]
retain];
if (!(colorDict && sysColorDict))
NSLog(@"ERROR: Failed to load color dictionaries.%@",
path = [mainBundle pathForResource:@"Actions" ofType:@"plist"];
if (path)
actionDict = [[NSDictionary dictionaryWithContentsOfFile:path] retain];
if (!(colorDict && sysColorDict && actionDict))
NSLog(@"ERROR: Failed to load dictionaries.%@",
MMSymlinkWarningString);
return self;
@@ -165,6 +173,7 @@ static NSString *MMSymlinkWarningString =
[drawData release]; drawData = nil;
[frontendProxy release]; frontendProxy = nil;
[connection release]; connection = nil;
[actionDict release]; actionDict = nil;
[sysColorDict release]; sysColorDict = nil;
[colorDict release]; colorDict = nil;
@@ -215,6 +224,16 @@ static NSString *MMSymlinkWarningString =
return connection;
}
- (NSDictionary *)actionDict
{
return actionDict;
}
- (void)queueMessage:(int)msgid properties:(NSDictionary *)props
{
[self queueMessage:msgid data:[props dictionaryAsData]];
}
- (BOOL)checkin
{
if (![self connection]) {
@@ -429,9 +448,10 @@ static NSString *MMSymlinkWarningString =
// NOTE! This method gets called a lot; if we were to flush every time it
// got called MacVim would feel unresponsive. So there is a time out which
// ensures that the queue isn't flushed too often.
if (!force && lastFlushDate && -[lastFlushDate timeIntervalSinceNow]
< MMFlushTimeoutInterval
&& [drawData length] < MMFlushQueueLenHint)
if (exiting ||
(!force && lastFlushDate &&
-[lastFlushDate timeIntervalSinceNow] < MMFlushTimeoutInterval &&
[drawData length] < MMFlushQueueLenHint))
return;
if ([drawData length] > 0) {
@@ -451,7 +471,12 @@ static NSString *MMSymlinkWarningString =
[drawData setLength:0];
}
if ([outputQueue count] > 0) {
if ([outputQueue count] > 0 || force) {
// When 'force' is set we always update the Vim state to ensure that
// MacVim has a copy of the latest state (since 'force' is typically
// set just before Vim takes a nap whilst waiting for input).
[self queueVimStateMessage];
@try {
[frontendProxy processCommandQueue:outputQueue];
}
@@ -723,98 +748,6 @@ static NSString *MMSymlinkWarningString =
return retval;
}
- (void)addMenuWithTag:(int)tag parent:(int)parentTag name:(char *)name
atIndex:(int)index
{
//NSLog(@"addMenuWithTag:%d parent:%d name:%s atIndex:%d", tag, parentTag,
// name, index);
int namelen = name ? strlen(name) : 0;
NSMutableData *data = [NSMutableData data];
[data appendBytes:&tag length:sizeof(int)];
[data appendBytes:&parentTag length:sizeof(int)];
[data appendBytes:&namelen length:sizeof(int)];
if (namelen > 0) [data appendBytes:name length:namelen];
[data appendBytes:&index length:sizeof(int)];
[self queueMessage:AddMenuMsgID data:data];
}
- (void)addMenuItemWithTag:(int)tag parent:(int)parentTag name:(char *)name
tip:(char *)tip icon:(char *)icon
keyEquivalent:(int)key modifiers:(int)mods
action:(NSString *)action atIndex:(int)index
{
//NSLog(@"addMenuItemWithTag:%d parent:%d name:%s tip:%s atIndex:%d", tag,
// parentTag, name, tip, index);
int namelen = name ? strlen(name) : 0;
int tiplen = tip ? strlen(tip) : 0;
int iconlen = icon ? strlen(icon) : 0;
int eventFlags = vimModMaskToEventModifierFlags(mods);
int actionlen = [action lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
NSMutableData *data = [NSMutableData data];
key = specialKeyToNSKey(key);
[data appendBytes:&tag length:sizeof(int)];
[data appendBytes:&parentTag length:sizeof(int)];
[data appendBytes:&namelen length:sizeof(int)];
if (namelen > 0) [data appendBytes:name length:namelen];
[data appendBytes:&tiplen length:sizeof(int)];
if (tiplen > 0) [data appendBytes:tip length:tiplen];
[data appendBytes:&iconlen length:sizeof(int)];
if (iconlen > 0) [data appendBytes:icon length:iconlen];
[data appendBytes:&actionlen length:sizeof(int)];
if (actionlen > 0) [data appendBytes:[action UTF8String] length:actionlen];
[data appendBytes:&index length:sizeof(int)];
[data appendBytes:&key length:sizeof(int)];
[data appendBytes:&eventFlags length:sizeof(int)];
[self queueMessage:AddMenuItemMsgID data:data];
}
- (void)removeMenuItemWithTag:(int)tag
{
NSMutableData *data = [NSMutableData data];
[data appendBytes:&tag length:sizeof(int)];
[self queueMessage:RemoveMenuItemMsgID data:data];
}
- (void)enableMenuItemWithTag:(int)tag state:(int)enabled
{
NSMutableData *data = [NSMutableData data];
[data appendBytes:&tag length:sizeof(int)];
[data appendBytes:&enabled length:sizeof(int)];
[self queueMessage:EnableMenuItemMsgID data:data];
}
- (void)showPopupMenuWithName:(char *)name atMouseLocation:(BOOL)mouse
{
int len = strlen(name);
int row = -1, col = -1;
if (len <= 0) return;
if (!mouse && curwin) {
row = curwin->w_wrow;
col = curwin->w_wcol;
}
NSMutableData *data = [NSMutableData data];
[data appendBytes:&row length:sizeof(int)];
[data appendBytes:&col length:sizeof(int)];
[data appendBytes:&len length:sizeof(int)];
[data appendBytes:name length:len];
[self queueMessage:ShowPopupMenuMsgID data:data];
}
- (void)showToolbar:(int)enable flags:(int)flags
{
NSMutableData *data = [NSMutableData data];
@@ -1055,9 +988,13 @@ static NSString *MMSymlinkWarningString =
return NO;
}
- (void)enterFullscreen
- (void)enterFullscreen:(int)fuoptions background:(int)bg
{
[self queueMessage:EnterFullscreenMsgID data:nil];
NSMutableData *data = [NSMutableData data];
[data appendBytes:&fuoptions length:sizeof(int)];
bg = MM_COLOR(bg);
[data appendBytes:&bg length:sizeof(int)];
[self queueMessage:EnterFullscreenMsgID data:data];
}
- (void)leaveFullscreen
@@ -1065,6 +1002,13 @@ static NSString *MMSymlinkWarningString =
[self queueMessage:LeaveFullscreenMsgID data:nil];
}
- (void)setAntialias:(BOOL)antialias
{
int msgid = antialias ? EnableAntialiasMsgID : DisableAntialiasMsgID;
[self queueMessage:msgid data:nil];
}
- (void)updateModifiedFlag
{
// Notify MacVim if _any_ buffer has changed from unmodified to modified or
@@ -1243,6 +1187,8 @@ static NSString *MMSymlinkWarningString =
- (BOOL)starRegisterToPasteboard:(byref NSPasteboard *)pboard
{
// TODO: This method should share code with clip_mch_request_selection().
if (VIsual_active && (State & NORMAL) && clip_star.available) {
// If there is no pasteboard, return YES to indicate that there is text
// to copy.
@@ -1529,6 +1475,23 @@ static NSString *MMSymlinkWarningString =
@implementation MMBackend (Private)
- (void)queueVimStateMessage
{
// NOTE: This is the place to add Vim state that needs to be accessed from
// MacVim. Do not add state that could potentially require lots of memory
// since this message gets sent each time the output queue is forcibly
// flushed (e.g. storing the currently selected text would be a bad idea).
// We take this approach of "pushing" the state to MacVim to avoid having
// to make synchronous calls from MacVim to Vim in order to get state.
NSDictionary *vimState = [NSDictionary dictionaryWithObjectsAndKeys:
[[NSFileManager defaultManager] currentDirectoryPath], @"pwd",
[NSNumber numberWithInt:p_mh], @"p_mh",
nil];
[self queueMessage:SetVimStateMsgID data:[vimState dictionaryAsData]];
}
- (void)processInputQueue
{
// NOTE: One of the input events may cause this method to be called
@@ -1604,14 +1567,12 @@ static NSString *MMSymlinkWarningString =
//NSLog(@"[VimTask] Resizing shell to %dx%d.", cols, rows);
gui_resize_shell(cols, rows);
} else if (ExecuteMenuMsgID == msgid) {
if (!data) return;
const void *bytes = [data bytes];
int tag = *((int*)bytes); bytes += sizeof(int);
vimmenu_T *menu = (vimmenu_T*)tag;
// TODO! Make sure 'menu' is a valid menu pointer!
if (menu) {
gui_menu_cb(menu);
NSDictionary *attrs = [NSDictionary dictionaryWithData:data];
if (attrs) {
NSArray *desc = [attrs objectForKey:@"descriptor"];
vimmenu_T *menu = menu_for_descriptor(desc);
if (menu)
gui_menu_cb(menu);
}
} else if (ToggleToolbarMsgID == msgid) {
[self handleToggleToolbar];
@@ -2420,22 +2381,6 @@ static int eventModifierFlagsToVimModMask(int modifierFlags)
return modMask;
}
static int vimModMaskToEventModifierFlags(int mods)
{
int flags = 0;
if (mods & MOD_MASK_SHIFT)
flags |= NSShiftKeyMask;
if (mods & MOD_MASK_CTRL)
flags |= NSControlKeyMask;
if (mods & MOD_MASK_ALT)
flags |= NSAlternateKeyMask;
if (mods & MOD_MASK_CMD)
flags |= NSCommandKeyMask;
return flags;
}
static int eventModifierFlagsToVimMouseModMask(int modifierFlags)
{
int modMask = 0;
@@ -2457,68 +2402,3 @@ static int eventButtonNumberToVimMouseButton(int buttonNumber)
return (buttonNumber >= 0 && buttonNumber < 3)
? mouseButton[buttonNumber] : -1;
}
static int specialKeyToNSKey(int key)
{
if (!IS_SPECIAL(key))
return key;
static struct {
int special;
int nskey;
} sp2ns[] = {
{ K_UP, NSUpArrowFunctionKey },
{ K_DOWN, NSDownArrowFunctionKey },
{ K_LEFT, NSLeftArrowFunctionKey },
{ K_RIGHT, NSRightArrowFunctionKey },
{ K_F1, NSF1FunctionKey },
{ K_F2, NSF2FunctionKey },
{ K_F3, NSF3FunctionKey },
{ K_F4, NSF4FunctionKey },
{ K_F5, NSF5FunctionKey },
{ K_F6, NSF6FunctionKey },
{ K_F7, NSF7FunctionKey },
{ K_F8, NSF8FunctionKey },
{ K_F9, NSF9FunctionKey },
{ K_F10, NSF10FunctionKey },
{ K_F11, NSF11FunctionKey },
{ K_F12, NSF12FunctionKey },
{ K_F13, NSF13FunctionKey },
{ K_F14, NSF14FunctionKey },
{ K_F15, NSF15FunctionKey },
{ K_F16, NSF16FunctionKey },
{ K_F17, NSF17FunctionKey },
{ K_F18, NSF18FunctionKey },
{ K_F19, NSF19FunctionKey },
{ K_F20, NSF20FunctionKey },
{ K_F21, NSF21FunctionKey },
{ K_F22, NSF22FunctionKey },
{ K_F23, NSF23FunctionKey },
{ K_F24, NSF24FunctionKey },
{ K_F25, NSF25FunctionKey },
{ K_F26, NSF26FunctionKey },
{ K_F27, NSF27FunctionKey },
{ K_F28, NSF28FunctionKey },
{ K_F29, NSF29FunctionKey },
{ K_F30, NSF30FunctionKey },
{ K_F31, NSF31FunctionKey },
{ K_F32, NSF32FunctionKey },
{ K_F33, NSF33FunctionKey },
{ K_F34, NSF34FunctionKey },
{ K_F35, NSF35FunctionKey },
{ K_DEL, NSBackspaceCharacter },
{ K_BS, NSDeleteCharacter },
{ K_HOME, NSHomeFunctionKey },
{ K_END, NSEndFunctionKey },
{ K_PAGEUP, NSPageUpFunctionKey },
{ K_PAGEDOWN, NSPageDownFunctionKey }
};
int i;
for (i = 0; i < sizeof(sp2ns)/sizeof(sp2ns[0]); ++i) {
if (sp2ns[i].special == key)
return sp2ns[i].nskey;
}
return 0;
}
+14 -4
View File
@@ -1,7 +1,7 @@
/* vi:set ts=8 sts=4 sw=4 ft=objc:
*
* VIM - Vi IMproved by Bram Moolenaar
* MacVim GUI port by Bjorn Winckler
* VIM - Vi IMproved by Bram Moolenaar
* MacVim GUI port by Bjorn Winckler
*
* Do ":help uganda" in Vim to read copying and usage conditions.
* Do ":help credits" in Vim to see a list of people who contributed.
@@ -19,11 +19,21 @@
MMVimView *view;
NSPoint oldPosition;
NSString *oldTabBarStyle;
// These are only valid in fullscreen mode and store pre-fu vim size
int nonFuRows, nonFuColumns;
// These store the size vim had right after entering fu mode
int startFuRows, startFuColumns;
// This stores the contents of fuoptions_flags at fu start time
int startFuFlags;
}
- (MMFullscreenWindow *)initWithWindow:(NSWindow *)t view:(MMVimView *)v;
- (MMFullscreenWindow *)initWithWindow:(NSWindow *)t view:(MMVimView *)v
backgroundColor:(NSColor *)back;
- (void)enterFullscreen;
- (void)enterFullscreen:(int)fuoptions;
- (void)leaveFullscreen;
- (void)centerView;
+84 -5
View File
@@ -1,7 +1,7 @@
/* vi:set ts=8 sts=4 sw=4 ft=objc:
*
* VIM - Vi IMproved by Bram Moolenaar
* MacVim GUI port by Bjorn Winckler
* VIM - Vi IMproved by Bram Moolenaar
* MacVim GUI port by Bjorn Winckler
*
* Do ":help uganda" in Vim to read copying and usage conditions.
* Do ":help credits" in Vim to see a list of people who contributed.
@@ -23,6 +23,7 @@
* Author: Nico Weber
*/
#import "MMVimController.h"
#import "MMFullscreenWindow.h"
#import <PSMTabBarControl.h>
#import "MMVimView.h"
@@ -30,6 +31,11 @@
#import "MMWindowController.h"
#import <Carbon/Carbon.h>
// These have to be the same as in option.h
#define FUOPT_MAXVERT 0x001
#define FUOPT_MAXHORZ 0x002
#define FUOPT_BGCOLOR_HLGROUP 0x004
static int numFullscreenWindows = 0;
@@ -41,7 +47,8 @@ static int numFullscreenWindows = 0;
@implementation MMFullscreenWindow
- (MMFullscreenWindow *)initWithWindow:(NSWindow *)t view:(MMVimView *)v
- (MMFullscreenWindow *)initWithWindow:(NSWindow *)t view:(MMVimView *)v
backgroundColor:(NSColor *)back
{
NSScreen* screen = [t screen];
@@ -68,7 +75,7 @@ static int numFullscreenWindows = 0;
[self setHasShadow:NO];
[self setShowsResizeIndicator:NO];
[self setBackgroundColor:[NSColor blackColor]];
[self setBackgroundColor:back];
[self setReleasedWhenClosed:NO];
return self;
@@ -82,7 +89,7 @@ static int numFullscreenWindows = 0;
[super dealloc];
}
- (void)enterFullscreen
- (void)enterFullscreen:(int)fuoptions
{
[self hideDockIfAppropriate];
@@ -123,6 +130,42 @@ static int numFullscreenWindows = 0;
// focus gained message
[self setDelegate:delegate];
// resize vim view according to fuoptions
int currRows, currColumns;
[[view textView] getMaxRows:&currRows columns:&currColumns];
int fuRows = currRows, fuColumns = currColumns;
int maxRows, maxColumns;
NSSize size = [[self screen] visibleFrame].size;
[view constrainRows:&maxRows columns:&maxColumns toSize:size];
// Store current pre-fu vim size
nonFuRows = currRows;
nonFuColumns = currColumns;
// Compute current fu size
if (fuoptions & FUOPT_MAXVERT)
fuRows = maxRows;
if (fuoptions & FUOPT_MAXHORZ)
fuColumns = maxColumns;
startFuFlags = fuoptions;
// if necessary, resize vim to target fu size
if (currRows != fuRows || currColumns != fuColumns) {
int newSize[2] = { fuRows, fuColumns };
NSData *data = [NSData dataWithBytes:newSize length:2*sizeof(int)];
MMVimController *vimController =
[[self windowController] vimController];
[vimController sendMessage:SetTextDimensionsMsgID data:data];
[[view textView] setMaxRows:fuRows columns:fuColumns];
}
startFuRows = fuRows;
startFuColumns = fuColumns;
// move vim view to the window's center
[self centerView];
@@ -149,6 +192,32 @@ static int numFullscreenWindows = 0;
didBlend = YES;
}
// restore old vim view size
int currRows, currColumns;
[[view textView] getMaxRows:&currRows columns:&currColumns];
int newRows = currRows, newColumns = currColumns;
// compute desired non-fu size.
// if current fu size is equal to fu size at fu enter time,
// restore the old size
//
if (startFuFlags & FUOPT_MAXVERT && startFuRows == currRows)
newRows = nonFuRows;
if (startFuFlags & FUOPT_MAXHORZ && startFuColumns == currColumns)
newColumns = nonFuColumns;
// resize vim if necessary
if (currRows != newRows || currColumns != newColumns) {
int newSize[2] = { newRows, newColumns };
NSData *data = [NSData dataWithBytes:newSize length:2*sizeof(int)];
MMVimController *vimController =
[[self windowController] vimController];
[vimController sendMessage:SetTextDimensionsMsgID data:data];
[[view textView] setMaxRows:newRows columns:newColumns];
}
// fix up target controller
[self retain]; // NSWindowController releases us once
[[self windowController] setWindow:target];
@@ -166,6 +235,7 @@ static int numFullscreenWindows = 0;
// window.
[view removeFromSuperviewWithoutNeedingDisplay];
[[target contentView] addSubview:view];
[view setFrameOrigin:oldPosition];
[self close];
@@ -228,6 +298,15 @@ static int numFullscreenWindows = 0;
[super performClose:sender];
}
- (BOOL)validateMenuItem:(NSMenuItem *)item
{
if ([item action] == @selector(vimMenuItemAction:)
|| [item action] == @selector(performClose:))
return [item tag];
return YES;
}
@end // MMFullscreenWindow
+10
View File
@@ -258,6 +258,16 @@ static NSString *MMWideCharacterAttributeName = @"MMWideChar";
|| col+cells > maxColumns || !string || !(fg && bg && sp))
return;
BOOL hasControlChars = [string rangeOfCharacterFromSet:
[NSCharacterSet controlCharacterSet]].location != NSNotFound;
if (hasControlChars) {
// HACK! If a string for some reason contains control characters, then
// draw blanks instead (otherwise charRangeForRow::: fails).
NSRange subRange = { 0, cells };
flags &= ~DRAW_WIDE;
string = [[emptyRowString string] substringWithRange:subRange];
}
// Find range of characters in text storage to replace.
int acol = col;
int acells = cells;
+2 -2
View File
@@ -13,7 +13,6 @@
@interface MMTextView : NSTextView {
BOOL shouldDrawInsertionPoint;
NSEvent *lastMouseDownEvent;
NSTrackingRectTag trackingRectTag;
BOOL isDragging;
BOOL isAutoscrolling;
@@ -29,11 +28,11 @@
int preEditRow;
int preEditColumn;
int mouseShape;
BOOL antialias;
}
- (id)initWithFrame:(NSRect)frame;
- (NSEvent *)lastMouseDownEvent;
- (void)setShouldDrawInsertionPoint:(BOOL)on;
- (void)setPreEditRow:(int)row column:(int)col;
- (void)drawInsertionPointAtRow:(int)row column:(int)col shape:(int)shape
@@ -41,6 +40,7 @@
- (void)hideMarkedTextField;
- (void)performBatchDrawWithData:(NSData *)data;
- (void)setMouseShape:(int)shape;
- (void)setAntialias:(BOOL)antialias;
//
// MMTextStorage methods
+100 -24
View File
@@ -22,6 +22,7 @@
#import "MMWindowController.h"
#import "MMVimController.h"
#import "MMTypesetter.h"
#import "MMAppController.h"
#import "MacVim.h"
@@ -51,10 +52,12 @@ enum {
- (BOOL)convertRow:(int)row column:(int)column toPoint:(NSPoint *)point;
- (NSRect)trackingRect;
- (void)dispatchKeyEvent:(NSEvent *)event;
- (MMWindowController *)windowController;
- (MMVimController *)vimController;
- (void)startDragTimerWithInterval:(NSTimeInterval)t;
- (void)dragTimerFired:(NSTimer *)timer;
- (void)sendKeyDown:(const char *)chars length:(int)len modifiers:(int)flags;
- (void)hideMouseCursor;
@end
@@ -111,6 +114,9 @@ enum {
return nil;
}
// NOTE: If the default changes to 'NO' then the intialization of
// p_antialias in option.c must change as well.
antialias = YES;
return self;
}
@@ -124,15 +130,9 @@ enum {
markedTextField = nil;
}
[lastMouseDownEvent release]; lastMouseDownEvent = nil;
[super dealloc];
}
- (NSEvent *)lastMouseDownEvent
{
return lastMouseDownEvent;
}
- (BOOL)shouldDrawInsertionPoint
{
// NOTE: The insertion point is drawn manually in drawRect:. It would be
@@ -334,6 +334,11 @@ enum {
[self setCursor];
}
- (void)setAntialias:(BOOL)state
{
antialias = state;
}
- (NSFont *)font
{
return [(MMTextStorage*)[self textStorage] font];
@@ -442,6 +447,9 @@ enum {
- (void)drawRect:(NSRect)rect
{
NSGraphicsContext *context = [NSGraphicsContext currentContext];
[context setShouldAntialias:antialias];
[super drawRect:rect];
if (shouldDrawInsertionPoint) {
@@ -457,7 +465,11 @@ enum {
ipRect.origin.y += ipRect.size.height - frac;
ipRect.size.height = frac;
} else if (MMInsertionPointVertical == insertionPointShape) {
int frac = ([ts cellSize].width* insertionPointFraction + 99)/100;
int frac = ([ts cellSize].width * insertionPointFraction + 99)/100;
ipRect.size.width = frac;
} else if (MMInsertionPointVerticalRight == insertionPointShape) {
int frac = ([ts cellSize].width * insertionPointFraction + 99)/100;
ipRect.origin.x += ipRect.size.width - frac;
ipRect.size.width = frac;
}
@@ -555,8 +567,7 @@ enum {
}
}
// TODO: Support 'mousehide' (check p_mh)
[NSCursor setHiddenUntilMouseMoves:YES];
[self hideMouseCursor];
// NOTE: 'string' is either an NSString or an NSAttributedString. Since we
// do not support attributes, simply pass the corresponding NSString in the
@@ -629,19 +640,25 @@ enum {
&& !(116 == [event keyCode] || 121 == [event keyCode]))
return NO;
// HACK! KeyCode 50 represent the key which switches between windows
// within an application (like Cmd+Tab is used to switch between
// applications). Return NO here, else the window switching does not work.
if ([event keyCode] == 50)
return NO;
// HACK! Let the main menu try to handle any key down event, before
// passing it on to vim, otherwise key equivalents for menus will
// effectively be disabled.
if ([[NSApp mainMenu] performKeyEquivalent:event])
return YES;
// HACK! KeyCode 50 represent the key which switches between windows
// within an application (like Cmd+Tab is used to switch between
// applications). Return NO here, else the window switching does not work.
//
// Will this hack work for all languages / keyboard layouts?
if ([event keyCode] == 50)
return NO;
// HACK! Give the default main menu a chance to handle the key down event.
// This is to ensure that the standard mappings (which are in the default
// main menu) are always available, also when the default Vim menus are
// used (these do not set any key equivalents!).
if ([[[MMAppController sharedInstance] defaultMainMenu]
performKeyEquivalent:event])
return YES;
// HACK! On Leopard Ctrl-key events end up here instead of keyDown:.
if (flags & NSControlKeyMask) {
@@ -812,8 +829,6 @@ enum {
if (![self convertPoint:pt toRow:&row column:&col])
return;
lastMouseDownEvent = [event copy];
int button = [event buttonNumber];
int flags = [event modifierFlags];
int count = [event clickCount];
@@ -1108,6 +1123,54 @@ enum {
// The font panel is updated whenever the font is set.
}
//
// NOTE: The menu items cut/copy/paste/undo/redo/select all/... must be bound
// to the same actions as in IB otherwise they will not work with dialogs. All
// we do here is forward these actions to the Vim process.
//
- (IBAction)cut:(id)sender
{
[[self windowController] vimMenuItemAction:sender];
}
- (IBAction)copy:(id)sender
{
[[self windowController] vimMenuItemAction:sender];
}
- (IBAction)paste:(id)sender
{
[[self windowController] vimMenuItemAction:sender];
}
- (IBAction)undo:(id)sender
{
[[self windowController] vimMenuItemAction:sender];
}
- (IBAction)redo:(id)sender
{
[[self windowController] vimMenuItemAction:sender];
}
- (IBAction)selectAll:(id)sender
{
[[self windowController] vimMenuItemAction:sender];
}
- (BOOL)validateMenuItem:(NSMenuItem *)item
{
if ([item action] == @selector(cut:)
|| [item action] == @selector(copy:)
|| [item action] == @selector(paste:)
|| [item action] == @selector(undo:)
|| [item action] == @selector(redo:)
|| [item action] == @selector(selectAll:))
return [item tag];
return YES;
}
@end // MMTextView
@@ -1248,13 +1311,17 @@ enum {
[self sendKeyDown:bytes length:len modifiers:mods];
}
- (MMVimController *)vimController
- (MMWindowController *)windowController
{
id windowController = [[self window] windowController];
if ([windowController isKindOfClass:[MMWindowController class]])
return (MMWindowController*)windowController;
return nil;
}
// TODO: Make sure 'windowController' is a MMWindowController before type
// casting.
return [(MMWindowController*)windowController vimController];
- (MMVimController *)vimController
{
return [[self windowController] vimController];
}
- (void)startDragTimerWithInterval:(NSTimeInterval)t
@@ -1316,12 +1383,21 @@ enum {
[data appendBytes:&len length:sizeof(int)];
[data appendBytes:chars length:len];
// TODO: Support 'mousehide' (check p_mh)
[NSCursor setHiddenUntilMouseMoves:YES];
[self hideMouseCursor];
//NSLog(@"%s len=%d chars=0x%x", _cmd, len, chars[0]);
[[self vimController] sendMessage:KeyDownMsgID data:data];
}
}
- (void)hideMouseCursor
{
// Check 'mousehide' option
id mh = [[[self vimController] vimState] objectForKey:@"p_mh"];
if (mh && ![mh boolValue])
[NSCursor setHiddenUntilMouseMoves:NO];
else
[NSCursor setHiddenUntilMouseMoves:YES];
}
@end // MMTextView (Private)
+4 -4
View File
@@ -27,9 +27,8 @@
id backendProxy;
BOOL inProcessCommandQueue;
NSMutableArray *sendQueue;
NSMutableArray *mainMenuItems;
NSMenu *mainMenu;
NSMutableArray *popupMenuItems;
BOOL shouldUpdateMainMenu;
NSToolbar *toolbar;
NSMutableDictionary *toolbarItemDict;
int pid;
@@ -39,7 +38,7 @@
int resendMsgid;
NSData *resendData;
#endif
NSMenu *lastMenuSearched;
NSDictionary *vimState;
}
- (id)initWithBackend:(id)backend pid:(int)processIdentifier;
@@ -48,6 +47,8 @@
- (void)setServerName:(NSString *)name;
- (NSString *)serverName;
- (MMWindowController *)windowController;
- (NSDictionary *)vimState;
- (NSMenu *)mainMenu;
- (void)cleanup;
- (void)dropFiles:(NSArray *)filenames forceOpen:(BOOL)force;
- (void)dropString:(NSString *)string;
@@ -58,5 +59,4 @@
timeout:(NSTimeInterval)timeout;
- (void)addVimInput:(NSString *)string;
- (NSString *)evaluateVimExpression:(NSString *)expr;
- (void)updateMainMenu;
@end
+406 -339
View File
@@ -61,22 +61,28 @@ static NSTimeInterval MMResendInterval = 0.5;
- (void)savePanelDidEnd:(NSSavePanel *)panel code:(int)code
context:(void *)context;
- (void)alertDidEnd:(MMAlert *)alert code:(int)code context:(void *)context;
- (NSMenuItem *)recurseMenuItemForTag:(int)tag rootMenu:(NSMenu *)root;
- (NSMenuItem *)menuItemForTag:(int)tag;
- (NSMenu *)menuForTag:(int)tag;
- (NSMenuItem *)menuItemForDescriptor:(NSArray *)desc;
- (NSMenu *)parentMenuForDescriptor:(NSArray *)desc;
- (NSMenu *)topLevelMenuForTitle:(NSString *)title;
- (void)addMenuWithTag:(int)tag parent:(int)parentTag title:(NSString *)title
atIndex:(int)idx;
- (void)addMenuItemWithTag:(int)tag parent:(NSMenu *)parent
title:(NSString *)title tip:(NSString *)tip
keyEquivalent:(int)key modifiers:(int)mask
action:(NSString *)action atIndex:(int)idx;
- (NSToolbarItem *)toolbarItemForTag:(int)tag index:(int *)index;
- (void)addToolbarItemToDictionaryWithTag:(int)tag label:(NSString *)title
- (void)addMenuWithDescriptor:(NSArray *)desc atIndex:(int)index;
- (void)addMenuItemWithDescriptor:(NSArray *)desc
atIndex:(int)index
tip:(NSString *)tip
icon:(NSString *)icon
keyEquivalent:(NSString *)keyEquivalent
modifierMask:(int)modifierMask
action:(NSString *)action
isAlternate:(BOOL)isAlternate;
- (void)removeMenuItemWithDescriptor:(NSArray *)desc;
- (void)enableMenuItemWithDescriptor:(NSArray *)desc state:(BOOL)on;
- (void)addToolbarItemToDictionaryWithLabel:(NSString *)title
toolTip:(NSString *)tip icon:(NSString *)icon;
- (void)addToolbarItemWithTag:(int)tag label:(NSString *)label
- (void)addToolbarItemWithLabel:(NSString *)label
tip:(NSString *)tip icon:(NSString *)icon
atIndex:(int)idx;
- (void)popupMenuWithDescriptor:(NSArray *)desc
atRow:(NSNumber *)row
column:(NSNumber *)col;
- (void)connectionDidDie:(NSNotification *)notification;
#if MM_RESEND_LAST_FAILURE
- (void)resendTimerFired:(NSTimer *)timer;
@@ -84,6 +90,13 @@ static NSTimeInterval MMResendInterval = 0.5;
@end
@interface NSToolbar (MMExtras)
- (int)indexOfItemWithItemIdentifier:(NSString *)identifier;
- (NSToolbarItem *)itemAtIndex:(int)idx;
- (NSToolbarItem *)itemWithItemIdentifier:(NSString *)identifier;
@end
@implementation MMVimController
@@ -95,7 +108,6 @@ static NSTimeInterval MMResendInterval = 0.5;
[[MMWindowController alloc] initWithVimController:self];
backendProxy = [backend retain];
sendQueue = [NSMutableArray new];
mainMenuItems = [[NSMutableArray alloc] init];
popupMenuItems = [[NSMutableArray alloc] init];
toolbarItemDict = [[NSMutableDictionary alloc] init];
pid = processIdentifier;
@@ -110,6 +122,25 @@ static NSTimeInterval MMResendInterval = 0.5;
selector:@selector(connectionDidDie:)
name:NSConnectionDidDieNotification object:connection];
// Set up a main menu with only a "MacVim" menu (copied from a template
// which itself is set up in MainMenu.nib). The main menu is populated
// by Vim later on.
mainMenu = [[NSMenu alloc] initWithTitle:@"MainMenu"];
NSMenuItem *appMenuItem = [[MMAppController sharedInstance]
appMenuItemTemplate];
appMenuItem = [[appMenuItem copy] autorelease];
// Note: If the title of the application menu is anything but what
// CFBundleName says then the application menu will not be typeset in
// boldface for some reason. (It should already be set when we copy
// from the default main menu, but this is not the case for some
// reason.)
NSString *appName = [[NSBundle mainBundle]
objectForInfoDictionaryKey:@"CFBundleName"];
[appMenuItem setTitle:appName];
[mainMenu addItem:appMenuItem];
isInitialized = YES;
}
@@ -132,9 +163,11 @@ static NSTimeInterval MMResendInterval = 0.5;
[toolbarItemDict release]; toolbarItemDict = nil;
[toolbar release]; toolbar = nil;
[popupMenuItems release]; popupMenuItems = nil;
[mainMenuItems release]; mainMenuItems = nil;
[windowController release]; windowController = nil;
[vimState release]; vimState = nil;
[mainMenu release]; mainMenu = nil;
[super dealloc];
}
@@ -143,6 +176,16 @@ static NSTimeInterval MMResendInterval = 0.5;
return windowController;
}
- (NSDictionary *)vimState
{
return vimState;
}
- (NSMenu *)mainMenu
{
return mainMenu;
}
- (void)setServerName:(NSString *)name
{
if (name != serverName) {
@@ -382,6 +425,15 @@ static NSTimeInterval MMResendInterval = 0.5;
{
if (!isInitialized) return;
if (!dir) {
// 'dir == nil' means: set dir to the pwd of the Vim process, or let
// open dialog decide (depending on the below user default).
BOOL trackPwd = [[NSUserDefaults standardUserDefaults]
boolForKey:MMDialogsTrackPwdKey];
if (trackPwd)
dir = [vimState objectForKey:@"pwd"];
}
if (saving) {
[[NSSavePanel savePanel] beginSheetForDirectory:dir file:nil
modalForWindow:[windowController window]
@@ -474,33 +526,33 @@ static NSTimeInterval MMResendInterval = 0.5;
{
if (!isInitialized) return;
unsigned i, count = [queue count];
if (count % 2) {
NSLog(@"WARNING: Uneven number of components (%d) in flush queue "
"message; ignoring this message.", count);
return;
@try {
unsigned i, count = [queue count];
if (count % 2) {
NSLog(@"WARNING: Uneven number of components (%d) in flush queue "
"message; ignoring this message.", count);
return;
}
inProcessCommandQueue = YES;
//NSLog(@"======== %s BEGIN ========", _cmd);
for (i = 0; i < count; i += 2) {
NSData *value = [queue objectAtIndex:i];
NSData *data = [queue objectAtIndex:i+1];
int msgid = *((int*)[value bytes]);
//NSLog(@"%s%s", _cmd, MessageStrings[msgid]);
[self handleMessage:msgid data:data];
}
//NSLog(@"======== %s END ========", _cmd);
}
inProcessCommandQueue = YES;
//NSLog(@"======== %s BEGIN ========", _cmd);
for (i = 0; i < count; i += 2) {
NSData *value = [queue objectAtIndex:i];
NSData *data = [queue objectAtIndex:i+1];
int msgid = *((int*)[value bytes]);
//NSLog(@"%s%s", _cmd, MessageStrings[msgid]);
[self handleMessage:msgid data:data];
}
//NSLog(@"======== %s END ========", _cmd);
if (shouldUpdateMainMenu) {
[self updateMainMenu];
@catch (NSException *e) {
NSLog(@"Exception caught whilst processing command queue: %@", e);
}
[windowController processCommandQueueDidFinish];
inProcessCommandQueue = NO;
if ([sendQueue count] > 0) {
@@ -538,45 +590,6 @@ static NSTimeInterval MMResendInterval = 0.5;
return nil;
}
- (void)updateMainMenu
{
NSMenu *mainMenu = [NSApp mainMenu];
// Stop NSApp from updating the Window menu.
[NSApp setWindowsMenu:nil];
// Remove all menus from main menu (except the MacVim menu).
int i, count = [mainMenu numberOfItems];
for (i = count-1; i > 0; --i) {
[mainMenu removeItemAtIndex:i];
}
// Add menus from 'mainMenuItems' to main menu.
count = [mainMenuItems count];
for (i = 0; i < count; ++i) {
[mainMenu addItem:[mainMenuItems objectAtIndex:i]];
}
// Set the new Window menu.
// TODO! Need to look for 'Window' in all localized languages.
NSMenu *windowMenu = [[mainMenu itemWithTitle:@"Window"] submenu];
if (windowMenu) {
// Remove all AppKit owned menu items (tag == 0); they will be added
// again when setWindowsMenu: is called.
count = [windowMenu numberOfItems];
for (i = count-1; i >= 0; --i) {
NSMenuItem *item = [windowMenu itemAtIndex:i];
if (![item tag]) {
[windowMenu removeItem:item];
}
}
[NSApp setWindowsMenu:windowMenu];
}
shouldUpdateMainMenu = NO;
}
@end // MMVimController
@@ -623,126 +636,26 @@ static NSTimeInterval MMResendInterval = 0.5;
[string release];
} else if (AddMenuMsgID == msgid) {
NSString *title = nil;
const void *bytes = [data bytes];
int tag = *((int*)bytes); bytes += sizeof(int);
int parentTag = *((int*)bytes); bytes += sizeof(int);
int len = *((int*)bytes); bytes += sizeof(int);
if (len > 0) {
title = [[NSString alloc] initWithBytes:(void*)bytes length:len
encoding:NSUTF8StringEncoding];
bytes += len;
}
int idx = *((int*)bytes); bytes += sizeof(int);
if (MenuToolbarType == parentTag) {
if (!toolbar) {
// NOTE! Each toolbar must have a unique identifier, else each
// window will have the same toolbar.
NSString *ident = [NSString stringWithFormat:@"%d.%d",
(int)self, tag];
toolbar = [[NSToolbar alloc] initWithIdentifier:ident];
[toolbar setShowsBaselineSeparator:NO];
[toolbar setDelegate:self];
[toolbar setDisplayMode:NSToolbarDisplayModeIconOnly];
[toolbar setSizeMode:NSToolbarSizeModeSmall];
[windowController setToolbar:toolbar];
}
} else if (title) {
[self addMenuWithTag:tag parent:parentTag title:title atIndex:idx];
}
[title release];
NSDictionary *attrs = [NSDictionary dictionaryWithData:data];
[self addMenuWithDescriptor:[attrs objectForKey:@"descriptor"]
atIndex:[[attrs objectForKey:@"index"] intValue]];
} else if (AddMenuItemMsgID == msgid) {
NSString *title = nil, *tip = nil, *icon = nil, *action = nil;
const void *bytes = [data bytes];
int tag = *((int*)bytes); bytes += sizeof(int);
int parentTag = *((int*)bytes); bytes += sizeof(int);
int namelen = *((int*)bytes); bytes += sizeof(int);
if (namelen > 0) {
title = [[NSString alloc] initWithBytes:(void*)bytes length:namelen
encoding:NSUTF8StringEncoding];
bytes += namelen;
}
int tiplen = *((int*)bytes); bytes += sizeof(int);
if (tiplen > 0) {
tip = [[NSString alloc] initWithBytes:(void*)bytes length:tiplen
encoding:NSUTF8StringEncoding];
bytes += tiplen;
}
int iconlen = *((int*)bytes); bytes += sizeof(int);
if (iconlen > 0) {
icon = [[NSString alloc] initWithBytes:(void*)bytes length:iconlen
encoding:NSUTF8StringEncoding];
bytes += iconlen;
}
int actionlen = *((int*)bytes); bytes += sizeof(int);
if (actionlen > 0) {
action = [[NSString alloc] initWithBytes:(void*)bytes
length:actionlen
encoding:NSUTF8StringEncoding];
bytes += actionlen;
}
int idx = *((int*)bytes); bytes += sizeof(int);
if (idx < 0) idx = 0;
int key = *((int*)bytes); bytes += sizeof(int);
int mask = *((int*)bytes); bytes += sizeof(int);
NSString *ident = [NSString stringWithFormat:@"%d.%d",
(int)self, parentTag];
if (toolbar && [[toolbar identifier] isEqual:ident]) {
[self addToolbarItemWithTag:tag label:title tip:tip icon:icon
atIndex:idx];
} else {
NSMenu *parent = [self menuForTag:parentTag];
[self addMenuItemWithTag:tag parent:parent title:title tip:tip
keyEquivalent:key modifiers:mask action:action
atIndex:idx];
}
[title release];
[tip release];
[icon release];
[action release];
NSDictionary *attrs = [NSDictionary dictionaryWithData:data];
[self addMenuItemWithDescriptor:[attrs objectForKey:@"descriptor"]
atIndex:[[attrs objectForKey:@"index"] intValue]
tip:[attrs objectForKey:@"tip"]
icon:[attrs objectForKey:@"icon"]
keyEquivalent:[attrs objectForKey:@"keyEquivalent"]
modifierMask:[[attrs objectForKey:@"modifierMask"] intValue]
action:[attrs objectForKey:@"action"]
isAlternate:[[attrs objectForKey:@"isAlternate"] boolValue]];
} else if (RemoveMenuItemMsgID == msgid) {
const void *bytes = [data bytes];
int tag = *((int*)bytes); bytes += sizeof(int);
id item;
int idx;
if ((item = [self toolbarItemForTag:tag index:&idx])) {
[toolbar removeItemAtIndex:idx];
} else if ((item = [self menuItemForTag:tag])) {
[item retain];
if ([item menu] == [NSApp mainMenu] || ![item menu]) {
// NOTE: To be on the safe side we try to remove the item from
// both arrays (it is ok to call removeObject: even if an array
// does not contain the object to remove).
[mainMenuItems removeObject:item];
[popupMenuItems removeObject:item];
}
if ([item menu])
[[item menu] removeItem:item];
[item release];
}
// Reset cached menu, just to be on the safe side.
lastMenuSearched = nil;
NSDictionary *attrs = [NSDictionary dictionaryWithData:data];
[self removeMenuItemWithDescriptor:[attrs objectForKey:@"descriptor"]];
} else if (EnableMenuItemMsgID == msgid) {
const void *bytes = [data bytes];
int tag = *((int*)bytes); bytes += sizeof(int);
int state = *((int*)bytes); bytes += sizeof(int);
id item = [self toolbarItemForTag:tag index:NULL];
if (!item)
item = [self menuItemForTag:tag];
[item setEnabled:state];
NSDictionary *attrs = [NSDictionary dictionaryWithData:data];
[self enableMenuItemWithDescriptor:[attrs objectForKey:@"descriptor"]
state:[[attrs objectForKey:@"enable"] boolValue]];
} else if (ShowToolbarMsgID == msgid) {
const void *bytes = [data bytes];
int enable = *((int*)bytes); bytes += sizeof(int);
@@ -841,23 +754,10 @@ static NSTimeInterval MMResendInterval = 0.5;
[actionName release];
} else if (ShowPopupMenuMsgID == msgid) {
const void *bytes = [data bytes];
int row = *((int*)bytes); bytes += sizeof(int);
int col = *((int*)bytes); bytes += sizeof(int);
int len = *((int*)bytes); bytes += sizeof(int);
NSString *title = [[NSString alloc]
initWithBytes:(void*)bytes length:len
encoding:NSUTF8StringEncoding];
NSMenu *menu = [self topLevelMenuForTitle:title];
if (menu) {
[windowController popupMenu:menu atRow:row column:col];
} else {
NSLog(@"WARNING: Cannot popup menu with title %@; no such menu.",
title);
}
[title release];
NSDictionary *attrs = [NSDictionary dictionaryWithData:data];
[self popupMenuWithDescriptor:[attrs objectForKey:@"descriptor"]
atRow:[attrs objectForKey:@"row"]
column:[attrs objectForKey:@"column"]];
} else if (SetMouseShapeMsgID == msgid) {
const void *bytes = [data bytes];
int shape = *((int*)bytes); bytes += sizeof(int);
@@ -878,7 +778,12 @@ static NSTimeInterval MMResendInterval = 0.5;
[self setServerName:name];
[name release];
} else if (EnterFullscreenMsgID == msgid) {
[windowController enterFullscreen];
const void *bytes = [data bytes];
int fuoptions = *((int*)bytes); bytes += sizeof(int);
int bg = *((int*)bytes);
NSColor *back = [NSColor colorWithArgbInt:bg];
[windowController enterFullscreen:fuoptions backgroundColor:back];
} else if (LeaveFullscreenMsgID == msgid) {
[windowController leaveFullscreen];
} else if (BuffersNotModifiedMsgID == msgid) {
@@ -889,6 +794,16 @@ static NSTimeInterval MMResendInterval = 0.5;
const int *dim = (const int*)[data bytes];
[[[windowController vimView] textView] setPreEditRow:dim[0]
column:dim[1]];
} else if (EnableAntialiasMsgID == msgid) {
[[[windowController vimView] textView] setAntialias:YES];
} else if (DisableAntialiasMsgID == msgid) {
[[[windowController vimView] textView] setAntialias:NO];
} else if (SetVimStateMsgID == msgid) {
NSDictionary *dict = [NSDictionary dictionaryWithData:data];
if (dict) {
[vimState release];
vimState = [dict retain];
}
} else {
NSLog(@"WARNING: Unknown message received (msgid=%d)", msgid);
}
@@ -897,9 +812,15 @@ static NSTimeInterval MMResendInterval = 0.5;
- (void)savePanelDidEnd:(NSSavePanel *)panel code:(int)code
context:(void *)context
{
NSString *string = (code == NSOKButton) ? [panel filename] : nil;
NSString *path = (code == NSOKButton) ? [panel filename] : nil;
@try {
[backendProxy setDialogReturn:string];
[backendProxy setDialogReturn:path];
// Add file to the "Recent Files" menu (this ensures that files that
// are opened/saved from a :browse command are added to this menu).
if (path)
[[NSDocumentController sharedDocumentController]
noteNewRecentFilePath:path];
}
@catch (NSException *e) {
NSLog(@"Exception caught in %s %@", _cmd, e);
@@ -927,74 +848,61 @@ static NSTimeInterval MMResendInterval = 0.5;
}
}
- (NSMenuItem *)recurseMenuItemForTag:(int)tag rootMenu:(NSMenu *)root
- (NSMenuItem *)menuItemForDescriptor:(NSArray *)desc
{
if (root) {
NSMenuItem *item = [root itemWithTag:tag];
if (item) {
lastMenuSearched = root;
return item;
}
if (!(desc && [desc count] > 0)) return nil;
NSArray *items = [root itemArray];
unsigned i, count = [items count];
for (i = 0; i < count; ++i) {
item = [items objectAtIndex:i];
if ([item hasSubmenu]) {
item = [self recurseMenuItemForTag:tag
rootMenu:[item submenu]];
if (item) {
lastMenuSearched = [item submenu];
return item;
}
}
}
NSString *rootName = [desc objectAtIndex:0];
NSArray *rootItems = [rootName hasPrefix:@"PopUp"] ? popupMenuItems
: [mainMenu itemArray];
NSMenuItem *item = nil;
int i, count = [rootItems count];
for (i = 0; i < count; ++i) {
item = [rootItems objectAtIndex:i];
if ([[item title] isEqual:rootName])
break;
}
return nil;
if (i == count) return nil;
count = [desc count];
for (i = 1; i < count; ++i) {
item = [[item submenu] itemWithTitle:[desc objectAtIndex:i]];
if (!item) return nil;
}
return item;
}
- (NSMenuItem *)menuItemForTag:(int)tag
- (NSMenu *)parentMenuForDescriptor:(NSArray *)desc
{
// First search the same menu that was search last time this method was
// called. Since this method is often called for each menu item in a
// menu this can significantly improve search times.
if (lastMenuSearched) {
NSMenuItem *item = [self recurseMenuItemForTag:tag
rootMenu:lastMenuSearched];
if (item) return item;
}
if (!(desc && [desc count] > 0)) return nil;
// Search the main menu.
int i, count = [mainMenuItems count];
NSString *rootName = [desc objectAtIndex:0];
NSArray *rootItems = [rootName hasPrefix:@"PopUp"] ? popupMenuItems
: [mainMenu itemArray];
NSMenu *menu = nil;
int i, count = [rootItems count];
for (i = 0; i < count; ++i) {
NSMenuItem *item = [mainMenuItems objectAtIndex:i];
if ([item tag] == tag) return item;
item = [self recurseMenuItemForTag:tag rootMenu:[item submenu]];
if (item) {
lastMenuSearched = [item submenu];
return item;
NSMenuItem *item = [rootItems objectAtIndex:i];
if ([[item title] isEqual:rootName]) {
menu = [item submenu];
break;
}
}
// Search the popup menus.
count = [popupMenuItems count];
for (i = 0; i < count; ++i) {
NSMenuItem *item = [popupMenuItems objectAtIndex:i];
if ([item tag] == tag) return item;
item = [self recurseMenuItemForTag:tag rootMenu:[item submenu]];
if (item) {
lastMenuSearched = [item submenu];
return item;
}
if (!menu) return nil;
count = [desc count] - 1;
for (i = 1; i < count; ++i) {
NSMenuItem *item = [menu itemWithTitle:[desc objectAtIndex:i]];
menu = [item submenu];
if (!menu) return nil;
}
return nil;
}
- (NSMenu *)menuForTag:(int)tag
{
return [[self menuItemForTag:tag] submenu];
return menu;
}
- (NSMenu *)topLevelMenuForTitle:(NSString *)title
@@ -1008,9 +916,9 @@ static NSTimeInterval MMResendInterval = 0.5;
return [item submenu];
}
count = [mainMenuItems count];
count = [mainMenu numberOfItems];
for (i = 0; i < count; ++i) {
NSMenuItem *item = [mainMenuItems objectAtIndex:i];
NSMenuItem *item = [mainMenu itemAtIndex:i];
if ([title isEqual:[item title]])
return [item submenu];
}
@@ -1018,99 +926,191 @@ static NSTimeInterval MMResendInterval = 0.5;
return nil;
}
- (void)addMenuWithTag:(int)tag parent:(int)parentTag title:(NSString *)title
atIndex:(int)idx
- (void)addMenuWithDescriptor:(NSArray *)desc atIndex:(int)idx
{
NSMenu *parent = [self menuForTag:parentTag];
if (!(desc && [desc count] > 0 && idx >= 0)) return;
NSString *rootName = [desc objectAtIndex:0];
if ([rootName isEqual:@"ToolBar"]) {
// The toolbar only has one menu, we take this as a hint to create a
// toolbar, then we return.
if (!toolbar) {
// NOTE! Each toolbar must have a unique identifier, else each
// window will have the same toolbar.
NSString *ident = [NSString stringWithFormat:@"%d", (int)self];
toolbar = [[NSToolbar alloc] initWithIdentifier:ident];
[toolbar setShowsBaselineSeparator:NO];
[toolbar setDelegate:self];
[toolbar setDisplayMode:NSToolbarDisplayModeIconOnly];
[toolbar setSizeMode:NSToolbarSizeModeSmall];
[windowController setToolbar:toolbar];
}
return;
}
// This is either a main menu item or a popup menu item.
NSString *title = [desc lastObject];
NSMenuItem *item = [[NSMenuItem alloc] init];
NSMenu *menu = [[NSMenu alloc] initWithTitle:title];
[menu setAutoenablesItems:NO];
[item setTag:tag];
[item setTitle:title];
[item setSubmenu:menu];
if (parent) {
NSMenu *parent = [self parentMenuForDescriptor:desc];
if (!parent && [rootName hasPrefix:@"PopUp"]) {
if ([popupMenuItems count] <= idx) {
[popupMenuItems addObject:item];
} else {
[popupMenuItems insertObject:item atIndex:idx];
}
} else {
// If descriptor has no parent and its not a popup (or toolbar) menu,
// then it must belong to main menu.
if (!parent) parent = mainMenu;
if ([parent numberOfItems] <= idx) {
[parent addItem:item];
} else {
[parent insertItem:item atIndex:idx];
}
} else {
NSMutableArray *items = (MenuPopupType == parentTag)
? popupMenuItems : mainMenuItems;
if ([items count] <= idx) {
[items addObject:item];
} else {
[items insertObject:item atIndex:idx];
}
shouldUpdateMainMenu = (MenuPopupType != parentTag);
}
[item release];
[menu release];
}
- (void)addMenuItemWithTag:(int)tag parent:(NSMenu *)parent
title:(NSString *)title tip:(NSString *)tip
keyEquivalent:(int)key modifiers:(int)mask
action:(NSString *)action atIndex:(int)idx
- (void)addMenuItemWithDescriptor:(NSArray *)desc
atIndex:(int)idx
tip:(NSString *)tip
icon:(NSString *)icon
keyEquivalent:(NSString *)keyEquivalent
modifierMask:(int)modifierMask
action:(NSString *)action
isAlternate:(BOOL)isAlternate
{
if (parent) {
NSMenuItem *item = nil;
if (!title || ([title hasPrefix:@"-"] && [title hasSuffix:@"-"])) {
item = [NSMenuItem separatorItem];
} else {
item = [[[NSMenuItem alloc] init] autorelease];
[item setTitle:title];
// TODO: Check that 'action' is a valid action (nothing will happen
// if it isn't, but it would be nice with a warning).
if (action) [item setAction:NSSelectorFromString(action)];
else [item setAction:@selector(vimMenuItemAction:)];
if (tip) [item setToolTip:tip];
if (!(desc && [desc count] > 1 && idx >= 0)) return;
if (key != 0) {
NSString *keyString =
[NSString stringWithFormat:@"%C", key];
[item setKeyEquivalent:keyString];
[item setKeyEquivalentModifierMask:mask];
NSString *title = [desc lastObject];
NSString *rootName = [desc objectAtIndex:0];
if ([rootName isEqual:@"ToolBar"]) {
if (toolbar && [desc count] == 2)
[self addToolbarItemWithLabel:title tip:tip icon:icon atIndex:idx];
return;
}
NSMenu *parent = [self parentMenuForDescriptor:desc];
if (!parent) {
NSLog(@"WARNING: Menu item '%@' has no parent",
[desc componentsJoinedByString:@"->"]);
return;
}
NSMenuItem *item = nil;
if (0 == [title length]
|| ([title hasPrefix:@"-"] && [title hasSuffix:@"-"])) {
item = [NSMenuItem separatorItem];
[item setTitle:title];
} else {
item = [[[NSMenuItem alloc] init] autorelease];
[item setTitle:title];
// Note: It is possible to set the action to a message that "doesn't
// exist" without problems. We take advantage of this when adding
// "dummy items" e.g. when dealing with the "Recent Files" menu (in
// which case a recentFilesDummy: action is set, although it is never
// used).
if ([action length] > 0)
[item setAction:NSSelectorFromString(action)];
else
[item setAction:@selector(vimMenuItemAction:)];
if ([tip length] > 0) [item setToolTip:tip];
if ([keyEquivalent length] > 0) {
[item setKeyEquivalent:keyEquivalent];
[item setKeyEquivalentModifierMask:modifierMask];
}
[item setAlternate:isAlternate];
// The tag is used to indicate whether Vim thinks a menu item should be
// enabled or disabled. By default Vim thinks menu items are enabled.
[item setTag:1];
}
if ([parent numberOfItems] <= idx) {
[parent addItem:item];
} else {
[parent insertItem:item atIndex:idx];
}
}
- (void)removeMenuItemWithDescriptor:(NSArray *)desc
{
if (!(desc && [desc count] > 0)) return;
NSString *title = [desc lastObject];
NSString *rootName = [desc objectAtIndex:0];
if ([rootName isEqual:@"ToolBar"]) {
if (toolbar) {
if ([desc count] == 1) {
[windowController setToolbar:nil];
[toolbar release]; toolbar = nil;
} else if ([desc count] == 2) {
int idx = [toolbar indexOfItemWithItemIdentifier:title];
if (idx != NSNotFound)
[toolbar removeItemAtIndex:idx];
}
}
return;
}
// NOTE! The tag is used to idenfity which menu items were
// added by Vim (tag != 0) and which were added by the AppKit
// (tag == 0).
[item setTag:tag];
NSMenuItem *item = [self menuItemForDescriptor:desc];
if (!item) {
NSLog(@"Failed to remove menu item, descriptor not found: %@",
[desc componentsJoinedByString:@"->"]);
return;
}
if ([parent numberOfItems] <= idx) {
[parent addItem:item];
} else {
[parent insertItem:item atIndex:idx];
[item retain];
if ([item menu] == [NSApp mainMenu] || ![item menu]) {
// NOTE: To be on the safe side we try to remove the item from
// both arrays (it is ok to call removeObject: even if an array
// does not contain the object to remove).
[popupMenuItems removeObject:item];
}
if ([item menu])
[[item menu] removeItem:item];
[item release];
}
- (void)enableMenuItemWithDescriptor:(NSArray *)desc state:(BOOL)on
{
if (!(desc && [desc count] > 0)) return;
/*NSLog(@"%sable item %@", on ? "En" : "Dis",
[desc componentsJoinedByString:@"->"]);*/
NSString *rootName = [desc objectAtIndex:0];
if ([rootName isEqual:@"ToolBar"]) {
if (toolbar && [desc count] == 2) {
NSString *title = [desc lastObject];
[[toolbar itemWithItemIdentifier:title] setEnabled:on];
}
} else {
NSLog(@"WARNING: Menu item '%@' (tag=%d) has no parent.", title, tag);
// Use tag to set whether item is enabled or disabled instead of
// calling setEnabled:. This way the menus can autoenable themselves
// but at the same time Vim can set if a menu is enabled whenever it
// wants to.
[[self menuItemForDescriptor:desc] setTag:on];
}
}
- (NSToolbarItem *)toolbarItemForTag:(int)tag index:(int *)index
{
if (!toolbar) return nil;
NSArray *items = [toolbar items];
int i, count = [items count];
for (i = 0; i < count; ++i) {
NSToolbarItem *item = [items objectAtIndex:i];
if ([item tag] == tag) {
if (index) *index = i;
return item;
}
}
return nil;
}
- (void)addToolbarItemToDictionaryWithTag:(int)tag label:(NSString *)title
- (void)addToolbarItemToDictionaryWithLabel:(NSString *)title
toolTip:(NSString *)tip icon:(NSString *)icon
{
// If the item corresponds to a separator then do nothing, since it is
@@ -1121,7 +1121,6 @@ static NSTimeInterval MMResendInterval = 0.5;
return;
NSToolbarItem *item = [[NSToolbarItem alloc] initWithItemIdentifier:title];
[item setTag:tag];
[item setLabel:title];
[item setToolTip:tip];
[item setAction:@selector(vimMenuItemAction:)];
@@ -1144,7 +1143,7 @@ static NSTimeInterval MMResendInterval = 0.5;
[item release];
}
- (void)addToolbarItemWithTag:(int)tag label:(NSString *)label tip:(NSString
- (void)addToolbarItemWithLabel:(NSString *)label tip:(NSString
*)tip icon:(NSString *)icon atIndex:(int)idx
{
if (!toolbar) return;
@@ -1165,8 +1164,7 @@ static NSTimeInterval MMResendInterval = 0.5;
}
}
[self addToolbarItemToDictionaryWithTag:tag label:label toolTip:tip
icon:icon];
[self addToolbarItemToDictionaryWithLabel:label toolTip:tip icon:icon];
int maxIdx = [[toolbar items] count];
if (maxIdx < idx) idx = maxIdx;
@@ -1174,6 +1172,39 @@ static NSTimeInterval MMResendInterval = 0.5;
[toolbar insertItemWithItemIdentifier:label atIndex:idx];
}
- (void)popupMenuWithDescriptor:(NSArray *)desc
atRow:(NSNumber *)row
column:(NSNumber *)col
{
NSMenu *menu = [[self menuItemForDescriptor:desc] submenu];
if (!menu) return;
id textView = [[windowController vimView] textView];
NSPoint pt;
if (row && col) {
// TODO: Let textView convert (row,col) to NSPoint.
int r = [row intValue];
int c = [col intValue];
NSSize cellSize = [textView cellSize];
pt = NSMakePoint((c+1)*cellSize.width, (r+1)*cellSize.height);
pt = [textView convertPoint:pt toView:nil];
} else {
pt = [[windowController window] mouseLocationOutsideOfEventStream];
}
NSEvent *event = [NSEvent mouseEventWithType:NSRightMouseDown
location:pt
modifierFlags:0
timestamp:0
windowNumber:[[windowController window] windowNumber]
context:nil
eventNumber:0
clickCount:0
pressure:1.0];
[NSMenu popUpContextMenu:menu withEvent:event forView:textView];
}
- (void)connectionDidDie:(NSNotification *)notification
{
//NSLog(@"%@ %s%@", [self className], _cmd, notification);
@@ -1181,14 +1212,14 @@ static NSTimeInterval MMResendInterval = 0.5;
[self cleanup];
// NOTE! This causes the call to removeVimController: to be delayed.
[[NSApp delegate]
[[MMAppController sharedInstance]
performSelectorOnMainThread:@selector(removeVimController:)
withObject:self waitUntilDone:NO];
}
- (NSString *)description
{
return [NSString stringWithFormat:@"%@ : isInitialized=%d inProcessCommandQueue=%d mainMenuItems=%@ popupMenuItems=%@ toolbar=%@", [self className], isInitialized, inProcessCommandQueue, mainMenuItems, popupMenuItems, toolbar];
return [NSString stringWithFormat:@"%@ : isInitialized=%d inProcessCommandQueue=%d mainMenu=%@ popupMenuItems=%@ toolbar=%@", [self className], isInitialized, inProcessCommandQueue, mainMenu, popupMenuItems, toolbar];
}
#if MM_RESEND_LAST_FAILURE
@@ -1215,6 +1246,42 @@ static NSTimeInterval MMResendInterval = 0.5;
@implementation NSToolbar (MMExtras)
- (int)indexOfItemWithItemIdentifier:(NSString *)identifier
{
NSArray *items = [self items];
int i, count = [items count];
for (i = 0; i < count; ++i) {
id item = [items objectAtIndex:i];
if ([[item itemIdentifier] isEqual:identifier])
return i;
}
return NSNotFound;
}
- (NSToolbarItem *)itemAtIndex:(int)idx
{
NSArray *items = [self items];
if (idx < 0 || idx >= [items count])
return nil;
return [items objectAtIndex:idx];
}
- (NSToolbarItem *)itemWithItemIdentifier:(NSString *)identifier
{
int idx = [self indexOfItemWithItemIdentifier:identifier];
return idx != NSNotFound ? [self itemAtIndex:idx] : nil;
}
@end // NSToolbar (MMExtras)
@implementation MMAlert
- (void)dealloc
{
+9
View File
@@ -129,4 +129,13 @@
[super performClose:sender];
}
- (BOOL)validateMenuItem:(NSMenuItem *)item
{
if ([item action] == @selector(vimMenuItemAction:)
|| [item action] == @selector(performClose:))
return [item tag];
return YES;
}
@end // MMWindow
+4 -2
View File
@@ -51,7 +51,6 @@
- (void)setFont:(NSFont *)font;
- (void)setWideFont:(NSFont *)font;
- (void)processCommandQueueDidFinish;
- (void)popupMenu:(NSMenu *)menu atRow:(int)row column:(int)col;
- (void)showTabBar:(BOOL)on;
- (void)showToolbar:(BOOL)on size:(int)size mode:(int)mode;
- (void)setMouseShape:(int)shape;
@@ -59,7 +58,7 @@
- (void)liveResizeWillStart;
- (void)liveResizeDidEnd;
- (void)enterFullscreen;
- (void)enterFullscreen:(int)fuoptions backgroundColor:(NSColor *)back;
- (void)leaveFullscreen;
- (void)setBuffersModified:(BOOL)mod;
@@ -68,5 +67,8 @@
- (IBAction)performClose:(id)sender;
- (IBAction)findNext:(id)sender;
- (IBAction)findPrevious:(id)sender;
- (IBAction)vimMenuItemAction:(id)sender;
- (IBAction)fontSizeUp:(id)sender;
- (IBAction)fontSizeDown:(id)sender;
@end
+73 -54
View File
@@ -76,7 +76,6 @@
- (NSSize)constrainContentSizeToScreenSize:(NSSize)contentSize;
- (void)updateResizeConstraints;
- (NSTabViewItem *)addNewTabViewItem;
- (IBAction)vimMenuItemAction:(id)sender;
- (BOOL)askBackendForStarRegister:(NSPasteboard *)pb;
- (void)hideTablineSeparator:(BOOL)hide;
- (void)doFindNext:(BOOL)next;
@@ -264,7 +263,7 @@
- (void)openWindow
{
[[NSApp delegate] windowControllerWillOpen:self];
[[MMAppController sharedInstance] windowControllerWillOpen:self];
[self addNewTabViewItem];
@@ -367,7 +366,9 @@
// NOTE: This is called when the transparency changes so set the opacity
// flag on the window here (should be faster if the window is opaque).
BOOL isOpaque = [back alphaComponent] == 1.0f;
[[self window] setOpaque:isOpaque];
[decoratedWindow setOpaque:isOpaque];
if (fullscreenEnabled)
[fullscreenWindow setOpaque:isOpaque];
[vimView setDefaultColorsBackground:back foreground:fore];
}
@@ -410,33 +411,6 @@
}
}
- (void)popupMenu:(NSMenu *)menu atRow:(int)row column:(int)col
{
if (!setupDone) return;
NSEvent *event;
if (row >= 0 && col >= 0) {
// TODO: Let textView convert (row,col) to NSPoint.
NSSize cellSize = [[vimView textView] cellSize];
NSPoint pt = { (col+1)*cellSize.width, (row+1)*cellSize.height };
pt = [[vimView textView] convertPoint:pt toView:nil];
event = [NSEvent mouseEventWithType:NSRightMouseDown
location:pt
modifierFlags:0
timestamp:0
windowNumber:[[self window] windowNumber]
context:nil
eventNumber:0
clickCount:0
pressure:1.0];
} else {
event = [[vimView textView] lastMouseDownEvent];
}
[NSMenu popUpContextMenu:menu withEvent:event forView:[vimView textView]];
}
- (void)showTabBar:(BOOL)on
{
[[vimView tabBarControl] setHidden:!on];
@@ -544,13 +518,13 @@
}
}
- (void)enterFullscreen
- (void)enterFullscreen:(int)fuoptions backgroundColor:(NSColor *)back
{
if (fullscreenEnabled) return;
fullscreenWindow = [[MMFullscreenWindow alloc]
initWithWindow:decoratedWindow view:vimView];
[fullscreenWindow enterFullscreen];
initWithWindow:decoratedWindow view:vimView backgroundColor:back];
[fullscreenWindow enterFullscreen:fuoptions];
[fullscreenWindow setDelegate:self];
fullscreenEnabled = YES;
@@ -593,11 +567,12 @@
- (IBAction)performClose:(id)sender
{
// NOTE: File->Close is bound to this action message instead binding it
// directly to the below vim input so that File->Close also works for
// auxiliary windows such as the About dialog. (If we were to bind the
// below, then <D-w> will not close e.g. the About dialog.)
[vimController addVimInput:@"<C-\\><C-N>:conf q<CR>"];
// NOTE: With the introduction of :macmenu it is possible to bind
// File.Close to ":conf q" but at the same time have it send off the
// performClose: action. For this reason we no longer need the CloseMsgID
// message. However, we still need File.Close to send performClose:
// otherwise Cmd-w will not work on dialogs.
[self vimMenuItemAction:sender];
}
- (IBAction)findNext:(id)sender
@@ -610,12 +585,56 @@
[self doFindNext:NO];
}
- (IBAction)vimMenuItemAction:(id)sender
{
if (![sender isKindOfClass:[NSMenuItem class]]) return;
// TODO: Make into category on NSMenuItem which returns descriptor.
NSMenuItem *item = (NSMenuItem*)sender;
NSMutableArray *desc = [NSMutableArray arrayWithObject:[item title]];
NSMenu *menu = [item menu];
while (menu) {
[desc insertObject:[menu title] atIndex:0];
menu = [menu supermenu];
}
// The "MainMenu" item is part of the Cocoa menu and should not be part of
// the descriptor.
if ([[desc objectAtIndex:0] isEqual:@"MainMenu"])
[desc removeObjectAtIndex:0];
NSDictionary *attrs = [NSDictionary dictionaryWithObject:desc
forKey:@"descriptor"];
[vimController sendMessage:ExecuteMenuMsgID data:[attrs dictionaryAsData]];
}
- (IBAction)fontSizeUp:(id)sender
{
[[NSFontManager sharedFontManager] modifyFont:
[NSNumber numberWithInt:NSSizeUpFontAction]];
}
- (IBAction)fontSizeDown:(id)sender
{
[[NSFontManager sharedFontManager] modifyFont:
[NSNumber numberWithInt:NSSizeDownFontAction]];
}
- (BOOL)validateMenuItem:(NSMenuItem *)item
{
if ([item action] == @selector(vimMenuItemAction:)
|| [item action] == @selector(performClose:))
return [item tag];
return YES;
}
// -- NSWindow delegate ------------------------------------------------------
- (void)windowDidBecomeMain:(NSNotification *)notification
{
[vimController updateMainMenu];
[[MMAppController sharedInstance] setMainMenu:[vimController mainMenu]];
[vimController sendMessage:GotFocusMsgID data:nil];
if ([vimView textView]) {
@@ -678,12 +697,22 @@
BOOL zoomBoth = [[NSUserDefaults standardUserDefaults]
boolForKey:MMZoomBothKey];
if ((zoomBoth && !cmdLeftClick) || (!zoomBoth && cmdLeftClick))
return frame;
if (!((zoomBoth && !cmdLeftClick) || (!zoomBoth && cmdLeftClick))) {
// Zoom in horizontal direction only.
NSRect currentFrame = [win frame];
frame.size.width = currentFrame.size.width;
frame.origin.x = currentFrame.origin.x;
}
NSRect currentFrame = [win frame];
frame.size.width = currentFrame.size.width;
frame.origin.x = currentFrame.origin.x;
// HACK! The window frame is often higher than the 'defaultFrame' (the fact
// that 'defaultFrame' doesn't cover the entire area up to the menu bar
// seems like a Cocoa bug). To ensure that the window doesn't move
// downwards when the zoom button is clicked we check for this situation
// and return a frame whose max Y coordinate is no lower than the current
// max Y coordinate.
float delta = NSMaxY([win frame]) - NSMaxY(frame);
if (delta > 0)
frame.origin.y += delta;
return frame;
}
@@ -771,16 +800,6 @@
return [vimView addNewTabViewItem];
}
- (IBAction)vimMenuItemAction:(id)sender
{
int tag = [sender tag];
NSMutableData *data = [NSMutableData data];
[data appendBytes:&tag length:sizeof(int)];
[vimController sendMessage:ExecuteMenuMsgID data:data];
}
- (BOOL)askBackendForStarRegister:(NSPasteboard *)pb
{
// TODO: Can this be done with evaluateExpression: instead?
+26 -1
View File
@@ -160,6 +160,9 @@ enum {
ODBEditMsgID,
XcodeModMsgID,
LiveResizeMsgID,
EnableAntialiasMsgID,
DisableAntialiasMsgID,
SetVimStateMsgID,
};
@@ -180,6 +183,7 @@ enum {
MMInsertionPointHorizontal,
MMInsertionPointVertical,
MMInsertionPointHollow,
MMInsertionPointVerticalRight,
};
@@ -224,6 +228,7 @@ extern NSString *MMZoomBothKey;
extern NSString *MMCurrentPreferencePaneKey;
extern NSString *MMLoginShellCommandKey;
extern NSString *MMLoginShellArgumentKey;
extern NSString *MMDialogsTrackPwdKey;
// Enum for MMUntitledWindowKey
enum {
@@ -235,6 +240,12 @@ enum {
// Vim pasteboard type (holds motion type + string)
extern NSString *VimPBoardType;
// Loads all fonts in the Resouces folder of the app bundle and returns a font
// container reference (which should be used to deactivate the loaded fonts).
ATSFontContainerRef loadFonts();
@@ -268,6 +279,21 @@ NSString *buildSearchTextCommand(NSString *searchText);
@interface NSDocumentController (MMExtras)
- (void)noteNewRecentFilePath:(NSString *)path;
@end
@interface NSDictionary (MMExtras)
+ (id)dictionaryWithData:(NSData *)data;
- (NSData *)dictionaryAsData;
@end
// ODB Editor Suite Constants (taken from ODBEditorSuite.h)
#define keyFileSender 'FSnd'
#define keyFileSenderToken 'FTok'
@@ -281,4 +307,3 @@ NSString *buildSearchTextCommand(NSString *searchText);
// MacVim Apple Event Constants
#define keyMMUntitledWindow 'MMuw'
+47
View File
@@ -73,6 +73,9 @@ char *MessageStrings[] =
"ODBEditMsgID",
"XcodeModMsgID",
"LiveResizeMsgID",
"EnableAntialiasMsgID",
"DisableAntialiasMsgID",
"SetVimStateMsgID",
};
@@ -104,6 +107,13 @@ NSString *MMZoomBothKey = @"MMZoomBoth";
NSString *MMCurrentPreferencePaneKey = @"MMCurrentPreferencePane";
NSString *MMLoginShellCommandKey = @"MMLoginShellCommand";
NSString *MMLoginShellArgumentKey = @"MMLoginShellArgument";
NSString *MMDialogsTrackPwdKey = @"MMDialogsTrackPwd";
// Vim pasteboard type (holds motion type + string)
NSString *VimPBoardType = @"VimPBoardType";
@@ -285,3 +295,40 @@ buildSearchTextCommand(NSString *searchText)
@end // NSColor (MMExtras)
@implementation NSDocumentController (MMExtras)
- (void)noteNewRecentFilePath:(NSString *)path
{
NSURL *url = [NSURL fileURLWithPath:path];
if (url)
[self noteNewRecentDocumentURL:url];
}
@end // NSDocumentController (MMExtras)
@implementation NSDictionary (MMExtras)
+ (id)dictionaryWithData:(NSData *)data
{
id plist = [NSPropertyListSerialization
propertyListFromData:data
mutabilityOption:NSPropertyListImmutable
format:NULL
errorDescription:NULL];
return [plist isKindOfClass:[NSDictionary class]] ? plist : nil;
}
- (NSData *)dictionaryAsData
{
return [NSPropertyListSerialization dataFromPropertyList:self
format:NSPropertyListBinaryFormat_v1_0 errorDescription:NULL];
}
@end
+3 -3
View File
@@ -698,7 +698,7 @@
i386,
);
COPY_PHASE_STRIP = YES;
CURRENT_PROJECT_VERSION = 24;
CURRENT_PROJECT_VERSION = 30;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(FRAMEWORK_SEARCH_PATHS_QUOTED_1)",
@@ -739,7 +739,7 @@
buildSettings = {
ARCHS = "$(NATIVE_ARCH)";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 24;
CURRENT_PROJECT_VERSION = 30;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(FRAMEWORK_SEARCH_PATHS_QUOTED_1)",
@@ -770,7 +770,7 @@
buildSettings = {
ARCHS = "$(NATIVE_ARCH)";
COPY_PHASE_STRIP = YES;
CURRENT_PROJECT_VERSION = 24;
CURRENT_PROJECT_VERSION = 30;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(FRAMEWORK_SEARCH_PATHS_QUOTED_1)",
+353 -157
View File
@@ -32,7 +32,15 @@ static float MMMaxFontSize = 100.0f;
static NSFont *gui_macvim_font_with_name(char_u *name);
static BOOL gui_macvim_is_valid_action(NSString *action);
static int specialKeyToNSKey(int key);
static int vimModMaskToEventModifierFlags(int mods);
NSArray *descriptor_for_menu(vimmenu_T *menu);
vimmenu_T *menu_for_descriptor(NSArray *desc);
@interface NSString (VimStrings)
+ (id)stringWithVimString:(char_u *)s;
@end
@@ -480,44 +488,75 @@ clip_mch_own_selection(VimClipboard *cbd)
clip_mch_request_selection(VimClipboard *cbd)
{
NSPasteboard *pb = [NSPasteboard generalPasteboard];
NSString *pbType = [pb availableTypeFromArray:
[NSArray arrayWithObject:NSStringPboardType]];
if (pbType) {
NSMutableString *string =
NSArray *supportedTypes = [NSArray arrayWithObjects:VimPBoardType,
NSStringPboardType, nil];
NSString *bestType = [pb availableTypeFromArray:supportedTypes];
if (!bestType) return;
int motion_type = MCHAR;
NSString *string = nil;
if ([bestType isEqual:VimPBoardType]) {
// This type should consist of an array with two objects:
// 1. motion type (NSNumber)
// 2. text (NSString)
// If this is not the case we fall back on using NSStringPboardType.
id plist = [pb propertyListForType:VimPBoardType];
if ([plist isKindOfClass:[NSArray class]] && [plist count] == 2) {
id obj = [plist objectAtIndex:1];
if ([obj isKindOfClass:[NSString class]]) {
motion_type = [[plist objectAtIndex:0] intValue];
string = obj;
}
}
}
if (!string) {
// Use NSStringPboardType. The motion type is set to line-wise if the
// string contains at least one EOL character, otherwise it is set to
// character-wise (block-wise is never used).
NSMutableString *mstring =
[[pb stringForType:NSStringPboardType] mutableCopy];
if (!mstring) return;
// Replace unrecognized end-of-line sequences with \x0a (line feed).
NSRange range = { 0, [string length] };
unsigned n = [string replaceOccurrencesOfString:@"\x0d\x0a"
NSRange range = { 0, [mstring length] };
unsigned n = [mstring replaceOccurrencesOfString:@"\x0d\x0a"
withString:@"\x0a" options:0
range:range];
if (0 == n) {
n = [string replaceOccurrencesOfString:@"\x0d" withString:@"\x0a"
n = [mstring replaceOccurrencesOfString:@"\x0d" withString:@"\x0a"
options:0 range:range];
}
// Scan for newline character to decide whether the string should be
// pasted linewise or characterwise.
int type = MCHAR;
if (0 < n || NSNotFound != [string rangeOfString:@"\n"].location)
type = MLINE;
// pasted line-wise or character-wise.
motion_type = MCHAR;
if (0 < n || NSNotFound != [mstring rangeOfString:@"\n"].location)
motion_type = MLINE;
char_u *str = (char_u*)[string UTF8String];
int len = [string lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
#ifdef FEAT_MBYTE
if (input_conv.vc_type != CONV_NONE)
str = string_convert(&input_conv, str, &len);
#endif
if (str)
clip_yank_selection(type, str, len, cbd);
#ifdef FEAT_MBYTE
if (input_conv.vc_type != CONV_NONE)
vim_free(str);
#endif
string = mstring;
}
if (!(MCHAR == motion_type || MLINE == motion_type || MBLOCK == motion_type
|| MAUTO == motion_type))
motion_type = MCHAR;
char_u *str = (char_u*)[string UTF8String];
int len = [string lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
#ifdef FEAT_MBYTE
if (input_conv.vc_type != CONV_NONE)
str = string_convert(&input_conv, str, &len);
#endif
if (str)
clip_yank_selection(motion_type, str, len, cbd);
#ifdef FEAT_MBYTE
if (input_conv.vc_type != CONV_NONE)
vim_free(str);
#endif
}
@@ -534,8 +573,8 @@ clip_mch_set_selection(VimClipboard *cbd)
// Get the text to put on the pasteboard.
long_u llen = 0; char_u *str = 0;
int type = clip_convert_selection(&str, &llen, cbd);
if (type < 0)
int motion_type = clip_convert_selection(&str, &llen, cbd);
if (motion_type < 0)
return;
// TODO: Avoid overflow.
@@ -554,9 +593,16 @@ clip_mch_set_selection(VimClipboard *cbd)
NSString *string = [[NSString alloc]
initWithBytes:str length:len encoding:NSUTF8StringEncoding];
// See clip_mch_request_selection() for info on pasteboard types.
NSPasteboard *pb = [NSPasteboard generalPasteboard];
[pb declareTypes:[NSArray arrayWithObject:NSStringPboardType]
owner:nil];
NSArray *supportedTypes = [NSArray arrayWithObjects:VimPBoardType,
NSStringPboardType, nil];
[pb declareTypes:supportedTypes owner:nil];
NSNumber *motion = [NSNumber numberWithInt:motion_type];
NSArray *plist = [NSArray arrayWithObjects:motion, string, nil];
[pb setPropertyList:plist forType:VimPBoardType];
[pb setString:string forType:NSStringPboardType];
[string release];
@@ -570,34 +616,61 @@ clip_mch_set_selection(VimClipboard *cbd)
/*
* Add a sub menu to the menu bar.
* A menu descriptor represents the "address" of a menu as an array of strings.
* E.g. the menu "File->Close" has descriptor { "File", "Close" }.
*/
NSArray *
descriptor_for_menu(vimmenu_T *menu)
{
if (!menu) return nil;
NSMutableArray *desc = [NSMutableArray array];
while (menu) {
NSString *name = [NSString stringWithVimString:menu->dname];
[desc insertObject:name atIndex:0];
menu = menu->parent;
}
return desc;
}
vimmenu_T *
menu_for_descriptor(NSArray *desc)
{
if (!(desc && [desc count] > 0)) return NULL;
vimmenu_T *menu = root_menu;
int i, count = [desc count];
for (i = 0; i < count; ++i) {
NSString *component = [desc objectAtIndex:i];
while (menu) {
NSString *name = [NSString stringWithVimString:menu->dname];
if ([component isEqual:name]) {
if (i+1 == count)
return menu; // Matched all components, so return menu
menu = menu->children;
break;
}
menu = menu->next;
}
}
return NULL;
}
/*
* Add a submenu to the menu bar, toolbar, or a popup menu.
*/
void
gui_mch_add_menu(vimmenu_T *menu, int idx)
{
// HACK! If menu has no parent, then we set the parent tag to the type of
// menu it is. This will not mix up tag and type because pointers can not
// take values close to zero (and the tag is simply the value of the
// pointer).
int parent = (int)menu->parent;
if (!parent) {
parent = menu_is_popup(menu->name) ? MenuPopupType :
menu_is_toolbar(menu->name) ? MenuToolbarType :
MenuMenubarType;
}
char_u *dname = menu->dname;
#ifdef FEAT_MBYTE
dname = CONVERT_TO_UTF8(dname);
#endif
[[MMBackend sharedInstance]
addMenuWithTag:(int)menu parent:parent name:(char*)dname
atIndex:idx];
#ifdef FEAT_MBYTE
CONVERT_TO_UTF8_FREE(dname);
#endif
NSArray *desc = descriptor_for_menu(menu);
[[MMBackend sharedInstance] queueMessage:AddMenuMsgID properties:
[NSDictionary dictionaryWithObjectsAndKeys:
desc, @"descriptor",
[NSNumber numberWithInt:idx], @"index",
nil]];
}
@@ -612,55 +685,25 @@ gui_mch_add_menu_item(vimmenu_T *menu, int idx)
char_u *icon = menu->iconfile ? menu->iconfile :
menu->iconidx >= 0 ? menu->dname :
NULL;
//char *name = menu_is_separator(menu->name) ? NULL : (char*)menu->dname;
char_u *name = menu->dname;
char_u *tip = menu->strings[MENU_INDEX_TIP]
? menu->strings[MENU_INDEX_TIP] : menu->actext;
char_u *map_str = menu->strings[MENU_INDEX_NORMAL];
NSArray *desc = descriptor_for_menu(menu);
NSString *keyEquivalent = menu->mac_key
? [NSString stringWithFormat:@"%C", specialKeyToNSKey(menu->mac_key)]
: [NSString string];
int modifierMask = vimModMaskToEventModifierFlags(menu->mac_mods);
#ifdef FEAT_MBYTE
icon = CONVERT_TO_UTF8(icon);
name = CONVERT_TO_UTF8(name);
tip = CONVERT_TO_UTF8(tip);
map_str = CONVERT_TO_UTF8(map_str);
#endif
// HACK! Check if menu is mapped to ':macaction actionName:'; if so, pass
// the action along so that MacVim can bind the menu item to this action.
// This means that if a menu item maps to an action in normal mode, then
// all other modes will also use the same action.
NSString *action = nil;
if (map_str) {
NSString *mapping = [NSString stringWithCString:(char*)map_str
encoding:NSUTF8StringEncoding];
NSArray *parts = [mapping componentsSeparatedByString:@" "];
if ([parts count] >=2
&& [[parts objectAtIndex:0] hasPrefix:@":maca"]) {
action = [parts objectAtIndex:1];
action = [action stringByTrimmingCharactersInSet:
[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if (!gui_macvim_is_valid_action(action))
action = nil;
}
}
[[MMBackend sharedInstance]
addMenuItemWithTag:(int)menu
parent:(int)menu->parent
name:(char*)name
tip:(char*)tip
icon:(char*)icon
keyEquivalent:menu->mac_key
modifiers:menu->mac_mods
action:action
atIndex:idx];
#ifdef FEAT_MBYTE
CONVERT_TO_UTF8_FREE(icon);
CONVERT_TO_UTF8_FREE(name);
CONVERT_TO_UTF8_FREE(tip);
CONVERT_TO_UTF8_FREE(map_str);
#endif
[[MMBackend sharedInstance] queueMessage:AddMenuItemMsgID properties:
[NSDictionary dictionaryWithObjectsAndKeys:
desc, @"descriptor",
[NSNumber numberWithInt:idx], @"index",
[NSString stringWithVimString:tip], @"tip",
[NSString stringWithVimString:icon], @"icon",
keyEquivalent, @"keyEquivalent",
[NSNumber numberWithInt:modifierMask], @"modifierMask",
[NSString stringWithVimString:menu->mac_action], @"action",
[NSNumber numberWithBool:menu->mac_alternate], @"isAlternate",
nil]];
}
@@ -670,7 +713,9 @@ gui_mch_add_menu_item(vimmenu_T *menu, int idx)
void
gui_mch_destroy_menu(vimmenu_T *menu)
{
[[MMBackend sharedInstance] removeMenuItemWithTag:(int)menu];
NSArray *desc = descriptor_for_menu(menu);
[[MMBackend sharedInstance] queueMessage:RemoveMenuItemMsgID properties:
[NSDictionary dictionaryWithObject:desc forKey:@"descriptor"]];
}
@@ -683,12 +728,17 @@ gui_mch_menu_grey(vimmenu_T *menu, int grey)
/* Only update menu if the 'grey' state has changed to avoid having to pass
* lots of unnecessary data to MacVim. (Skipping this test makes MacVim
* pause noticably on mode changes. */
if (menu->was_grey != grey)
{
menu->was_grey = grey;
[[MMBackend sharedInstance]
enableMenuItemWithTag:(int)menu state:!grey];
}
NSArray *desc = descriptor_for_menu(menu);
if (menu->was_grey == grey)
return;
menu->was_grey = grey;
[[MMBackend sharedInstance] queueMessage:EnableMenuItemMsgID properties:
[NSDictionary dictionaryWithObjectsAndKeys:
desc, @"descriptor",
[NSNumber numberWithInt:!grey], @"enable",
nil]];
}
@@ -710,18 +760,9 @@ gui_mch_menu_hidden(vimmenu_T *menu, int hidden)
void
gui_mch_show_popupmenu(vimmenu_T *menu)
{
char_u *name = menu->name;
#ifdef FEAT_MBYTE
name = CONVERT_TO_UTF8(name);
#endif
[[MMBackend sharedInstance] showPopupMenuWithName:(char*)name
atMouseLocation:YES];
#ifdef FEAT_MBYTE
CONVERT_TO_UTF8_FREE(name);
#endif
NSArray *desc = descriptor_for_menu(menu);
[[MMBackend sharedInstance] queueMessage:ShowPopupMenuMsgID properties:
[NSDictionary dictionaryWithObject:desc forKey:@"descriptor"]];
}
@@ -731,16 +772,19 @@ gui_mch_show_popupmenu(vimmenu_T *menu)
void
gui_make_popup(char_u *path_name, int mouse_pos)
{
#ifdef FEAT_MBYTE
path_name = CONVERT_TO_UTF8(path_name);
#endif
vimmenu_T *menu = gui_find_menu(path_name);
if (!(menu && menu->children)) return;
[[MMBackend sharedInstance] showPopupMenuWithName:(char*)path_name
atMouseLocation:mouse_pos];
NSArray *desc = descriptor_for_menu(menu);
NSDictionary *p = (mouse_pos || NULL == curwin)
? [NSDictionary dictionaryWithObject:desc forKey:@"descriptor"]
: [NSDictionary dictionaryWithObjectsAndKeys:
desc, @"descriptor",
[NSNumber numberWithInt:curwin->w_wrow], @"row",
[NSNumber numberWithInt:curwin->w_wcol], @"column",
nil];
#ifdef FEAT_MBYTE
CONVERT_TO_UTF8_FREE(path_name);
#endif
[[MMBackend sharedInstance] queueMessage:ShowPopupMenuMsgID properties:p];
}
@@ -1029,11 +1073,24 @@ gui_mch_draw_part_cursor(int w, int h, guicolor_T color)
// font dimensions. Thus these parameters are useless. Instead we look at
// the shape_table to determine the shape and size of the cursor (just like
// gui_update_cursor() does).
#ifdef FEAT_RIGHTLEFT
// If 'rl' is set the insert mode cursor must be drawn on the right-hand
// side of a text cell.
int rl = curwin ? curwin->w_p_rl : FALSE;
#else
int rl = FALSE;
#endif
int idx = get_shape_idx(FALSE);
int shape = MMInsertionPointBlock;
switch (shape_table[idx].shape) {
case SHAPE_HOR: shape = MMInsertionPointHorizontal; break;
case SHAPE_VER: shape = MMInsertionPointVertical; break;
case SHAPE_HOR:
shape = MMInsertionPointHorizontal;
break;
case SHAPE_VER:
shape = rl ? MMInsertionPointVerticalRight
: MMInsertionPointVertical;
break;
}
return [[MMBackend sharedInstance]
@@ -1165,12 +1222,12 @@ ex_macaction(eap)
arg = CONVERT_TO_UTF8(arg);
#endif
NSString *name = [NSString stringWithCString:(char*)arg
encoding:NSUTF8StringEncoding];
if (gui_macvim_is_valid_action(name)) {
NSDictionary *actionDict = [[MMBackend sharedInstance] actionDict];
NSString *name = [NSString stringWithUTF8String:(char*)arg];
if (actionDict && [actionDict objectForKey:name] != nil) {
[[MMBackend sharedInstance] executeActionWithName:name];
} else {
EMSG2(_("E???: \"%s\" is not a valid action"), eap->arg);
EMSG2(_("E???: Invalid action: %s"), eap->arg);
}
#ifdef FEAT_MBYTE
@@ -1475,32 +1532,11 @@ gui_mch_toggle_tearoffs(int enable)
}
static BOOL
gui_macvim_is_valid_action(NSString *action)
{
static NSDictionary *actionDict = nil;
if (!actionDict) {
NSBundle *mainBundle = [NSBundle mainBundle];
NSString *path = [mainBundle pathForResource:@"Actions"
ofType:@"plist"];
if (path) {
actionDict = [[NSDictionary alloc] initWithContentsOfFile:path];
} else {
// Allocate bogus dictionary so that error only pops up once.
actionDict = [NSDictionary new];
EMSG(_("E???: Failed to load action dictionary"));
}
}
return [actionDict objectForKey:action] != nil;
}
void
gui_mch_enter_fullscreen()
gui_mch_enter_fullscreen(int fuoptions_flags, guicolor_T bg)
{
[[MMBackend sharedInstance] enterFullscreen];
[[MMBackend sharedInstance] enterFullscreen:fuoptions_flags background:bg];
}
@@ -1542,6 +1578,13 @@ gui_macvim_add_to_find_pboard(char_u *pat)
[pb setString:s forType:NSStringPboardType];
}
void
gui_macvim_set_antialias(int antialias)
{
[[MMBackend sharedInstance] setAntialias:antialias];
}
@@ -1827,3 +1870,156 @@ odb_end(void)
}
#endif // FEAT_ODB_EDITOR
char_u *
get_macaction_name(expand_T *xp, int idx)
{
static char_u *str = NULL;
NSDictionary *actionDict = [[MMBackend sharedInstance] actionDict];
if (nil == actionDict || idx < 0 || idx >= [actionDict count])
return NULL;
NSString *string = [[actionDict allKeys] objectAtIndex:idx];
if (!string)
return NULL;
char_u *plainStr = (char_u*)[string UTF8String];
#ifdef FEAT_MBYTE
if (str) {
vim_free(str);
str = NULL;
}
if (input_conv.vc_type != CONV_NONE) {
int len = [string lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
str = string_convert(&input_conv, plainStr, &len);
plainStr = str;
}
#endif
return plainStr;
}
int
is_valid_macaction(char_u *action)
{
int isValid = NO;
NSDictionary *actionDict = [[MMBackend sharedInstance] actionDict];
if (actionDict) {
#ifdef FEAT_MBYTE
action = CONVERT_TO_UTF8(action);
#endif
NSString *string = [NSString stringWithUTF8String:(char*)action];
isValid = (nil != [actionDict objectForKey:string]);
#ifdef FEAT_MBYTE
CONVERT_TO_UTF8_FREE(action);
#endif
}
return isValid;
}
static int specialKeyToNSKey(int key)
{
if (!IS_SPECIAL(key))
return key;
static struct {
int special;
int nskey;
} sp2ns[] = {
{ K_UP, NSUpArrowFunctionKey },
{ K_DOWN, NSDownArrowFunctionKey },
{ K_LEFT, NSLeftArrowFunctionKey },
{ K_RIGHT, NSRightArrowFunctionKey },
{ K_F1, NSF1FunctionKey },
{ K_F2, NSF2FunctionKey },
{ K_F3, NSF3FunctionKey },
{ K_F4, NSF4FunctionKey },
{ K_F5, NSF5FunctionKey },
{ K_F6, NSF6FunctionKey },
{ K_F7, NSF7FunctionKey },
{ K_F8, NSF8FunctionKey },
{ K_F9, NSF9FunctionKey },
{ K_F10, NSF10FunctionKey },
{ K_F11, NSF11FunctionKey },
{ K_F12, NSF12FunctionKey },
{ K_F13, NSF13FunctionKey },
{ K_F14, NSF14FunctionKey },
{ K_F15, NSF15FunctionKey },
{ K_F16, NSF16FunctionKey },
{ K_F17, NSF17FunctionKey },
{ K_F18, NSF18FunctionKey },
{ K_F19, NSF19FunctionKey },
{ K_F20, NSF20FunctionKey },
{ K_F21, NSF21FunctionKey },
{ K_F22, NSF22FunctionKey },
{ K_F23, NSF23FunctionKey },
{ K_F24, NSF24FunctionKey },
{ K_F25, NSF25FunctionKey },
{ K_F26, NSF26FunctionKey },
{ K_F27, NSF27FunctionKey },
{ K_F28, NSF28FunctionKey },
{ K_F29, NSF29FunctionKey },
{ K_F30, NSF30FunctionKey },
{ K_F31, NSF31FunctionKey },
{ K_F32, NSF32FunctionKey },
{ K_F33, NSF33FunctionKey },
{ K_F34, NSF34FunctionKey },
{ K_F35, NSF35FunctionKey },
{ K_DEL, NSBackspaceCharacter },
{ K_BS, NSDeleteCharacter },
{ K_HOME, NSHomeFunctionKey },
{ K_END, NSEndFunctionKey },
{ K_PAGEUP, NSPageUpFunctionKey },
{ K_PAGEDOWN, NSPageDownFunctionKey }
};
int i;
for (i = 0; i < sizeof(sp2ns)/sizeof(sp2ns[0]); ++i) {
if (sp2ns[i].special == key)
return sp2ns[i].nskey;
}
return 0;
}
static int vimModMaskToEventModifierFlags(int mods)
{
int flags = 0;
if (mods & MOD_MASK_SHIFT)
flags |= NSShiftKeyMask;
if (mods & MOD_MASK_CTRL)
flags |= NSControlKeyMask;
if (mods & MOD_MASK_ALT)
flags |= NSAlternateKeyMask;
if (mods & MOD_MASK_CMD)
flags |= NSCommandKeyMask;
return flags;
}
@implementation NSString (VimStrings)
+ (id)stringWithVimString:(char_u *)s
{
if (s) {
#ifdef FEAT_MBYTE
s = CONVERT_TO_UTF8(s);
#endif
NSString *string = [NSString stringWithUTF8String:(char*)s];
#ifdef FEAT_MBYTE
CONVERT_TO_UTF8_FREE(s);
#endif
return string;
}
return [NSString string];
}
@end
+73 -54
View File
@@ -1,7 +1,7 @@
" System gvimrc file for MacVim
"
" Maintainer: Bjorn Winckler <bjorn.winckler@gmail.com>
" Last Change: Thu Mar 6 2008
" Last Change: Sun May 19 2008
"
" This is a work in progress. If you feel so inclined, please help me improve
" this file.
@@ -42,13 +42,15 @@ aunmenu File.-SEP4-
aunmenu File.Exit
aunmenu File.Save-Exit
an <silent> 10.290 File.New\ Window :maca newWindow:<CR>
an <silent> 10.290 File.New\ Window <Nop>
an 10.295 File.New\ Tab :tabnew<CR>
an <silent> 10.310 File.&Open\.\.\. :maca fileOpen:<CR>
an <silent> 10.310 File.Open\.\.\. <Nop>
an <silent> 10.325 File.Open\ Recent <Nop>
an 10.328 File.-SEP0- <Nop>
an <silent> 10.330 File.Close\ Window<Tab>:qa :confirm qa<CR>
an <silent> 10.331 File.Close :maca performClose:<CR>
"an 10.331 File.Close\ Tab :tabclose<CR>
an <silent> 10.330 File.Close\ Window<Tab>:qa :conf qa<CR>
an <silent> 10.332 File.Close :conf q<CR>
an <silent> 10.341 File.Save\ All :browse conf wa<CR>
an 10.350 File.Save\ As\.\.\.<Tab>:sav :browse confirm saveas<CR>
" Edit menu
@@ -57,8 +59,8 @@ aunmenu Edit.Find
aunmenu Edit.Find\ and\ Replace
an 20.410.10 Edit.Find.Find\.\.\.<Tab>/ /
an 20.410.20 Edit.Find.Find\ Next :maca findNext:<CR>
an 20.410.30 Edit.Find.Find\ Previous :maca findPrevious:<CR>
an 20.410.20 Edit.Find.Find\ Next <Nop>
an 20.410.30 Edit.Find.Find\ Previous <Nop>
vmenu 20.410.35 Edit.Find.Use\ Selection\ for\ Find y:let @/=@"<CR>n
an 20.410.40 Edit.Find.-SEP1- <Nop>
an 20.410.50 Edit.Find.Find\ and\ Replace\.\.\.<Tab>:%s :%s/
@@ -66,27 +68,34 @@ vunmenu Edit.Find.Find\ and\ Replace\.\.\.<Tab>:%s
vnoremenu Edit.Find.Find\ and\ Replace\.\.\.<Tab>:s :s/
an 20.460 Edit.-SEP4- <Nop>
an 20.465.10 Edit.Font.Show\ Fonts :maca orderFrontFontPanel:<CR>
an 20.465.10 Edit.Font.Show\ Fonts <Nop>
an 20.465.20 Edit.Font.-SEP5- <Nop>
an 20.465.30 Edit.Font.Bigger :maca fontSizeUp:<CR>
an 20.465.40 Edit.Font.Smaller :maca fontSizeDown:<CR>
an 20.470 Edit.Special\ Characters\.\.\. :maca orderFrontCharacterPalette:<CR>
an 20.465.30 Edit.Font.Bigger <Nop>
an 20.465.40 Edit.Font.Smaller <Nop>
an 20.470 Edit.Special\ Characters\.\.\. <Nop>
" Window menu (should be next to Help so give it a high priority)
aunmenu Window
an <silent> 9900.300 Window.Minimize :maca performMiniaturize:<CR>
an <silent> 9900.310 Window.Zoom :maca performZoom:<CR>
an <silent> 9900.300 Window.Minimize <Nop>
an <silent> 9900.301 Window.Minimize\ All <Nop>
an <silent> 9900.310 Window.Zoom <Nop>
an <silent> 9900.311 Window.Zoom\ All <Nop>
an <silent> 9900.320 Window.Toggle\ Full\ Screen\ Mode :set invfullscreen<CR>
an 9900.330 Window.-SEP1- <Nop>
" TODO! Grey out if no tabs are visible.
an <silent> 9900.340 Window.Previous\ Tab :tabprevious<CR>
an <silent> 9900.350 Window.Next\ Tab :tabnext<CR>
an 9900.360 Window.-SEP2- <Nop>
an <silent> 9900.370 Window.Bring\ All\ To\ Front :maca arrangeInFront:<CR>
an <silent> 9900.370 Window.Bring\ All\ To\ Front <Nop>
" Help menu
an 9999.1 Help.MacVim\ Help :h gui_mac<CR>
an <silent> 9999.2 Help.MacVim\ Website <Nop>
an 9999.3 Help.-sep0- <Nop>
"
" Toolbar
@@ -183,51 +192,61 @@ endif " exists("macvim_hig_shift_movement")
"
" Menu key equivalents (these should always have the 'D' modifier set)
" Set up menu key equivalents (these should always have the 'D' modifier set),
" action bindings, and alternate items.
"
" Note: menu items which should execute an action are bound to <Nop>; the
" action message is specified here via the :macmenu command.
"
macmenukey File.New\ Window <D-n>
macmenukey File.New\ Tab <D-t>
macm File.New\ Window key=<D-n> action=newWindow:
macm File.New\ Tab key=<D-t>
macm File.Open\.\.\. key=<D-o> action=fileOpen:
macm File.Open\ Tab\.\.\. key=<D-T>
macm File.Open\ Recent action=recentFilesDummy:
macm File.Close\ Window key=<D-W>
macm File.Close key=<D-w> action=performClose:
macm File.Save key=<D-s>
macm File.Save\ All key=<D-M-s> alt=YES
macm File.Save\ As\.\.\. key=<D-S>
macm File.Print key=<D-p>
macmenukey File.Open\.\.\. <D-o>
macmenukey File.Open\ Tab\.\.\. <D-T>
macmenukey File.Close\ Window <D-W>
"macmenukey File.Close\ Tab <D-w>
macmenukey File.Close <D-w>
macmenukey File.Save <D-s>
macmenukey File.Save\ As\.\.\. <D-S>
macmenukey File.Print <D-p>
macm Edit.Undo key=<D-z> action=undo:
macm Edit.Redo key=<D-Z> action=redo:
macm Edit.Cut key=<D-x> action=cut:
macm Edit.Copy key=<D-c> action=copy:
macm Edit.Paste key=<D-v> action=paste:
macm Edit.Select\ All key=<D-a> action=selectAll:
macm Edit.Find.Find\.\.\. key=<D-f>
macm Edit.Find.Find\ Next key=<D-g> action=findNext:
macm Edit.Find.Find\ Previous key=<D-G> action=findPrevious:
macm Edit.Find.Use\ Selection\ for\ Find key=<D-e>
macm Edit.Special\ Characters\.\.\. key=<D-M-t>
macm Edit.Font.Show\ Fonts action=orderFrontFontPanel:
macm Edit.Font.Bigger key=<D-=> action=fontSizeUp:
macm Edit.Font.Smaller key=<D--> action=fontSizeDown:
macm Edit.Special\ Characters\.\.\. action=orderFrontCharacterPalette:
macmenukey Edit.Undo <D-z>
macmenukey Edit.Redo <D-Z>
macmenukey Edit.Cut <D-x>
macmenukey Edit.Copy <D-c>
macmenukey Edit.Paste <D-v>
macmenukey Edit.Select\ All <D-a>
macmenukey Edit.Find.Find\.\.\. <D-f>
macmenukey Edit.Find.Find\ Next <D-g>
macmenukey Edit.Find.Find\ Previous <D-G>
macmenukey Edit.Find.Use\ Selection\ for\ Find <D-e>
macmenukey Edit.Special\ Characters\.\.\. <D-M-t>
macmenukey Edit.Font.Bigger <D-=>
macmenukey Edit.Font.Smaller <D-->
macm Tools.Spelling.To\ Next\ error key=<D-;>
macm Tools.Spelling.Suggest\ Corrections key=<D-:>
macm Tools.Make key=<D-b>
macm Tools.List\ Errors key=<D-l>
macm Tools.List\ Messages key=<D-L>
macm Tools.Next\ Error key=<D-C-Right>
macm Tools.Previous\ Error key=<D-C-Left>
macm Tools.Older\ List key=<D-C-Up>
macm Tools.Newer\ List key=<D-C-Down>
macmenukey Tools.Spelling.To\ Next\ error <D-;>
macmenukey Tools.Spelling.Suggest\ Corrections <D-:>
macmenukey Tools.Make <D-b>
macmenukey Tools.List\ Errors <D-l>
macmenukey Tools.List\ Messages <D-L>
macmenukey Tools.Next\ Error <D-C-Right>
macmenukey Tools.Previous\ Error <D-C-Left>
macmenukey Tools.Older\ List <D-C-Up>
macmenukey Tools.Newer\ List <D-C-Down>
macmenukey Window.Minimize <D-m>
macmenukey Window.Zoom <D-C-z>
macmenukey Window.Toggle\ Full\ Screen\ Mode <D-F>
macmenukey Window.Previous\ Tab <D-{>
macmenukey Window.Next\ Tab <D-}>
macm Window.Minimize key=<D-m> action=performMiniaturize:
macm Window.Minimize\ All key=<D-M-m> action=miniaturizeAll: alt=YES
macm Window.Zoom key=<D-C-z> action=performZoom:
macm Window.Zoom\ All key=<D-M-C-z> action=zoomAll: alt=YES
macm Window.Toggle\ Full\ Screen\ Mode key=<D-F>
macm Window.Previous\ Tab key=<D-{>
macm Window.Next\ Tab key=<D-}>
macm Window.Bring\ All\ To\ Front action=arrangeInFront:
macm Help.MacVim\ Website action=openWebsite:
" Restore the previous value of 'cpoptions'.
let &cpo = s:cpo_save
+162
View File
@@ -40,6 +40,168 @@
Sparkle supports updates in zip, tar, tbz, tgz, or dmg format.
-->
<item>
<title>Snapshot 30 released</title>
<description><![CDATA[
<h1>MacVim snapshot 30 released</h1>
<p> Changes since snapshot 28:
<ul>
<li> copy&paste and other "Edit" menu items now work as expected with dialogs
(such as open/save). </li>
<li> some menus (such as the "Window" menu) has got some new items </li>
<li> general menu improvements when no editor window is open </li>
<li> ability to access some OS X default Cmd-keys even if menus are
completely altered (e.g. when starting with "-u NONE") </li>
<li> QuickLook works with .vim files (patch by Nico Weber) </li>
<li> insert mode cursor honors the 'rightleft' option </li>
<li> no more "freezes" during :shell </li>
<li> no beeping on Cmd-q </li>
<li> Cmd-w works in full-screen again </li>
<li> window dimensions properly restored when leaving full-screen when
"maxvert" is in 'fuoptions' </li>
<li> support for 'mousehide' option </li>
<li> latest vim patches and runtime files </li>
</ul>
</p>
<p> The only difference between snapshot 29 and 30 is that the former did not
handle window cycling very well with international keyboard layouts. </p>
]]></description>
<pubDate>Sun, 8 Jun 2008 16:43 CET</pubDate>
<enclosure type="application/octet-stream"
url="http://macvim.googlecode.com/files/MacVim-snapshot-30.tbz"
length="8137308"
sparkle:version="30"
sparkle:shortVersionString="7.1"
/>
</item>
<item>
<title>Snapshot 28 released</title>
<description><![CDATA[
<h1>MacVim snapshot 28 released</h1>
<p><em>The ":macmenukey" command is now deprecated. Please update your .gvimrc
file to use the ":macmenu" command instead (if you use ":macmenukey").</em></p>
<p> Changes since snapshot 27:
<ul>
<li> Added the ":macmenu" commmand (see ":h macmenu") and deprecated
":macmenukey"</li>
<li> Cmd-w now works even when mappings to &lt;-\&gt; are present </li>
<li> Added "File.Save All" menu item (Cmd-Alt-s) </li>
<li> The Logitech Control Center no longer causes any problems </li>
<li> "Edit" menu items now work better with open and save dialogs </li>
<li> The 'backspace' option now includes "indent,eol,start" by default </li>
<li> Open and save dialogs track the present working directory </li>
</ul>
</p>
]]></description>
<pubDate>Sun, 25 May 2008 19:40 CET</pubDate>
<enclosure type="application/octet-stream"
url="http://macvim.googlecode.com/files/MacVim-snapshot-28.tbz"
length="8124499"
sparkle:version="28"
sparkle:shortVersionString="7.1"
/>
</item>
<item>
<title>Snapshot 27 released</title>
<description><![CDATA[
<h1>MacVim snapshot 27 released</h1>
<p> This is the first snapshot compiled on the new Mac I bought with money
donated from MacVim users! There were problems with compiling universal
binaries with Ruby and Perl support on PPC/Tiger so I was hoping to be able
to include these now that I have Intel/Leopard. The good news is that Ruby
support is now included, but Perl still is problematic and I had to drop
TCL support. I will try to get these working in a future snapshot.
</p>
<p> Here is the list of changes since snapshot 26:
<ul>
<li> 'fuoptions' now support setting the background color while in
full-screen mode, check ":h 'fuopt'" (patch by Enno Lübbers) </li>
<li> &lt;D-w&gt; shows confirmation dialog when buffer is modified </li>
<li> setting 'antialias' from gvimrc now works </li>
<li> zooming a window no longer causes it to move downwards </li>
<li> the File menu now contains a "Recent Files" submenu; note that only
files opened from Finder or with the ":browse" command are added to this
list, and not files opened with e.g. ":e" (patch by Nico Weber) </li>
<li> includes latest Vim patches and runtime files </li>
</ul>
</p>
]]></description>
<pubDate>Mon, 12 May 2008 22:05 CET</pubDate>
<enclosure type="application/octet-stream"
url="http://macvim.googlecode.com/files/MacVim-snapshot-27-fixed.tbz"
length="8102568"
sparkle:version="27"
sparkle:shortVersionString="7.1"
/>
</item>
<item>
<title>Snapshot 26 released</title>
<description><![CDATA[
<h1>MacVim snapshot 26 released</h1>
<p> This snapshot contains a fix to the bug which caused the first window to
open in the wrong position as well as an initial version of the new MacVim
icon. </p>
]]></description>
<pubDate>Fri, 11 Apr 2008 20:37 CET</pubDate>
<enclosure type="application/octet-stream"
url="http://macvim.googlecode.com/files/MacVim-snapshot-26.tbz"
length="8147362"
sparkle:version="26"
sparkle:shortVersionString="7.1"
/>
</item>
<item>
<title>Snapshot 25 released</title>
<description><![CDATA[
<h1>MacVim snapshot 25 released</h1>
<p> This snapshot adds support for two new options: 'antialias' and
'fuoptions'. The former lets you turn text antialiasing on or off (it's
on by default), the latter can be used to make the view maximize when
full-screen is entered. See the built-in help for more information (:h
'anti' and :h 'fuopt'). </p>
<p> Another minor addition is that &lt;C-c&gt; and &lt;C-v&gt; work with
block-wise selections (do note that &lt;C-v&gt; behaves like "P", not "p").
Also, &lt;D-w&gt; now works in ex-mode and in a command-line window. </p>
<p> Here is the list of changes since snapshot 24:
<ul>
<li> support 'antialias' option (Jjgod Jiang) </li>
<li> add option 'fuoptions' to control resizing when full-screen is entered
(Nico Weber) </li>
<li> fixed bug where transparency setting was lost after leaving full-screen
(Nico Weber) </li>
<li> help menu contains MacVim help and website link </li>
<li> &lt;D-w&gt; now works in ex-mode and in command-line window </li>
<li> :macaction command supports command-line completion (Nico Weber) </li>
<li> copy/paste respects block selections (requested by George Harker) </li>
<li> window no longer cascades from preferences panel </li>
</ul>
</p>
]]></description>
<pubDate>Fri, 06 Apr 2008 19:11 CET</pubDate>
<enclosure type="application/octet-stream"
url="http://macvim.googlecode.com/files/MacVim-snapshot-25.tbz"
length="8042440"
sparkle:version="25"
sparkle:shortVersionString="7.1"
/>
</item>
<item>
<title>Snapshot 24 released</title>
<description><![CDATA[
+6 -4
View File
@@ -1,10 +1,12 @@
#!/bin/sh
export MACOSX_DEPLOYMENT_TARGET=10.4
# Increment build number
/Developer/Tools/agvtool next-version -all > /dev/null
/Developer/usr/bin/agvtool next-version -all > /dev/null
# Get current build number
BUILDNUM=`/Developer/Tools/agvtool what-version -terse`
BUILDNUM=`/Developer/usr/bin/agvtool what-version -terse`
DEST=~/Desktop/MacVim-snapshot-$BUILDNUM
echo '****************************************************'
@@ -16,8 +18,8 @@ echo ''
echo 'BUILDING VIM BINARY'
echo ' running configure...'
cd .. && ./configure --enable-gui=macvim --with-mac-arch=both \
--with-features=huge --enable-pythoninterp --enable-tclinterp \
--enable-cscope \
--with-features=huge --enable-pythoninterp \
--enable-cscope --enable-rubyinterp \
--with-compiledby="Bjorn Winckler <bjorn.winckler@gmail.com>" > /dev/null
echo ' cleaning...'
Binary file not shown.
+5 -1
View File
@@ -1,6 +1,10 @@
" System vimrc file for MacVim
"
" Maintainer: Bjorn Winckler <bjorn.winckler@gmail.com>
" Last Change: Sat Aug 11 14:26:41 CEST 2007
" Last Change: Sun May 25 2008
set nocompatible
" The default for 'backspace' is very confusing to new users, so change it to a
" more sensible value. Add "set backspace&" to your ~/.vimrc to reset it.
set backspace+=indent,eol,start
+18 -12
View File
@@ -1,6 +1,7 @@
# Makefile for Vim on Win32 (Windows NT/2000/XP/2003 and Windows 95/98/Me)
# and Win64, using the Microsoft Visual C++ compilers. Known to work with
# VC5, VC6 (VS98), VC7.0 (VS2002), VC7.1 (VS2003), and VC8 (VS2005).
# VC5, VC6 (VS98), VC7.0 (VS2002), VC7.1 (VS2003), VC8 (VS2005),
# and VC9 (VS2008).
#
# To build using other Windows compilers, see INSTALLpc.txt
#
@@ -285,7 +286,8 @@ XPM_INC = -I $(XPM)\include
# need shell32.lib for ExtractIcon()
# gdi32.lib and comdlg32.lib for printing support
# ole32.lib and uuid.lib are needed for FEAT_SHORTCUT
CON_LIB = advapi32.lib shell32.lib gdi32.lib comdlg32.lib ole32.lib uuid.lib
CON_LIB = oldnames.lib kernel32.lib advapi32.lib shell32.lib gdi32.lib \
comdlg32.lib ole32.lib uuid.lib /machine:$(CPU) /nodefaultlib
!if "$(DELAYLOAD)" == "yes"
CON_LIB = $(CON_LIB) /DELAYLOAD:comdlg32.dll /DELAYLOAD:ole32.dll DelayImp.lib
!endif
@@ -331,6 +333,7 @@ MSVCVER = 5.0
!endif
!if "$(_NMAKE_VER)" == "6.00.8168.0"
MSVCVER = 6.0
CPU = ix86
!endif
!if "$(_NMAKE_VER)" == "7.00.9466"
MSVCVER = 7.0
@@ -344,6 +347,9 @@ MSVCVER = 8.0
!if "$(_NMAKE_VER)" == "8.00.50727.762"
MSVCVER = 8.0
!endif
!if "$(_NMAKE_VER)" == "9.00.20706.01"
MSVCVER = 9.0
!endif
!endif
# Abort bulding VIM if version of VC is unrecognised.
@@ -352,13 +358,13 @@ MSVCVER = 8.0
!message Cannot determine Visual C version being used. If you are using the
!message Windows SDK then you must have the environment variable MSVCVER set to
!message your version of the VC compiler. If you are not using the Express
!message version of Visual C you van either set MSVCVER or update this makefile
!message to handle the new value for _NMAKE_VER.
!message version of Visual C, you can either set MSVCVER or update this makefile
!message to handle the new value for _NMAKE_VER, "$(_NMAKE_VER)".
!error Make aborted.
!endif
# Convert processor ID to MVC-compatible number
!if "$(MSVCVER)" != "8.0"
!if ("$(MSVCVER)" != "8.0") && ("$(MSVCVER)" != "9.0")
!if "$(CPUNR)" == "i386"
CPUARG = /G3
!elseif "$(CPUNR)" == "i486"
@@ -373,7 +379,7 @@ CPUARG = /G7 /arch:SSE2
CPUARG =
!endif
!else
# VC8 only allows specifying SSE architecture
# VC8/9 only allows specifying SSE architecture
!if "$(CPUNR)" == "pentium4"
CPUARG = /arch:SSE2
!endif
@@ -391,7 +397,7 @@ OPTFLAG = /O2
!else # MAXSPEED
OPTFLAG = /Ox
!endif
!if "$(MSVCVER)" == "8.0"
!if ("$(MSVCVER)" == "8.0") || ("$(MSVCVER)" == "9.0")
# Use link time code generation if not worried about size
!if "$(OPTIMIZE)" != "SPACE"
OPTFLAG = $(OPTFLAG) /GL
@@ -404,11 +410,11 @@ CFLAGS = $(CFLAGS) /MD
LIBC = msvcrt.lib
! else
LIBC = libcmt.lib
CFLAGS = $(CFLAGS) /MT
CFLAGS = $(CFLAGS) /Zl /MT
! endif
!else # DEBUG
VIM = vimd
! if "$(CPU)" == "i386"
! if ("$(CPU)" == "i386") || ("$(CPU)" == "ix86")
DEBUGINFO = /ZI
! endif
CFLAGS = $(CFLAGS) -D_DEBUG -DDEBUG /Od
@@ -424,7 +430,7 @@ CFLAGS = $(CFLAGS) /MDd
LIBC = $(LIBC) msvcrtd.lib
! else
LIBC = $(LIBC) libcmtd.lib
CFLAGS = $(CFLAGS) /MTd
CFLAGS = $(CFLAGS) /Zl /MTd
! endif
!endif # DEBUG
@@ -534,7 +540,7 @@ GUI_OBJ = \
$(OUTDIR)\gui_w32.obj \
$(OUTDIR)\os_w32exe.obj
GUI_LIB = \
oldnames.lib kernel32.lib gdi32.lib version.lib $(IME_LIB) \
gdi32.lib version.lib $(IME_LIB) \
winspool.lib comctl32.lib advapi32.lib shell32.lib \
/machine:$(CPU) /nodefaultlib
!else
@@ -757,7 +763,7 @@ LINKARGS2 = $(CON_LIB) $(GUI_LIB) $(LIBC) $(OLE_LIB) user32.lib $(SNIFF_LIB) \
# Report link time code generation progress if used.
!ifdef NODEBUG
!if "$(MSVCVER)" == "8.0"
!if ("$(MSVCVER)" == "8.0") || ("$(MSVCVER)" == "9.0")
!if "$(OPTIMIZE)" != "SPACE"
LINKARGS1 = $(LINKARGS1) /LTCG:STATUS
!endif
+12 -4
View File
@@ -545,7 +545,7 @@ LINT_OPTIONS = -beprxzF
# For unknown reasons adding "-lc" fixes a linking problem with GCC. That's
# probably a bug in the "-pg" implementation.
# Need to recompile everything after changing this: "make clean" "make".
#PROFILE_CFLAGS = -pg -g
#PROFILE_CFLAGS = -pg -g -DWE_ARE_PROFILING
#PROFILE_LIBS = -pg
#PROFILE_LIBS = -pg -lc
@@ -780,6 +780,8 @@ LINT_OPTIONS = -beprxzF
# 1) make config
# 2) edit auto/config.mk, add -n32 to LDFLAGS
# 3) make
#
#Alternatively: use -o32 instead of -n32.
###
### (C) On SCO Unix v3.2.5 (and probably other versions) the termcap library,
@@ -1074,7 +1076,7 @@ PRINTSOURCE = ../runtime/print
# default vi editor, it will create a link from vi to Vim when doing
# "make install". An existing file will be overwritten!
# When not using it, some make programs can't handle an undefined $(LINKIT).
#LINKIT = -ln -f -s $(BINDIR)/$(VIMTARGET) /usr/bin/vi
#LINKIT = ln -f -s $(DEST_BIN)/$(VIMTARGET) $(DESTDIR)/usr/bin/vi
LINKIT = @echo >/dev/null
###
@@ -1306,6 +1308,9 @@ LINT_EXTRA = -DUSE_SNIFF -DHANGUL_INPUT -D"__attribute__(x)="
DEPEND_CFLAGS = -DPROTO -DDEPEND -DFEAT_GUI $(LINT_CFLAGS)
# If you have problems with flags that cproto doesn't support, and you are
# using GNU make, you can try using the other line to filter out arguments.
#PFLAGS = $(PROTO_FLAGS) -DPROTO $(filter -D% -I%, $(LINT_CFLAGS))
PFLAGS = $(PROTO_FLAGS) -DPROTO $(LINT_CFLAGS)
ALL_LIB_DIRS = $(GUI_LIBS_DIR) $(X_LIBS_DIR)
@@ -1883,6 +1888,8 @@ installmacros: $(DEST_VIM) $(DEST_RT) $(DEST_MACRO)
installtutorbin: $(DEST_VIM)
$(INSTALL_DATA) vimtutor $(DEST_BIN)/$(VIMNAME)tutor
chmod $(SCRIPTMOD) $(DEST_BIN)/$(VIMNAME)tutor
$(INSTALL_DATA) gvimtutor $(DEST_BIN)/$(GVIMNAME)tutor
chmod $(SCRIPTMOD) $(DEST_BIN)/$(GVIMNAME)tutor
installtutor: $(DEST_RT) $(DEST_TUTOR)
-$(INSTALL_DATA) $(TUTORSOURCE)/README* $(TUTORSOURCE)/tutor* $(DEST_TUTOR)
@@ -2091,6 +2098,7 @@ installmanlinks:
uninstall: uninstall_runtime
-rm -f $(DEST_BIN)/$(VIMTARGET)
-rm -f $(DEST_BIN)/vimtutor
-rm -f $(DEST_BIN)/gvimtutor
-rm -f $(DEST_BIN)/$(EXTARGET) $(DEST_BIN)/$(VIEWTARGET)
-rm -f $(DEST_BIN)/$(GVIMTARGET) $(DEST_BIN)/$(GVIEWTARGET)
-rm -f $(DEST_BIN)/$(RVIMTARGET) $(DEST_BIN)/$(RVIEWTARGET)
@@ -2187,7 +2195,7 @@ SHADOWDIR = shadow
shadow: runtime pixmaps
mkdir $(SHADOWDIR)
cd $(SHADOWDIR); ln -s ../*.[ch] ../*.in ../*.sh ../*.xs ../*.xbm ../toolcheck ../proto ../vimtutor ../mkinstalldirs .
cd $(SHADOWDIR); ln -s ../*.[ch] ../*.in ../*.sh ../*.xs ../*.xbm ../toolcheck ../proto ../po ../vimtutor ../gvimtutor ../mkinstalldirs .
mkdir $(SHADOWDIR)/auto
cd $(SHADOWDIR)/auto; ln -s ../../auto/configure .
cd $(SHADOWDIR); rm -f auto/link.sed
@@ -2206,7 +2214,7 @@ shadow: runtime pixmaps
cd $(SHADOWDIR)/testdir; ln -s ../../testdir/Makefile \
../../testdir/vimrc.unix \
../../testdir/*.in \
../../testdir/unix.vim \
../../testdir/*.vim \
../../testdir/*.ok .
# Link needed for doing "make install" in a shadow directory.
+89
View File
@@ -845,6 +845,7 @@ Optional Features:
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--disable-darwin Disable Darwin (Mac OS X) support.
--disable-selinux Don't check for SELinux support.
--disable-xsmp Disable XSMP session management
--disable-xsmp-interact Disable XSMP interaction
--enable-mzschemeinterp Include MzScheme interpreter.
@@ -3611,6 +3612,94 @@ echo "${ECHO_T}no" >&6
esac
fi
echo "$as_me:$LINENO: checking --disable-selinux argument" >&5
echo $ECHO_N "checking --disable-selinux argument... $ECHO_C" >&6
# Check whether --enable-selinux or --disable-selinux was given.
if test "${enable_selinux+set}" = set; then
enableval="$enable_selinux"
else
enable_selinux="yes"
fi;
if test "$enable_selinux" = "yes"; then
echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
echo "$as_me:$LINENO: checking for is_selinux_enabled in -lselinux" >&5
echo $ECHO_N "checking for is_selinux_enabled in -lselinux... $ECHO_C" >&6
if test "${ac_cv_lib_selinux_is_selinux_enabled+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lselinux $LIBS"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char is_selinux_enabled ();
int
main ()
{
is_selinux_enabled ();
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -z "$ac_c_werror_flag"
|| test ! -s conftest.err'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_lib_selinux_is_selinux_enabled=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_lib_selinux_is_selinux_enabled=no
fi
rm -f conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:$LINENO: result: $ac_cv_lib_selinux_is_selinux_enabled" >&5
echo "${ECHO_T}$ac_cv_lib_selinux_is_selinux_enabled" >&6
if test $ac_cv_lib_selinux_is_selinux_enabled = yes; then
LIBS="$LIBS -lselinux"
cat >>confdefs.h <<\_ACEOF
#define HAVE_SELINUX 1
_ACEOF
fi
else
echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6
fi
echo "$as_me:$LINENO: checking --with-features argument" >&5
+4 -3
View File
@@ -4922,7 +4922,7 @@ chk_modeline(lnum, flags)
return retval;
}
#ifdef FEAT_VIMINFO
#if defined(FEAT_VIMINFO) || defined(PROTO)
int
read_viminfo_bufferlist(virp, writing)
vir_T *virp;
@@ -5043,13 +5043,14 @@ buf_spname(buf)
#if defined(FEAT_QUICKFIX) && defined(FEAT_WINDOWS)
if (bt_quickfix(buf))
{
win_T *win;
win_T *win = NULL;
tabpage_T *tp;
/*
* For location list window, w_llist_ref points to the location list.
* For quickfix window, w_llist_ref is NULL.
*/
FOR_ALL_WINDOWS(win)
FOR_ALL_TAB_WINDOWS(tp, win)
if (win->w_buffer == buf)
break;
if (win != NULL && win->w_llist_ref != NULL)
+1
View File
@@ -155,6 +155,7 @@
#undef HAVE_READLINK
#undef HAVE_RENAME
#undef HAVE_SELECT
#undef HAVE_SELINUX
#undef HAVE_SETENV
#undef HAVE_SETPGID
#undef HAVE_SETSID
+13
View File
@@ -308,6 +308,19 @@ case `uname` in
esac
fi
dnl Link with -lselinux for SELinux stuff; if not found
AC_MSG_CHECKING(--disable-selinux argument)
AC_ARG_ENABLE(selinux,
[ --disable-selinux Don't check for SELinux support.],
, enable_selinux="yes")
if test "$enable_selinux" = "yes"; then
AC_MSG_RESULT(no)
AC_CHECK_LIB(selinux, is_selinux_enabled,
[LIBS="$LIBS -lselinux"
AC_DEFINE(HAVE_SELINUX)])
else
AC_MSG_RESULT(yes)
fi
dnl Check user requested features.
+1 -1
View File
@@ -1365,7 +1365,7 @@ install_registry(void)
printf("Creating \"Edit with Vim\" popup menu entry\n");
fprintf(fd, "HKEY_CLASSES_ROOT\\CLSID\\%s\n", vim_ext_clsid);
fprintf(fd, "[HKEY_CLASSES_ROOT\\CLSID\\%s]\n", vim_ext_clsid);
fprintf(fd, "@=\"%s\"\n", vim_ext_name);
fprintf(fd, "[HKEY_CLASSES_ROOT\\CLSID\\%s\\InProcServer32]\n",
vim_ext_clsid);
+2 -2
View File
@@ -5491,7 +5491,7 @@ insertchar(c, flags, second_indent)
#if defined(FEAT_EVAL)
int do_internal = TRUE;
if (*curbuf->b_p_fex != NUL)
if (*curbuf->b_p_fex != NUL && (flags & INSCHAR_NO_FEX) == 0)
{
do_internal = (fex_format(curwin->w_cursor.lnum, 1L, c) != 0);
/* It may be required to save for undo again, e.g. when setline()
@@ -6057,7 +6057,7 @@ auto_format(trailblank, prev_line)
* be adjusted for the text formatting.
*/
saved_cursor = pos;
format_lines((linenr_T)-1);
format_lines((linenr_T)-1, FALSE);
curwin->w_cursor = saved_cursor;
saved_cursor.lnum = 0;
+131 -80
View File
@@ -507,6 +507,7 @@ static void f_filewritable __ARGS((typval_T *argvars, typval_T *rettv));
static void f_filter __ARGS((typval_T *argvars, typval_T *rettv));
static void f_finddir __ARGS((typval_T *argvars, typval_T *rettv));
static void f_findfile __ARGS((typval_T *argvars, typval_T *rettv));
static void f_fnameescape __ARGS((typval_T *argvars, typval_T *rettv));
static void f_fnamemodify __ARGS((typval_T *argvars, typval_T *rettv));
static void f_foldclosed __ARGS((typval_T *argvars, typval_T *rettv));
static void f_foldclosedend __ARGS((typval_T *argvars, typval_T *rettv));
@@ -7107,6 +7108,7 @@ static struct fst
{"filter", 2, 2, f_filter},
{"finddir", 1, 3, f_finddir},
{"findfile", 1, 3, f_findfile},
{"fnameescape", 1, 1, f_fnameescape},
{"fnamemodify", 2, 2, f_fnamemodify},
{"foldclosed", 1, 1, f_foldclosed},
{"foldclosedend", 1, 1, f_foldclosedend},
@@ -9464,6 +9466,19 @@ f_findfile(argvars, rettv)
findfilendir(argvars, rettv, FINDFILE_FILE);
}
/*
* "fnameescape({string})" function
*/
static void
f_fnameescape(argvars, rettv)
typval_T *argvars;
typval_T *rettv;
{
rettv->vval.v_string = vim_strsave_fnameescape(
get_tv_string(&argvars[0]), FALSE);
rettv->v_type = VAR_STRING;
}
/*
* "fnamemodify({fname}, {mods})" function
*/
@@ -13974,6 +13989,7 @@ f_reverse(argvars, rettv)
rettv->vval.v_list = l;
rettv->v_type = VAR_LIST;
++l->lv_refcount;
l->lv_idx = l->lv_len - l->lv_idx - 1;
}
}
@@ -14682,6 +14698,8 @@ f_setline(argvars, rettv)
appended_lines_mark(lcount, added);
}
static void set_qf_ll_list __ARGS((win_T *wp, typval_T *list_arg, typval_T *action_arg, typval_T *rettv));
/*
* Used by "setqflist()" and "setloclist()" functions
*/
@@ -15220,7 +15238,7 @@ f_sort(argvars, rettv)
if (!item_compare_func_err)
{
/* Clear the List and append the items in the sorted order. */
l->lv_first = l->lv_last = NULL;
l->lv_first = l->lv_last = l->lv_idx_item = NULL;
l->lv_len = 0;
for (i = 0; i < len; ++i)
list_append(l, ptrs[i]);
@@ -21070,8 +21088,12 @@ static int shortpath_for_invalid_fname __ARGS((char_u **fname, char_u **bufp, in
static int shortpath_for_partial __ARGS((char_u **fnamep, char_u **bufp, int *fnamelen));
/*
* Get the short pathname of a file.
* Returns 1 on success. *fnamelen is 0 for nonexistent path.
* Get the short path (8.3) for the filename in "fnamep".
* Only works for a valid file name.
* When the path gets longer "fnamep" is changed and the allocated buffer
* is put in "bufp".
* *fnamelen is the length of "fnamep" and set to 0 for a nonexistent path.
* Returns OK on success, FAIL on failure.
*/
static int
get_short_pathname(fnamep, bufp, fnamelen)
@@ -21079,36 +21101,44 @@ get_short_pathname(fnamep, bufp, fnamelen)
char_u **bufp;
int *fnamelen;
{
int l,len;
int l, len;
char_u *newbuf;
len = *fnamelen;
l = GetShortPathName(*fnamep, *fnamep, len);
if (l > len - 1)
{
/* If that doesn't work (not enough space), then save the string
* and try again with a new buffer big enough
*/
* and try again with a new buffer big enough. */
newbuf = vim_strnsave(*fnamep, l);
if (newbuf == NULL)
return 0;
return FAIL;
vim_free(*bufp);
*fnamep = *bufp = newbuf;
l = GetShortPathName(*fnamep,*fnamep,l+1);
/* Really should always succeed, as the buffer is big enough */
/* Really should always succeed, as the buffer is big enough. */
l = GetShortPathName(*fnamep, *fnamep, l+1);
}
*fnamelen = l;
return 1;
return OK;
}
/*
* Create a short path name. Returns the length of the buffer it needs.
* Doesn't copy over the end of the buffer passed in.
* Get the short path (8.3) for the filename in "fname". The converted
* path is returned in "bufp".
*
* Some of the directories specified in "fname" may not exist. This function
* will shorten the existing directories at the beginning of the path and then
* append the remaining non-existing path.
*
* fname - Pointer to the filename to shorten. On return, contains the
* pointer to the shortened pathname
* bufp - Pointer to an allocated buffer for the filename.
* fnamelen - Length of the filename pointed to by fname
*
* Returns OK on success (or nothing done) and FAIL on failure (out of memory).
*/
static int
shortpath_for_invalid_fname(fname, bufp, fnamelen)
@@ -21116,85 +21146,106 @@ shortpath_for_invalid_fname(fname, bufp, fnamelen)
char_u **bufp;
int *fnamelen;
{
char_u *s, *p, *pbuf2, *pbuf3;
char_u *short_fname, *save_fname, *pbuf_unused;
char_u *endp, *save_endp;
char_u ch;
int len, len2, plen, slen;
int old_len, len;
int new_len, sfx_len;
int retval = OK;
/* Make a copy */
len2 = *fnamelen;
pbuf2 = vim_strnsave(*fname, len2);
pbuf3 = NULL;
old_len = *fnamelen;
save_fname = vim_strnsave(*fname, old_len);
pbuf_unused = NULL;
short_fname = NULL;
s = pbuf2 + len2 - 1; /* Find the end */
slen = 1;
plen = len2;
endp = save_fname + old_len - 1; /* Find the end of the copy */
save_endp = endp;
if (after_pathsep(pbuf2, s + 1))
/*
* Try shortening the supplied path till it succeeds by removing one
* directory at a time from the tail of the path.
*/
len = 0;
for (;;)
{
--s;
++slen;
--plen;
/* go back one path-separator */
while (endp > save_fname && !after_pathsep(save_fname, endp + 1))
--endp;
if (endp <= save_fname)
break; /* processed the complete path */
/*
* Replace the path separator with a NUL and try to shorten the
* resulting path.
*/
ch = *endp;
*endp = 0;
short_fname = save_fname;
len = STRLEN(short_fname) + 1;
if (get_short_pathname(&short_fname, &pbuf_unused, &len) == FAIL)
{
retval = FAIL;
goto theend;
}
*endp = ch; /* preserve the string */
if (len > 0)
break; /* successfully shortened the path */
/* failed to shorten the path. Skip the path separator */
--endp;
}
do
if (len > 0)
{
/* Go back one path-separator */
while (s > pbuf2 && !after_pathsep(pbuf2, s + 1))
{
--s;
++slen;
--plen;
}
if (s <= pbuf2)
break;
/*
* Succeeded in shortening the path. Now concatenate the shortened
* path with the remaining path at the tail.
*/
/* Remember the character that is about to be splatted */
ch = *s;
*s = 0; /* get_short_pathname requires a null-terminated string */
/* Compute the length of the new path. */
sfx_len = (int)(save_endp - endp) + 1;
new_len = len + sfx_len;
/* Try it in situ */
p = pbuf2;
if (!get_short_pathname(&p, &pbuf3, &plen))
{
vim_free(pbuf2);
return -1;
}
*s = ch; /* Preserve the string */
} while (plen == 0);
if (plen > 0)
{
/* Remember the length of the new string. */
*fnamelen = len = plen + slen;
*fnamelen = new_len;
vim_free(*bufp);
if (len > len2)
if (new_len > old_len)
{
/* If there's not enough space in the currently allocated string,
* then copy it to a buffer big enough.
*/
*fname= *bufp = vim_strnsave(p, len);
/* There is not enough space in the currently allocated string,
* copy it to a buffer big enough. */
*fname = *bufp = vim_strnsave(short_fname, new_len);
if (*fname == NULL)
return -1;
{
retval = FAIL;
goto theend;
}
}
else
{
/* Transfer pbuf2 to being the main buffer (it's big enough) */
*fname = *bufp = pbuf2;
if (p != pbuf2)
strncpy(*fname, p, plen);
pbuf2 = NULL;
/* Transfer short_fname to the main buffer (it's big enough),
* unless get_short_pathname() did its work in-place. */
*fname = *bufp = save_fname;
if (short_fname != save_fname)
vim_strncpy(save_fname, short_fname, len);
save_fname = NULL;
}
/* Concat the next bit */
strncpy(*fname + plen, s, slen);
(*fname)[len] = '\0';
/* concat the not-shortened part of the path */
vim_strncpy(*fname + len, endp, sfx_len);
(*fname)[new_len] = NUL;
}
vim_free(pbuf3);
vim_free(pbuf2);
return 0;
theend:
vim_free(pbuf_unused);
vim_free(save_fname);
return retval;
}
/*
* Get a pathname for a partial path.
* Returns OK for success, FAIL for failure.
*/
static int
shortpath_for_partial(fnamep, bufp, fnamelen)
@@ -21224,8 +21275,8 @@ shortpath_for_partial(fnamep, bufp, fnamelen)
len = tflen = (int)STRLEN(tfname);
if (!get_short_pathname(&tfname, &pbuf, &len))
return -1;
if (get_short_pathname(&tfname, &pbuf, &len) == FAIL)
return FAIL;
if (len == 0)
{
@@ -21234,8 +21285,8 @@ shortpath_for_partial(fnamep, bufp, fnamelen)
* there's not a lot of point in guessing what it might be.
*/
len = tflen;
if (shortpath_for_invalid_fname(&tfname, &pbuf, &len) == -1)
return -1;
if (shortpath_for_invalid_fname(&tfname, &pbuf, &len) == FAIL)
return FAIL;
}
/* Count the paths backward to find the beginning of the desired string. */
@@ -21259,7 +21310,7 @@ shortpath_for_partial(fnamep, bufp, fnamelen)
if (p >= tfname)
*p = '~';
else
return -1;
return FAIL;
}
else
++p;
@@ -21270,7 +21321,7 @@ shortpath_for_partial(fnamep, bufp, fnamelen)
*bufp = pbuf;
*fnamep = p;
return 0;
return OK;
}
#endif /* WIN3264 */
@@ -21278,7 +21329,7 @@ shortpath_for_partial(fnamep, bufp, fnamelen)
* Adjust a filename, according to a string of modifiers.
* *fnamep must be NUL terminated when called. When returning, the length is
* determined by *fnamelen.
* Returns valid flags.
* Returns VALID_ flags or -1 for failure.
* When there is an error, *fnamep is set to NULL.
*/
int
@@ -21490,7 +21541,7 @@ repeat:
*/
if (!has_fullname && !vim_isAbsName(*fnamep))
{
if (shortpath_for_partial(fnamep, bufp, fnamelen) == -1)
if (shortpath_for_partial(fnamep, bufp, fnamelen) == FAIL)
return -1;
}
else
@@ -21500,7 +21551,7 @@ repeat:
/* Simple case, already have the full-name
* Nearly always shorter, so try first time. */
l = *fnamelen;
if (!get_short_pathname(fnamep, bufp, &l))
if (get_short_pathname(fnamep, bufp, &l) == FAIL)
return -1;
if (l == 0)
@@ -21508,7 +21559,7 @@ repeat:
/* Couldn't find the filename.. search the paths.
*/
l = *fnamelen;
if (shortpath_for_invalid_fname(fnamep, bufp, &l ) == -1)
if (shortpath_for_invalid_fname(fnamep, bufp, &l) == FAIL)
return -1;
}
*fnamelen = l;
+5 -1
View File
@@ -1160,6 +1160,7 @@ do_filter(line1, line2, eap, cmd, do_in, do_out)
if (!do_out)
msg_putchar('\n');
/* Create the shell command in allocated memory. */
cmd_buf = make_filter_cmd(cmd, itmp, otmp);
if (cmd_buf == NULL)
goto filterend;
@@ -1180,7 +1181,10 @@ do_filter(line1, line2, eap, cmd, do_in, do_out)
if (do_out)
{
if (u_save((linenr_T)(line2), (linenr_T)(line2 + 1)) == FAIL)
{
vim_free(cmd_buf);
goto error;
}
redraw_curbuf_later(VALID);
}
read_linecount = curbuf->b_ml.ml_line_count;
@@ -4471,7 +4475,7 @@ do_sub(eap)
/*
* The new text is build up step by step, to avoid too much
* copying. There are these pieces:
* sub_firstline The old text, unmodifed.
* sub_firstline The old text, unmodified.
* copycol Column in the old text where we started
* looking for a match; from here old text still
* needs to be copied to the new text.
+2 -2
View File
@@ -597,8 +597,8 @@ EX(CMD_match, "match", ex_match,
RANGE|NOTADR|EXTRA|CMDWIN),
EX(CMD_macaction, "macaction", ex_macaction,
EXTRA|NOSPC|NEEDARG),
EX(CMD_macmenukey, "macmenukey", ex_macmenukey,
EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN),
EX(CMD_macmenu, "macmenu", ex_macmenu,
EXTRA|TRLBAR|CMDWIN),
EX(CMD_menu, "menu", ex_menu,
RANGE|NOTADR|ZEROR|BANG|EXTRA|TRLBAR|NOTRLCOM|USECTRLV|CMDWIN),
EX(CMD_menutranslate, "menutranslate", ex_menutranslate,
+13 -7
View File
@@ -466,7 +466,7 @@ static void ex_folddo __ARGS((exarg_T *eap));
#ifndef FEAT_GUI_MACVIM
# define ex_macaction ex_ni
# define ex_macmenukey ex_ni
# define ex_macmenu ex_ni
#endif
/*
@@ -3015,7 +3015,7 @@ modifier_len(cmd)
break;
if (!isalpha(p[j]) && j >= cmdmods[i].minlen
&& (p == cmd || cmdmods[i].has_count))
return j + (p - cmd);
return j + (int)(p - cmd);
}
return 0;
}
@@ -3764,7 +3764,7 @@ set_one_cmd_context(xp, buff)
case CMD_tmenu: case CMD_tunmenu:
case CMD_popup: case CMD_tearoff: case CMD_emenu:
#ifdef FEAT_GUI_MACVIM
case CMD_macmenukey:
case CMD_macmenu:
#endif
return set_context_in_menu_cmd(xp, cmd, arg, forceit);
#endif
@@ -3792,6 +3792,14 @@ set_one_cmd_context(xp, buff)
break;
#endif
#ifdef FEAT_GUI_MACVIM
case CMD_macaction:
xp->xp_context = EXPAND_MACACTION;
xp->xp_pattern = arg;
break;
#endif
#endif /* FEAT_CMDL_COMPL */
default:
@@ -3941,8 +3949,7 @@ get_address(ptr, skip, to_other_file)
curwin->w_cursor.col = 0;
searchcmdlen = 0;
if (!do_search(NULL, c, cmd, 1L,
SEARCH_HIS + SEARCH_MSG + SEARCH_START,
NULL))
SEARCH_HIS | SEARCH_MSG, NULL))
{
curwin->w_cursor = pos;
cmd = NULL;
@@ -3989,8 +3996,7 @@ get_address(ptr, skip, to_other_file)
pos.col = 0;
if (searchit(curwin, curbuf, &pos,
*cmd == '?' ? BACKWARD : FORWARD,
(char_u *)"", 1L,
SEARCH_MSG + SEARCH_START,
(char_u *)"", 1L, SEARCH_MSG,
i, (linenr_T)0, NULL) != FAIL)
lnum = pos.lnum;
else
+31 -13
View File
@@ -3657,20 +3657,9 @@ ExpandEscape(xp, str, numfiles, files, options)
}
}
#ifdef BACKSLASH_IN_FILENAME
{
char_u buf[20];
int j = 0;
/* Don't escape '[' and '{' if they are in 'isfname'. */
for (p = PATH_ESC_CHARS; *p != NUL; ++p)
if ((*p != '[' && *p != '{') || !vim_isfilec(*p))
buf[j++] = *p;
buf[j] = NUL;
p = vim_strsave_escaped(files[i], buf);
}
p = vim_strsave_fnameescape(files[i], FALSE);
#else
p = vim_strsave_escaped(files[i],
xp->xp_shell ? SHELL_ESC_CHARS : PATH_ESC_CHARS);
p = vim_strsave_fnameescape(files[i], xp->xp_shell);
#endif
if (p != NULL)
{
@@ -3709,6 +3698,32 @@ ExpandEscape(xp, str, numfiles, files, options)
}
}
/*
* Escape special characters in "fname" for when used as a file name argument
* after a Vim command, or, when "shell" is non-zero, a shell command.
* Returns the result in allocated memory.
*/
char_u *
vim_strsave_fnameescape(fname, shell)
char_u *fname;
int shell;
{
#ifdef BACKSLASH_IN_FILENAME
char_u buf[20];
int j = 0;
char_u *p;
/* Don't escape '[' and '{' if they are in 'isfname'. */
for (p = PATH_ESC_CHARS; *p != NUL; ++p)
if ((*p != '[' && *p != '{') || !vim_isfilec(*p))
buf[j++] = *p;
buf[j] = NUL;
return vim_strsave_escaped(fname, buf);
#else
return vim_strsave_escaped(fname, shell ? SHELL_ESC_CHARS : PATH_ESC_CHARS);
#endif
}
/*
* Put a backslash before the file name in "pp", which is in allocated memory.
*/
@@ -4449,6 +4464,9 @@ ExpandFromContext(xp, pat, num_file, file, options)
{EXPAND_LANGUAGE, get_lang_arg, TRUE},
#endif
{EXPAND_ENV_VARS, get_env_name, TRUE},
#ifdef FEAT_GUI_MACVIM
{EXPAND_MACACTION, get_macaction_name, FALSE},
#endif
};
int i;
+7
View File
@@ -1296,3 +1296,10 @@
#ifdef FEAT_GUI_MACVIM
#define FEAT_GUI_SCROLL_WHEEL_FORCE
#endif
/*
* Support for enabling/disabling antialiased text.
*/
#if defined(FEAT_GUI) && defined(MACOS_X)
#define FEAT_ANTIALIAS
#endif
+93 -45
View File
@@ -1288,12 +1288,49 @@ retry:
#ifdef FEAT_MBYTE
else if (conv_restlen > 0)
{
/* Reached end-of-file but some trailing bytes could
* not be converted. Truncated file? */
if (conv_error == 0)
conv_error = linecnt;
if (bad_char_behavior != BAD_DROP)
/*
* Reached end-of-file but some trailing bytes could
* not be converted. Truncated file?
*/
/* When we did a conversion report an error. */
if (fio_flags != 0
# ifdef USE_ICONV
|| iconv_fd != (iconv_t)-1
# endif
)
{
if (conv_error == 0)
conv_error = curbuf->b_ml.ml_line_count
- linecnt + 1;
}
/* Remember the first linenr with an illegal byte */
else if (illegal_byte == 0)
illegal_byte = curbuf->b_ml.ml_line_count
- linecnt + 1;
if (bad_char_behavior == BAD_DROP)
{
*(ptr - conv_restlen) = NUL;
conv_restlen = 0;
}
else
{
/* Replace the trailing bytes with the replacement
* character if we were converting; if we weren't,
* leave the UTF8 checking code to do it, as it
* works slightly differently. */
if (bad_char_behavior != BAD_KEEP && (fio_flags != 0
# ifdef USE_ICONV
|| iconv_fd != (iconv_t)-1
# endif
))
{
while (conv_restlen > 0)
{
*(--ptr) = bad_char_behavior;
--conv_restlen;
}
}
fio_flags = 0; /* don't convert this */
# ifdef USE_ICONV
if (iconv_fd != (iconv_t)-1)
@@ -1302,20 +1339,6 @@ retry:
iconv_fd = (iconv_t)-1;
}
# endif
if (bad_char_behavior == BAD_KEEP)
{
/* Keep the trailing bytes as-is. */
size = conv_restlen;
ptr -= conv_restlen;
}
else
{
/* Replace the trailing bytes with the
* replacement character. */
size = 1;
*--ptr = bad_char_behavior;
}
conv_restlen = 0;
}
}
#endif
@@ -1397,6 +1420,11 @@ retry:
goto retry;
}
}
/* Include not converted bytes. */
ptr -= conv_restlen;
size += conv_restlen;
conv_restlen = 0;
#endif
/*
* Break here for a read error or end-of-file.
@@ -1406,11 +1434,6 @@ retry:
#ifdef FEAT_MBYTE
/* Include not converted bytes. */
ptr -= conv_restlen;
size += conv_restlen;
conv_restlen = 0;
# ifdef USE_ICONV
if (iconv_fd != (iconv_t)-1)
{
@@ -1872,12 +1895,12 @@ retry:
size = (long)((ptr + real_size) - dest);
ptr = dest;
}
else if (enc_utf8 && conv_error == 0 && !curbuf->b_p_bin)
else if (enc_utf8 && !curbuf->b_p_bin)
{
/* Reading UTF-8: Check if the bytes are valid UTF-8.
* Need to start before "ptr" when part of the character was
* read in the previous read() call. */
for (p = ptr - utf_head_off(buffer, ptr); ; ++p)
int incomplete_tail = FALSE;
/* Reading UTF-8: Check if the bytes are valid UTF-8. */
for (p = ptr; ; ++p)
{
int todo = (int)((ptr + size) - p);
int l;
@@ -1891,43 +1914,56 @@ retry:
* read() will get the next bytes, we'll check it
* then. */
l = utf_ptr2len_len(p, todo);
if (l > todo)
if (l > todo && !incomplete_tail)
{
/* Incomplete byte sequence, the next read()
* should get them and check the bytes. */
p += todo;
break;
/* Avoid retrying with a different encoding when
* a truncated file is more likely, or attempting
* to read the rest of an incomplete sequence when
* we have already done so. */
if (p > ptr || filesize > 0)
incomplete_tail = TRUE;
/* Incomplete byte sequence, move it to conv_rest[]
* and try to read the rest of it, unless we've
* already done so. */
if (p > ptr)
{
conv_restlen = todo;
mch_memmove(conv_rest, p, conv_restlen);
size -= conv_restlen;
break;
}
}
if (l == 1)
if (l == 1 || l > todo)
{
/* Illegal byte. If we can try another encoding
* do that. */
if (can_retry)
* do that, unless at EOF where a truncated
* file is more likely than a conversion error. */
if (can_retry && !incomplete_tail)
break;
/* Remember the first linenr with an illegal byte */
if (illegal_byte == 0)
illegal_byte = readfile_linenr(linecnt, ptr, p);
# ifdef USE_ICONV
/* When we did a conversion report an error. */
if (iconv_fd != (iconv_t)-1 && conv_error == 0)
conv_error = readfile_linenr(linecnt, ptr, p);
# endif
/* Remember the first linenr with an illegal byte */
if (conv_error == 0 && illegal_byte == 0)
illegal_byte = readfile_linenr(linecnt, ptr, p);
/* Drop, keep or replace the bad byte. */
if (bad_char_behavior == BAD_DROP)
{
mch_memmove(p, p+1, todo - 1);
mch_memmove(p, p + 1, todo - 1);
--p;
--size;
}
else if (bad_char_behavior != BAD_KEEP)
*p = bad_char_behavior;
}
p += l - 1;
else
p += l - 1;
}
}
if (p < ptr + size)
if (p < ptr + size && !incomplete_tail)
{
/* Detected a UTF-8 error. */
rewind_retry:
@@ -3651,6 +3687,9 @@ buf_write(buf, fname, sfname, start, end, eap, append, forceit,
)
mch_setperm(backup,
(perm & 0707) | ((perm & 07) << 3));
# ifdef HAVE_SELINUX
mch_copy_sec(fname, backup);
# endif
#endif
/*
@@ -3686,6 +3725,9 @@ buf_write(buf, fname, sfname, start, end, eap, append, forceit,
#endif
#ifdef HAVE_ACL
mch_set_acl(backup, acl);
#endif
#ifdef HAVE_SELINUX
mch_copy_sec(fname, backup);
#endif
break;
}
@@ -4309,6 +4351,12 @@ restore_backup:
}
#endif
#ifdef HAVE_SELINUX
/* Probably need to set the security context. */
if (!backup_copy)
mch_copy_sec(backup, wfname);
#endif
#ifdef UNIX
/* When creating a new file, set its owner/group to that of the original
* file. Get the new device and inode number. */
@@ -9244,7 +9292,7 @@ aucmd_prepbuf(aco, buf)
aco_save_T *aco; /* structure to save values in */
buf_T *buf; /* new curbuf */
{
aco->save_buf = buf;
aco->save_buf = curbuf;
curbuf = buf;
curwin->w_buffer = buf;
}
+1 -1
View File
@@ -1263,7 +1263,7 @@ EXTERN int echo_wid_arg INIT(= FALSE); /* --echo-wid argument */
* The value of the --windowid argument.
* For embedding gvim inside another application.
*/
EXTERN int win_socket_id INIT(= 0);
EXTERN long_u win_socket_id INIT(= 0);
#endif
#if defined(FEAT_CLIENTSERVER) || defined(FEAT_EVAL)
+9
View File
@@ -4955,6 +4955,15 @@ gui_update_screen()
{
update_topline();
validate_cursor();
#ifdef FEAT_AUTOCMD
/* Trigger CursorMoved if the cursor moved. */
if (!finish_op && has_cursormoved()
&& !equalpos(last_cursormoved, curwin->w_cursor))
{
apply_autocmds(EVENT_CURSORMOVED, NULL, NULL, FALSE, curbuf);
last_cursormoved = curwin->w_cursor;
}
#endif
update_screen(0); /* may need to update the screen */
setcursor();
out_flush(); /* make sure output has been written */
+1 -1
View File
@@ -495,7 +495,7 @@ typedef struct Gui
#endif
#ifdef FEAT_GUI_SCROLL_WHEEL_FORCE
int scroll_wheel_force;
int scroll_wheel_force;
#endif
} gui_T;
+667 -231
View File
File diff suppressed because it is too large Load Diff
+8
View File
@@ -0,0 +1,8 @@
#!/bin/sh
# Start GUI Vim on a copy of the tutor file.
# Usage: gvimtutor [xx]
# See vimtutor for usage.
exec `dirname $0`/vimtutor -g "$@"
+95 -16
View File
@@ -1400,7 +1400,7 @@ cs_lookup_cmd(eap)
return NULL;
/* Store length of eap->arg before it gets modified by strtok(). */
eap_arg_len = STRLEN(eap->arg);
eap_arg_len = (int)STRLEN(eap->arg);
if ((stok = strtok((char *)(eap->arg), (const char *)" ")) == NULL)
return NULL;
@@ -2096,6 +2096,18 @@ cs_read_prompt(i)
return CSCOPE_SUCCESS;
}
#if defined(UNIX) && defined(SIGALRM)
/*
* Used to catch and ignore SIGALRM below.
*/
/* ARGSUSED */
static RETSIGTYPE
sig_handler SIGDEFARG(sigarg)
{
/* do nothing */
SIGRETURN;
}
#endif
/*
* PRIVATE: cs_release_csp
@@ -2108,9 +2120,6 @@ cs_release_csp(i, freefnpp)
int i;
int freefnpp;
{
#if defined(UNIX)
int pstat;
#else
/*
* Trying to exit normally (not sure whether it is fit to UNIX cscope
*/
@@ -2119,6 +2128,88 @@ cs_release_csp(i, freefnpp)
(void)fputs("q\n", csinfo[i].to_fp);
(void)fflush(csinfo[i].to_fp);
}
#if defined(UNIX)
{
int waitpid_errno;
int pstat;
pid_t pid;
# if defined(HAVE_SIGACTION)
struct sigaction sa, old;
/* Use sigaction() to limit the waiting time to two seconds. */
sigemptyset(&sa.sa_mask);
sa.sa_handler = sig_handler;
sa.sa_flags = SA_NODEFER;
sigaction(SIGALRM, &sa, &old);
alarm(2); /* 2 sec timeout */
/* Block until cscope exits or until timer expires */
pid = waitpid(csinfo[i].pid, &pstat, 0);
waitpid_errno = errno;
/* cancel pending alarm if still there and restore signal */
alarm(0);
sigaction(SIGALRM, &old, NULL);
# else
int waited;
/* Can't use sigaction(), loop for two seconds. First yield the CPU
* to give cscope a chance to exit quickly. */
sleep(0);
for (waited = 0; waited < 40; ++waited)
{
pid = waitpid(csinfo[i].pid, &pstat, WNOHANG);
waitpid_errno = errno;
if (pid != 0)
break; /* break unless the process is still running */
mch_delay(50L, FALSE); /* sleep 50 ms */
}
# endif
/*
* If the cscope process is still running: kill it.
* Safety check: If the PID would be zero here, the entire X session
* would be killed. -1 and 1 are dangerous as well.
*/
if (pid < 0 && csinfo[i].pid > 1)
{
# ifdef ECHILD
int alive = TRUE;
if (waitpid_errno == ECHILD)
{
/*
* When using 'vim -g', vim is forked and cscope process is
* no longer a child process but a sibling. So waitpid()
* fails with errno being ECHILD (No child processes).
* Don't send SIGKILL to cscope immediately but wait
* (polling) for it to exit normally as result of sending
* the "q" command, hence giving it a chance to clean up
* its temporary files.
*/
int waited;
sleep(0);
for (waited = 0; waited < 40; ++waited)
{
/* Check whether cscope process is still alive */
if (kill(csinfo[i].pid, 0) != 0)
{
alive = FALSE; /* cscope process no longer exists */
break;
}
mch_delay(50L, FALSE); /* sleep 50ms */
}
}
if (alive)
# endif
{
kill(csinfo[i].pid, SIGKILL);
(void)waitpid(csinfo[i].pid, &pstat, 0);
}
}
}
#else /* !UNIX */
if (csinfo[i].hProc != NULL)
{
/* Give cscope a chance to exit normally */
@@ -2133,18 +2224,6 @@ cs_release_csp(i, freefnpp)
if (csinfo[i].to_fp != NULL)
(void)fclose(csinfo[i].to_fp);
/*
* Safety check: If the PID would be zero here, the entire X session would
* be killed. -1 and 1 are dangerous as well.
*/
#if defined(UNIX)
if (csinfo[i].pid > 1)
{
kill(csinfo[i].pid, SIGTERM);
(void)waitpid(csinfo[i].pid, &pstat, 0);
}
#endif
if (freefnpp)
{
vim_free(csinfo[i].fname);
+9 -3
View File
@@ -34,6 +34,12 @@ extern HWND s_hwnd;
extern HWND vim_parent_hwnd;
}
#if _MSC_VER < 1300
/* Work around old versions of basetsd.h which wrongly declares
* UINT_PTR as unsigned long */
# define UINT_PTR UINT
#endif
#include "if_ole.h" // Interface definitions
#include "iid_ole.c" // UUID definitions (compile here)
@@ -107,7 +113,7 @@ public:
STDMETHOD(SendKeys)(BSTR keys);
STDMETHOD(Eval)(BSTR expr, BSTR *result);
STDMETHOD(SetForeground)(void);
STDMETHOD(GetHwnd)(UINT *result);
STDMETHOD(GetHwnd)(UINT_PTR *result);
private:
// Constructor is private - create using CVim::Create()
@@ -288,9 +294,9 @@ CVim::Invoke(
}
STDMETHODIMP
CVim::GetHwnd(UINT *result)
CVim::GetHwnd(UINT_PTR *result)
{
*result = (UINT) s_hwnd;
*result = (UINT_PTR)s_hwnd;
return S_OK;
}
+3 -3
View File
@@ -79,7 +79,7 @@ EXTERN_C const IID IID_IVim;
virtual HRESULT STDMETHODCALLTYPE SetForeground( void) = 0;
virtual HRESULT STDMETHODCALLTYPE GetHwnd(
/* [retval][out] */ UINT __RPC_FAR *result) = 0;
/* [retval][out] */ UINT_PTR __RPC_FAR *result) = 0;
};
@@ -143,7 +143,7 @@ EXTERN_C const IID IID_IVim;
HRESULT ( STDMETHODCALLTYPE __RPC_FAR *GetHwnd )(
IVim __RPC_FAR * This,
/* [retval][out] */ UINT __RPC_FAR *result);
/* [retval][out] */ UINT_PTR __RPC_FAR *result);
END_INTERFACE
} IVimVtbl;
@@ -236,7 +236,7 @@ void __RPC_STUB IVim_SetForeground_Stub(
HRESULT STDMETHODCALLTYPE IVim_GetHwnd_Proxy(
IVim __RPC_FAR * This,
/* [retval][out] */ UINT __RPC_FAR *result);
/* [retval][out] */ UINT_PTR __RPC_FAR *result);
void __RPC_STUB IVim_GetHwnd_Stub(
+1 -1
View File
@@ -20,7 +20,7 @@ interface IVim : IDispatch
HRESULT SendKeys([in]BSTR keys);
HRESULT Eval([in]BSTR expr, [out, retval]BSTR* result);
HRESULT SetForeground(void);
HRESULT GetHwnd([out, retval]UINT* result);
HRESULT GetHwnd([out, retval]UINT_PTR* result);
};
// Component and type library definitions
+115 -87
View File
@@ -38,6 +38,8 @@
# undef HAVE_STDARG_H /* Python's config.h defines it as well. */
#endif
#define PY_SSIZE_T_CLEAN
#include <Python.h>
#if defined(MACOS) && !defined(MACOS_X_UNIX)
# include "macglue.h"
@@ -55,6 +57,22 @@ struct PyMethodDef { int a; };
# define PySequenceMethods int
#endif
#if defined(PY_VERSION_HEX) && PY_VERSION_HEX >= 0x02050000
# define PyInt Py_ssize_t
# define PyInquiry lenfunc
# define PyIntArgFunc ssizeargfunc
# define PyIntIntArgFunc ssizessizeargfunc
# define PyIntObjArgProc ssizeobjargproc
# define PyIntIntObjArgProc ssizessizeobjargproc
#else
# define PyInt int
# define PyInquiry inquiry
# define PyIntArgFunc intargfunc
# define PyIntIntArgFunc intintargfunc
# define PyIntObjArgProc intobjargproc
# define PyIntIntObjArgProc intintobjargproc
#endif
/* Parser flags */
#define single_input 256
#define file_input 257
@@ -150,11 +168,11 @@ static void (*dll_PyGILState_Release)(PyGILState_STATE);
static long(*dll_PyInt_AsLong)(PyObject *);
static PyObject*(*dll_PyInt_FromLong)(long);
static PyTypeObject* dll_PyInt_Type;
static PyObject*(*dll_PyList_GetItem)(PyObject *, int);
static PyObject*(*dll_PyList_GetItem)(PyObject *, PyInt);
static PyObject*(*dll_PyList_Append)(PyObject *, PyObject *);
static PyObject*(*dll_PyList_New)(int size);
static int(*dll_PyList_SetItem)(PyObject *, int, PyObject *);
static int(*dll_PyList_Size)(PyObject *);
static PyObject*(*dll_PyList_New)(PyInt size);
static int(*dll_PyList_SetItem)(PyObject *, PyInt, PyObject *);
static PyInt(*dll_PyList_Size)(PyObject *);
static PyTypeObject* dll_PyList_Type;
static PyObject*(*dll_PyImport_ImportModule)(const char *);
static PyObject*(*dll_PyDict_New)(void);
@@ -163,8 +181,8 @@ static PyObject*(*dll_PyModule_GetDict)(PyObject *);
static int(*dll_PyRun_SimpleString)(char *);
static char*(*dll_PyString_AsString)(PyObject *);
static PyObject*(*dll_PyString_FromString)(const char *);
static PyObject*(*dll_PyString_FromStringAndSize)(const char *, int);
static int(*dll_PyString_Size)(PyObject *);
static PyObject*(*dll_PyString_FromStringAndSize)(const char *, PyInt);
static PyInt(*dll_PyString_Size)(PyObject *);
static PyTypeObject* dll_PyString_Type;
static int(*dll_PySys_SetObject)(char *, PyObject *);
static int(*dll_PySys_SetArgv)(int, char **);
@@ -367,10 +385,10 @@ static int PythonMod_Init(void);
* ----------------------------------------------
*/
static PyObject *GetBufferLine(buf_T *, int);
static PyObject *GetBufferLineList(buf_T *, int, int);
static PyObject *GetBufferLineList(buf_T *, PyInt, PyInt);
static int SetBufferLine(buf_T *, int, PyObject *, int *);
static int SetBufferLineList(buf_T *, int, int, PyObject *, int *);
static int SetBufferLineList(buf_T *, PyInt, PyInt, PyObject *, int *);
static int InsertBufferLines(buf_T *, int, PyObject *, int *);
static PyObject *LineToString(const char *);
@@ -773,8 +791,8 @@ OutputWrite(PyObject *self, PyObject *args)
static PyObject *
OutputWritelines(PyObject *self, PyObject *args)
{
int n;
int i;
PyInt n;
PyInt i;
PyObject *list;
int error = ((OutputObject *)(self))->error;
@@ -986,11 +1004,11 @@ static void BufferDestructor(PyObject *);
static PyObject *BufferGetattr(PyObject *, char *);
static PyObject *BufferRepr(PyObject *);
static int BufferLength(PyObject *);
static PyObject *BufferItem(PyObject *, int);
static PyObject *BufferSlice(PyObject *, int, int);
static int BufferAssItem(PyObject *, int, PyObject *);
static int BufferAssSlice(PyObject *, int, int, PyObject *);
static PyInt BufferLength(PyObject *);
static PyObject *BufferItem(PyObject *, PyInt);
static PyObject *BufferSlice(PyObject *, PyInt, PyInt);
static PyInt BufferAssItem(PyObject *, PyInt, PyObject *);
static PyInt BufferAssSlice(PyObject *, PyInt, PyInt, PyObject *);
static PyObject *BufferAppend(PyObject *, PyObject *);
static PyObject *BufferMark(PyObject *, PyObject *);
@@ -1017,11 +1035,11 @@ static void RangeDestructor(PyObject *);
static PyObject *RangeGetattr(PyObject *, char *);
static PyObject *RangeRepr(PyObject *);
static int RangeLength(PyObject *);
static PyObject *RangeItem(PyObject *, int);
static PyObject *RangeSlice(PyObject *, int, int);
static int RangeAssItem(PyObject *, int, PyObject *);
static int RangeAssSlice(PyObject *, int, int, PyObject *);
static PyInt RangeLength(PyObject *);
static PyObject *RangeItem(PyObject *, PyInt);
static PyObject *RangeSlice(PyObject *, PyInt, PyInt);
static PyInt RangeAssItem(PyObject *, PyInt, PyObject *);
static PyInt RangeAssSlice(PyObject *, PyInt, PyInt, PyObject *);
static PyObject *RangeAppend(PyObject *, PyObject *);
@@ -1029,15 +1047,15 @@ static PyObject *RangeAppend(PyObject *, PyObject *);
* -------------------------------------------
*/
static int WinListLength(PyObject *);
static PyObject *WinListItem(PyObject *, int);
static PyInt WinListLength(PyObject *);
static PyObject *WinListItem(PyObject *, PyInt);
/* Buffer list type - Implementation functions
* -------------------------------------------
*/
static int BufListLength(PyObject *);
static PyObject *BufListItem(PyObject *, int);
static PyInt BufListLength(PyObject *);
static PyObject *BufListItem(PyObject *, PyInt);
/* Current objects type - Implementation functions
* -----------------------------------------------
@@ -1130,6 +1148,16 @@ VimToPython(typval_T *our_tv, int depth, PyObject *lookupDict)
result = Py_BuildValue("s", buf);
PyDict_SetItemString(lookupDict, ptrBuf, result);
}
#ifdef FEAT_FLOAT
else if (our_tv->v_type == VAR_FLOAT)
{
char buf[NUMBUFLEN];
sprintf(buf, "%f", our_tv->vval.v_float);
result = Py_BuildValue("s", buf);
PyDict_SetItemString(lookupDict, ptrBuf, result);
}
#endif
else if (our_tv->v_type == VAR_LIST)
{
list_T *list = our_tv->vval.v_list;
@@ -1245,7 +1273,7 @@ CheckBuffer(BufferObject *this)
}
static PyObject *
RBItem(BufferObject *self, int n, int start, int end)
RBItem(BufferObject *self, PyInt n, int start, int end)
{
if (CheckBuffer(self))
return NULL;
@@ -1260,9 +1288,9 @@ RBItem(BufferObject *self, int n, int start, int end)
}
static PyObject *
RBSlice(BufferObject *self, int lo, int hi, int start, int end)
RBSlice(BufferObject *self, PyInt lo, PyInt hi, int start, int end)
{
int size;
PyInt size;
if (CheckBuffer(self))
return NULL;
@@ -1283,8 +1311,8 @@ RBSlice(BufferObject *self, int lo, int hi, int start, int end)
return GetBufferLineList(self->buf, lo+start, hi+start);
}
static int
RBAssItem(BufferObject *self, int n, PyObject *val, int start, int end, int *new_end)
static PyInt
RBAssItem(BufferObject *self, PyInt n, PyObject *val, int start, int end, int *new_end)
{
int len_change;
@@ -1306,8 +1334,8 @@ RBAssItem(BufferObject *self, int n, PyObject *val, int start, int end, int *new
return 0;
}
static int
RBAssSlice(BufferObject *self, int lo, int hi, PyObject *val, int start, int end, int *new_end)
static PyInt
RBAssSlice(BufferObject *self, PyInt lo, PyInt hi, PyObject *val, int start, int end, int *new_end)
{
int size;
int len_change;
@@ -1384,13 +1412,13 @@ static struct PyMethodDef BufferMethods[] = {
};
static PySequenceMethods BufferAsSeq = {
(inquiry) BufferLength, /* sq_length, len(x) */
(PyInquiry) BufferLength, /* sq_length, len(x) */
(binaryfunc) 0, /* BufferConcat, */ /* sq_concat, x+y */
(intargfunc) 0, /* BufferRepeat, */ /* sq_repeat, x*n */
(intargfunc) BufferItem, /* sq_item, x[i] */
(intintargfunc) BufferSlice, /* sq_slice, x[i:j] */
(intobjargproc) BufferAssItem, /* sq_ass_item, x[i]=v */
(intintobjargproc) BufferAssSlice, /* sq_ass_slice, x[i:j]=v */
(PyIntArgFunc) 0, /* BufferRepeat, */ /* sq_repeat, x*n */
(PyIntArgFunc) BufferItem, /* sq_item, x[i] */
(PyIntIntArgFunc) BufferSlice, /* sq_slice, x[i:j] */
(PyIntObjArgProc) BufferAssItem, /* sq_ass_item, x[i]=v */
(PyIntIntObjArgProc) BufferAssSlice, /* sq_ass_slice, x[i:j]=v */
};
static PyTypeObject BufferType = {
@@ -1516,7 +1544,7 @@ BufferRepr(PyObject *self)
/******************/
static int
static PyInt
BufferLength(PyObject *self)
{
/* HOW DO WE SIGNAL AN ERROR FROM THIS FUNCTION? */
@@ -1527,29 +1555,29 @@ BufferLength(PyObject *self)
}
static PyObject *
BufferItem(PyObject *self, int n)
BufferItem(PyObject *self, PyInt n)
{
return RBItem((BufferObject *)(self), n, 1,
(int)((BufferObject *)(self))->buf->b_ml.ml_line_count);
}
static PyObject *
BufferSlice(PyObject *self, int lo, int hi)
BufferSlice(PyObject *self, PyInt lo, PyInt hi)
{
return RBSlice((BufferObject *)(self), lo, hi, 1,
(int)((BufferObject *)(self))->buf->b_ml.ml_line_count);
}
static int
BufferAssItem(PyObject *self, int n, PyObject *val)
static PyInt
BufferAssItem(PyObject *self, PyInt n, PyObject *val)
{
return RBAssItem((BufferObject *)(self), n, val, 1,
(int)((BufferObject *)(self))->buf->b_ml.ml_line_count,
NULL);
}
static int
BufferAssSlice(PyObject *self, int lo, int hi, PyObject *val)
static PyInt
BufferAssSlice(PyObject *self, PyInt lo, PyInt hi, PyObject *val)
{
return RBAssSlice((BufferObject *)(self), lo, hi, val, 1,
(int)((BufferObject *)(self))->buf->b_ml.ml_line_count,
@@ -1627,13 +1655,13 @@ static struct PyMethodDef RangeMethods[] = {
};
static PySequenceMethods RangeAsSeq = {
(inquiry) RangeLength, /* sq_length, len(x) */
(PyInquiry) RangeLength, /* sq_length, len(x) */
(binaryfunc) 0, /* RangeConcat, */ /* sq_concat, x+y */
(intargfunc) 0, /* RangeRepeat, */ /* sq_repeat, x*n */
(intargfunc) RangeItem, /* sq_item, x[i] */
(intintargfunc) RangeSlice, /* sq_slice, x[i:j] */
(intobjargproc) RangeAssItem, /* sq_ass_item, x[i]=v */
(intintobjargproc) RangeAssSlice, /* sq_ass_slice, x[i:j]=v */
(PyIntArgFunc) 0, /* RangeRepeat, */ /* sq_repeat, x*n */
(PyIntArgFunc) RangeItem, /* sq_item, x[i] */
(PyIntIntArgFunc) RangeSlice, /* sq_slice, x[i:j] */
(PyIntObjArgProc) RangeAssItem, /* sq_ass_item, x[i]=v */
(PyIntIntObjArgProc) RangeAssSlice, /* sq_ass_slice, x[i:j]=v */
};
static PyTypeObject RangeType = {
@@ -1738,7 +1766,7 @@ RangeRepr(PyObject *self)
/****************/
static int
static PyInt
RangeLength(PyObject *self)
{
/* HOW DO WE SIGNAL AN ERROR FROM THIS FUNCTION? */
@@ -1749,7 +1777,7 @@ RangeLength(PyObject *self)
}
static PyObject *
RangeItem(PyObject *self, int n)
RangeItem(PyObject *self, PyInt n)
{
return RBItem(((RangeObject *)(self))->buf, n,
((RangeObject *)(self))->start,
@@ -1757,15 +1785,15 @@ RangeItem(PyObject *self, int n)
}
static PyObject *
RangeSlice(PyObject *self, int lo, int hi)
RangeSlice(PyObject *self, PyInt lo, PyInt hi)
{
return RBSlice(((RangeObject *)(self))->buf, lo, hi,
((RangeObject *)(self))->start,
((RangeObject *)(self))->end);
}
static int
RangeAssItem(PyObject *self, int n, PyObject *val)
static PyInt
RangeAssItem(PyObject *self, PyInt n, PyObject *val)
{
return RBAssItem(((RangeObject *)(self))->buf, n, val,
((RangeObject *)(self))->start,
@@ -1773,8 +1801,8 @@ RangeAssItem(PyObject *self, int n, PyObject *val)
&((RangeObject *)(self))->end);
}
static int
RangeAssSlice(PyObject *self, int lo, int hi, PyObject *val)
static PyInt
RangeAssSlice(PyObject *self, PyInt lo, PyInt hi, PyObject *val)
{
return RBAssSlice(((RangeObject *)(self))->buf, lo, hi, val,
((RangeObject *)(self))->start,
@@ -1801,13 +1829,13 @@ typedef struct
BufListObject;
static PySequenceMethods BufListAsSeq = {
(inquiry) BufListLength, /* sq_length, len(x) */
(PyInquiry) BufListLength, /* sq_length, len(x) */
(binaryfunc) 0, /* sq_concat, x+y */
(intargfunc) 0, /* sq_repeat, x*n */
(intargfunc) BufListItem, /* sq_item, x[i] */
(intintargfunc) 0, /* sq_slice, x[i:j] */
(intobjargproc) 0, /* sq_ass_item, x[i]=v */
(intintobjargproc) 0, /* sq_ass_slice, x[i:j]=v */
(PyIntArgFunc) 0, /* sq_repeat, x*n */
(PyIntArgFunc) BufListItem, /* sq_item, x[i] */
(PyIntIntArgFunc) 0, /* sq_slice, x[i:j] */
(PyIntObjArgProc) 0, /* sq_ass_item, x[i]=v */
(PyIntIntObjArgProc) 0, /* sq_ass_slice, x[i:j]=v */
};
static PyTypeObject BufListType = {
@@ -1837,7 +1865,7 @@ static PyTypeObject BufListType = {
*/
/*ARGSUSED*/
static int
static PyInt
BufListLength(PyObject *self)
{
buf_T *b = firstbuf;
@@ -1854,7 +1882,7 @@ BufListLength(PyObject *self)
/*ARGSUSED*/
static PyObject *
BufListItem(PyObject *self, int n)
BufListItem(PyObject *self, PyInt n)
{
buf_T *b;
@@ -2119,13 +2147,13 @@ typedef struct
WinListObject;
static PySequenceMethods WinListAsSeq = {
(inquiry) WinListLength, /* sq_length, len(x) */
(PyInquiry) WinListLength, /* sq_length, len(x) */
(binaryfunc) 0, /* sq_concat, x+y */
(intargfunc) 0, /* sq_repeat, x*n */
(intargfunc) WinListItem, /* sq_item, x[i] */
(intintargfunc) 0, /* sq_slice, x[i:j] */
(intobjargproc) 0, /* sq_ass_item, x[i]=v */
(intintobjargproc) 0, /* sq_ass_slice, x[i:j]=v */
(PyIntArgFunc) 0, /* sq_repeat, x*n */
(PyIntArgFunc) WinListItem, /* sq_item, x[i] */
(PyIntIntArgFunc) 0, /* sq_slice, x[i:j] */
(PyIntObjArgProc) 0, /* sq_ass_item, x[i]=v */
(PyIntIntObjArgProc) 0, /* sq_ass_slice, x[i:j]=v */
};
static PyTypeObject WinListType = {
@@ -2154,7 +2182,7 @@ static PyTypeObject WinListType = {
/* Window list object - Implementation
*/
/*ARGSUSED*/
static int
static PyInt
WinListLength(PyObject *self)
{
win_T *w = firstwin;
@@ -2171,7 +2199,7 @@ WinListLength(PyObject *self)
/*ARGSUSED*/
static PyObject *
WinListItem(PyObject *self, int n)
WinListItem(PyObject *self, PyInt n)
{
win_T *w;
@@ -2351,10 +2379,10 @@ GetBufferLine(buf_T *buf, int n)
* including, hi. The list is returned as a Python list of string objects.
*/
static PyObject *
GetBufferLineList(buf_T *buf, int lo, int hi)
GetBufferLineList(buf_T *buf, PyInt lo, PyInt hi)
{
int i;
int n = hi - lo;
PyInt i;
PyInt n = hi - lo;
PyObject *list = PyList_New(n);
if (list == NULL)
@@ -2517,7 +2545,7 @@ SetBufferLine(buf_T *buf, int n, PyObject *line, int *len_change)
* is set to the change in the buffer length.
*/
static int
SetBufferLineList(buf_T *buf, int lo, int hi, PyObject *list, int *len_change)
SetBufferLineList(buf_T *buf, PyInt lo, PyInt hi, PyObject *list, int *len_change)
{
/* First of all, we check the thpe of the supplied Python object.
* There are three cases:
@@ -2527,8 +2555,8 @@ SetBufferLineList(buf_T *buf, int lo, int hi, PyObject *list, int *len_change)
*/
if (list == Py_None || list == NULL)
{
int i;
int n = hi - lo;
PyInt i;
PyInt n = hi - lo;
buf_T *savebuf = curbuf;
PyErr_Clear();
@@ -2564,9 +2592,9 @@ SetBufferLineList(buf_T *buf, int lo, int hi, PyObject *list, int *len_change)
}
else if (PyList_Check(list))
{
int i;
int new_len = PyList_Size(list);
int old_len = hi - lo;
PyInt i;
PyInt new_len = PyList_Size(list);
PyInt old_len = hi - lo;
int extra = 0; /* lines added to text, can be negative */
char **array;
buf_T *savebuf;
@@ -2745,8 +2773,8 @@ InsertBufferLines(buf_T *buf, int n, PyObject *lines, int *len_change)
}
else if (PyList_Check(lines))
{
int i;
int size = PyList_Size(lines);
PyInt i;
PyInt size = PyList_Size(lines);
char **array;
buf_T *savebuf;
@@ -2831,7 +2859,7 @@ InsertBufferLines(buf_T *buf, int n, PyObject *lines, int *len_change)
LineToString(const char *str)
{
PyObject *result;
int len = strlen(str);
PyInt len = strlen(str);
char *p;
/* Allocate an Python string object, with uninitialised contents. We
@@ -2871,8 +2899,8 @@ StringToLine(PyObject *obj)
{
const char *str;
char *save;
int len;
int i;
PyInt len;
PyInt i;
char *p;
if (obj == NULL || !PyString_Check(obj))
+4 -4
View File
@@ -1605,15 +1605,15 @@ early_arg_scan(parmp)
else if (STRICMP(argv[i], "--socketid") == 0)
# endif
{
unsigned int id;
int count;
long_u id;
int count;
if (i == argc - 1)
mainerr_arg_missing((char_u *)argv[i]);
if (STRNICMP(argv[i+1], "0x", 2) == 0)
count = sscanf(&(argv[i + 1][2]), "%x", &id);
count = sscanf(&(argv[i + 1][2]), SCANF_HEX_LONG_U, &id);
else
count = sscanf(argv[i+1], "%u", &id);
count = sscanf(argv[i + 1], SCANF_DECIMAL_LONG_U, &id);
if (count != 1)
mainerr(ME_INVALID_ARG, (char_u *)argv[i]);
else
+1 -1
View File
@@ -522,7 +522,7 @@ fname2fnum(fm)
int len;
expand_env((char_u *)"~/", NameBuff, MAXPATHL);
len = STRLEN(NameBuff);
len = (int)STRLEN(NameBuff);
vim_strncpy(NameBuff + len, fm->fname + 2, MAXPATHL - len - 1);
}
else
+9 -6
View File
@@ -1973,8 +1973,10 @@ utf_class(c)
{0x205f, 0x205f, 0},
{0x2060, 0x27ff, 1}, /* punctuation and symbols */
{0x2070, 0x207f, 0x2070}, /* superscript */
{0x2080, 0x208f, 0x2080}, /* subscript */
{0x2983, 0x2998, 1},
{0x2080, 0x2094, 0x2080}, /* subscript */
{0x20a0, 0x27ff, 1}, /* all kinds of symbols */
{0x2800, 0x28ff, 0x2800}, /* braille */
{0x2900, 0x2998, 1}, /* arrows, brackets, etc. */
{0x29d8, 0x29db, 1},
{0x29fc, 0x29fd, 1},
{0x3000, 0x3000, 0}, /* ideographic space */
@@ -5518,13 +5520,13 @@ preedit_callback_setup(GdkIC *ic)
preedit_caret_cb.callback = (XIMProc)preedit_caret_cbproc;
preedit_done_cb.callback = (XIMProc)preedit_done_cbproc;
preedit_attr
= XVaCreateNestedList (0,
= XVaCreateNestedList(0,
XNPreeditStartCallback, &preedit_start_cb,
XNPreeditDrawCallback, &preedit_draw_cb,
XNPreeditCaretCallback, &preedit_caret_cb,
XNPreeditDoneCallback, &preedit_done_cb,
0);
XSetICValues (xxic, XNPreeditAttributes, preedit_attr, 0);
NULL);
XSetICValues(xxic, XNPreeditAttributes, preedit_attr, NULL);
XFree(preedit_attr);
}
@@ -5534,7 +5536,8 @@ reset_state_setup(GdkIC *ic)
{
#ifdef USE_X11R6_XIM
/* don't change the input context when we call reset */
XSetICValues(((GdkICPrivate*)ic)->xic, XNResetState, XIMPreserveState, 0);
XSetICValues(((GdkICPrivate *)ic)->xic, XNResetState, XIMPreserveState,
NULL);
#endif
}
+5
View File
@@ -1346,5 +1346,10 @@ mf_do_open(mfp, fname, flags)
mfp->mf_ffname = NULL;
}
else
{
#ifdef HAVE_SELINUX
mch_copy_sec(fname, mfp->mf_fname);
#endif
mch_hide(mfp->mf_fname); /* try setting the 'hidden' flag */
}
}
+354 -101
View File
@@ -1038,6 +1038,9 @@ free_menu(menup)
# ifdef FEAT_GUI_MOTIF
vim_free(menu->xpm_fname);
# endif
#ifdef FEAT_GUI_MACVIM
vim_free(menu->mac_action);
#endif
#endif
for (i = 0; i < MENU_MODES; i++)
free_menu_string(menu, i);
@@ -2137,6 +2140,9 @@ ex_emenu(eap)
char_u *p;
int idx;
char_u *mode;
#ifdef FEAT_GUI_MACVIM
char_u *old_arg;
#endif
saved_name = vim_strsave(eap->arg);
if (saved_name == NULL)
@@ -2243,8 +2249,10 @@ ex_emenu(eap)
idx = MENU_INDEX_NORMAL;
}
if (idx != MENU_INDEX_INVALID && menu->strings[idx] != NULL)
if (idx != MENU_INDEX_INVALID && menu->strings[idx] != NULL &&
menu->strings[idx][0] != NUL)
{
/* When executing a script or function execute the commands right now.
* Otherwise put them in the typeahead buffer. */
#ifdef FEAT_EVAL
@@ -2256,6 +2264,19 @@ ex_emenu(eap)
ins_typebuf(menu->strings[idx], menu->noremap[idx], 0,
TRUE, menu->silent[idx]);
}
#ifdef FEAT_GUI_MACVIM
else if (menu->mac_action != NULL && menu->strings[idx][0] == NUL)
{
/* This allows us to bind a menu to an action without mapping to
* anything so that pressing the menu's key equivalent and typing
* ":emenu ..." does the same thing. (HACK: We count on the fact that
* ex_macaction() only looks at eap->arg.) */
old_arg = eap->arg;
eap->arg = menu->mac_action;
ex_macaction(eap);
eap->arg = old_arg;
}
#endif /* FEAT_GUI_MACVIM */
else
EMSG2(_("E335: Menu not defined for %s mode"), mode);
}
@@ -2473,32 +2494,145 @@ menutrans_lookup(name, len)
#ifdef FEAT_GUI_MACVIM
vimmenu_T *
menu_for_path(char_u *menu_path)
{
vimmenu_T *menu;
char_u *name;
char_u *saved_name;
char_u *p;
saved_name = vim_strsave(menu_path);
if (saved_name == NULL)
return NULL;
menu = root_menu;
name = saved_name;
while (*name)
{
/* Find in the menu hierarchy */
p = menu_name_skip(name);
while (menu != NULL)
{
if (menu_name_equal(name, menu))
{
if (*p == NUL && menu->children != NULL)
{
EMSG(_("E333: Menu path must lead to a menu item"));
menu = NULL;
}
else if (*p != NUL && menu->children == NULL)
{
EMSG(_(e_notsubmenu));
menu = NULL;
}
break;
}
menu = menu->next;
}
if (menu == NULL || *p == NUL)
break;
menu = menu->children;
name = p;
}
vim_free(saved_name);
if (menu == NULL)
{
EMSG2(_("E334: Menu not found: %s"), menu_path);
return NULL;
}
return menu;
}
/*
* Handle the ":macmenu" command.
*/
void
ex_macmenukey(eap)
ex_macmenu(eap)
exarg_T *eap;
{
char_u *arg = eap->arg;
char_u *keys, *name, *p;
vimmenu_T *menu;
vimmenu_T *menu = NULL;
char_u *arg;
char_u *menu_path;
char_u *p;
char_u *keys;
int len;
#ifdef FEAT_MULTI_LANG
char_u *tofree = NULL;
char_u *new_cmd;
#endif
char_u *linep;
char_u *key_start;
char_u *key = NULL;
char_u *arg_start = NULL;
int error = FALSE;
char_u *action = NULL;
int mac_key = 0;
int mac_mods = 0;
int mac_alternate = 0;
char_u *last_dash;
int modifiers;
int bit;
int key;
int set_action = FALSE;
int set_key = FALSE;
int set_alt = FALSE;
arg = eap->arg;
#ifdef FEAT_MULTI_LANG
/*
* Translate menu names as specified with ":menutrans" commands.
*/
menu_path = arg;
while (*menu_path)
{
/* find the end of one part and check if it should be translated */
p = menu_skip_part(menu_path);
keys = menutrans_lookup(menu_path, (int)(p - menu_path));
if (keys != NULL)
{
/* found a match: replace with the translated part */
len = (int)STRLEN(keys);
new_cmd = alloc((unsigned)STRLEN(arg) + len + 1);
if (new_cmd == NULL)
break;
mch_memmove(new_cmd, arg, menu_path - arg);
mch_memmove(new_cmd + (menu_path - arg), keys, (size_t)len);
STRCPY(new_cmd + (menu_path - arg) + len, p);
p = new_cmd + (menu_path - arg) + len;
vim_free(tofree);
tofree = new_cmd;
arg = new_cmd;
}
if (*p != '.')
break;
menu_path = p + 1;
}
#endif
/*
* Isolate the menu name.
* Skip the menu name, and translate <Tab> into a real TAB.
*/
name = arg;
if (*name == '.')
menu_path = arg;
if (*menu_path == '.')
{
EMSG2(_(e_invarg2), name);
return;
EMSG2(_(e_invarg2), menu_path);
goto theend;
}
while (*arg && !vim_iswhite(*arg))
{
if ((*arg == '\\' || *arg == Ctrl_V) && arg[1] != NUL)
arg++;
else if (STRNICMP(arg, "<TAB>", 5) == 0)
{
*arg = TAB;
mch_memmove(arg + 1, arg + 5, STRLEN(arg + 4));
}
arg++;
}
if (*arg != NUL)
@@ -2506,108 +2640,227 @@ ex_macmenukey(eap)
arg = skipwhite(arg);
keys = arg;
// TODO: move to gui_find_menu_item(path_name)
menu = root_menu;
while (*name)
{
/* find the end of one dot-separated name and put a NUL at the dot */
p = menu_name_skip(name);
menu = menu_for_path(menu_path);
if (!menu) goto theend;
while (menu != NULL)
/*
* Parse all key=value arguments.
*/
arg = NULL;
linep = keys;
while (!ends_excmd(*linep))
{
key_start = linep;
if (*linep == '=')
{
if (STRCMP(name, menu->name) == 0 || STRCMP(name, menu->dname) == 0)
{
if (*p == NUL)
{
if (menu->children != NULL)
menu = NULL;
goto search_end;
}
break;
}
menu = menu->next;
}
if (menu == NULL) /* didn't find it */
EMSG2(_("E415: unexpected equal sign: %s"), key_start);
error = TRUE;
break;
}
/* Found a match, search the sub-menu. */
menu = menu->children;
name = p;
/*
* Isolate the key ("action", "alt", or "key").
*/
while (*linep && !vim_iswhite(*linep) && *linep != '=')
++linep;
vim_free(key);
key = vim_strnsave_up(key_start, (int)(linep - key_start));
if (key == NULL)
{
error = TRUE;
break;
}
linep = skipwhite(linep);
/*
* Check for the equal sign.
*/
if (*linep != '=')
{
EMSG2(_("E416: missing equal sign: %s"), key_start);
error = TRUE;
break;
}
++linep;
/*
* Isolate the argument.
*/
linep = skipwhite(linep);
arg_start = linep;
linep = skiptowhite(linep);
if (linep == arg_start)
{
EMSG2(_("E417: missing argument: %s"), key_start);
error = TRUE;
break;
}
vim_free(arg);
arg = vim_strnsave(arg_start, (int)(linep - arg_start));
if (arg == NULL)
{
error = TRUE;
break;
}
/*
* Store the argument.
*/
if (STRCMP(key, "ACTION") == 0)
{
action = vim_strsave(arg);
if (action == NULL)
{
error = TRUE;
break;
}
if (!is_valid_macaction(action))
{
EMSG2(_("E???: Invalid action: %s"), arg);
error = TRUE;
break;
}
set_action = TRUE;
}
else if (STRCMP(key, "ALT") == 0)
{
len = (int)STRLEN(arg);
if ( (len == 1 && (*arg == '0' || *arg == '1')) ||
(STRICMP("no", arg) == 0 || STRICMP("yes", arg) == 0) )
{
mac_alternate = (*arg == '1' || STRICMP("yes", arg) == 0);
set_alt = TRUE;
}
else
{
EMSG2(_(e_invarg2), arg);
error = TRUE;
break;
}
}
else if (STRCMP(key, "KEY") == 0)
{
if (arg[0] != '<')
{
EMSG2(_(e_invarg2), arg);
error = TRUE;
break;
}
if (STRICMP("<nop>", arg) == 0)
{
/* This is to let the user unset a key equivalent, thereby
* freeing up that key combination to be used for a :map
* command (which would otherwise not be possible since key
* equivalents take precedence over :map). */
mac_key = 0;
mac_mods = 0;
set_key = TRUE;
continue;
}
/* Find end of modifier list */
last_dash = arg;
for (p = arg + 1; *p == '-' || vim_isIDc(*p); p++)
{
if (*p == '-')
{
last_dash = p;
if (p[1] != NUL && p[2] == '>')
++p; /* anything accepted, like <C-?> */
}
if (p[0] == 't' && p[1] == '_' && p[2] && p[3])
p += 3; /* skip t_xx, xx may be '-' or '>' */
}
if (*p == '>') /* found matching '>' */
{
/* Which modifiers are given? */
mac_mods = 0x0;
for (p = arg + 1; p < last_dash; p++)
{
if (*p != '-')
{
bit = name_to_mod_mask(*p);
if (bit == 0x0)
break; /* Illegal modifier name */
mac_mods |= bit;
}
}
/*
* Legal modifier name.
*/
if (p >= last_dash)
{
/*
* Modifier with single letter, or special key name.
*/
if (mac_mods != 0 && last_dash[2] == '>')
mac_key = last_dash[1];
else
{
mac_key = get_special_key_code(last_dash + 1);
mac_key = handle_x_keys(mac_key);
}
}
}
set_key = (mac_key != 0);
if (mac_key == 0)
{
EMSG2(_(e_invarg2), arg);
error = TRUE;
break;
}
}
else
{
EMSG2(_(e_invarg2), key_start);
error = TRUE;
break;
}
/*
* Continue with next argument.
*/
linep = skipwhite(linep);
}
search_end:
if (!menu) {
EMSG(_("E337: Menu not found - check menu names"));
return;
}
vim_free(key);
vim_free(arg);
if (keys[0] == '<')
/*
* Store all the keys that were set in the menu item.
*/
if (!error)
{
key = 0;
/* Find end of modifier list */
last_dash = keys;
for (p = keys + 1; *p == '-' || vim_isIDc(*p); p++)
{
if (*p == '-')
{
last_dash = p;
if (p[1] != NUL && p[2] == '>')
++p; /* anything accepted, like <C-?> */
}
if (p[0] == 't' && p[1] == '_' && p[2] && p[3])
p += 3; /* skip t_xx, xx may be '-' or '>' */
}
if (*p == '>') /* found matching '>' */
{
/* Which modifiers are given? */
modifiers = 0x0;
for (p = keys + 1; p < last_dash; p++)
{
if (*p != '-')
{
bit = name_to_mod_mask(*p);
if (bit == 0x0)
break; /* Illegal modifier name */
modifiers |= bit;
}
}
/*
* Legal modifier name.
*/
if (p >= last_dash)
{
/*
* Modifier with single letter, or special key name.
*/
if (modifiers != 0 && last_dash[2] == '>')
key = last_dash[1];
else
{
key = get_special_key_code(last_dash + 1);
key = handle_x_keys(key);
}
}
}
if (key != 0)
{
menu->mac_key = key;
menu->mac_mods = modifiers;
}
}
else if (keys[0] == NUL)
{
/* Clear the key equivalent */
menu->mac_key = 0;
menu->mac_mods = 0;
if (set_action)
menu->mac_action = action;
if (set_key)
{
menu->mac_key = mac_key;
menu->mac_mods = mac_mods;
}
if (set_alt)
menu->mac_alternate = mac_alternate;
}
else
{
EMSG(_(e_invarg));
vim_free(action);
}
theend:
#ifdef FEAT_MULTI_LANG
vim_free(tofree);
#else
;
#endif
}
#endif /* FEAT_GUI_MACVIM */
+6 -2
View File
@@ -751,7 +751,7 @@ vim_mem_profile_dump()
#endif
/*
* Note: if unsinged is 16 bits we can only allocate up to 64K with alloc().
* Note: if unsigned is 16 bits we can only allocate up to 64K with alloc().
* Use lalloc for larger blocks.
*/
char_u *
@@ -1082,7 +1082,11 @@ free_all_mem()
win_free_all();
#endif
/* Free all buffers. */
/* Free all buffers. Reset 'autochdir' to avoid accessing things that
* were freed already. */
#ifdef FEAT_AUTOCHDIR
p_acd = FALSE;
#endif
for (buf = firstbuf; buf != NULL; )
{
nextbuf = buf->b_next;
+3 -3
View File
@@ -1216,7 +1216,7 @@ nb_partialremove(linenr_T lnum, colnr_T first, colnr_T last)
int lastbyte = last;
oldtext = ml_get(lnum);
oldlen = STRLEN(oldtext);
oldlen = (int)STRLEN(oldtext);
if (first >= (colnr_T)oldlen || oldlen == 0) /* just in case */
return;
if (lastbyte >= oldlen)
@@ -1241,8 +1241,8 @@ nb_joinlines(linenr_T first, linenr_T other)
int len_first, len_other;
char_u *p;
len_first = STRLEN(ml_get(first));
len_other = STRLEN(ml_get(other));
len_first = (int)STRLEN(ml_get(first));
len_other = (int)STRLEN(ml_get(other));
p = alloc((unsigned)(len_first + len_other + 1));
if (p != NULL)
{
+4 -2
View File
@@ -8364,6 +8364,7 @@ nv_wordcmd(cap)
int n;
int word_end;
int flag = FALSE;
pos_T startpos = curwin->w_cursor;
/*
* Set inclusive for the "E" and "e" command.
@@ -8424,8 +8425,9 @@ nv_wordcmd(cap)
else
n = fwd_word(cap->count1, cap->arg, cap->oap->op_type != OP_NOP);
/* Don't leave the cursor on the NUL past the end of line. */
if (n != FAIL)
/* Don't leave the cursor on the NUL past the end of line. Unless we
* didn't move it forward. */
if (lt(startpos, curwin->w_cursor))
adjust_cursor(cap->oap);
if (n == FAIL && cap->oap->op_type == OP_NOP)
+4 -3
View File
@@ -4380,7 +4380,7 @@ op_format(oap, keep_cursor)
if (keep_cursor)
saved_cursor = oap->cursor_start;
format_lines(oap->line_count);
format_lines(oap->line_count, keep_cursor);
/*
* Leave the cursor at the first non-blank of the last formatted line.
@@ -4495,8 +4495,9 @@ fex_format(lnum, count, c)
* first line.
*/
void
format_lines(line_count)
format_lines(line_count, avoid_fex)
linenr_T line_count;
int avoid_fex; /* don't use 'formatexpr' */
{
int max_len;
int is_not_par; /* current line not part of parag. */
@@ -4666,7 +4667,7 @@ format_lines(line_count)
#ifdef FEAT_COMMENTS
+ (do_comments ? INSCHAR_DO_COM : 0)
#endif
, second_indent);
+ (avoid_fex ? INSCHAR_NO_FEX : 0), second_indent);
State = old_State;
p_smd = smd_save;
second_indent = -1;
+146 -6
View File
@@ -478,14 +478,16 @@ static struct vimoption
#endif
(char_u *)0L}},
{"antialias", "anti", P_BOOL|P_VI_DEF|P_VIM|P_RCLR,
#if defined(FEAT_GUI) && defined(MACOS_X)
#ifdef FEAT_ANTIALIAS
(char_u *)&p_antialias, PV_NONE,
{(char_u *)FALSE, (char_u *)FALSE}
#else
(char_u *)NULL, PV_NONE,
{(char_u *)FALSE, (char_u *)FALSE}
#endif
},
#if FEAT_GUI_MACVIM
{(char_u *)TRUE, (char_u *)0L}},
#else
{(char_u *)FALSE, (char_u *)0L}},
#endif
{"arabic", "arab", P_BOOL|P_VI_DEF|P_VIM,
#ifdef FEAT_ARABIC
(char_u *)VAR_WIN, PV_ARAB,
@@ -1159,6 +1161,14 @@ static struct vimoption
(char_u *)NULL, PV_NONE,
#endif
{(char_u *)FALSE, (char_u *)0L}},
{"fuoptions", "fuopt", P_STRING|P_COMMA|P_NODUP|P_VI_DEF,
#ifdef FEAT_FULLSCREEN
(char_u *)&p_fuoptions, PV_NONE,
{(char_u *)"maxvert", (char_u *)0L}},
#else
(char_u *)NULL, PV_NONE,
{(char_u *)NULL, (char_u *)0L}},
#endif
{"gdefault", "gd", P_BOOL|P_VI_DEF|P_VIM,
(char_u *)&p_gd, PV_NONE,
{(char_u *)FALSE, (char_u *)0L}},
@@ -1846,7 +1856,8 @@ static struct vimoption
},
{"paragraphs", "para", P_STRING|P_VI_DEF,
(char_u *)&p_para, PV_NONE,
{(char_u *)"IPLPPPQPP LIpplpipbp", (char_u *)0L}},
{(char_u *)"IPLPPPQPP TPHPLIPpLpItpplpipbp",
(char_u *)0L}},
{"paste", NULL, P_BOOL|P_VI_DEF|P_PRI_MKRC,
(char_u *)&p_paste, PV_NONE,
{(char_u *)FALSE, (char_u *)0L}},
@@ -2946,6 +2957,9 @@ static void fill_breakat_flags __ARGS((void));
static int opt_strings_flags __ARGS((char_u *val, char **values, unsigned *flagp, int list));
static int check_opt_strings __ARGS((char_u *val, char **values, int));
static int check_opt_wim __ARGS((void));
#ifdef FEAT_FULLSCREEN
static int check_fuoptions __ARGS((char_u *, unsigned *, int *));
#endif
/*
* Initialize the options, first part.
@@ -5067,6 +5081,10 @@ didset_options()
#endif
#ifdef FEAT_FOLDING
(void)opt_strings_flags(p_fdo, p_fdo_values, &fdo_flags, TRUE);
#endif
#ifdef FEAT_FULLSCREEN
(void)check_fuoptions(p_fuoptions, &fuoptions_flags,
&fuoptions_bgcolor);
#endif
(void)opt_strings_flags(p_dy, p_dy_values, &dy_flags, TRUE);
#ifdef FEAT_VIRTUALEDIT
@@ -6590,6 +6608,16 @@ did_set_string_option(opt_idx, varp, new_value_alloced, oldval, errbuf,
}
#endif
#ifdef FEAT_FULLSCREEN
/* 'fuoptions' */
else if (varp == &p_fuoptions)
{
if (check_fuoptions(p_fuoptions, &fuoptions_flags,
&fuoptions_bgcolor) != OK)
errmsg = e_invarg;
}
#endif
#ifdef FEAT_VIRTUALEDIT
/* 'virtualedit' */
else if (varp == &p_ve)
@@ -7302,9 +7330,32 @@ set_bool_option(opt_idx, varp, value, opt_flags)
else if ((int *)varp == &p_fullscreen && gui.in_use)
{
if (p_fullscreen && !old_value)
gui_mch_enter_fullscreen();
{
guicolor_T fg, bg;
if (fuoptions_flags & FUOPT_BGCOLOR_HLGROUP)
{
/* Find out background color from colorscheme
* via highlight group id */
syn_id2colors(fuoptions_bgcolor, &fg, &bg);
}
else
{
/* set explicit background color */
bg = fuoptions_bgcolor;
}
gui_mch_enter_fullscreen(fuoptions_flags, bg);
}
else if (!p_fullscreen && old_value)
{
gui_mch_leave_fullscreen();
}
}
#endif
#if defined(FEAT_ANTIALIAS) && defined(FEAT_GUI_MACVIM)
else if ((int *)varp == &p_antialias)
{
gui_macvim_set_antialias(p_antialias);
}
#endif
@@ -10751,3 +10802,92 @@ check_ff_value(p)
{
return check_opt_strings(p, p_ff_values, FALSE);
}
#ifdef FEAT_FULLSCREEN
/*
* Read the 'fuoptions' option, set fuoptions_flags and
* fuoptions_bgcolor.
*/
static int
check_fuoptions(p_fuoptions, flags, bgcolor)
char_u *p_fuoptions; /* fuoptions string */
unsigned *flags; /* fuoptions flags */
int *bgcolor; /* background highlight group id */
{
unsigned new_fuoptions_flags;
int new_fuoptions_bgcolor;
char_u *p;
char_u hg_term; /* character terminating
highlight group string in
'background' option' */
int i,j,k;
new_fuoptions_flags = 0;
new_fuoptions_bgcolor = 0xFF000000;
for (p = p_fuoptions; *p; ++p)
{
for (i = 0; ASCII_ISALPHA(p[i]); ++i)
;
if (p[i] != NUL && p[i] != ',' && p[i] != ':')
return FAIL;
if (i == 10 && STRNCMP(p, "background", 10) == 0)
{
if (p[i] != ':') return FAIL;
i++;
if (p[i] == NUL) return FAIL;
if (p[i] == '#')
{
/* explicit color (#aarrggbb) */
i++;
for (j = i; j < i+8 && vim_isxdigit(p[j]); ++j)
;
if (j < i+8)
return FAIL; /* less than 8 digits */
if (p[j] != NUL && p[j] != ',')
return FAIL;
new_fuoptions_bgcolor = 0;
for (k = 0; k < 8; k++)
new_fuoptions_bgcolor = new_fuoptions_bgcolor * 16 +
hex2nr(p[i+k]);
i = j;
/* mark bgcolor as an explicit argb color */
new_fuoptions_flags &= ~FUOPT_BGCOLOR_HLGROUP;
}
else
{
/* highlight group name */
for (j = i; ASCII_ISALPHA(p[j]); ++j)
;
if (p[j] != NUL && p[j] != ',')
return FAIL;
hg_term = p[j];
p[j] = NUL; /* temporarily terminate string */
new_fuoptions_bgcolor = syn_name2id((char_u*)(p+i));
p[j] = hg_term; /* restore string */
if (! new_fuoptions_bgcolor)
return FAIL;
i = j;
/* mark bgcolor as highlight group id */
new_fuoptions_flags |= FUOPT_BGCOLOR_HLGROUP;
}
}
else if (i == 7 && STRNCMP(p, "maxhorz", 7) == 0)
new_fuoptions_flags |= FUOPT_MAXHORZ;
else if (i == 7 && STRNCMP(p, "maxvert", 7) == 0)
new_fuoptions_flags |= FUOPT_MAXVERT;
else
return FAIL;
p += i;
if (*p == NUL)
break;
if (*p == ':')
return FAIL;
}
*flags = new_fuoptions_flags;
*bgcolor = new_fuoptions_bgcolor;
return OK;
}
#endif
+11 -2
View File
@@ -309,8 +309,8 @@ EXTERN int p_acd; /* 'autochdir' */
#ifdef FEAT_MBYTE
EXTERN char_u *p_ambw; /* 'ambiwidth' */
#endif
#if defined(FEAT_GUI) && defined(MACOS_X)
EXTERN int *p_antialias; /* 'antialias' */
#ifdef FEAT_ANTIALIAS
EXTERN int p_antialias; /* 'antialias' */
#endif
EXTERN int p_ar; /* 'autoread' */
EXTERN int p_aw; /* 'autowrite' */
@@ -470,6 +470,15 @@ EXTERN int p_fs; /* 'fsync' */
#endif
#ifdef FEAT_FULLSCREEN
EXTERN int p_fullscreen;
EXTERN char_u *p_fuoptions;
EXTERN unsigned fuoptions_flags;
EXTERN int fuoptions_bgcolor;
#define FUOPT_MAXVERT 0x001
#define FUOPT_MAXHORZ 0x002
#define FUOPT_BGCOLOR_HLGROUP 0x004 /* if set, fuoptions_bgcolor
is a highlight group
id. Else, it's an explicit
argb color. */
#endif
EXTERN int p_gd; /* 'gdefault' */
#ifdef FEAT_PRINTER
+64 -2
View File
@@ -45,6 +45,11 @@
# include <X11/SM/SMlib.h>
#endif
#ifdef HAVE_SELINUX
# include <selinux/selinux.h>
static int selinux_enabled = -1;
#endif
/*
* Use this prototype for select, some include files have a wrong prototype
*/
@@ -269,8 +274,9 @@ static struct signalinfo
#ifdef SIGVTALRM
{SIGVTALRM, "VTALRM", TRUE},
#endif
#if defined(SIGPROF) && !defined(FEAT_MZSCHEME)
/* MzScheme uses SIGPROF for its own needs */
#if defined(SIGPROF) && !defined(FEAT_MZSCHEME) && !defined(WE_ARE_PROFILING)
/* MzScheme uses SIGPROF for its own needs; On Linux with profiling
* this makes Vim exit. WE_ARE_PROFILING is defined in Makefile. */
{SIGPROF, "PROF", TRUE},
#endif
#ifdef SIGXCPU
@@ -2558,6 +2564,62 @@ typedef struct vim_acl_solaris_T {
} vim_acl_solaris_T;
# endif
#if defined(HAVE_SELINUX) || defined(PROTO)
/*
* Copy security info from "from_file" to "to_file".
*/
void
mch_copy_sec(from_file, to_file)
char_u *from_file;
char_u *to_file;
{
if (from_file == NULL)
return;
if (selinux_enabled == -1)
selinux_enabled = is_selinux_enabled();
if (selinux_enabled > 0)
{
security_context_t from_context = NULL;
security_context_t to_context = NULL;
if (getfilecon((char *)from_file, &from_context) < 0)
{
/* If the filesystem doesn't support extended attributes,
the original had no special security context and the
target cannot have one either. */
if (errno == EOPNOTSUPP)
return;
MSG_PUTS(_("\nCould not get security context for "));
msg_outtrans(from_file);
msg_putchar('\n');
return;
}
if (getfilecon((char *)to_file, &to_context) < 0)
{
MSG_PUTS(_("\nCould not get security context for "));
msg_outtrans(to_file);
msg_putchar('\n');
freecon (from_context);
return ;
}
if (strcmp(from_context, to_context) != 0)
{
if (setfilecon((char *)to_file, from_context) < 0)
{
MSG_PUTS(_("\nCould not set security context for "));
msg_outtrans(to_file);
msg_putchar('\n');
}
}
freecon(to_context);
freecon(from_context);
}
}
#endif /* HAVE_SELINUX */
/*
* Return a pointer to the ACL of file "fname" in allocated memory.
* Return NULL if the ACL is not available for whatever reason.
+25 -6
View File
@@ -2856,7 +2856,7 @@ handler_routine(
windgoto((int)Rows - 1, 0);
g_fForceExit = TRUE;
sprintf((char *)IObuff, _("Vim: Caught %s event\n"),
vim_snprintf((char *)IObuff, IOSIZE, _("Vim: Caught %s event\n"),
(dwCtrlType == CTRL_CLOSE_EVENT
? _("close")
: dwCtrlType == CTRL_LOGOFF_EVENT
@@ -3282,12 +3282,13 @@ mch_call_shell(
{
/* we use "command" or "cmd" to start the shell; slow but easy */
char_u *newcmd;
newcmd = lalloc((long_u) (
long_u cmdlen = (
#ifdef FEAT_GUI_W32
STRLEN(vimrun_path) +
#endif
STRLEN(p_sh) + STRLEN(p_shcf) + STRLEN(cmd) + 10), TRUE);
STRLEN(p_sh) + STRLEN(p_shcf) + STRLEN(cmd) + 10);
newcmd = lalloc(cmdlen, TRUE);
if (newcmd != NULL)
{
char_u *cmdbase = (*cmd == '"' ? cmd + 1 : cmd);
@@ -3373,14 +3374,15 @@ mch_call_shell(
if (!s_dont_use_vimrun)
/* Use vimrun to execute the command. It opens a console
* window, which can be closed without killing Vim. */
sprintf((char *)newcmd, "%s%s%s %s %s",
vim_snprintf((char *)newcmd, cmdlen, "%s%s%s %s %s",
vimrun_path,
(msg_silent != 0 || (options & SHELL_DOOUT))
? "-s " : "",
p_sh, p_shcf, cmd);
else
#endif
sprintf((char *)newcmd, "%s %s %s", p_sh, p_shcf, cmd);
vim_snprintf((char *)newcmd, cmdlen, "%s %s %s",
p_sh, p_shcf, cmd);
x = mch_system((char *)newcmd, options);
}
vim_free(newcmd);
@@ -4664,12 +4666,29 @@ mch_fopen(char *name, char *mode)
# endif
)
{
# if defined(DEBUG) && _MSC_VER > 1200
/* Work around an annoying assertion in the Microsoft debug CRT
* when mode's text/binary setting doesn't match _get_fmode(). */
char newMode = mode[strlen(mode) - 1];
int oldMode = 0;
_get_fmode(&oldMode);
if (newMode == 't')
_set_fmode(_O_TEXT);
else if (newMode == 'b')
_set_fmode(_O_BINARY);
# endif
wn = enc_to_ucs2(name, NULL);
wm = enc_to_ucs2(mode, NULL);
if (wn != NULL && wm != NULL)
f = _wfopen(wn, wm);
vim_free(wn);
vim_free(wm);
# if defined(DEBUG) && _MSC_VER > 1200
_set_fmode(oldMode);
# endif
if (f != NULL)
return f;
/* Retry with non-wide function (for Windows 98). Can't use
+1 -1
View File
@@ -337,7 +337,7 @@ pum_redraw()
if (rt != NULL)
{
len = STRLEN(rt);
len = (int)STRLEN(rt);
if (len > pum_width)
{
for (j = pum_width; j < len; ++j)
+1
View File
@@ -24,6 +24,7 @@ char_u *ExpandOne __ARGS((expand_T *xp, char_u *str, char_u *orig, int options,
void ExpandInit __ARGS((expand_T *xp));
void ExpandCleanup __ARGS((expand_T *xp));
void ExpandEscape __ARGS((expand_T *xp, char_u *str, int numfiles, char_u **files, int options));
char_u *vim_strsave_fnameescape __ARGS((char_u *fname, int shell));
void tilde_replace __ARGS((char_u *orig_pat, int num_files, char_u **files));
char_u *sm_gettail __ARGS((char_u *s));
char_u *addstar __ARGS((char_u *fname, int len, int context));
+4 -1
View File
@@ -190,13 +190,16 @@ int serverPeekReply(int port, char_u **str);
int serverReadReply(int port, char_u **str);
int serverSendReply(char_u *serverid, char_u *str);
void gui_mch_enter_fullscreen(void);
void gui_mch_enter_fullscreen(int fuoptions_flags, guicolor_T bg);
void gui_mch_leave_fullscreen(void);
void gui_macvim_update_modified_flag();
void gui_macvim_add_to_find_pboard(char_u *pat);
void gui_macvim_set_antialias(int antialias);
OSErr odb_buffer_close(buf_T *buf);
OSErr odb_post_buffer_write(buf_T *buf);
void odb_end(void);
char_u *get_macaction_name(expand_T *xp, int idx);
int is_valid_macaction(char_u *action);
+1
View File
@@ -20,6 +20,7 @@ void ex_emenu __ARGS((exarg_T *eap));
vimmenu_T *gui_find_menu __ARGS((char_u *path_name));
void ex_menutranslate __ARGS((exarg_T *eap));
#ifdef FEAT_GUI_MACVIM
void ex_macmenu __ARGS((exarg_T *eap));
void ex_macmenukey __ARGS((exarg_T *eap));
#endif
/* vim: set ft=c : */
+1 -1
View File
@@ -41,7 +41,7 @@ int do_join __ARGS((int insert_space));
void op_format __ARGS((oparg_T *oap, int keep_cursor));
void op_formatexpr __ARGS((oparg_T *oap));
int fex_format __ARGS((linenr_T lnum, long count, int c));
void format_lines __ARGS((linenr_T line_count));
void format_lines __ARGS((linenr_T line_count, int avoid_fex));
int paragraph_start __ARGS((linenr_T lnum));
int do_addsub __ARGS((int command, linenr_T Prenum1));
int read_viminfo_register __ARGS((vir_T *virp, int force));
+1
View File
@@ -34,6 +34,7 @@ int mch_isFullName __ARGS((char_u *fname));
void fname_case __ARGS((char_u *name, int len));
long mch_getperm __ARGS((char_u *name));
int mch_setperm __ARGS((char_u *name, long perm));
void mch_copy_sec __ARGS((char_u *from_file, char_u *to_file));
vim_acl_T mch_get_acl __ARGS((char_u *fname));
void mch_set_acl __ARGS((char_u *fname, vim_acl_T aclent));
void mch_free_acl __ARGS((vim_acl_T aclent));
+2
View File
@@ -106,7 +106,9 @@ struct efm_S
static int qf_init_ext __ARGS((qf_info_T *qi, char_u *efile, buf_T *buf, typval_T *tv, char_u *errorformat, int newlist, linenr_T lnumfirst, linenr_T lnumlast));
static void qf_new_list __ARGS((qf_info_T *qi));
static void ll_free_all __ARGS((qf_info_T **pqi));
static int qf_add_entry __ARGS((qf_info_T *qi, qfline_T **prevp, char_u *dir, char_u *fname, int bufnum, char_u *mesg, long lnum, int col, int vis_col, char_u *pattern, int nr, int type, int valid));
static qf_info_T *ll_new_list __ARGS((void));
static void qf_msg __ARGS((qf_info_T *qi));
static void qf_free __ARGS((qf_info_T *qi, int idx));
static char_u *qf_types __ARGS((int, int));
+90 -12
View File
@@ -3039,6 +3039,15 @@ typedef struct
} se_u;
} save_se_T;
/* used for BEHIND and NOBEHIND matching */
typedef struct regbehind_S
{
regsave_T save_after;
regsave_T save_behind;
save_se_T save_start[NSUBEXP];
save_se_T save_end[NSUBEXP];
} regbehind_T;
static char_u *reg_getline __ARGS((linenr_T lnum));
static long vim_regexec_both __ARGS((char_u *line, colnr_T col, proftime_T *tm));
static long regtry __ARGS((regprog_T *prog, colnr_T col));
@@ -3046,6 +3055,8 @@ static void cleanup_subexpr __ARGS((void));
#ifdef FEAT_SYN_HL
static void cleanup_zsubexpr __ARGS((void));
#endif
static void save_subexpr __ARGS((regbehind_T *bp));
static void restore_subexpr __ARGS((regbehind_T *bp));
static void reg_nextline __ARGS((void));
static void reg_save __ARGS((regsave_T *save, garray_T *gap));
static void reg_restore __ARGS((regsave_T *save, garray_T *gap));
@@ -3166,19 +3177,12 @@ typedef struct regitem_S
save_se_T sesave;
regsave_T regsave;
} rs_un; /* room for saving reginput */
short rs_no; /* submatch nr */
short rs_no; /* submatch nr or BEHIND/NOBEHIND */
} regitem_T;
static regitem_T *regstack_push __ARGS((regstate_T state, char_u *scan));
static void regstack_pop __ARGS((char_u **scan));
/* used for BEHIND and NOBEHIND matching */
typedef struct regbehind_S
{
regsave_T save_after;
regsave_T save_behind;
} regbehind_T;
/* used for STAR, PLUS and BRACE_SIMPLE matching */
typedef struct regstar_S
{
@@ -4888,6 +4892,10 @@ regmatch(scan)
status = RA_FAIL;
else
{
/* Need to save the subexpr to be able to restore them
* when there is a match but we don't use it. */
save_subexpr(((regbehind_T *)rp) - 1);
rp->rs_no = op;
reg_save(&rp->rs_un.regsave, &backpos);
/* First try if what follows matches. If it does then we
@@ -5118,15 +5126,20 @@ regmatch(scan)
reg_restore(&(((regbehind_T *)rp) - 1)->save_after,
&backpos);
else
/* But we didn't want a match. */
{
/* But we didn't want a match. Need to restore the
* subexpr, because what follows matched, so they have
* been set. */
status = RA_NOMATCH;
restore_subexpr(((regbehind_T *)rp) - 1);
}
regstack_pop(&scan);
regstack.ga_len -= sizeof(regbehind_T);
}
else
{
/* No match: Go back one character. May go to previous
* line once. */
/* No match or a match that doesn't end where we want it: Go
* back one character. May go to previous line once. */
no = OK;
if (REG_MULTI)
{
@@ -5160,6 +5173,13 @@ regmatch(scan)
/* Advanced, prepare for finding match again. */
reg_restore(&rp->rs_un.regsave, &backpos);
scan = OPERAND(rp->rs_scan);
if (status == RA_MATCH)
{
/* We did match, so subexpr may have been changed,
* need to restore them for the next try. */
status = RA_NOMATCH;
restore_subexpr(((regbehind_T *)rp) - 1);
}
}
else
{
@@ -5172,7 +5192,16 @@ regmatch(scan)
status = RA_MATCH;
}
else
status = RA_NOMATCH;
{
/* We do want a proper match. Need to restore the
* subexpr if we had a match, because they may have
* been set. */
if (status == RA_MATCH)
{
status = RA_NOMATCH;
restore_subexpr(((regbehind_T *)rp) - 1);
}
}
regstack_pop(&scan);
regstack.ga_len -= sizeof(regbehind_T);
}
@@ -5819,6 +5848,55 @@ cleanup_zsubexpr()
}
#endif
/*
* Save the current subexpr to "bp", so that they can be restored
* later by restore_subexpr().
*/
static void
save_subexpr(bp)
regbehind_T *bp;
{
int i;
for (i = 0; i < NSUBEXP; ++i)
{
if (REG_MULTI)
{
bp->save_start[i].se_u.pos = reg_startpos[i];
bp->save_end[i].se_u.pos = reg_endpos[i];
}
else
{
bp->save_start[i].se_u.ptr = reg_startp[i];
bp->save_end[i].se_u.ptr = reg_endp[i];
}
}
}
/*
* Restore the subexpr from "bp".
*/
static void
restore_subexpr(bp)
regbehind_T *bp;
{
int i;
for (i = 0; i < NSUBEXP; ++i)
{
if (REG_MULTI)
{
reg_startpos[i] = bp->save_start[i].se_u.pos;
reg_endpos[i] = bp->save_end[i].se_u.pos;
}
else
{
reg_startp[i] = bp->save_start[i].se_u.ptr;
reg_endp[i] = bp->save_end[i].se_u.ptr;
}
}
}
/*
* Advance reglnum, regline and reginput to the next line.
*/
+6 -1
View File
@@ -4527,7 +4527,7 @@ win_line(wp, lnum, startrow, endrow, nochange)
#endif
col == W_WIDTH(wp) - 1)
&& (*ptr != NUL
|| (wp->w_p_list && lcs_eol != NUL && p_extra != at_end_str)
|| (wp->w_p_list && lcs_eol_one > 0)
|| (n_extra && (c_extra != NUL || *p_extra != NUL))))
{
c = lcs_ext;
@@ -9357,6 +9357,11 @@ showruler(always)
)
maketitle();
#endif
#ifdef FEAT_WINDOWS
/* Redraw the tab pages line if needed. */
if (redraw_tabline)
draw_tabline();
#endif
}
#ifdef FEAT_CMDL_INFO
+4 -1
View File
@@ -547,7 +547,10 @@ searchit(win, buf, pos, dir, pat, count, options, pat_use, stop_lnum, tm)
return FAIL;
}
if (options & SEARCH_START)
/* When not accepting a match at the start position set "extra_col" to a
* non-zero value. Don't do that when starting at MAXCOL, since MAXCOL +
* 1 is zero. */
if ((options & SEARCH_START) || pos->col == MAXCOL)
extra_col = 0;
#ifdef FEAT_MBYTE
/* Watch out for the "col" being MAXCOL - 2, used in a closed fold. */
+26 -9
View File
@@ -753,6 +753,7 @@ static int set_spell_finish __ARGS((spelltab_T *new_st));
static int spell_iswordp __ARGS((char_u *p, buf_T *buf));
static int spell_iswordp_nmw __ARGS((char_u *p));
#ifdef FEAT_MBYTE
static int spell_mb_isword_class __ARGS((int cl));
static int spell_iswordp_w __ARGS((int *p, buf_T *buf));
#endif
static int write_spell_prefcond __ARGS((FILE *fd, garray_T *gap));
@@ -2268,6 +2269,8 @@ spell_move_to(wp, dir, allwords, curline, attrp)
/*
* For spell checking: concatenate the start of the following line "line" into
* "buf", blanking-out special characters. Copy less then "maxlen" bytes.
* Keep the blanks at the start of the next line, this is used in win_line()
* to skip those bytes if the word was OK.
*/
void
spell_cat_line(buf, line, maxlen)
@@ -2284,12 +2287,14 @@ spell_cat_line(buf, line, maxlen)
if (*p != NUL)
{
*buf = ' ';
vim_strncpy(buf + 1, line, maxlen - 2);
n = (int)(p - line);
if (n >= maxlen)
n = maxlen - 1;
vim_memset(buf + 1, ' ', n);
/* Only worth concatenating if there is something else than spaces to
* concatenate. */
n = (int)(p - line) + 1;
if (n < maxlen - 1)
{
vim_memset(buf, ' ', n);
vim_strncpy(buf + n, p, maxlen - 1 - n);
}
}
}
@@ -9785,7 +9790,7 @@ spell_iswordp(p, buf)
c = mb_ptr2char(s);
if (c > 255)
return mb_get_class(s) >= 2;
return spell_mb_isword_class(mb_get_class(s));
return spelltab.st_isw[c];
}
#endif
@@ -9808,7 +9813,7 @@ spell_iswordp_nmw(p)
{
c = mb_ptr2char(p);
if (c > 255)
return mb_get_class(p) >= 2;
return spell_mb_isword_class(mb_get_class(p));
return spelltab.st_isw[c];
}
#endif
@@ -9816,6 +9821,18 @@ spell_iswordp_nmw(p)
}
#ifdef FEAT_MBYTE
/*
* Return TRUE if word class indicates a word character.
* Only for characters above 255.
* Unicode subscript and superscript are not considered word characters.
*/
static int
spell_mb_isword_class(cl)
int cl;
{
return cl >= 2 && cl != 0x2070 && cl != 0x2080;
}
/*
* Return TRUE if "p" points to a word character.
* Wide version of spell_iswordp().
@@ -9837,7 +9854,7 @@ spell_iswordp_w(p, buf)
if (*s > 255)
{
if (enc_utf8)
return utf_class(*s) >= 2;
return spell_mb_isword_class(utf_class(*s));
if (enc_dbcs)
return dbcs_class((unsigned)*s >> 8, *s & 0xff) >= 2;
return 0;
+5 -3
View File
@@ -2254,9 +2254,11 @@ struct VimMenu
PtWidget_t *submenu_id;
#endif
#ifdef FEAT_GUI_MACVIM
int mac_key; /* Key equivalent */
int mac_mods; /* Modifier flags for the above */
int was_grey; /* Remember last 'grey' state */
char_u *mac_action; /* Action this menu sends */
int mac_key; /* Key equivalent */
int mac_mods; /* Modifier flags for the above */
int mac_alternate; /* Item is alternate of previous item */
int was_grey; /* Remember last 'grey' state */
#endif
};
#else
+88
View File
@@ -681,6 +681,94 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
311,
/**/
310,
/**/
309,
/**/
308,
/**/
307,
/**/
306,
/**/
305,
/**/
304,
/**/
303,
/**/
302,
/**/
301,
/**/
300,
/**/
299,
/**/
298,
/**/
297,
/**/
296,
/**/
295,
/**/
294,
/**/
293,
/**/
292,
/**/
291,
/**/
290,
/**/
289,
/**/
288,
/**/
287,
/**/
286,
/**/
285,
/**/
284,
/**/
283,
/**/
282,
/**/
281,
/**/
280,
/**/
279,
/**/
278,
/**/
277,
/**/
276,
/**/
275,
/**/
274,
/**/
273,
/**/
272,
/**/
271,
/**/
270,
/**/
269,
/**/
268,
/**/
267,
/**/

Some files were not shown because too many files have changed in this diff Show More