From 765a2b4ff157f3303f0f8d7d6379cb849004a679 Mon Sep 17 00:00:00 2001 From: salad Date: Mon, 2 Nov 2020 21:37:01 +0100 Subject: strplen --- src/c_init.c | 25 +++++++++++++++++++++++++ src/m_loop.c | 5 ++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/c_init.c b/src/c_init.c index 6847c14..53af0a3 100644 --- a/src/c_init.c +++ b/src/c_init.c @@ -23,6 +23,30 @@ #include "s_struct.h" #include "m_prompt.h" +unsigned int + c_plen(char *prompt) +{ + unsigned int i; + unsigned int size; + + i = 0; + size = 0; + while (prompt[i] != '\0') + { + if (ft_isalpha(prompt[i])) + { + i++; + size++; + } + else + { + + i++; + } + } + return (size); +} + short c_set_term_raw(char mode) { @@ -128,6 +152,7 @@ short c_init_line(psx, &tcaps); tputs(tgetstr("cr", NULL), 1, ft_putchar); m_prompt_psx(psx, msh); + ft_printf("%u", c_plen(msh->ps[0])); ft_bzero(nread, 5); if (!(c_get_win_size(&tcaps.ws))) return (-1); diff --git a/src/m_loop.c b/src/m_loop.c index 94e3027..83caf6a 100644 --- a/src/m_loop.c +++ b/src/m_loop.c @@ -138,7 +138,10 @@ unsigned char m_loop(int fd, t_msh *msh) msh->curr_hist_ptr = hist; while (gnl > 0) { - gnl = c_gnl(fd, &line, 1, msh); + if (fd == STDIN_FILENO) + gnl = c_gnl(fd, &line, 1, msh); + else + gnl = get_next_line(fd, &line); m_delete_comments(line); if (line[0] != C_NUL) { -- cgit v1.2.3