1
0
mirror of https://github.com/gryf/zoom.vim.git synced 2026-02-17 01:05:46 +01:00

Added MacOS X support

This commit is contained in:
2013-10-31 18:55:08 +01:00
parent 69a6175be2
commit 757f513c62
2 changed files with 63 additions and 12 deletions

25
README
View File

@@ -1,8 +1,28 @@
This is fork of a mirror of http://www.vim.org/scripts/script.php?script_id=2321 This is fork of a mirror of http://www.vim.org/scripts/script.php?script_id=2321
Control Vim editor font size with keyboard or mouse. Control Vim editor font size with keyboard or mouse.
==============================================================================
Remarks.
This plugin is for GUI only. This plugin is for GUI only.
Currently, this plugin olny works for fonts, that are defined as a typeface
name AND the size. For example: >
set guifont=DejaVu\ Sans\ Mono\ 12
set guifont=Consolas:h10:cEASTEUROPE
set guifont=Monaco:h11
Putting only name will not work at all, since guessing default font size for
all of the operating system can be difficult.
For Linux, *BSD or other unix-like system it will be assumed, that graphical
environment is an X11 system. Wayland, or other non-X solutions will be added
as they emerged, however wayland-x11 driver may work OOTB.
==============================================================================
Usage:
Normal Mode: Normal Mode:
Keypad + ... incerase font size Keypad + ... incerase font size
@@ -19,11 +39,14 @@ Command-line Mode:
:ZoomReset ... reset font size to initial state :ZoomReset ... reset font size to initial state
============================================================================== ==============================================================================
Installing
1. Copy the zoom.vim script to 1. Copy the zoom.vim script to
$HOME/vimfiles/plugin or $HOME/.vim/plugin directory. $HOME/vimfiles/plugin or $HOME/.vim/plugin directory.
Refer to ':help add-plugin', ':help add-global-plugin' and Refer to ':help add-plugin', ':help add-global-plugin' and
':help runtimepath' for more details about Vim plugins. ':help runtimepath' for more details about Vim plugins.
Or just use pathogen (https://github.com/tpope/vim-pathogen)
Or just use pathogen (https://github.com/tpope/vim-pathogen) or simmilar
solution
2. Restart Vim. 2. Restart Vim.

View File

@@ -1,5 +1,5 @@
"The guard. Zoom will only work in graphical Vim. For terminal version try to " Zoom will only work in graphical Vim. For terminal version try to find out
"find out how to increase/decrease font size in your terminal emulator. " how to increase/decrease font size in your terminal emulator.
if !has("gui") if !has("gui")
finish finish
endif endif
@@ -30,14 +30,19 @@ nmap <C-ScrollWheelDown> :ZoomOut<CR>
" guifont size + 1 " guifont size + 1
function! s:ZoomIn() function! s:ZoomIn()
" Let's check, what system we are dealing with " Let's check, what system we are dealing with.
if has("win32") " TODO: This will work only with clearly defined font names AND sizes.
" Putting only name will not work at all, since guessing default font size
" can be difficult.
if has("win32") || has("mac")
let l:fsize = substitute(&guifont, '^.*:h\([^:]*\).*$', '\1', '') let l:fsize = substitute(&guifont, '^.*:h\([^:]*\).*$', '\1', '')
let l:fsize += 1 let l:fsize += 1
let l:guifont = substitute(&guifont, ':h\([^:]*\)', ':h' . l:fsize, '') let l:guifont = substitute(&guifont, ':h\([^:]*\)', ':h' . l:fsize, '')
let &guifont = l:guifont let &guifont = l:guifont
elseif has('unix') " That will assume, that under Linux or *BSD systems graphical environment
" TODO: Might not work on OS X " is an X11 system. Wayland, or other non-X solutions will be added as they
" emerged, however wayland-x11 driver may work OOTB.
elseif has('unix') && has("x11")
let l:font = split(&guifont) let l:font = split(&guifont)
let l:font[-1] = l:font[-1] + 1 let l:font[-1] = l:font[-1] + 1
let &guifont = join(l:font, " ") let &guifont = join(l:font, " ")
@@ -47,12 +52,12 @@ endfunction
" guifont size - 1 " guifont size - 1
function! s:ZoomOut() function! s:ZoomOut()
" Same as above " Same as above
if has("win32") if has("win32") || has("mac")
let l:fsize = substitute(&guifont, '^.*:h\([^:]*\).*$', '\1', '') let l:fsize = substitute(&guifont, '^.*:h\([^:]*\).*$', '\1', '')
let l:fsize -= 1 let l:fsize -= 1
let l:guifont = substitute(&guifont, ':h\([^:]*\)', ':h' . l:fsize, '') let l:guifont = substitute(&guifont, ':h\([^:]*\)', ':h' . l:fsize, '')
let &guifont = l:guifont let &guifont = l:guifont
elseif has('unix') elseif has('unix') && has("x11")
let l:font = split(&guifont) let l:font = split(&guifont)
let l:font[-1] = l:font[-1] - 1 let l:font[-1] = l:font[-1] - 1
let &guifont = join(l:font, " ") let &guifont = join(l:font, " ")
@@ -72,15 +77,35 @@ zoom.vim : control gui font size with "+" or "-" keypad keys.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
$VIMRUNTIMEPATH/plugin/zoom.vim $VIMRUNTIMEPATH/plugin/zoom.vim
============================================================================== ==============================================================================
author : OMI TAKU author : OMI TAKU, gryf
url : http://nanasi.jp/ url : http://nanasi.jp/
email : mail@nanasi.jp email : mail@nanasi.jp
version : 2008/07/18 10:00:00 version : 2008/07/18 10:00:00, 2013-10-31 18:53:01
============================================================================== ==============================================================================
Control Vim editor font size with keyboard or mouse. Control Vim editor font size with keyboard or mouse.
==============================================================================
Remarks.
This plugin is for GUI only. This plugin is for GUI only.
Currently, this plugin olny works for fonts, that are defined as a typeface
name AND the size. For example: >
set guifont=DejaVu\ Sans\ Mono\ 12
set guifont=Consolas:h10:cEASTEUROPE
set guifont=Monaco:h11
Putting only name will not work at all, since guessing default font size for
all of the operating system can be difficult.
For Linux, *BSD or other unix-like system it will be assumed, that graphical
environment is an X11 system. Wayland, or other non-X solutions will be added
as they emerged, however wayland-x11 driver may work OOTB.
==============================================================================
Usage:
Normal Mode: Normal Mode:
Keypad + ... incerase font size Keypad + ... incerase font size
@@ -97,12 +122,15 @@ Command-line Mode:
:ZoomReset ... reset font size to initial state :ZoomReset ... reset font size to initial state
============================================================================== ==============================================================================
Installing
1. Copy the zoom.vim script to 1. Copy the zoom.vim script to
$HOME/vimfiles/plugin or $HOME/.vim/plugin directory. $HOME/vimfiles/plugin or $HOME/.vim/plugin directory.
Refer to ':help add-plugin', ':help add-global-plugin' and Refer to ':help add-plugin', ':help add-global-plugin' and
':help runtimepath' for more details about Vim plugins. ':help runtimepath' for more details about Vim plugins.
Or just use pathogen (https://github.com/tpope/vim-pathogen)
Or just use pathogen (https://github.com/tpope/vim-pathogen) or simmilar
solution
2. Restart Vim. 2. Restart Vim.