about summary refs log tree commit diff stats
path: root/tile.c
blob: d03e4faa7df63a9a2be26900c1f13bf2a732f1c9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/* See LICENSE file for copyright and license details. */
#include "dwm.h"
#include <stdio.h>

/* static */

static double mwfact = MWFACT;

/* extern */

void
addtomwfact(const char *arg) {
	double delta;

	if(isarrange(tile))
		return;

	/* arg handling, manipulate mwfact */
	if(arg && (1 == sscanf(arg, "%lf", &delta))) {
		if(delta + mwfact > 0.1 && delta + mwfact < 0.9)
			mwfact += delta;
	}
	arrange();
}

void
tile(void) {
	unsigned int i, n, nx, ny, nw, nh, mw, th;
	Client *c;

	for(n = 0, c = nexttiled(clients); c; c = nexttiled(c->next))
		n++;

	/* window geoms */
	mw = (n == 1) ? waw : mwfact * waw;
	th = (n > 1) ? wah / (n - 1) : 0;
	if(n > 1 && th < bh)
		th = wah;

	nx = wax;
	ny = way;
	for(i = 0, c = clients; c; c = c->next)
		if(isvisible(c)) {
			if(c->isfloating)
				continue;
			c->ismax = False;
			if(i == 0) { /* master */
				nw = mw - 2 * c->border;
				nh = wah - 2 * c->border;
			}
			else {  /* tile window */
				if(i == 1) {
					ny = way;
					nx += mw;
				}
				nw = waw - mw - 2 * c->border;
				if(i + 1 == n) /* remainder */
					nh = (way + wah) - ny - 2 * c->border;
				else
					nh = th - 2 * c->border;
			}
			resize(c, nx, ny, nw, nh, False);
			if(n > 1 && th != wah)
				ny += nh + 2 * c->border;
			i++;
		}
}

void
zoom(const char *arg) {
	Client *c;

	if(!sel || !isarrange(tile) || sel->isfloating)
		return;
	if((c = sel) == nexttiled(clients))
		if(!(c = nexttiled(c->next)))
			return;
	detach(c);
	attach(c);
	focus(c);
	arrange();
}
ss="k">e> <C-o>$ inoremap <C-a> <C-o>0 set foldmethod=indent set foldlevel=99 let g:SimpylFold_docstring_preview=1 au BufNewFile,BufRead *.py \ set tabstop=4 | \ set softtabstop=4 | \ set shiftwidth=4 | \ set textwidth=79 | \ set expandtab | \ set autoindent | \ set fileformat=unix | \ let g:SuperTabDefaultCompletionType = "context" | \ let g:SuperTabContextDefaultCompletionType = "<c-x><c-o>" augroup vimrc_autocmds autocmd! autocmd FileType python highlight Excess ctermbg=Red guibg=Red autocmd FileType python match Excess /\%79v.*/ autocmd FileType python set nowrap augroup END if has('gui_running') set background=dark colorscheme solarized else set t_Co=256 colorscheme jellybeans "colorscheme fruity "colorscheme solarized "colorscheme inkpot "colorscheme zenburn "colorscheme molokai "colorscheme badwolf "colorscheme bubblegum-256-dark endif "call togglebg#map("<F9>") " override colours on some systems if hostname() =~ '^wolfman' let g:gruvbox_termcolors=16 colorscheme gruvbox elseif hostname() =~ '^CHESTER' colorscheme fruity endif set number nmap <leader>t <ESC>:TagbarToggle<cr> imap <leader>t <ESC>:TagbarToggle<cr>i "let g:ycm_autoclose_preview_window_after_completion=1 "map <leader>g :YcmCompleter GoToDefinitionElseDeclaration<CR> let g:pydiction_location = '/home/user/.vim/bundle/pydiction/complete-dict' set laststatus=2 " set showmode set noshowmode " turn this off for airline set ruler set encoding=utf-8 set showcmd set scrolloff=2 "set autoindent "set smartindent "set cindent inoremap # X<BS># set mouse= "if has('mouse') " set mouse=a "endif set incsearch set ignorecase set smartcase set cino=>4 set showmatch set hlsearch " autocmd BufRead,BufNewFile *.lsp,*.lisp so ~/VIlisp-2.0/VIlisp.vim | set bufhidden=hide nmap <silent> <F3> :silent nohlsearch<CR> imap <silent> <F3> <C-o>:silent nohlsearch<CR> " colorscheme inkpot " colorscheme darkblue nmap <silent> <F4> :silent setlocal spell spelllang=en_gb<CR> imap <silent> <F4> <C-o>:silent setlocal spell spelllang=en_gb<CR> nmap <silent> <F5> :silent setlocal nospell<CR> imap <silent> <F5> <C-o>:silent setlocal nospell<CR> nmap <silent> <F2> :silent set diffopt+=iwhite<CR> imap <silent> <F2> <C-o>:silent set diffopt+=iwhite<CR> " on some systems this is not detected correcly set background=dark autocmd BufRead *.upc set filetype=c autocmd BufRead *.gnu set filetype=gnuplot autocmd FileType c,cpp set cindent if !exists("autocommands_loaded") let autocommands_loaded = 1 augroup C autocmd BufRead *.c set cindent augroup END endif " gnu indentation style " augroup C " autocmd BufRead *.c set cinoptions={.5s,:.5s,+.5s,t0,g0,^-2,e-2,n-2,p2s,(0,=.5s formatoptions=croql cindent shiftwidth=4 tabstop=8 " augroup END " Show tabs and trailing whitespace visually "if (&termencoding == "utf-8") || has("gui_running") " if v:version >= 700 " set list listchars=tab:»·,trail:·,extends:…,nbsp:‗ " else " set list listchars=tab:»·,trail:·,extends:… " endif "else if v:version >= 700 set list listchars=tab:>-,trail:.,extends:>,nbsp:_ else set list listchars=tab:>-,trail:.,extends:> endif "endif " Enable modelines only on secure vim versions if (v:version >= 604) set modeline else set nomodeline endif set tabstop=4 set expandtab set shiftwidth=4 set shiftround set matchpairs+=<:> if has('gui') set guioptions-=m set guioptions-=T set guioptions-=l set guioptions-=L set guioptions-=r set guioptions-=R "set number end " Nice statusbar - replaced by airline "set laststatus=2 "set statusline= "set statusline+=%2*%-3.3n%0*\ " buffer number "set statusline+=%f\ " file name "set statusline+=%h%1*%m%r%w%0* " flags "set statusline+=\[%{strlen(&ft)?&ft:'none'}, " filetype "set statusline+=%{&encoding}, " encoding "set statusline+=%{&fileformat}] " file format "set statusline+=%= " right align "set statusline+=%2*0x%-8B\ " current char "set statusline+=%-14.(%l,%c%V%)\ %<%P " offset "if filereadable(expand("$VIM/vimfiles/plugin/vimbuddy.vim")) " set statusline+=\ %{VimBuddy()} " vim buddy "endif if has('title') && (has('gui_running') || &title) set titlestring= set titlestring+=%f\ " file name set titlestring+=%h%m%r%w " flags set titlestring+=\ -\ %{v:progname} " program name endif " If possible, try to use a narrow number column. if v:version >= 700 try setlocal numberwidth=3 catch endtry endif " Filter expected errors from make "if has("eval") && v:version >= 700 " let &makeprg='nice make $* 2>&1 \| sed -u -n ' " let &makeprg.='-e "/should fail/s/:\([0-9]\)/∶\1/g" ' " let &makeprg.='-e "/usr.share.aclocal.*underquoted/s/:\([0-9]\)/∶\1/g" ' " let &makeprg.='-e "s/\([0-9]\{2\}\):\([0-9]\{2\}\):\([0-9]\{2\}\)/\1∶\2∶\3/g" ' " let &makeprg.='-e "/-version-info/s/:\([0-9]\)/∶\1/g" ' " let &makeprg.='-e "/^/p" ' "endif " autocmd FileType tex set makeprg=pdflatex\ %\ $* " autocmd FileType bib set makeprg=bibtex\ %\ $* nmap q: :q " tab completion - taken from ciaranm's vimrc "if has("eval") " function! CleverTab() " if strpart(getline('.'), 0, col('.') - 1) =~ '^\s*$' " return "\<Tab>" " else " return "\<C-N>" " endif " endfun " inoremap <Tab> <C-R>=CleverTab()<CR> " inoremap <S-Tab> <C-P> "endif if has("autocmd") au VimEnter * nohls endif set backspace=indent,eol,start set showfulltag set lazyredraw "set noerrorbells set visualbell set wildmenu set wildignore+=*.o,*~,.lo,.class,*/target/** set suffixes+=.in,.a set hidden set winminheight=1 autocmd FileType perl set makeprg=perl\ -c\ %\ $* autocmd FileType perl set errorformat=%f:%l:%m autocmd FileType perl set autowrite set viminfo='1000,f1,:1000,/1000 set history=500 set backup "set patchmode=.clean set dictionary=/usr/share/dict/words "set complete=.,w,u,t,i,d,k set complete=.,w,u,t,i,d "autocmd BufRead *.py set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class "autocmd BufRead *.py set nocindent "autocmd BufWritePre *.py normal m`:%s/\s\+$//e `` "let g:syntastic_python_checkers = ['pyflakes'] "let g:syntastic_python_python_exec = 'python3' let g:syntastic_check_on_open = 0 let g:syntastic_disabled_filetypes=['python'] " use jedi instead set colorcolumn=80 set cursorline nnoremap <silent> <Leader>l ml:execute 'match Search /\%'.line('.').'l/'<CR> nnoremap <silent> <Leader>m ml:execute 'match'<CR> nnoremap <silent> <leader>c :execute 'sign unplace * buffer=' . bufnr('')<CR> nmap <leader>C <ESC>:lclose<CR> nmap <leader>x <ESC>:cclose<CR> nmap <leader><tab> <ESC>:bnext<CR> noremap <F8> :PymodeLintAuto<CR> " python-mode config, hopefully without jedi-vim conflicts - BUNDLE DISABLED "let g:pymode_rope = 0 "let g:pymode_rope_completion = 0 "let g:pymode_indent = 1 "let g:pymode_doc = 0 ""let g:pymode_doc_bind = '<leader>K' ""let g:pymode_rope_goto_definition_bind = '<leader>g' "let g:pymode_lint = 1 "let g:pymode_lint_write = 1 ""let g:pymode_lint_checker = "pyflakes,pep8,pylint,pep257,mccabe" "let g:pymode_lint_checker = "pyflakes,pep8" "let g:pymode_lint_message = 1 "let g:pymode_lint_on_fly = 0 "let g:pymode_lint_cwindow = 1 "let g:pymode_virtualenv = 1 "let g:pymode_breakpoint = 1 "let g:pymode_breakpoint_bind = '<leader>B' "let g:pymode_run_bind = '<leader>R' "let g:pymode_syntax = 1 "let g:pymode_syntax_all = 1 "let g:pymode_syntax_indent_errors = g:pymode_syntax_all "let g:pymode_syntax_space_errors = g:pymode_syntax_all "let g:pymode_rope_autoimport = 1 "let g:pymode_rope_autoimport_import_after_complete = 1 " if we're using hdima/python-syntax instead of python mode let python_highlight_all=1 " if we're using nvie/vim-flake8 instead of python mode let g:flake8_show_quickfix=1 let g:flake8_show_in_gutter=1 let g:flake8_show_in_file=1 "autocmd BufWritePost *.py call Flake8() autocmd FileType python map <buffer> <F6> :call flake8#Flake8UnplaceMarkers()<CR> " doesn't work with python3 (no activate_this.py) "py << EOF "import os.path "import sys "import vim "if 'VIRTUAL_ENV' in os.environ: " project_base_dir = os.environ['VIRTUAL_ENV'] " sys.path.insert(0, project_base_dir) " activate_this = os.path.join(project_base_dir, 'bin/activate_this.py') " execfile(activate_this, dict(__file__=activate_this)) "EOF " disable this on slow systems let g:jedi#popup_on_dot = 0 if has('gui_running') let g:airline#extensions#tabline#enabled = 1 let g:airline#extensions#tabline#buffer_nr_show = 1 endif let g:airline#extensions#bufferline#enabled = 1 "let g:airline#extensions#bufferline#overwrite_variables = 1 map <silent> <C-E> :silent Lexplore<CR> if has('gui_running') let g:netrw_liststyle = 3 else let g:netrw_liststyle = 0 endif let g:netrw_winsize = -20 let g:netrw_browse_split = 4 let g:netrw_banner = 0 let g:netrw_altv = 1 let g:netrw_preview = 1 let g:netrw_sort_sequence = '[\/]$,*' let g:netrw_chgwin=2 set autochdir " vim: set shiftwidth=4 softtabstop=4 expandtab tw=72 :