--- lbbs/include/screen.h 2025/05/17 06:46:23 1.6 +++ lbbs/include/screen.h 2025/05/31 03:37:47 1.13 @@ -17,14 +17,27 @@ #ifndef _SCREEN_H_ #define _SCREEN_H_ -extern void moveto(int row, int col); +#include -extern void clrtoeol(); +#define CTRL_SEQ_CLR_LINE "\033[K" +#define MSG_EXT_MAX_LEN 200 -extern void clrline(int line_begin, int line_end); +struct display_ctx_t +{ + int reach_begin; // of data + int reach_end; // of data + long line_top; // current screen + long line_bottom; // current screen + char msg[MSG_EXT_MAX_LEN]; +}; +typedef struct display_ctx_t DISPLAY_CTX; -extern void clrtobot(int line_begin); +typedef int (*display_data_key_handler)(int *p_key, DISPLAY_CTX *p_ctx); +extern void moveto(int row, int col); +extern void clrtoeol(); +extern void clrline(int line_begin, int line_end); +extern void clrtobot(int line_begin); extern void clearscr(); extern int press_any_key(); @@ -32,13 +45,16 @@ extern int press_any_key(); extern void set_input_echo(int echo); extern int str_input(char *buffer, int buffer_length, int echo_mode); - extern int get_data(int row, int col, char *prompt, char *buffer, int buffer_length, int echo_mode); -extern int display_file_ex(const char *filename, int begin_line, int wait); - -extern int show_top(const char *status); +// eof_exit = 0 : Do not exit at EOF +// 1 : Prompt for any key at EOF, then exit +// 2 : Exit at EOF without prompt +extern int display_data(const void *p_data, long line_total, const long *p_line_offsets, int begin_line, int eof_exit, + display_data_key_handler key_handler, const char *help_filename); +extern int display_file(const char *filename, int begin_line, int eof_exit); +extern int show_top(const char *str_left, const char *str_center, const char *str_right); extern int show_bottom(const char *msg); extern int show_active_board();