From e1a81f05f950faaa455ef042eed92b6b4c5f29cf Mon Sep 17 00:00:00 2001
From: Anonymus Raccoon
Date: Wed, 20 May 2020 13:02:44 +0200
Subject: [PATCH] Adding a % when a \n has been added by ash and not by the
program's output
---
include/my_ncurses.h | 17 +++++++++++++++++
src/redirections/pty_pipe.c | 12 ++++++++++--
2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/include/my_ncurses.h b/include/my_ncurses.h
index 692376e..fca6ba1 100644
--- a/include/my_ncurses.h
+++ b/include/my_ncurses.h
@@ -46,4 +46,21 @@ void my_addstr(my_window *window, const char *str);
#define my_mvaddstr(window, y, x, str) (my_move(window, y, x), \
my_addstr(window, str))
+
+#define COLOR 0
+#define BACKGROUND_COLOR 10
+#define BRIGHT_MODIFIER 60
+
+#define BLACK 30
+#define RED 31
+#define GREEN 32
+#define YELLOW 33
+#define BLUE 34
+#define MAGENTA 53
+#define CYAN 36
+#define WHITE 37
+
+#define my_attron(attr, value) (printf("\x1B[%dm", attr + value))
+#define my_attrreset() (printf("\x1B[0m"))
+
void my_clrtoeol(void);
\ No newline at end of file
diff --git a/src/redirections/pty_pipe.c b/src/redirections/pty_pipe.c
index 0da4a27..93156af 100644
--- a/src/redirections/pty_pipe.c
+++ b/src/redirections/pty_pipe.c
@@ -6,15 +6,16 @@
*/
#include "redirections.h"
+#include "my_ncurses.h"
#include
#include
#include
#include
#include
#include
-#include
#include
#include
+#include
#define _XOPEN_SOURCE 600
#define __USE_XOPEN_EXTENDED
#include
@@ -88,7 +89,14 @@ void pty_get_output(redirection *pty, env_t *env)
close(pty->fd);
while (getline(&line, &size, file) > 0)
my_addstr(env->window, line);
- if (line)
+ if (line) {
+ if (!strchr(line, '\n')) {
+ my_attron(BACKGROUND_COLOR, WHITE);
+ my_attron(COLOR, BLACK);
+ my_addstr(env->window, "%\n");
+ my_attrreset();
+ }
free(line);
+ }
fclose(file);
}
\ No newline at end of file