sbenning: Remove some old files

This commit is contained in:
m4s 2016-12-10 10:53:22 +01:00
parent 0c61957b6c
commit 8f22367d91
26 changed files with 60 additions and 716 deletions

View file

@ -6,7 +6,7 @@
/* By: sbenning <sbenning@student.42.fr> +#+ +:+ +#+ */ /* By: sbenning <sbenning@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/09 02:05:22 by sbenning #+# #+# */ /* Created: 2016/12/09 02:05:22 by sbenning #+# #+# */
/* Updated: 2016/12/09 18:27:29 by sbenning ### ########.fr */ /* Updated: 2016/12/10 10:42:43 by sbenning ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -18,32 +18,64 @@
* TODO Same for MACOSX * TODO Same for MACOSX
*/ */
# define RL_INSERT_CODE 0x7e325b1b # ifdef LINUX
# define RL_CLEAR_CODE 0xc # define RL_INSERT_CODE 0x7e325b1b
# define RL_NL_CODE 0xa # define RL_CLEAR_CODE 0xc
# define RL_LEFT_CODE 0x445b1b # define RL_NL_CODE 0xa
# define RL_RIGHT_CODE 0x435b1b # define RL_LEFT_CODE 0x445b1b
# define RL_WLEFT_CODE 0x44323b315b1b # define RL_RIGHT_CODE 0x435b1b
# define RL_WRIGHT_CODE 0x43323b315b1b # define RL_WLEFT_CODE 0x44323b315b1b
# define RL_HOME_CODE 0x485b1b # define RL_WRIGHT_CODE 0x43323b315b1b
# define RL_END_CODE 0x465b1b # define RL_HOME_CODE 0x485b1b
# define RL_PAGEUP_CODE 0x7e355b1b # define RL_END_CODE 0x465b1b
# define RL_PAGEDOWN_CODE 0x7e365b1b # define RL_PAGEUP_CODE 0x7e355b1b
# define RL_SELECT_RIGHT_CODE 0x43333b315b1b # define RL_PAGEDOWN_CODE 0x7e365b1b
# define RL_SELECT_LEFT_CODE 0x44333b315b1b # define RL_SELECT_RIGHT_CODE 0x43333b315b1b
# define RL_SELECT_PAGEUP_CODE 0x7e333b355b1b # define RL_SELECT_LEFT_CODE 0x44333b315b1b
# define RL_SELECT_PAGEDOWN_CODE 0x7e333b365b1b # define RL_SELECT_PAGEUP_CODE 0x7e333b355b1b
# define RL_SELECT_HOME_CODE 0x48333b315b1b # define RL_SELECT_PAGEDOWN_CODE 0x7e333b365b1b
# define RL_SELECT_END_CODE 0x46333b315b1b # define RL_SELECT_HOME_CODE 0x48333b315b1b
# define RL_SELECT_WRIGHT_CODE 0x43343b315b1b # define RL_SELECT_END_CODE 0x46333b315b1b
# define RL_SELECT_WLEFT_CODE 0x44343b315b1b # define RL_SELECT_WRIGHT_CODE 0x43343b315b1b
# define RL_RETARR_CODE 0x7f # define RL_SELECT_WLEFT_CODE 0x44343b315b1b
# define RL_SUPPR_CODE 0x7e335b1b # define RL_RETARR_CODE 0x7f
# define RL_ESC_CODE 0x5c # define RL_SUPPR_CODE 0x7e335b1b
# define RL_QUOTE_CODE 0x27 # define RL_ESC_CODE 0x5c
# define RL_DQUOTE_CODE 0x22 # define RL_QUOTE_CODE 0x27
# define RL_COPY_CODE 0x631b # define RL_DQUOTE_CODE 0x22
# define RL_CUT_CODE 0x781b # define RL_COPY_CODE 0x631b
# define RL_PASTE_CODE 0x761b # define RL_CUT_CODE 0x781b
# define RL_PASTE_CODE 0x761b
# endif
# ifdef MACOSX
# define RL_INSERT_CODE 0x53323b315b1b
# define RL_CLEAR_CODE 0xc
# define RL_NL_CODE 0xa
# define RL_LEFT_CODE 0x445b1b
# define RL_RIGHT_CODE 0x435b1b
# define RL_WLEFT_CODE 0x44323b315b1b
# define RL_WRIGHT_CODE 0x43323b315b1b
# define RL_HOME_CODE 0x485b1b
# define RL_END_CODE 0x465b1b
# define RL_PAGEUP_CODE 0x7e355b1b
# define RL_PAGEDOWN_CODE 0x7e365b1b
# define RL_SELECT_RIGHT_CODE 0x435b1b1b
# define RL_SELECT_LEFT_CODE 0x445b1b1b
# define RL_SELECT_PAGEUP_CODE 0x7e355b1b1b
# define RL_SELECT_PAGEDOWN_CODE 0x7e365b1b1b
# define RL_SELECT_HOME_CODE 0x48333b315b1b
# define RL_SELECT_END_CODE 0x46333b315b1b
# define RL_SELECT_WRIGHT_CODE 0x4330313b315b1b
# define RL_SELECT_WLEFT_CODE 0x4430313b315b1b
# define RL_RETARR_CODE 0x7f
# define RL_SUPPR_CODE 0x7e335b1b
# define RL_ESC_CODE 0x5c
# define RL_QUOTE_CODE 0x27
# define RL_DQUOTE_CODE 0x22
# define RL_COPY_CODE 0xa7c3
# define RL_CUT_CODE 0x8889e2
# define RL_PASTE_CODE 0x9a88e2
# endif
#endif #endif

View file

@ -1,21 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_clear_line.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View file

@ -1,30 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_cursor_left.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View file

@ -1,30 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_cursor_right.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View file

@ -1,33 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_history_add.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View file

@ -1,31 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_history_down.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View file

@ -1,29 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_history_up.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View file

@ -1,21 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_input_is_escaped.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View file

@ -1,68 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_interactive_sh.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}
}
}

View file

@ -1,23 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_key_ctrl_c.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View file

@ -1,22 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_key_ctrl_d.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View file

@ -1,33 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_key_default.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View file

@ -1,42 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_key_del.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View file

@ -1,26 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_key_enter.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View file

@ -1,24 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_line_down.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View file

@ -1,20 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_line_end.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View file

@ -1,20 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_line_start.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View file

@ -1,24 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_line_up.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View file

@ -1,19 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_prompt.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View file

@ -1,31 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_set_termios.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View file

@ -1,25 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_word_left.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View file

@ -1,24 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_word_right.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View file

@ -1,29 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* input_init.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}

View file

@ -1,21 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* qstate_dquote.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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;
}

View file

@ -1,23 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* qstate_none.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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;
}

View file

@ -1,19 +0,0 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* qstate_quote.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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;
}