#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
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)
{
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,
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);
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);
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