This commit is contained in:
Jack Halford 2016-11-21 18:27:03 +01:00
parent 4cc6576d32
commit f249b18aec
10 changed files with 63 additions and 203 deletions

View file

@ -8,7 +8,7 @@ if expand('%') == '' && !&modified && line('$') <= 1 && getline(1) == ''
let s:wipebuf = bufnr('%') let s:wipebuf = bufnr('%')
endif endif
set shortmess=aoO set shortmess=aoO
badd +51 src/lib_ls_long2.c badd +28 src/lib_ls_long2.c
badd +23 src/ft_ls_long.c badd +23 src/ft_ls_long.c
badd +1 includes/ft_ls.h badd +1 includes/ft_ls.h
badd +60 ~/.tmux.conf badd +60 ~/.tmux.conf
@ -26,8 +26,8 @@ badd +1 Makefile
badd +22 src/lib_error.c badd +22 src/lib_error.c
badd +32 src/lib_dirs.c badd +32 src/lib_dirs.c
badd +31 src/ft_dir_get_ents.c badd +31 src/ft_dir_get_ents.c
badd +9 libft/src/ft_printf/ft_printf.c badd +69 libft/src/ft_printf/ft_printf.c
badd +43 libft/includes/ft_printf.h badd +46 libft/includes/ft_printf.h
badd +2 libft/src/printing/ft_putstr_fd.c badd +2 libft/src/printing/ft_putstr_fd.c
badd +11 libft/includes/libft.h badd +11 libft/includes/libft.h
badd +2 libft/src/ft_printf/lib_fmt.c badd +2 libft/src/ft_printf/lib_fmt.c
@ -44,14 +44,16 @@ badd +25 libft/src/lst/ft_lst_removeif.c
badd +42 ~/.vimrc badd +42 ~/.vimrc
badd +12 src/ft_ent_has_dir.c badd +12 src/ft_ent_has_dir.c
badd +35 src/ft_ent_get_dirs.c badd +35 src/ft_ent_get_dirs.c
badd +1 src/lib_ent.c badd +18 src/lib_ent.c
badd +11 .Makefile.swp badd +11 .Makefile.swp
badd +18 ~/dotfiles/vim.symlink/plugins.vim badd +18 ~/dotfiles/vim.symlink/plugins.vim
badd +22 libft/src/str/ft_strsub.c badd +22 libft/src/str/ft_strsub.c
badd +1 libft/Makefile badd +1 libft/Makefile
badd +14 libft/src/btree/btree_print.c badd +14 libft/src/btree/btree_print.c
badd +14 libft/src/printing/ft_putaddr.c badd +14 libft/src/printing/ft_putaddr.c
badd +1 libft/src/str/ft_strinsert.c badd +13 libft/src/str/ft_strinsert.c
badd +20 libft/src/str/ft_strdel.c
badd +22 libft/src/str/ft_strjoin.c
args src/lib_ls_long2.c args src/lib_ls_long2.c
edit includes/ft_ls.h edit includes/ft_ls.h
set splitbelow splitright set splitbelow splitright
@ -123,19 +125,13 @@ if s:l < 1 | let s:l = 1 | endif
exe s:l exe s:l
normal! zt normal! zt
23 23
normal! 011l normal! 01l
tabedit src/lib_ent.c tabedit src/ft_ls.c
set splitbelow splitright set splitbelow splitright
wincmd _ | wincmd |
vsplit
1wincmd h
wincmd w
set nosplitbelow set nosplitbelow
set nosplitright set nosplitright
wincmd t wincmd t
set winheight=1 winwidth=1 set winheight=1 winwidth=1
exe 'vert 1resize ' . ((&columns * 90 + 90) / 181)
exe 'vert 2resize ' . ((&columns * 90 + 90) / 181)
argglobal argglobal
setlocal fdm=manual setlocal fdm=manual
setlocal fde=0 setlocal fde=0
@ -146,78 +142,13 @@ setlocal fml=1
setlocal fdn=20 setlocal fdn=20
setlocal fen setlocal fen
silent! normal! zE silent! normal! zE
let s:l = 38 - ((37 * winheight(0) + 40) / 80)
if s:l < 1 | let s:l = 1 | endif
exe s:l
normal! zt
38
normal! 01l
wincmd w
argglobal
edit src/ft_ls.c
setlocal fdm=manual
setlocal fde=0
setlocal fmr={{{,}}}
setlocal fdi=#
setlocal fdl=0
setlocal fml=1
setlocal fdn=20
setlocal fen
silent! normal! zE
let s:l = 49 - ((48 * winheight(0) + 40) / 80) let s:l = 49 - ((48 * winheight(0) + 40) / 80)
if s:l < 1 | let s:l = 1 | endif if s:l < 1 | let s:l = 1 | endif
exe s:l exe s:l
normal! zt normal! zt
49 49
normal! 026l normal! 026l
wincmd w tabnext 2
exe 'vert 1resize ' . ((&columns * 90 + 90) / 181)
exe 'vert 2resize ' . ((&columns * 90 + 90) / 181)
tabedit src/lib_ls_long2.c
set splitbelow splitright
set nosplitbelow
set nosplitright
wincmd t
set winheight=1 winwidth=1
argglobal
setlocal fdm=manual
setlocal fde=0
setlocal fmr={{{,}}}
setlocal fdi=#
setlocal fdl=0
setlocal fml=1
setlocal fdn=20
setlocal fen
silent! normal! zE
let s:l = 1 - ((0 * winheight(0) + 40) / 80)
if s:l < 1 | let s:l = 1 | endif
exe s:l
normal! zt
1
normal! 0
tabedit libft/src/str/ft_strinsert.c
set splitbelow splitright
set nosplitbelow
set nosplitright
wincmd t
set winheight=1 winwidth=1
argglobal
setlocal fdm=manual
setlocal fde=0
setlocal fmr={{{,}}}
setlocal fdi=#
setlocal fdl=0
setlocal fml=1
setlocal fdn=20
setlocal fen
silent! normal! zE
let s:l = 1 - ((0 * winheight(0) + 40) / 80)
if s:l < 1 | let s:l = 1 | endif
exe s:l
normal! zt
1
normal! 0
tabnext 4
if exists('s:wipebuf') if exists('s:wipebuf')
silent exe 'bwipe ' . s:wipebuf silent exe 'bwipe ' . s:wipebuf
endif endif

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:22:54 by jhalford #+# #+# */ /* Created: 2016/11/07 13:22:54 by jhalford #+# #+# */
/* Updated: 2016/11/16 10:53:57 by jhalford ### ########.fr */ /* Updated: 2016/11/21 18:20:10 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -43,6 +43,7 @@ struct s_fmt
}; };
int ft_vdprintf(int fd, const char *format, va_list ap); int ft_vdprintf(int fd, const char *format, va_list ap);
int ft_fmtcalc(char **final, char **str, va_list ap);
extern t_conv g_convs[]; extern t_conv g_convs[];

View file

@ -1,97 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* btree_print.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/14 18:06:24 by jhalford #+# #+# */
/* Updated: 2016/11/21 15:13:44 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "btree.h"
enum e_data
{
is_left,
offset,
depth,
};
static int print_t(t_btree *tree,
int data[3], char s[20][255], char *(*printer)(void *))
{
char b[20];
int width;
int left;
int right;
int i;
width = 5;
if (!tree)
return (0);
sprintf(b, "%5s", printer(tree->item));
left = print_t(tree->left, (int[3]){
1, data[offset], data[depth] + 1}, s, printer);
right = print_t(tree->right, (int[3]){
0, data[offset] + left + width, data[depth] + 1}, s, printer);
i = -1;
while (++i < width)
s[data[depth]][data[offset] + left + i] = b[i];
if (data[depth] && data[is_left])
{
i = -1;
while (++i < width)
s[data[depth] - 1][data[offset] + left + width / 2 + i] = '-';
s[data[depth] - 1][data[offset] + left + width / 2] = '.';
}
else if (data[depth] && !data[is_left])
{
i = -1;
while (++i < width)
s[data[depth] - 1][data[offset] - width / 2 + i] = '-';
s[data[depth] - 1][data[offset] + left + width / 2] = '.';
}
i = -1;
while (++i < width)
s[2 * data[depth]][data[offset] + left + i] = b[i];
if (data[depth] && data[is_left])
{
i = -1;
while (++i < width)
s[2 * data[depth] - 1][data[offset] + left + width / 2 + i] = '-';
s[2 * data[depth] - 1][data[offset] + left + width / 2] = '+';
s[2 * data[depth] - 1][
data[offset] + left + right + 3 * width / 2] = '+';
}
else if (data[depth] && !data[is_left])
{
i = -1;
while (++i < width)
s[2 * data[depth] - 1][data[offset] - width / 2 + i] = '-';
s[2 * data[depth] - 1][data[offset] + left + width / 2] = '+';
s[2 * data[depth] - 1][data[offset] - width / 2 - 1] = '+';
}
return (left + width + right);
}
void btree_print(t_btree *tree, char *(*printer)(void *))
{
char s[20][255];
char empty[255];
int i;
i = -1;
while (++i < 20)
sprintf(s[i], "%80s", " ");
sprintf(empty, "%80s", " ");
print_t(tree, (int[3]){0, 0, 0}, s, printer);
i = -1;
while (++i < 20)
{
if (ft_strcmp(s[i], empty) == 0)
break ;
printf("%s\n", s[i]);
}
}

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:33:27 by jhalford #+# #+# */ /* Created: 2016/11/07 13:33:27 by jhalford #+# #+# */
/* Updated: 2016/11/21 15:15:04 by jhalford ### ########.fr */ /* Updated: 2016/11/21 18:22:26 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -44,32 +44,44 @@ int ft_dprintf(int fd, const char *format, ...)
int ft_vdprintf(int fd, const char *format, va_list ap) int ft_vdprintf(int fd, const char *format, va_list ap)
{ {
char *str; char *str;
char *transform; char *tmp;
char final[1000]; char *final;
t_fmt *fmt;
str = (char *)format; str = (char *)format;
ft_bzero(final, 1000); final = ft_strnew(1);
while (*str) while (*str)
{ {
tmp = final;
if (*str == '%') if (*str == '%')
{ {
str++; if (ft_fmtcalc(&final, &str, ap))
if (!(fmt = ft_printf_parse(&str, ap))) return (1);
}
else
final = ft_strjoin(final, (char[]){*str++, 0});
ft_strdel(&tmp);
}
ft_putstr_fd(final, fd);
ft_strdel(&final);
return (0);
}
int ft_fmtcalc(char **final, char **str, va_list ap)
{
t_fmt *fmt;
char *transform;
*str += 1;
if (!(fmt = ft_printf_parse(str, ap)))
return (1); return (1);
if (!fmt->valid) if (!fmt->valid)
ft_strncat(final, &fmt->conversion, 1); ft_strncat(*final, &fmt->conversion, 1);
else else
{ {
transform = ft_transform(fmt, ap); transform = ft_transform(fmt, ap);
ft_strcat(final, transform); *final = ft_strjoin(*final, transform);
free(transform); ft_strdel(&transform);
} }
free(fmt); free(fmt);
}
else
ft_strncat(final, str++, 1);
}
ft_putstr_fd(final, fd);
return (0); return (0);
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:58:00 by jhalford #+# #+# */ /* Created: 2016/11/03 14:58:00 by jhalford #+# #+# */
/* Updated: 2016/11/03 14:58:00 by jhalford ### ########.fr */ /* Updated: 2016/11/21 18:03:21 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -14,6 +14,9 @@
void ft_strdel(char **as) void ft_strdel(char **as)
{ {
if (as)
{
free(*as); free(*as);
*as = NULL; *as = NULL;
}
} }

View file

@ -1,3 +1,15 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strinsert.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/21 18:21:57 by jhalford #+# #+# */
/* Updated: 2016/11/21 18:21:57 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h" #include "libft.h"
char *ft_strinsert(char *str, char c, int n) char *ft_strinsert(char *str, char c, int n)

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/03 14:58:18 by jhalford #+# #+# */ /* Created: 2016/11/03 14:58:18 by jhalford #+# #+# */
/* Updated: 2016/11/10 10:14:09 by jhalford ### ########.fr */ /* Updated: 2016/11/21 18:10:22 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 15:00:05 by jhalford #+# #+# */ /* Created: 2016/11/07 15:00:05 by jhalford #+# #+# */
/* Updated: 2016/11/21 17:22:13 by jhalford ### ########.fr */ /* Updated: 2016/11/21 18:23:05 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -14,8 +14,6 @@
void ft_ent_filter(t_list **ent, int opts) void ft_ent_filter(t_list **ent, int opts)
{ {
/* (void)ent; */
/* (void)opts; */
if (!(opts & OPTS_LA)) if (!(opts & OPTS_LA))
ft_lst_delif(ent, ".", &ft_lsdata_cmp0, &ft_ent_free); ft_lst_delif(ent, ".", &ft_lsdata_cmp0, &ft_ent_free);
} }

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 15:01:01 by jhalford #+# #+# */ /* Created: 2016/11/07 15:01:01 by jhalford #+# #+# */
/* Updated: 2016/11/21 17:29:24 by jhalford ### ########.fr */ /* Updated: 2016/11/21 17:54:05 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */

View file

@ -6,7 +6,7 @@
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */ /* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 15:00:15 by jhalford #+# #+# */ /* Created: 2016/11/07 15:00:15 by jhalford #+# #+# */
/* Updated: 2016/11/21 14:33:22 by jhalford ### ########.fr */ /* Updated: 2016/11/21 18:23:52 by jhalford ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */