]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
text-progress-bar: Try to be more defensive about text leaks fix-text-spew
authorRay Strode <rstrode@redhat.com>
Tue, 18 Sep 2012 19:31:35 +0000 (15:31 -0400)
committerRay Strode <rstrode@redhat.com>
Tue, 18 Sep 2012 19:31:35 +0000 (15:31 -0400)
We try to prevent text from showing through in the text splash,
by disable dmesg to screen and by redirecting console messages to
a log file.

Still, occasionally a kernel message may leak through.  This
commit tries to harden against that by moving the cursor up to
home when we aren't using it.

src/libply-splash-core/ply-text-display.c
src/libply-splash-core/ply-text-display.h
src/libply-splash-core/ply-text-progress-bar.c

index 7cabd98f4a67bfff41bfcf3e487053317f81458e..fcaff22ec309b04847261716eac69abceceaaaaa 100644 (file)
 #define MOVE_CURSOR_SEQUENCE "\033[%d;%df"
 #endif
 
+#ifndef SET_TOP_AND_BOTTOM_MARGINS_SEQUENCE
+#define SET_TOP_AND_BOTTOM_MARGINS_SEQUENCE "\033[%d;%dr"
+#endif
+
 #ifndef HIDE_CURSOR_SEQUENCE
 #define HIDE_CURSOR_SEQUENCE "\033[?25l"
 #endif
 #define COLOR_SEQUENCE_FORMAT "\033[%dm"
 #endif
 
+#ifndef ENABLE_WRAPPING_SEQUENCE
+#define ENABLE_WRAPPING_SEQUENCE "\033[?7h"
+#endif
+
+#ifndef DISABLE_WRAPPING_SEQUENCE
+#define DISABLE_WRAPPING_SEQUENCE "\033[?7l"
+#endif
+
 #ifndef PAUSE_SEQUENCE
 #define PAUSE_SEQUENCE "\023"
 #endif
@@ -147,6 +159,37 @@ ply_text_display_set_cursor_position (ply_text_display_t *display,
                       row, column);
 }
 
+void
+ply_text_display_set_scrollable_area (ply_text_display_t *display,
+                                      int                 top_row,
+                                      int                 bottom_row)
+{
+  int number_of_rows;
+
+  number_of_rows = ply_text_display_get_number_of_rows (display);
+
+  top_row = CLAMP (top_row, 0, bottom_row);
+  bottom_row = CLAMP (bottom_row, top_row, number_of_rows - 1);
+
+  ply_terminal_write (display->terminal,
+                      SET_TOP_AND_BOTTOM_MARGINS_SEQUENCE,
+                      top_row, bottom_row);
+}
+
+void
+ply_text_display_enable_wrapping (ply_text_display_t *display)
+{
+  ply_terminal_write (display->terminal,
+                      ENABLE_WRAPPING_SEQUENCE);
+}
+
+void
+ply_text_display_disable_wrapping (ply_text_display_t *display)
+{
+  ply_terminal_write (display->terminal,
+                      DISABLE_WRAPPING_SEQUENCE);
+}
+
 void
 ply_text_display_clear_screen (ply_text_display_t *display)
 {
index 3fd7dab23d5ccc107cc600e966106a59b74fed84..7f1e20b7f5bf25d898157c4c9369d599a5a62663 100644 (file)
@@ -54,6 +54,12 @@ int  ply_text_display_get_number_of_columns (ply_text_display_t *display);
 void ply_text_display_set_cursor_position (ply_text_display_t *display,
                                            int                 column,
                                            int                 row);
+void ply_text_display_set_scrollable_area (ply_text_display_t *display,
+                                           int                 top_row,
+                                           int                 bottom_row);
+void ply_text_display_enable_wrapping (ply_text_display_t *display);
+void ply_text_display_disable_wrapping (ply_text_display_t *display);
+
 __attribute__((__format__ (__printf__, 2, 3)))
 void ply_text_display_write (ply_text_display_t *display,
                              const char         *format,
index bf4b37810a94bff8d25e68a1cbbd58ca12156657..852f016b816e9639d5d694f8d66a6b31a672beb2 100644 (file)
@@ -184,6 +184,8 @@ ply_text_progress_bar_draw (ply_text_progress_bar_t *progress_bar)
 
     width = progress_bar->number_of_columns - 2 - strlen (os_string);
 
+    ply_text_display_disable_wrapping (progress_bar->display);
+    ply_text_display_set_scrollable_area (progress_bar->display, 0, progress_bar->row);
     ply_text_display_set_cursor_position (progress_bar->display,
                                           progress_bar->column,
                                           progress_bar->row);
@@ -210,6 +212,7 @@ ply_text_progress_bar_draw (ply_text_progress_bar_t *progress_bar)
 
         ply_text_display_write (progress_bar->display, "%c", ' ');
     }
+    ply_text_display_set_cursor_position (progress_bar->display, 0, 0);
 
     ply_text_display_set_background_color (progress_bar->display,
                                            PLY_TERMINAL_COLOR_BLACK);
@@ -230,10 +233,18 @@ ply_text_progress_bar_draw (ply_text_progress_bar_t *progress_bar)
                                               progress_bar->row);
 
         ply_text_display_write (progress_bar->display, "%s", os_string);
+        ply_text_display_set_cursor_position (progress_bar->display, 0, 0);
 
         ply_text_display_set_foreground_color (progress_bar->display,
                                                PLY_TERMINAL_COLOR_DEFAULT);
     }
+
+    ply_text_display_set_background_color (progress_bar->display,
+                                           PLY_TERMINAL_COLOR_DEFAULT);
+
+    ply_text_display_set_scrollable_area (progress_bar->display, 0, progress_bar->row - 1);
+    ply_text_display_set_cursor_position (progress_bar->display, 0, 0);
+    ply_text_display_enable_wrapping (progress_bar->display);
 }
 
 void