vim72-20100325-kaoriya-w64j.zip
[MacVim/KaoriYa.git] / runtime / plugin / scrnmode.vim
bloba931ab08d1d6e7d0b4aed13fa8fb5403cc4b0fed
1 " vim:set ts=8 sts=2 sw=2 tw=0:
3 " scrnmode.vim - Screen mode changer.
5 " Maintainer:   MURAOKA Taro <koron@tka.att.ne.jp>
6 " Last Change:  06-Feb-2006.
8 " Commands:     :ScreenMode {n}         Set screen mode {n} n:0-8
9 "               :SM {n}                 Same as :ScreenMode
10 "               :Revert                 Revert screen mode to start up (SM0)
11 "               :Double                 Double width (SM2)
12 "               :Fever                  Double width (SM8)
13 "               :FullScreen             Make window maximum with removing
14 "                                       UI components.
16 " Options:      'fever_guifont'         'guifont' for fever mode
18 " Old Commands: :HDensity               Start high-density mode (SM7)
19 "               :WWidth                 Double width mode (SM2)
20 "               :NDensity               Return normal-density mode (SM0)
22 " Bug:          After set full screen mode (more than 4), to set screen mode
23 "               4 cause too small edit area.
25 let s:version = '1.1'
27 if exists('g:plugin_scrnmode_disable')
28   finish
29 endif
31 "---------------------------------------------------------------------------
33 "---------------------------------------------------------------------------
35 let s:save_original_options = 0
37 function! s:SaveOptions()
38   if !exists('g:fever_guifont')
39     if has('win32')
40       let g:fever_guifont = substitute(&guifont, ':h[^:]*:', ':h7.5:', '')
41     else
42       let g:fever_guifont = &guifont
43     endif
44   endif
46   if !s:save_original_options 
47     let s:save_guioptions       = &guioptions
48     let s:save_guifont          = &guifont
49     let s:save_linespace        = &linespace
50     let s:save_columns          = &columns
51     let s:save_lines            = &lines
52     if has('win32') && has('kaoriya')
53       let s:save_charspace      = &charspace
54     endif
55     let s:save_original_options = 1
56   endif
57 endfunction
59 function! s:LoadOptions()
60   if s:save_original_options
61     if has('win32') && has('kaoriya')
62       let &charspace    = s:save_charspace
63     endif
64     let &guioptions     = s:save_guioptions
65     let &guifont        = s:save_guifont
66     let &linespace      = s:save_linespace
67     let &columns        = s:save_columns
68     let &lines          = s:save_lines
69   endif
70 endfunction
72 "---------------------------------------------------------------------------
74 function! s:ScreenMode(modenum)
75   if !has('gui_running')
76     return
77   endif
79   call s:SaveOptions()
80   if a:modenum < 4
81     simalt ~r
82   endif
83   call s:LoadOptions()
85   if a:modenum <= 0
86     return
87   endif
88   if a:modenum == 1
89     let &guioptions = substitute(s:save_guioptions, '[lLrRmT]', '', 'g')
90     return
91   endif
93   if a:modenum <= 3
94     let &columns = s:save_columns * 2 + 1
95     if a:modenum == 3
96       let &guioptions = substitute(s:save_guioptions, '[lLrRmT]', '', 'g')
97     endif
98     return
99   endif
101   if a:modenum >= 4
102     " Full screen window
103     if a:modenum >= 7
104       let &guifont = g:fever_guifont
105     endif
106     if a:modenum >= 6
107       if has('win32') && has('kaoriya')
108         set charspace=0
109       endif
110       if a:modenum != 7
111         set linespace=0
112       endif
113     endif
114     let new_guioptions = s:save_guioptions
115     if a:modenum >= 5
116       let new_guioptions = substitute(new_guioptions, '[lLrRmT]', '', 'g')
117       if has('win32') && has('kaoriya')
118         let new_guioptions = new_guioptions.'C'
119       endif
120     endif
121     let &guioptions = new_guioptions
122     simalt ~x
123     return
124   endif
125 endfunction
127 function! s:FullScreen()
128   let &guioptions = substitute(&guioptions, '[LRTlrm]', '', 'g')
129   simalt ~x
130 endfunction
132 "---------------------------------------------------------------------------
134 command! -nargs=1 ScreenMode    call <SID>ScreenMode(<args>)
135 command! -nargs=1 SM            call <SID>ScreenMode(<args>)
136 command! -nargs=0 Revert        call <SID>ScreenMode(0)
137 command! -nargs=0 Double        call <SID>ScreenMode(2)
138 command! -nargs=0 Fever         call <SID>ScreenMode(8)
139 command! -nargs=0 FullScreen    call <SID>FullScreen()
141 command! -nargs=0 NDensity      call <SID>ScreenMode(0)
142 command! -nargs=0 WWidth        call <SID>ScreenMode(2)
143 command! -nargs=0 HDensity      call <SID>ScreenMode(7)