summaryrefslogtreecommitdiffstats
path: root/src/c_keys_next.c
diff options
context:
space:
mode:
authorjoe <rbousset@42lyon.fr>2020-12-01 16:12:02 +0100
committerjoe <rbousset@42lyon.fr>2020-12-01 16:12:02 +0100
commit214eae8a55bde34ca412084bebdb378a696152cc (patch)
tree70404f68b1b86035fe4835d8cf2da61dcefc5eba /src/c_keys_next.c
parentNot quite done (diff)
download42-minishell-214eae8a55bde34ca412084bebdb378a696152cc.tar.gz
42-minishell-214eae8a55bde34ca412084bebdb378a696152cc.tar.bz2
42-minishell-214eae8a55bde34ca412084bebdb378a696152cc.tar.xz
42-minishell-214eae8a55bde34ca412084bebdb378a696152cc.tar.zst
42-minishell-214eae8a55bde34ca412084bebdb378a696152cc.zip
Bav
Diffstat (limited to '')
-rw-r--r--src/c_keys_next.c45
1 files changed, 23 insertions, 22 deletions
diff --git a/src/c_keys_next.c b/src/c_keys_next.c
index 99f01b9..629d9f8 100644
--- a/src/c_keys_next.c
+++ b/src/c_keys_next.c
@@ -15,31 +15,32 @@
#include <term.h>
#include "c_init.h"
+#include "c_keys.h"
#include "d_define.h"
#include "s_struct.h"
-short c_key_up(t_caps *tcaps, t_msh *msh)
+short c_key_up(char *line[], t_caps *tcaps, t_msh *msh)
{
- /* static char *ptr; */
- /* static t_bool set = TRUE; */
- /* */
- /* if (set == TRUE) */
- /* { */
- /* ptr = msh->curr_hist_ptr + ft_strlen(msh->curr_hist_ptr); */
- /* set = FALSE; */
- /* } */
- /* while (ptr - msh->curr_hist_ptr != 0 && *ptr != '\n') */
- /* { */
- /* ft_printf("{%c}\n", *ptr); */
- /* ptr--; */
- /* } */
- /* ptr += 1; */
- /* ft_dprintf(1, "[%s]\n", ptr); */
- (void)msh;
- (void)tcaps;
- ft_dprintf(0, "qwe");
- /* tcaps->cpos = 0; */
- /* tcaps->lpos = 0; */
- /* tputs(tgetstr("nd", NULL), 1, ft_putchar); */
+ char tmp[ARG_MAX];
+ static char *ptr;
+ static t_bool set = TRUE;
+
+ if (set == TRUE)
+ {
+ ptr = msh->curr_hist_ptr + ft_strlen(msh->curr_hist_ptr);
+ set = FALSE;
+ }
+ ptr -= 2;
+ while (ptr - msh->curr_hist_ptr != 0 && *ptr != '\n')
+ {
+ ptr--;
+ }
+ ptr += 1;
+ c_home_key(tcaps->plen, tcaps);
+ ft_substr_s(tmp, ptr, 0, ft_strclen(ptr, '\n'));
+ ft_memdel((void*)&(*line));
+ tputs(tgetstr("ce", NULL), 1, ft_putchar);
+ *line = ft_strdup(tmp);
+ tcaps->cpos = ft_strlen(*line);
return (1);
}