This commit is contained in:
gbaconni
2021-10-29 06:02:17 +00:00
parent ba5cb17459
commit 483d1c500b
3 changed files with 12 additions and 215 deletions

View File

@@ -1,165 +0,0 @@
--- stdheader.vim 2021-06-10 22:51:40.000000000 +0200
+++ stdheader.vim 2021-10-25 09:58:04.000000000 +0200
@@ -3,10 +3,10 @@
" ::: :::::::: "
" stdheader.vim :+: :+: :+: "
" +:+ +:+ +:+ "
-" By: zaz <zaz@staff.42.fr> +#+ +:+ +#+ "
+" By: <gbaconni@student.42lausanne.ch> +#+ +:+ +#+ "
" +#+#+#+#+#+ +#+ "
" Created: 2013/06/15 12:45:56 by zaz #+# #+# "
-" Updated: 2021/02/01 12:32:13 by xitope ### ########.fr "
+" Updated: 2021/10/25 09:58:04 by gbaconni ### lausanne.ch "
" "
" **************************************************************************** "
@@ -18,7 +18,7 @@
\" +#+ +:+ +#+ ",
\"+#+#+#+#+#+ +#+ ",
\" #+# #+# ",
- \" ### ########.fr "
+ \" ### lausanne.ch "
\]
let s:styles = [
@@ -60,91 +60,91 @@
let s:marginlen = 5
let s:contentlen = s:linelen - (3 * s:marginlen - 1) - strlen(s:asciiart[0])
-function s:trimlogin ()
+function! s:trimlogin ()
let l:trimlogin = strpart($USER, 0, 9)
if strlen(l:trimlogin) == 0
- let l:trimlogin = "marvin"
+ let l:trimlogin = "rfederer"
endif
return l:trimlogin
endfunction
-function s:trimemail ()
+function! s:trimemail ()
let l:trimemail = strpart($MAIL, 0, s:contentlen - 16)
if strlen(l:trimemail) == 0
- let l:trimemail = "marvin@42lausanne.ch"
+ let l:trimemail = "rfederer@student.42lausanne.ch"
endif
return l:trimemail
endfunction
-function s:midgap ()
+function! s:midgap ()
return repeat(' ', s:marginlen - 1)
endfunction
-function s:lmargin ()
+function! s:lmargin ()
return repeat(' ', s:marginlen - strlen(s:start))
endfunction
-function s:rmargin ()
+function! s:rmargin ()
return repeat(' ', s:marginlen - strlen(s:end))
endfunction
-function s:empty_content ()
+function! s:empty_content ()
return repeat(' ', s:contentlen)
endfunction
-function s:left ()
+function! s:left ()
return s:start . s:lmargin()
endfunction
-function s:right ()
+function! s:right ()
return s:rmargin() . s:end
endfunction
-function s:bigline ()
+function! s:bigline ()
return s:start . ' ' . repeat(s:fill, s:linelen - 2 - strlen(s:start) - strlen(s:end)) . ' ' . s:end
endfunction
-function s:logo1 ()
+function! s:logo1 ()
return s:left() . s:empty_content() . s:midgap() . s:asciiart[0] . s:right()
endfunction
-function s:fileline ()
+function! s:fileline ()
let l:trimfile = strpart(fnamemodify(bufname('%'), ':t'), 0, s:contentlen)
return s:left() . l:trimfile . repeat(' ', s:contentlen - strlen(l:trimfile)) . s:midgap() . s:asciiart[1] . s:right()
endfunction
-function s:logo2 ()
+function! s:logo2 ()
return s:left() . s:empty_content() . s:midgap() .s:asciiart[2] . s:right()
endfunction
-function s:coderline ()
+function! s:coderline ()
let l:contentline = "By: ". s:trimlogin () . ' <' . s:trimemail () . '>'
return s:left() . l:contentline . repeat(' ', s:contentlen - strlen(l:contentline)) . s:midgap() . s:asciiart[3] . s:right()
endfunction
-function s:logo3 ()
+function! s:logo3 ()
return s:left() . s:empty_content() . s:midgap() .s:asciiart[4] . s:right()
endfunction
-function s:dateline (prefix, logo)
+function! s:dateline (prefix, logo)
let l:date = strftime("%Y/%m/%d %H:%M:%S")
let l:contentline = a:prefix . ": " . l:date . " by " . s:trimlogin ()
return s:left() . l:contentline . repeat(' ', s:contentlen - strlen(l:contentline)) . s:midgap() . s:asciiart[a:logo] . s:right()
endfunction
-function s:createline ()
+function! s:createline ()
return s:dateline("Created", 5)
endfunction
-function s:updateline ()
+function! s:updateline ()
return s:dateline("Updated", 6)
endfunction
-function s:emptyline ()
+function! s:emptyline ()
return s:start . repeat(' ', s:linelen - strlen(s:start) - strlen(s:end)) . s:end
endfunction
-function s:filetype ()
+function! s:filetype ()
let l:file = fnamemodify(bufname("%"), ':t')
let s:start = '#'
@@ -162,7 +162,7 @@
endfor
endfunction
-function s:insert ()
+function! s:insert ()
call s:filetype ()
call append(0, "")
@@ -179,7 +179,7 @@
call append (0, s:bigline())
endfunction
-function s:update ()
+function! s:update ()
call s:filetype ()
let l:pattern = s:start . repeat(' ', 5 - strlen(s:start)) . "Updated: [0-9]"
@@ -190,6 +190,6 @@
endif
endfunction
-command Stdheader call s:insert ()
+command! Stdheader call s:insert ()
nmap <F1> :Stdheader<CR>
-autocmd BufWritePre * call s:update ()
\ No newline at end of file
+autocmd BufWritePre * call s:update ()

View File

@@ -33,7 +33,7 @@ let s:types = {
\['!', '!', '/'] \['!', '!', '/']
\} \}
function! s:filetype() function s:filetype()
let l:f = s:filename() let l:f = s:filename()
let s:start = '#' let s:start = '#'
@@ -50,17 +50,17 @@ function! s:filetype()
endfunction endfunction
function! s:ascii(n) function s:ascii(n)
return s:asciiart[a:n - 3] return s:asciiart[a:n - 3]
endfunction endfunction
function! s:textline(left, right) function s:textline(left, right)
let l:left = strpart(a:left, 0, s:length - s:margin * 3 - strlen(a:right) + 1) let l:left = strpart(a:left, 0, s:length - s:margin * 3 - strlen(a:right) + 1)
return s:start . repeat(' ', s:margin - strlen(s:start)) . l:left . repeat(' ', s:length - s:margin * 2 - strlen(l:left) - strlen(a:right)) . a:right . repeat(' ', s:margin - strlen(s:end)) . s:end return s:start . repeat(' ', s:margin - strlen(s:start)) . l:left . repeat(' ', s:length - s:margin * 2 - strlen(l:left) - strlen(a:right)) . a:right . repeat(' ', s:margin - strlen(s:end)) . s:end
endfunction endfunction
function! s:line(n) function s:line(n)
if a:n == 1 || a:n == 11 " top and bottom line if a:n == 1 || a:n == 11 " top and bottom line
return s:start . ' ' . repeat(s:fill, s:length - strlen(s:start) - strlen(s:end) - 2) . ' ' . s:end return s:start . ' ' . repeat(s:fill, s:length - strlen(s:start) - strlen(s:end) - 2) . ' ' . s:end
elseif a:n == 2 || a:n == 10 " blank line elseif a:n == 2 || a:n == 10 " blank line
@@ -78,7 +78,7 @@ function! s:line(n)
endif endif
endfunction endfunction
function! s:user() function s:user()
let l:user = $USER let l:user = $USER
if strlen(l:user) == 0 if strlen(l:user) == 0
let l:user = "marvin" let l:user = "marvin"
@@ -86,7 +86,7 @@ function! s:user()
return l:user return l:user
endfunction endfunction
function! s:mail() function s:mail()
let l:mail = $MAIL let l:mail = $MAIL
if strlen(l:mail) == 0 if strlen(l:mail) == 0
let l:mail = "marvin@42.fr" let l:mail = "marvin@42.fr"
@@ -94,7 +94,7 @@ function! s:mail()
return l:mail return l:mail
endfunction endfunction
function! s:filename() function s:filename()
let l:filename = expand("%:t") let l:filename = expand("%:t")
if strlen(l:filename) == 0 if strlen(l:filename) == 0
let l:filename = "< new >" let l:filename = "< new >"
@@ -102,11 +102,11 @@ function! s:filename()
return l:filename return l:filename
endfunction endfunction
function! s:date() function s:date()
return strftime("%Y/%m/%d %H:%M:%S") return strftime("%Y/%m/%d %H:%M:%S")
endfunction endfunction
function! s:insert() function s:insert()
let l:line = 11 let l:line = 11
" empty line after header " empty line after header
@@ -119,7 +119,7 @@ function! s:insert()
endwhile endwhile
endfunction endfunction
function! s:update() function s:update()
call s:filetype() call s:filetype()
if getline(9) =~ s:start . repeat(' ', s:margin - strlen(s:start)) . "Updated: " if getline(9) =~ s:start . repeat(' ', s:margin - strlen(s:start)) . "Updated: "
if &mod if &mod
@@ -131,13 +131,13 @@ function! s:update()
return 1 return 1
endfunction endfunction
function! s:stdheader() function s:stdheader()
if s:update() if s:update()
call s:insert() call s:insert()
endif endif
endfunction endfunction
" Bind command and shortcut " Bind command and shortcut
command! Stdheader call s:stdheader () command Stdheader call s:stdheader ()
map <F1> :Stdheader<CR> map <F1> :Stdheader<CR>
autocmd BufWritePre * call s:update () autocmd BufWritePre * call s:update ()

View File

@@ -1,38 +0,0 @@
--- stdheader.vim 2021-10-25 09:45:16.000000000 +0200
+++ stdheader.vim 2021-10-25 09:28:41.000000000 +0200
@@ -5,7 +5,7 @@
\" +#+ +:+ +#+ ",
\"+#+#+#+#+#+ +#+ ",
\" #+# #+# ",
- \" ### ########.fr "
+ \" ### lausanne.ch "
\]
let s:start = '/*'
@@ -70,7 +70,7 @@
elseif a:n == 4 " filename
return s:textline(s:filename(), s:ascii(a:n))
elseif a:n == 6 " author
- return s:textline("By: " . s:user() . " <" . s:mail() . ">", s:ascii(a:n))
+ return s:textline("By: " . "<" . s:mail() . ">", s:ascii(a:n))
elseif a:n == 8 " created
return s:textline("Created: " . s:date() . " by " . s:user(), s:ascii(a:n))
elseif a:n == 9 " updated
@@ -81,7 +81,7 @@
function! s:user()
let l:user = $USER
if strlen(l:user) == 0
- let l:user = "marvin"
+ let l:user = "rfederer"
endif
return l:user
endfunction
@@ -89,7 +89,7 @@
function! s:mail()
let l:mail = $MAIL
if strlen(l:mail) == 0
- let l:mail = "marvin@42.fr"
+ let l:mail = "rfederer@student.42lausanne.ch"
endif
return l:mail
endfunction