[sheepdog] [PATCH v3 3/4] util: add clean_screen helper

Liu Yuan namei.unix at gmail.com
Mon Aug 26 09:22:13 CEST 2013


Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
 include/util.h |    9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/include/util.h b/include/util.h
index b04f758..ace763b 100644
--- a/include/util.h
+++ b/include/util.h
@@ -331,6 +331,9 @@ static inline void sd_unlock(struct sd_lock *lock)
 #define TEXT_CYAN           "\033[0;36m"
 #define TEXT_BOLD_CYAN      "\033[1;36m"
 
+#define CLEAR_SCREEN        "\033[2J"
+#define RESET_CURSOR        "\033[1;1H"
+
 static inline bool is_stdin_console(void)
 {
 	return isatty(STDIN_FILENO);
@@ -341,6 +344,12 @@ static inline bool is_stdout_console(void)
 	return isatty(STDOUT_FILENO);
 }
 
+static inline void clear_screen(void)
+{
+	printf(CLEAR_SCREEN);
+	printf(RESET_CURSOR);
+}
+
 extern mode_t sd_def_fmode;
 extern mode_t sd_def_dmode;
 
-- 
1.7.9.5




More information about the sheepdog mailing list