From b18fbce9a7e33f7e54949ae8de32fd7fc42e6ad1 Mon Sep 17 00:00:00 2001 From: salad Date: Tue, 3 Nov 2020 00:03:48 +0100 Subject: this is it \(2009\) \: a Micheal Jackson Biopic --- src/m_prompt.c | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'src/m_prompt.c') diff --git a/src/m_prompt.c b/src/m_prompt.c index e36a07e..0fbd9f2 100644 --- a/src/m_prompt.c +++ b/src/m_prompt.c @@ -25,7 +25,7 @@ #include "s_struct.h" #include "u_vars.h" -static void m_subst_prompt_rice(char var[], t_msh *msh) +static void m_subst_prompt_rice(char var[], t_msh *msh) { size_t i; @@ -43,7 +43,7 @@ static void m_subst_prompt_rice(char var[], t_msh *msh) } } -static void m_update_psx(unsigned char x, t_msh *msh) +static void m_update_psx(unsigned char x, t_msh *msh) { char var[ARG_MAX]; char psx[5]; @@ -59,7 +59,33 @@ static void m_update_psx(unsigned char x, t_msh *msh) ft_strlcpy(msh->ps[x - 1], var, 255); } -void m_prompt_psx(unsigned char x, t_msh *msh) +unsigned int m_plen(char *prompt) +{ + unsigned int i; + unsigned int size; + + i = 0; + size = 0; + while (prompt[i] != '\0') + { + if (prompt[i] == 27) + { + while (prompt[i] != 'm' && prompt[i] != '\0') + i++; + } + if (ft_isalnum(prompt[i]) || + ft_ischarset("<>", prompt[i])) + { + size++; + i++; + } + else + i++; + } + return (size); +} + +void m_prompt_psx(unsigned char x, t_msh *msh) { m_update_psx(x, msh); ft_dprintf(STDERR_FILENO, "%s", msh->ps[x - 1]); -- cgit v1.2.3