aboutsummaryrefslogtreecommitdiff
path: root/vim/bundle/vim-table-mode/autoload/tablemode/utils.vim
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2016-06-30 16:03:25 +0200
committerKarel Kočí <cynerd@email.cz>2016-06-30 16:03:25 +0200
commite573b3020c032400eed60b649a2cbf55266e6bb0 (patch)
tree8f572394ac8433529c7a8e70d160a2fbe8268b4e /vim/bundle/vim-table-mode/autoload/tablemode/utils.vim
parentb8c667bd64b3edd38d56c63c5bd1db53a23b4499 (diff)
downloadmyconfigs-e573b3020c032400eed60b649a2cbf55266e6bb0.tar.gz
myconfigs-e573b3020c032400eed60b649a2cbf55266e6bb0.tar.bz2
myconfigs-e573b3020c032400eed60b649a2cbf55266e6bb0.zip
Add current configurations from old repository
Diffstat (limited to 'vim/bundle/vim-table-mode/autoload/tablemode/utils.vim')
-rw-r--r--vim/bundle/vim-table-mode/autoload/tablemode/utils.vim49
1 files changed, 49 insertions, 0 deletions
diff --git a/vim/bundle/vim-table-mode/autoload/tablemode/utils.vim b/vim/bundle/vim-table-mode/autoload/tablemode/utils.vim
new file mode 100644
index 0000000..215da6c
--- /dev/null
+++ b/vim/bundle/vim-table-mode/autoload/tablemode/utils.vim
@@ -0,0 +1,49 @@
+" Private Functions {{{1
+
+" Public Functions {{{1
+function! tablemode#utils#throw(string) abort "{{{2
+ let v:errmsg = 'table-mode: ' . a:string
+ throw v:errmsg
+endfunction
+
+function! tablemode#utils#line(row) "{{{2
+ if type(a:row) == type('')
+ return line(a:row)
+ else
+ return a:row
+ endif
+endfunction
+
+function! tablemode#utils#strip(string) "{{{2
+ return matchstr(a:string, '^\s*\zs.\{-}\ze\s*$')
+endfunction
+
+" function! tablemode#utils#strlen {{{2
+" To count multibyte characters accurately
+function! tablemode#utils#strlen(text)
+ return strlen(substitute(a:text, '.', 'x', 'g'))
+endfunction
+
+function! tablemode#utils#StrDisplayWidth(string) "{{{2
+ if exists('*strdisplaywidth')
+ return strdisplaywidth(a:string)
+ else
+ " Implement the tab handling part of strdisplaywidth for vim 7.2 and
+ " earlier - not much that can be done about handling doublewidth
+ " characters.
+ let rv = 0
+ let i = 0
+
+ for char in split(a:string, '\zs')
+ if char == "\t"
+ let rv += &ts - i
+ let i = 0
+ else
+ let rv += 1
+ let i = (i + 1) % &ts
+ endif
+ endfor
+
+ return rv
+ endif
+endfunction