changed some stuff with lineedit

This commit is contained in:
Maieul BOYER 2024-07-20 14:37:38 +02:00
parent 1d4fd27f97
commit 0cb2d91cac
No known key found for this signature in database
9 changed files with 95 additions and 139 deletions

View file

@ -6,37 +6,37 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/11 18:10:24 by maiboyer #+# #+# */
/* Updated: 2024/07/11 18:15:42 by maiboyer ### ########.fr */
/* Updated: 2024/07/20 13:51:27 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
#include "me/types.h"
#include "line/_line_internal.h"
#include "line/_line_functions.h"
#include "line/_line_internal.h"
#include "line/_line_structs.h"
#include "me/types.h"
/* This function is called when linenoise() is called with the standard
* input file descriptor not attached to a TTY. So for example when the
* program using linenoise is called in pipe or with a file redirected
* to its standard input. In this case, we want to be able to return the
* line regardless of its length (by default we are limited to 4k). */
t_str line_no_tty_impl(void)
bool line_no_tty_impl(t_str *out)
{
t_string line;
t_isize ret;
char chr;
t_string line;
t_isize ret;
char chr;
line = string_new(16);
while (true)
{
chr = '\n';
if (read_fd(get_stdin(), (t_u8 *)&chr, 1, &ret))
return (string_free(line), NULL);
return (string_free(line), *out = NULL, true);
if (ret == 0 || chr == '\n')
{
if (line.len == 0)
return (string_free(line), NULL);
return (line.buf);
return (string_free(line), *out = NULL, true);
return (*out = line.buf, true);
}
else
string_push_char(&line, chr);