Permalink
Browse files

Extract :Maximize from :Fullscreen (suggested by Benjamin Bergman)

  • Loading branch information...
1 parent 34ef803 commit 665a2b5fc747a3496680127bb71e40d816e0f2a0 @xolox committed Sep 17, 2011
Showing with 61 additions and 33 deletions.
  1. +7 −3 README.md
  2. +32 −19 autoload/xolox/shell.vim
  3. +16 −8 doc/shell.txt
  4. +6 −3 plugin/shell.vim
View
@@ -4,6 +4,8 @@ This plug-in aims to improve the integration between [Vim][vim] and its environm
* The `:Fullscreen` command and `<F11>` mapping toggle Vim between normal and full-screen mode (see the [screenshots](http://peterodding.com/code/vim/shell/screenshots/)). To invoke this functionality without using the `:Fullscreen` command see the `xolox#shell#fullscreen()` and `xolox#shell#is_fullscreen()` functions.
+ * The `:Maximize` command and `<Control-F11>` mapping toggle Vim between normal and maximized state: They show/hide Vim's menu bar, tool bar and/or tab line without hiding the operating system task bar.
+
* The `:Open` command and `<F6>` mapping know how to open file and directory names, URLs and e-mail addresses in your favorite programs (file manager, web browser, e-mail client, etc). To invoke this functionality without using the `:Open` command see my [open.vim](http://peterodding.com/code/vim/open-associated-programs/) plug-in, which was split off from `shell.vim` so that other Vim plug-ins can bundle it without bringing in all the other crap :-).
* The `xolox#shell#execute()` function enables other Vim plug-ins (like my [easytags.vim] [easytags] plug-in) to execute external commands in the background (i.e. asynchronously) *without opening a command prompt window on Windows*.
@@ -12,11 +14,13 @@ Two [Windows DLL files][dll] are included to perform these functions on Windows,
## Usage (commands & functions)
-### The `:Fullscreen` command
+### The `:Maximize` command
-The `:Fullscreen` command toggles Vim between normal and [full-screen mode](http://peterodding.com/code/vim/shell/screenshots/). It's mapped to `<F11>` by default, see `g:shell_mappings_enabled` if you don't like this.
+This command toggles the visibility of Vim's main menu, tool bar and/or tab line. It's mapped to `<Control-F11>` by default, see `g:shell_mappings_enabled` if you don't like this. If you want to change which items are hidden see the `g:shell_fullscreen_items` option.
+
+### The `:Fullscreen` command
-When you enter full-screen mode the main menu, toolbar and tabline are all hidden (see `g:shell_fullscreen_items` if you want to change this) and when possible Vim's [GUI window] [gui] is switched to real full-screen mode (hiding any [taskbars, panels or docks](http://en.wikipedia.org/wiki/Taskbar)). When you leave full-screen Vim's main menu, toolbar and tabline are restored and the [GUI window] [gui] is switched back to normal mode.
+The `:Fullscreen` command toggles Vim between normal and [full-screen mode](http://peterodding.com/code/vim/shell/screenshots/). It's mapped to `<F11>` by default, see `g:shell_mappings_enabled` if you don't like this. This command first executes `:Maximize` and then (if possible) switches Vim's [GUI window] [gui] to real full-screen mode (hiding any [taskbars, panels or docks](http://en.wikipedia.org/wiki/Taskbar)). When you leave full-screen Vim's main menu, toolbar and tabline are restored and the [GUI window] [gui] is switched back to normal mode.
Note that on UNIX this command even works inside of graphical terminal emulators like `gnome-terminal` or `xterm` (try it out!).
View
@@ -1,14 +1,15 @@
" Vim auto-load script
" Author: Peter Odding <peter@peterodding.com>
-" Last Change: September 4, 2011
+" Last Change: September 18, 2011
" URL: http://peterodding.com/code/vim/shell/
-let g:xolox#shell#version = '0.9.11'
+let g:xolox#shell#version = '0.9.12'
if !exists('s:fullscreen_enabled')
let s:enoimpl = "%s() hasn't been implemented on your platform! %s"
let s:contact = "If you have suggestions, please contact peter@peterodding.com."
let s:fullscreen_enabled = 0
+ let s:maximized = 0
endif
function! xolox#shell#open_cmd(arg) " -- implementation of the :Open command {{{1
@@ -137,16 +138,9 @@ function! xolox#shell#execute(command, synchronous, ...) " -- execute external c
endtry
endfunction
-function! xolox#shell#fullscreen() " -- toggle Vim between normal and full-screen mode {{{1
-
- " When entering full-screen...
- if !s:fullscreen_enabled
- " Save the window position and size when running Windows, because my
- " dynamic link library doesn't save/restore them while "wmctrl" does.
- if xolox#misc#os#is_win()
- let [s:lines_save, s:columns_save] = [&lines, &columns]
- let [s:winpos_x_save, s:winpos_y_save] = [getwinposx(), getwinposy()]
- endif
+function! xolox#shell#maximize(...) " -- show/hide Vim's menu, tool bar and/or tab line {{{1
+ let new_state = a:0 == 0 ? !s:maximized : a:1
+ if new_state && !s:maximized
" Hide the main menu, tool bar and/or tab line. Remember what was hidden
" so its visibility can be restored when the user leaves full-screen.
let s:go_toggled = ''
@@ -161,6 +155,31 @@ function! xolox#shell#fullscreen() " -- toggle Vim between normal and full-scree
let s:stal_save = &stal
set showtabline=0
endif
+ let s:maximized = 1
+ elseif s:maximized && !new_state
+ " Restore display of previously hidden GUI components?
+ let &go .= s:go_toggled
+ if exists('s:stal_save')
+ let &stal = s:stal_save
+ unlet s:stal_save
+ endif
+ unlet s:go_toggled
+ let s:maximized = 0
+ endif
+ return s:maximized
+endfunction
+
+function! xolox#shell#fullscreen() " -- toggle Vim between normal and full-screen mode {{{1
+
+ " When entering full-screen...
+ if !s:fullscreen_enabled
+ " Save the window position and size when running Windows, because my
+ " dynamic link library doesn't save/restore them while "wmctrl" does.
+ if xolox#misc#os#is_win()
+ let [s:lines_save, s:columns_save] = [&lines, &columns]
+ let [s:winpos_x_save, s:winpos_y_save] = [getwinposx(), getwinposy()]
+ endif
+ call xolox#shell#maximize(1)
endif
" Now try to toggle the real full-screen status of Vim's GUI window using a
@@ -187,13 +206,7 @@ function! xolox#shell#fullscreen() " -- toggle Vim between normal and full-scree
" When leaving full-screen...
if s:fullscreen_enabled
- " Restore display of previously hidden GUI components?
- let &go .= s:go_toggled
- if exists('s:stal_save')
- let &stal = s:stal_save
- unlet s:stal_save
- endif
- unlet s:go_toggled
+ call xolox#shell#maximize(0)
" Restore window position and size only on Windows -- I don't know why
" but the following actually breaks when running under "wmctrl"...
if xolox#misc#os#is_win()
View
@@ -8,6 +8,10 @@ This plug-in aims to improve the integration between Vim and its environment
without using the |:Fullscreen| command see the 'xolox#shell#fullscreen()'
and 'xolox#shell#is_fullscreen()' functions.
+ - The |:Maximize| command and '<Control-F11>' mapping toggle Vim between
+ normal and maximized state: They show/hide Vim's menu bar, tool bar and/or
+ tab line without hiding the operating system task bar.
+
- The |:Open| command and '<F6>' mapping know how to open file and directory
names, URLs and e-mail addresses in your favorite programs (file manager,
web browser, e-mail client, etc). To invoke this functionality without
@@ -27,18 +31,22 @@ while on UNIX external commands are used.
Usage (commands & functions) ~
-------------------------------------------------------------------------------
+The *:Maximize* command
+
+This command toggles the visibility of Vim's main menu, tool bar and/or tab
+line. It's mapped to '<Control-F11>' by default, see |g:shell_mappings_enabled|
+if you don't like this. If you want to change which items are hidden see the
+|g:shell_fullscreen_items| option.
+
+-------------------------------------------------------------------------------
The *:Fullscreen* command
The |:Fullscreen| command toggles Vim between normal and full-screen mode [1].
It's mapped to '<F11>' by default, see |g:shell_mappings_enabled| if you don't
-like this.
-
-When you enter full-screen mode the main menu, toolbar and tabline are all
-hidden (see |g:shell_fullscreen_items| if you want to change this) and when
-possible Vim's |GUI| window is switched to real full-screen mode (hiding any
-taskbars, panels or docks [5]). When you leave full-screen Vim's main menu,
-toolbar and tabline are restored and the |GUI| window is switched back to normal
-mode.
+like this. This command first executes |:Maximize| and then (if possible)
+switches Vim's |GUI| window to real full-screen mode (hiding any taskbars,
+panels or docks [5]). When you leave full-screen Vim's main menu, toolbar and
+tabline are restored and the |GUI| window is switched back to normal mode.
Note that on UNIX this command even works inside of graphical terminal
emulators like 'gnome-terminal' or 'xterm' (try it out!).
View
@@ -1,6 +1,6 @@
" Vim plug-in
" Author: Peter Odding <peter@peterodding.com>
-" Last Change: August 31, 2011
+" Last Change: September 18, 2011
" URL: http://peterodding.com/code/vim/shell/
" Support for automatic update using the GLVS plug-in.
@@ -28,15 +28,18 @@ augroup END
" Regular commands. {{{1
command! -bar -nargs=? -complete=file Open call xolox#shell#open_cmd(<q-args>)
+command! -bar Maximize call xolox#shell#maximize()
command! -bar Fullscreen call xolox#shell#fullscreen()
" Default key mappings. {{{1
if g:shell_mappings_enabled
- inoremap <F11> <C-o>:Fullscreen<CR>
- nnoremap <F11> :Fullscreen<CR>
inoremap <F6> <C-o>:Open<CR>
nnoremap <F6> :Open<CR>
+ inoremap <F11> <C-o>:Fullscreen<CR>
+ nnoremap <F11> :Fullscreen<CR>
+ inoremap <C-F11> <C-o>:Maximize<CR>
+ nnoremap <C-F11> :Maximize<CR>
endif
" Make sure the plug-in is only loaded once.

0 comments on commit 665a2b5

Please sign in to comment.