diff --git a/42sh/OLD/OLD_RL/rl_copy_function.c.old b/42sh/OLD/OLD_RL/rl_copy_function.c.old deleted file mode 100644 index abdc5005..00000000 --- a/42sh/OLD/OLD_RL/rl_copy_function.c.old +++ /dev/null @@ -1,23 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* rl_copy_function.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: sbenning +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/09 14:01:31 by sbenning #+# #+# */ -/* Updated: 2016/12/09 18:22:38 by sbenning ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_readline.h" - -int rl_copy_function(t_line *line, long int input) -{ - if (line->clipboard) - ft_memdel((void **)&line->clipboard); - if (rl_clipboard_new(line) < 0) - return (-1); - return (0); - (void)input; -} diff --git a/42sh/OLD/OLD_RL/rl_cut_function.c.old b/42sh/OLD/OLD_RL/rl_cut_function.c.old deleted file mode 100644 index 0319ea0b..00000000 --- a/42sh/OLD/OLD_RL/rl_cut_function.c.old +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* rl_cut_function.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: sbenning +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/09 14:19:20 by sbenning #+# #+# */ -/* Updated: 2016/12/09 16:24:12 by sbenning ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_readline.h" - -int rl_cut_function(t_line *line, long int input) -{ - if (line->clipboard) - ft_memdel((void **)&line->clipboard); - if (rl_clipboard_new_cut(line) < 0) - return (-1); - rl_reset_display_post(line); - return (0); - (void)input; -} diff --git a/42sh/OLD/OLD_RL/rl_dquote_function.c.old b/42sh/OLD/OLD_RL/rl_dquote_function.c.old deleted file mode 100644 index a6266282..00000000 --- a/42sh/OLD/OLD_RL/rl_dquote_function.c.old +++ /dev/null @@ -1,25 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* rl_dquote_function.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: sbenning +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/09 00:46:36 by sbenning #+# #+# */ -/* Updated: 2016/12/10 12:05:12 by sbenning ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_readline.h" - -int rl_dquote_function(t_line *line, long int input) -{ - if (RL_NOT(line->bitset, RL_ESC)) - { - if (RL_IS(line->bitset, RL_DQUOTE)) - RL_UNSET(line->bitset, RL_DQUOTE); - else - RL_SET(line->bitset, RL_DQUOTE); - } - return (rl_default_function(line, input)); -} diff --git a/42sh/OLD/OLD_RL/rl_end_function.c.old b/42sh/OLD/OLD_RL/rl_end_function.c.old deleted file mode 100644 index 7e66bafe..00000000 --- a/42sh/OLD/OLD_RL/rl_end_function.c.old +++ /dev/null @@ -1,25 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* rl_end_function.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: sbenning +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/08 19:29:15 by sbenning #+# #+# */ -/* Updated: 2016/12/09 12:04:48 by sbenning ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_readline.h" - -int rl_end_function(t_line *line, long int input) -{ - if (RL_IS(line->bitset, RL_SELECT)) - RL_UNSET(line->bitset, RL_SELECT); - if (line->pos == line->used) - return (0); - curs_forward(&line->curs, line->used - line->pos); - line->pos = line->used; - return (0); - (void)input; -} diff --git a/42sh/OLD/OLD_RL/rl_esc_function.c.old b/42sh/OLD/OLD_RL/rl_esc_function.c.old deleted file mode 100644 index ee1e85bf..00000000 --- a/42sh/OLD/OLD_RL/rl_esc_function.c.old +++ /dev/null @@ -1,20 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* rl_esc_function.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: sbenning +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/09 00:40:22 by sbenning #+# #+# */ -/* Updated: 2016/12/10 12:05:51 by sbenning ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_readline.h" - -int rl_esc_function(t_line *line, long int input) -{ - if (RL_NOT(line->bitset, RL_ESC)) - RL_SET(line->bitset, RL_ESC); - return (rl_default_function(line, input)); -} diff --git a/42sh/OLD/OLD_RL/rl_home_function.c.old b/42sh/OLD/OLD_RL/rl_home_function.c.old deleted file mode 100644 index 7e76f263..00000000 --- a/42sh/OLD/OLD_RL/rl_home_function.c.old +++ /dev/null @@ -1,25 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* rl_home_function.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: sbenning +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/08 19:28:10 by sbenning #+# #+# */ -/* Updated: 2016/12/09 12:04:47 by sbenning ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_readline.h" - -int rl_home_function(t_line *line, long int input) -{ - if (RL_IS(line->bitset, RL_SELECT)) - RL_UNSET(line->bitset, RL_SELECT); - if (!line->pos) - return (0); - curs_backward(&line->curs, line->pos); - line->pos = 0; - return (0); - (void)input; -} diff --git a/42sh/OLD/OLD_RL/rl_insert_function.c.old b/42sh/OLD/OLD_RL/rl_insert_function.c.old deleted file mode 100644 index cf986e29..00000000 --- a/42sh/OLD/OLD_RL/rl_insert_function.c.old +++ /dev/null @@ -1,23 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* rl_insert_function.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: sbenning +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/09 18:28:01 by sbenning #+# #+# */ -/* Updated: 2016/12/09 18:29:33 by sbenning ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_readline.h" - -int rl_insert_function(t_line *line, long int input) -{ - if (RL_IS(line->bitset, RL_INSERT)) - RL_UNSET(line->bitset, RL_INSERT); - else - RL_SET(line->bitset, RL_INSERT); - return (0); - (void)input; -} diff --git a/42sh/OLD/OLD_RL/rl_left_function.c.old b/42sh/OLD/OLD_RL/rl_left_function.c.old deleted file mode 100644 index f11b35f1..00000000 --- a/42sh/OLD/OLD_RL/rl_left_function.c.old +++ /dev/null @@ -1,25 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* rl_left_function.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: sbenning +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/08 19:17:13 by sbenning #+# #+# */ -/* Updated: 2016/12/09 12:37:48 by sbenning ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_readline.h" - -int rl_left_function(t_line *line, long int input) -{ - if (RL_IS(line->bitset, RL_SELECT)) - RL_UNSET(line->bitset, RL_SELECT); - if (!line->pos) - return (0); - curs_backward(&line->curs, 1); - line->pos -= 1; - return (0); - (void)input; -} diff --git a/42sh/OLD/OLD_RL/rl_nl_function.c.old b/42sh/OLD/OLD_RL/rl_nl_function.c.old deleted file mode 100644 index 8e212af2..00000000 --- a/42sh/OLD/OLD_RL/rl_nl_function.c.old +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* rl_nl_function.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: sbenning +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/08 19:03:22 by sbenning #+# #+# */ -/* Updated: 2016/12/12 12:09:12 by sbenning ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_readline.h" - -int rl_nl_function(t_line *line, long int input) -{ - if (RL_IS(line->bitset, RL_SELECT)) - RL_UNSET(line->bitset, RL_SELECT); - RL_SET(line->bitset, RL_STACK); - if (RL_NOT(line->bitset, RL_QUOTING)) - RL_SET(line->bitset, RL_FINISH); - return (0); - (void)input; -} diff --git a/42sh/OLD/OLD_RL/rl_pagedown_function.c.old b/42sh/OLD/OLD_RL/rl_pagedown_function.c.old deleted file mode 100644 index bd746dd4..00000000 --- a/42sh/OLD/OLD_RL/rl_pagedown_function.c.old +++ /dev/null @@ -1,30 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* rl_pagedown_function.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: sbenning +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/08 19:32:26 by sbenning #+# #+# */ -/* Updated: 2016/12/09 12:04:19 by sbenning ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_readline.h" - -int rl_pagedown_function(t_line *line, long int input) -{ - int len; - - if (RL_IS(line->bitset, RL_SELECT)) - RL_UNSET(line->bitset, RL_SELECT); - if (line->pos == line->used) - return (0); - len = line->used - line->pos; - len = (line->curs.win_co > len ? len : line->curs.win_co); - curs_forward(&line->curs, len); - line->pos += len; - return (0); - (void)input; -} - diff --git a/42sh/OLD/OLD_RL/rl_pageup_function.c.old b/42sh/OLD/OLD_RL/rl_pageup_function.c.old deleted file mode 100644 index c1402d41..00000000 --- a/42sh/OLD/OLD_RL/rl_pageup_function.c.old +++ /dev/null @@ -1,28 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* rl_pageup_function.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: sbenning +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/08 19:32:16 by sbenning #+# #+# */ -/* Updated: 2016/12/09 12:04:07 by sbenning ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_readline.h" - -int rl_pageup_function(t_line *line, long int input) -{ - int len; - - if (RL_IS(line->bitset, RL_SELECT)) - RL_UNSET(line->bitset, RL_SELECT); - if (!line->pos) - return (0); - len = (line->curs.win_co > line->pos ? line->pos : line->curs.win_co); - curs_backward(&line->curs, len); - line->pos -= len; - return (0); - (void)input; -} diff --git a/42sh/OLD/OLD_RL/rl_paste_function.c.old b/42sh/OLD/OLD_RL/rl_paste_function.c.old deleted file mode 100644 index 42a2fa79..00000000 --- a/42sh/OLD/OLD_RL/rl_paste_function.c.old +++ /dev/null @@ -1,41 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* rl_paste_function.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: sbenning +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/09 14:40:45 by sbenning #+# #+# */ -/* Updated: 2016/12/09 18:22:38 by sbenning ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_readline.h" - -int rl_paste_function(t_line *line, long int input) -{ - int len; - - if (RL_IS(line->bitset, RL_SELECT)) - RL_UNSET(line->bitset, RL_SELECT); - if (!line->clipboard) - return (0); - len = ft_strlen(line->clipboard); - if (!len) - return (0); - if (RL_IS(line->bitset, RL_INSERT)) - { - if (input_move(line, line->clipboard, len) < 0) - return (-1); - } - else - { - if (input_maj(line, line->clipboard, len) < 0) - return (-1); - } - rl_reset_display_post(line); - curs_forward(&line->curs, len); - line->pos += len; - return (0); - (void)input; -} diff --git a/42sh/OLD/OLD_RL/rl_quote_function.c.old b/42sh/OLD/OLD_RL/rl_quote_function.c.old deleted file mode 100644 index 834f6c61..00000000 --- a/42sh/OLD/OLD_RL/rl_quote_function.c.old +++ /dev/null @@ -1,25 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* rl_quote_function.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: sbenning +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/09 00:45:34 by sbenning #+# #+# */ -/* Updated: 2016/12/10 12:05:26 by sbenning ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_readline.h" - -int rl_quote_function(t_line *line, long int input) -{ - if (RL_NOT(line->bitset, RL_ESC)) - { - if (RL_IS(line->bitset, RL_QUOTE)) - RL_UNSET(line->bitset, RL_QUOTE); - else - RL_SET(line->bitset, RL_QUOTE); - } - return (rl_default_function(line, input)); -} diff --git a/42sh/OLD/OLD_RL/rl_retarr_function.c.old b/42sh/OLD/OLD_RL/rl_retarr_function.c.old deleted file mode 100644 index ad92bb15..00000000 --- a/42sh/OLD/OLD_RL/rl_retarr_function.c.old +++ /dev/null @@ -1,27 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* rl_retarr_function.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: sbenning +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/08 20:06:50 by sbenning #+# #+# */ -/* Updated: 2016/12/09 12:04:31 by sbenning ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_readline.h" - -int rl_retarr_function(t_line *line, long int input) -{ - if (RL_IS(line->bitset, RL_SELECT)) - RL_UNSET(line->bitset, RL_SELECT); - if (!line->pos) - return (0); - input_remove(line, 1); - curs_backward(&line->curs, 1); - line->pos -= 1; - rl_reset_display_post(line); - return (0); - (void)input; -} diff --git a/42sh/OLD/OLD_RL/rl_right_function.c.old b/42sh/OLD/OLD_RL/rl_right_function.c.old deleted file mode 100644 index e4172a86..00000000 --- a/42sh/OLD/OLD_RL/rl_right_function.c.old +++ /dev/null @@ -1,25 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* rl_right_function.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: sbenning +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/08 19:20:15 by sbenning #+# #+# */ -/* Updated: 2016/12/09 12:03:24 by sbenning ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_readline.h" - -int rl_right_function(t_line *line, long int input) -{ - if (RL_IS(line->bitset, RL_SELECT)) - RL_UNSET(line->bitset, RL_SELECT); - if (line->pos == line->used) - return (0); - curs_forward(&line->curs, 1); - line->pos += 1; - return (0); - (void)input; -} diff --git a/42sh/OLD/OLD_RL/rl_select_end_function.c.old b/42sh/OLD/OLD_RL/rl_select_end_function.c.old deleted file mode 100644 index 785785d7..00000000 --- a/42sh/OLD/OLD_RL/rl_select_end_function.c.old +++ /dev/null @@ -1,27 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* rl_select_end_function.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: sbenning +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/09 13:19:35 by sbenning #+# #+# */ -/* Updated: 2016/12/10 12:07:40 by sbenning ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_readline.h" - -int rl_select_end_function(t_line *line, long int input) -{ - int ret; - - if (line->pos == line->used) - return (0); - if (RL_NOT(line->bitset, RL_SELECT)) - line->select = line->pos; - ret = rl_end_function(line, input); - RL_SET(line->bitset, RL_SELECT); - rl_reset_display_ante(line); - return (ret); -} diff --git a/42sh/OLD/OLD_RL/rl_select_home_function.c.old b/42sh/OLD/OLD_RL/rl_select_home_function.c.old deleted file mode 100644 index 2f59596d..00000000 --- a/42sh/OLD/OLD_RL/rl_select_home_function.c.old +++ /dev/null @@ -1,27 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* rl_select_home_function.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: sbenning +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/09 13:18:43 by sbenning #+# #+# */ -/* Updated: 2016/12/10 12:07:55 by sbenning ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_readline.h" - -int rl_select_home_function(t_line *line, long int input) -{ - int ret; - - if (!line->pos) - return (0); - if (RL_NOT(line->bitset, RL_SELECT)) - line->select = line->pos; - ret = rl_home_function(line, input); - RL_SET(line->bitset, RL_SELECT); - rl_reset_display_post(line); - return (ret); -} diff --git a/42sh/OLD/OLD_RL/rl_select_left_function.c.old b/42sh/OLD/OLD_RL/rl_select_left_function.c.old deleted file mode 100644 index a3801cb0..00000000 --- a/42sh/OLD/OLD_RL/rl_select_left_function.c.old +++ /dev/null @@ -1,27 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* rl_select_left_function.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: sbenning +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/09 03:06:59 by sbenning #+# #+# */ -/* Updated: 2016/12/10 12:08:10 by sbenning ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_readline.h" - -int rl_select_left_function(t_line *line, long int input) -{ - int ret; - - if (!line->pos) - return (0); - if (RL_NOT(line->bitset, RL_SELECT)) - line->select = line->pos; - ret = rl_left_function(line, input); - RL_SET(line->bitset, RL_SELECT); - rl_reset_display_post(line); - return (ret); -} diff --git a/42sh/OLD/OLD_RL/rl_select_pagedown_function.c.old b/42sh/OLD/OLD_RL/rl_select_pagedown_function.c.old deleted file mode 100644 index 3f0cab1a..00000000 --- a/42sh/OLD/OLD_RL/rl_select_pagedown_function.c.old +++ /dev/null @@ -1,28 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* rl_select_right_function.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: sbenning +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/09 03:16:57 by sbenning #+# #+# */ -/* Updated: 2016/12/10 12:08:30 by sbenning ### ########.fr */ -/* */ -/* ************************************************************************** */ - - -#include "ft_readline.h" - -int rl_select_pagedown_function(t_line *line, long int input) -{ - int ret; - - if (line->pos == line->used) - return (0); - if (RL_NOT(line->bitset, RL_SELECT)) - line->select = line->pos; - ret = rl_pagedown_function(line, input); - RL_SET(line->bitset, RL_SELECT); - rl_reset_display_ante(line); - return (ret); -} diff --git a/42sh/OLD/OLD_RL/rl_select_pageup_function.c.old b/42sh/OLD/OLD_RL/rl_select_pageup_function.c.old deleted file mode 100644 index aff40bc9..00000000 --- a/42sh/OLD/OLD_RL/rl_select_pageup_function.c.old +++ /dev/null @@ -1,27 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* rl_select_left_function.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: sbenning +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/09 03:06:59 by sbenning #+# #+# */ -/* Updated: 2016/12/10 12:08:47 by sbenning ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_readline.h" - -int rl_select_pageup_function(t_line *line, long int input) -{ - int ret; - - if (!line->pos) - return (0); - if (RL_NOT(line->bitset, RL_SELECT)) - line->select = line->pos; - ret = rl_pageup_function(line, input); - RL_SET(line->bitset, RL_SELECT); - rl_reset_display_post(line); - return (ret); -} diff --git a/42sh/OLD/OLD_RL/rl_select_right_function.c.old b/42sh/OLD/OLD_RL/rl_select_right_function.c.old deleted file mode 100644 index 28495e7f..00000000 --- a/42sh/OLD/OLD_RL/rl_select_right_function.c.old +++ /dev/null @@ -1,28 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* rl_select_right_function.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: sbenning +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/09 03:16:57 by sbenning #+# #+# */ -/* Updated: 2016/12/09 12:37:31 by sbenning ### ########.fr */ -/* */ -/* ************************************************************************** */ - - -#include "ft_readline.h" - -int rl_select_right_function(t_line *line, long int input) -{ - int ret; - - if (line->pos == line->used) - return (0); - if (!RL_IS(line->bitset, RL_SELECT)) - line->select = line->pos; - ret = rl_right_function(line, input); - RL_SET(line->bitset, RL_SELECT); - rl_reset_display_ante(line); - return (ret); -} diff --git a/42sh/OLD/OLD_RL/rl_select_wleft_function.c.old b/42sh/OLD/OLD_RL/rl_select_wleft_function.c.old deleted file mode 100644 index 40843bd6..00000000 --- a/42sh/OLD/OLD_RL/rl_select_wleft_function.c.old +++ /dev/null @@ -1,27 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* rl_select_left_function.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: sbenning +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/09 03:06:59 by sbenning #+# #+# */ -/* Updated: 2016/12/10 12:09:03 by sbenning ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_readline.h" - -int rl_select_wleft_function(t_line *line, long int input) -{ - int ret; - - if (!line->pos) - return (0); - if (RL_NOT(line->bitset, RL_SELECT)) - line->select = line->pos; - ret = rl_wleft_function(line, input); - RL_SET(line->bitset, RL_SELECT); - rl_reset_display_post(line); - return (ret); -} diff --git a/42sh/OLD/OLD_RL/rl_select_wright_function.c.old b/42sh/OLD/OLD_RL/rl_select_wright_function.c.old deleted file mode 100644 index 96527e9f..00000000 --- a/42sh/OLD/OLD_RL/rl_select_wright_function.c.old +++ /dev/null @@ -1,28 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* rl_select_right_function.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: sbenning +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/09 03:16:57 by sbenning #+# #+# */ -/* Updated: 2016/12/10 12:09:16 by sbenning ### ########.fr */ -/* */ -/* ************************************************************************** */ - - -#include "ft_readline.h" - -int rl_select_wright_function(t_line *line, long int input) -{ - int ret; - - if (line->pos == line->used) - return (0); - if (RL_NOT(line->bitset, RL_SELECT)) - line->select = line->pos; - ret = rl_wright_function(line, input); - RL_SET(line->bitset, RL_SELECT); - rl_reset_display_ante(line); - return (ret); -} diff --git a/42sh/OLD/OLD_RL/rl_suppr_function.c.old b/42sh/OLD/OLD_RL/rl_suppr_function.c.old deleted file mode 100644 index 73e5fccf..00000000 --- a/42sh/OLD/OLD_RL/rl_suppr_function.c.old +++ /dev/null @@ -1,25 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* rl_suppr_function.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: sbenning +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/09 02:23:56 by sbenning #+# #+# */ -/* Updated: 2016/12/09 12:04:43 by sbenning ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_readline.h" - -int rl_suppr_function(t_line *line, long int input) -{ - if (RL_IS(line->bitset, RL_SELECT)) - RL_UNSET(line->bitset, RL_SELECT); - if (line->pos == line->used) - return (0); - input_remove(line, -1); - rl_reset_display_post(line); - return (0); - (void)input; -} diff --git a/42sh/OLD/OLD_RL/rl_wleft_function.c.old b/42sh/OLD/OLD_RL/rl_wleft_function.c.old deleted file mode 100644 index b869f74b..00000000 --- a/42sh/OLD/OLD_RL/rl_wleft_function.c.old +++ /dev/null @@ -1,45 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* rl_left_function.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: sbenning +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/08 19:17:13 by sbenning #+# #+# */ -/* Updated: 2016/12/09 12:03:42 by sbenning ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_readline.h" - -static int rl_previous_word(t_line *line) -{ - int i; - int len; - - if (RL_IS(line->bitset, RL_SELECT)) - RL_UNSET(line->bitset, RL_SELECT); - i = 0; - while (line->input[i] && i < line->pos) - { - if (!i && line->input[i] != ' ') - len = i; - if (i && line->input[i - 1] == ' ' && line->input[i] != ' ') - len = i; - i++; - } - return (line->pos - len); -} - -int rl_wleft_function(t_line *line, long int input) -{ - size_t len; - - if (!line->pos) - return (0); - len = rl_previous_word(line); - curs_backward(&line->curs, len); - line->pos -= len; - return (0); - (void)input; -} diff --git a/42sh/OLD/OLD_RL/rl_wright_function.c.old b/42sh/OLD/OLD_RL/rl_wright_function.c.old deleted file mode 100644 index 6ead739d..00000000 --- a/42sh/OLD/OLD_RL/rl_wright_function.c.old +++ /dev/null @@ -1,44 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* rl_right_function.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: sbenning +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/08 19:20:15 by sbenning #+# #+# */ -/* Updated: 2016/12/09 12:03:54 by sbenning ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "ft_readline.h" - -static int rl_next_word(t_line *line) -{ - int i; - int flag; - - if (RL_IS(line->bitset, RL_SELECT)) - RL_UNSET(line->bitset, RL_SELECT); - i = line->pos; - flag = 0; - while (line->input[i] && (line->input[i] == ' ' || !flag)) - { - if (line->input[i] == ' ') - flag = 1; - i++; - } - return (i - line->pos); -} - -int rl_wright_function(t_line *line, long int input) -{ - size_t len; - - if (line->pos == line->used) - return (0); - len = rl_next_word(line); - curs_forward(&line->curs, len); - line->pos += len; - return (0); - (void)input; -} diff --git a/42sh/OLD/ft_clear_line.c b/42sh/OLD/ft_clear_line.c deleted file mode 100644 index 24648a70..00000000 --- a/42sh/OLD/ft_clear_line.c +++ /dev/null @@ -1,21 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_clear_line.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/10 13:42:45 by jhalford #+# #+# */ -/* Updated: 2016/11/10 13:42:59 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "line_editing.h" - -int ft_clear_line(t_data *data, char *buf) -{ - ft_line_end(data, buf); - while (ft_key_del(data, buf)) - ; - return (1); -} diff --git a/42sh/OLD/ft_cursor_left.c b/42sh/OLD/ft_cursor_left.c deleted file mode 100644 index 62ba6d74..00000000 --- a/42sh/OLD/ft_cursor_left.c +++ /dev/null @@ -1,30 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_cursor_left.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/10 13:43:10 by jhalford #+# #+# */ -/* Updated: 2016/12/03 15:26:16 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "line_editing.h" - -int ft_cursor_left(t_data *data, char *buf) -{ - char *res; - - res = NULL; - (void)buf; - if (!data->line.input_pos) - return (0); - if (data->line.input[data->line.input_pos - 1] == '\n') - return (0); - data->line.input_pos--; - if (!(res = tgetstr("le", NULL))) - return (-1); - tputs(tgoto(res, 0, 0), 0, &ft_putchar); - return (1); -} diff --git a/42sh/OLD/ft_cursor_right.c b/42sh/OLD/ft_cursor_right.c deleted file mode 100644 index 60ddedc4..00000000 --- a/42sh/OLD/ft_cursor_right.c +++ /dev/null @@ -1,30 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_cursor_right.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/10 13:43:31 by jhalford #+# #+# */ -/* Updated: 2016/12/03 15:26:46 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "line_editing.h" - -int ft_cursor_right(t_data *data, char *buf) -{ - char *res; - - res = NULL; - (void)buf; - if (!data->line.input[data->line.input_pos]) - return (0); - if (data->line.input[data->line.input_pos] == '\n') - return (0); - data->line.input_pos++; - if ((res = tgetstr("nd", NULL)) == NULL) - return (-1); - tputs(tgoto(res, 0, 0), 0, &ft_putchar); - return (1); -} diff --git a/42sh/OLD/ft_history_add.c b/42sh/OLD/ft_history_add.c deleted file mode 100644 index 95490c18..00000000 --- a/42sh/OLD/ft_history_add.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_history_add.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/10 13:43:40 by jhalford #+# #+# */ -/* Updated: 2016/12/07 16:52:48 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "line_editing.h" - -int ft_history_add(t_data *data) -{ - t_dlist *new; - char *str; - - str = data->line.input; - if (data->line.history) - while (data->line.history->next) - data->line.history = data->line.history->next; - if (!data->line.history->prev - || ft_strcmp(str, (char *)data->line.history->prev->content)) - { - new = ft_dlstnew(str, sizeof(char) * (ft_strlen(str) + 1)); - ft_dlstadd_before(&data->line.history, new); - data->line.history = data->line.history->next; - ft_strdel((char **)&data->line.history->content); - } - return (0); -} diff --git a/42sh/OLD/ft_history_down.c b/42sh/OLD/ft_history_down.c deleted file mode 100644 index 989786a9..00000000 --- a/42sh/OLD/ft_history_down.c +++ /dev/null @@ -1,31 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_history_down.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/10 13:44:06 by jhalford #+# #+# */ -/* Updated: 2016/12/03 15:27:08 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "line_editing.h" - -int ft_history_down(t_data *data, char *buf) -{ - int i; - char *str; - - (void)buf; - if (!data->line.history) - return (0); - if (!data->line.history->next) - return (0); - data->line.history = data->line.history->next; - str = data->line.history->content; - i = 0; - if (!data->line.history->next) - ft_strdel(&str); - return (0); -} diff --git a/42sh/OLD/ft_history_up.c b/42sh/OLD/ft_history_up.c deleted file mode 100644 index ccc01d64..00000000 --- a/42sh/OLD/ft_history_up.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_history_up.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/10 13:44:15 by jhalford #+# #+# */ -/* Updated: 2016/12/07 16:52:28 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "line_editing.h" - -int ft_history_up(t_data *data, char *buf) -{ - int i; - char *str; - - (void)buf; - if (!data->line.history) - return (0); - if (!data->line.history->prev) - return (0); - data->line.history = data->line.history->prev; - str = data->line.history->content; - i = 0; - return (0); -} diff --git a/42sh/OLD/ft_input_is_escaped.c b/42sh/OLD/ft_input_is_escaped.c deleted file mode 100644 index 069a9647..00000000 --- a/42sh/OLD/ft_input_is_escaped.c +++ /dev/null @@ -1,21 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_input_is_escaped.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/10 13:44:17 by jhalford #+# #+# */ -/* Updated: 2016/11/10 13:44:17 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "line_editing.h" - -int ft_input_is_escaped(t_dlist *input_chain) -{ - if (*(char *)input_chain->content == '\\') - return (1); - else - return (0); -} diff --git a/42sh/OLD/ft_interactive_sh.c b/42sh/OLD/ft_interactive_sh.c deleted file mode 100644 index ece0bda1..00000000 --- a/42sh/OLD/ft_interactive_sh.c +++ /dev/null @@ -1,68 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_interactive_sh.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/01 12:14:12 by jhalford #+# #+# */ -/* Updated: 2016/12/07 17:27:25 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "line_editing.h" - -t_stof g_keys[] = { - {FT_KEY_C_K, NULL}, - {FT_KEY_TAB, &ft_key_default}, - {FT_KEY_C_H, &ft_line_start}, - {FT_KEY_C_L, &ft_line_end}, - {FT_KEY_C_U, &ft_clear_line}, - {FT_KEY_ESC, NULL}, - /* {FT_KEY_UP, &ft_history_up}, */ - /* {FT_KEY_DOWN, &ft_history_down}, */ - {FT_KEY_UP, NULL}, - {FT_KEY_DOWN, NULL}, - /* {FT_KEY_C_UP, &ft_line_up}, */ - /* {FT_KEY_C_DOWN, &ft_line_down}, */ - {FT_KEY_C_UP, NULL}, - {FT_KEY_C_DOWN, NULL}, - {FT_KEY_RIGHT, &ft_cursor_right}, - {FT_KEY_LEFT, &ft_cursor_left}, - {FT_KEY_C_RIGHT, &ft_word_right}, - {FT_KEY_C_LEFT, &ft_word_left}, - {FT_KEY_ENTER, &ft_key_enter}, - {FT_KEY_DEL, &ft_key_del}, - {FT_KEY_C_D, &ft_key_ctrl_d}, - {FT_KEY_C_C, &ft_key_ctrl_c}, - {FT_KEY_C_Z, NULL}, - {NULL, &ft_key_default}, -}; - -int ft_interactive_sh(t_data *data) -{ - char buf[4]; - int ret; - int i; - - if ((input_init(data))) - return (-1); - while (1) - { - ft_bzero(buf, 4); - ret = read(0, buf, 4); - i = 0; - while (g_keys[i].name && ft_strcmp(buf, g_keys[i].name)) - i++; - if (!g_keys[i].f) - continue ; - if ((ret = (*g_keys[i].f)(data, buf)) < 0) - return (-1); - else if (ret == 2) - { - ft_lstdel(&data->line.qstack, &ft_lst_cfree); - ft_set_termios(data, 0); - return (0); - } - } -} diff --git a/42sh/OLD/ft_key_ctrl_c.c b/42sh/OLD/ft_key_ctrl_c.c deleted file mode 100644 index eebb7d02..00000000 --- a/42sh/OLD/ft_key_ctrl_c.c +++ /dev/null @@ -1,23 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_key_ctrl_c.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/10 13:44:24 by jhalford #+# #+# */ -/* Updated: 2016/12/03 15:29:09 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "line_editing.h" - -int ft_key_ctrl_c(t_data *data, char *buf) -{ - (void)buf; - ft_strdel(&data->line.input); - data->line.input = ft_memalloc(10); - ft_putendl(""); - ft_prompt(); - return (0); -} diff --git a/42sh/OLD/ft_key_ctrl_d.c b/42sh/OLD/ft_key_ctrl_d.c deleted file mode 100644 index c882cc99..00000000 --- a/42sh/OLD/ft_key_ctrl_d.c +++ /dev/null @@ -1,22 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_key_ctrl_d.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/10 13:44:24 by jhalford #+# #+# */ -/* Updated: 2016/12/07 18:12:29 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "line_editing.h" - -int ft_key_ctrl_d(t_data *data, char *buf) -{ - (void)data; - (void)buf; - data_exit(data); - ft_putendl("exit"); - exit(0); -} diff --git a/42sh/OLD/ft_key_default.c b/42sh/OLD/ft_key_default.c deleted file mode 100644 index 4cb66621..00000000 --- a/42sh/OLD/ft_key_default.c +++ /dev/null @@ -1,33 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_key_default.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/28 18:45:23 by jhalford #+# #+# */ -/* Updated: 2016/12/09 14:48:01 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "line_editing.h" - -int ft_key_default(t_data *data, char *buf) -{ - char *res; - char *tmp; - - tmp = data->line.input; - data->line.input = ft_strinsert(data->line.input, *buf, data->line.input_pos); - data->line.input_pos++; - ft_strdel(&tmp); - qstate_update(data, *buf); - if ((res = tgetstr("IC", NULL))) - { - tputs(tgoto(res, 0, 0), 1, &ft_putchar); - ft_putchar(buf[0]); - return (0); - } - else - return (-1); -} diff --git a/42sh/OLD/ft_key_del.c b/42sh/OLD/ft_key_del.c deleted file mode 100644 index 4ce4e6fd..00000000 --- a/42sh/OLD/ft_key_del.c +++ /dev/null @@ -1,42 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_key_del.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/29 15:57:43 by jhalford #+# #+# */ -/* Updated: 2016/12/03 15:30:02 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "line_editing.h" - -int ft_key_del(t_data *data, char *buf) -{ - char *res; - - (void)data; - (void)buf; - if (!data->line.input_pos) - return (0); - if (data->line.input[data->line.input_pos - 1] == '\n') - return (0); - qstate_update(data, -1); - ft_strcpy(data->line.input + data->line.input_pos - 1, - data->line.input + data->line.input_pos); - data->line.input_pos--; - if ((res = tgetstr("le", NULL)) == NULL) - { - ft_printf("le error\n"); - return (-1); - } - tputs(tgoto(res, 0, 0), 0, &ft_putchar); - if ((res = tgetstr("DC", NULL)) == NULL) - { - ft_printf("DC error\n"); - return (-1); - } - tputs(tgoto(res, 0, 0), 0, &ft_putchar); - return (1); -} diff --git a/42sh/OLD/ft_key_enter.c b/42sh/OLD/ft_key_enter.c deleted file mode 100644 index 715b48a6..00000000 --- a/42sh/OLD/ft_key_enter.c +++ /dev/null @@ -1,26 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_key_enter.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/29 15:56:36 by jhalford #+# #+# */ -/* Updated: 2016/12/07 17:35:06 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "line_editing.h" - -int ft_key_enter(t_data *data, char *buf) -{ - (void)buf; - if (*(t_qstate*)data->line.qstack->content == Q_NONE) - { - ft_putchar('\n'); - return (2); - } - ft_key_default(data, buf); - ft_printf("> "); - return (0); -} diff --git a/42sh/OLD/ft_line_down.c b/42sh/OLD/ft_line_down.c deleted file mode 100644 index b04e747d..00000000 --- a/42sh/OLD/ft_line_down.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_line_down.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/10 13:44:31 by jhalford #+# #+# */ -/* Updated: 2016/11/10 13:44:31 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "line_editing.h" - -int ft_line_go_down(t_dlist **input_chain) -{ - char *res; - - (void)input_chain; - if ((res = tgetstr("up", NULL)) == NULL) - return (-1); - tputs(tgoto(res, 0, 0), 0, &ft_putchar); - return (0); -} diff --git a/42sh/OLD/ft_line_end.c b/42sh/OLD/ft_line_end.c deleted file mode 100644 index df7d2395..00000000 --- a/42sh/OLD/ft_line_end.c +++ /dev/null @@ -1,20 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_line_end.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/10 13:44:33 by jhalford #+# #+# */ -/* Updated: 2016/11/10 13:44:33 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "line_editing.h" - -int ft_line_end(t_data *data, char *buf) -{ - while (ft_cursor_right(data, buf)) - ; - return (0); -} diff --git a/42sh/OLD/ft_line_start.c b/42sh/OLD/ft_line_start.c deleted file mode 100644 index 354b4e74..00000000 --- a/42sh/OLD/ft_line_start.c +++ /dev/null @@ -1,20 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_line_start.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/10 13:44:34 by jhalford #+# #+# */ -/* Updated: 2016/11/10 13:44:34 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "line_editing.h" - -int ft_line_start(t_data *data, char *buf) -{ - while (ft_cursor_left(data, buf)) - ; - return (0); -} diff --git a/42sh/OLD/ft_line_up.c b/42sh/OLD/ft_line_up.c deleted file mode 100644 index 15804028..00000000 --- a/42sh/OLD/ft_line_up.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_line_up.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/10 13:44:35 by jhalford #+# #+# */ -/* Updated: 2016/11/10 13:44:35 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "line_editing.h" - -int ft_line_go_up(t_dlist **input_chain) -{ - char *res; - - (void)input_chain; - if ((res = tgetstr("up", NULL)) == NULL) - return (-1); - tputs(tgoto(res, 0, 0), 0, &ft_putchar); - return (0); -} diff --git a/42sh/OLD/ft_prompt.c b/42sh/OLD/ft_prompt.c deleted file mode 100644 index 32aa615e..00000000 --- a/42sh/OLD/ft_prompt.c +++ /dev/null @@ -1,19 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_prompt.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/10 14:22:34 by jhalford #+# #+# */ -/* Updated: 2016/11/28 15:16:30 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "line_editing.h" - -int ft_prompt(void) -{ - ft_putstr(SHELL_PROMPT); - return (0); -} diff --git a/42sh/OLD/ft_set_termios.c b/42sh/OLD/ft_set_termios.c deleted file mode 100644 index f51cb9de..00000000 --- a/42sh/OLD/ft_set_termios.c +++ /dev/null @@ -1,31 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_set_termios.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/01 12:14:09 by jhalford #+# #+# */ -/* Updated: 2016/12/07 14:20:59 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "line_editing.h" - -int ft_set_termios(t_data *data, int input_mode) -{ - struct termios term; - - (void)data; - if (tcgetattr(0, &term) == -1) - return (-1); - if (input_mode) - term.c_lflag &= ~(ICANON) & ~(ISIG) & ~(ECHO); - else - term.c_lflag |= ICANON | ISIG | ECHO; - term.c_cc[VMIN] = 1; - term.c_cc[VTIME] = 0; - if (tcsetattr(0, TCSADRAIN, &term) == -1) - return (-1); - return (0); -} diff --git a/42sh/OLD/ft_word_left.c b/42sh/OLD/ft_word_left.c deleted file mode 100644 index 6689c508..00000000 --- a/42sh/OLD/ft_word_left.c +++ /dev/null @@ -1,25 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_word_left.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/10 13:44:36 by jhalford #+# #+# */ -/* Updated: 2016/12/03 15:31:10 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "line_editing.h" - -int ft_word_left(t_data *data, char *buf) -{ - ft_cursor_left(data, buf); - while (FT_WS(data->line.input[data->line.input_pos - 1])) - if (!ft_cursor_left(data, buf)) - return (0); - while (!FT_WS(data->line.input[data->line.input_pos - 1])) - if (!ft_cursor_left(data, buf)) - return (0); - return (0); -} diff --git a/42sh/OLD/ft_word_right.c b/42sh/OLD/ft_word_right.c deleted file mode 100644 index 7999d2df..00000000 --- a/42sh/OLD/ft_word_right.c +++ /dev/null @@ -1,24 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* ft_word_right.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/10 13:44:37 by jhalford #+# #+# */ -/* Updated: 2016/12/03 15:31:25 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "line_editing.h" - -int ft_word_right(t_data *data, char *buf) -{ - while (!FT_WS(data->line.input[data->line.input_pos])) - if (!ft_cursor_right(data, buf)) - return (0); - while (FT_WS(data->line.input[data->line.input_pos])) - if (!ft_cursor_right(data, buf)) - return (0); - return (0); -} diff --git a/42sh/OLD/input_init.c b/42sh/OLD/input_init.c deleted file mode 100644 index bea6a347..00000000 --- a/42sh/OLD/input_init.c +++ /dev/null @@ -1,29 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* input_init.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/03 13:35:03 by jhalford #+# #+# */ -/* Updated: 2016/12/07 16:30:40 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "minishell.h" - -int input_init(t_data *data) -{ - char null; - - null = '\0'; - ft_strdel(&data->line.input); - data->line.input = ft_memalloc(10); - data->line.input_pos = 0; - data->line.qstack = ft_lstnew(NULL, sizeof(t_qstate)); - *((t_qstate*)data->line.qstack->content) = Q_NONE; - if (ft_set_termios(data, 1)) - return (-1); - ft_prompt(); - return (0); -} diff --git a/42sh/OLD/lexer/qstate_update.c b/42sh/OLD/lexer/qstate_update.c deleted file mode 100644 index 351b552e..00000000 --- a/42sh/OLD/lexer/qstate_update.c +++ /dev/null @@ -1,41 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* qstate_update.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/11/29 15:56:40 by jhalford #+# #+# */ -/* Updated: 2016/12/03 15:36:24 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "minishell.h" - -void qstate_update(t_data *data, char c) -{ - t_qstate *state; - t_qstate *new; - t_list **list; - t_list *tmp; - - list = &data->line.qstack; - state = (*list)->content; - if (c == -1) - { - tmp = ft_lstpop(list); - ft_lstdelone(&tmp, &ft_lst_cfree); - return ; - } - ft_lstadd(list, ft_lstnew(NULL, sizeof(t_qstate))); - new = (*list)->content; - *new = *state; - if (*state == Q_NONE) - qstate_none(new, c); - else if (*state == Q_QUOTE) - qstate_quote(new, c); - else if (*state == Q_DQUOTE) - qstate_dquote(new, c); - else if (*state == Q_BACKSLASH) - *new = *(t_qstate*)(*list)->next->next->content; -} diff --git a/42sh/OLD/qstate_dquote.c b/42sh/OLD/qstate_dquote.c deleted file mode 100644 index 15cd7f93..00000000 --- a/42sh/OLD/qstate_dquote.c +++ /dev/null @@ -1,21 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* qstate_dquote.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/03 12:10:09 by jhalford #+# #+# */ -/* Updated: 2016/12/03 12:26:09 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "line_editing.h" - -void qstate_dquote(t_qstate *new, char c) -{ - if (c == '\\') - *new = Q_BACKSLASH; - else if (c == '\"') - *new = Q_NONE; -} diff --git a/42sh/OLD/qstate_none.c b/42sh/OLD/qstate_none.c deleted file mode 100644 index f1f2e8c4..00000000 --- a/42sh/OLD/qstate_none.c +++ /dev/null @@ -1,23 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* qstate_none.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/03 12:08:48 by jhalford #+# #+# */ -/* Updated: 2016/12/03 12:51:29 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "line_editing.h" - -void qstate_none(t_qstate *new, char c) -{ - if (c == '\\') - *new = Q_BACKSLASH; - else if (c == '\"') - *new = Q_DQUOTE; - else if (c == '\'') - *new = Q_QUOTE; -} diff --git a/42sh/OLD/qstate_quote.c b/42sh/OLD/qstate_quote.c deleted file mode 100644 index 3e76a128..00000000 --- a/42sh/OLD/qstate_quote.c +++ /dev/null @@ -1,19 +0,0 @@ -/* ************************************************************************** */ -/* */ -/* ::: :::::::: */ -/* qstate_quote.c :+: :+: :+: */ -/* +:+ +:+ +:+ */ -/* By: jhalford +#+ +:+ +#+ */ -/* +#+#+#+#+#+ +#+ */ -/* Created: 2016/12/03 12:10:09 by jhalford #+# #+# */ -/* Updated: 2016/12/03 12:26:06 by jhalford ### ########.fr */ -/* */ -/* ************************************************************************** */ - -#include "line_editing.h" - -void qstate_quote(t_qstate *new, char c) -{ - if (c == '\'') - *new = Q_NONE; -}