/[LeafOK_CVS]/lbbs/src/screen.c
ViewVC logotype

Diff of /lbbs/src/screen.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.27 by sysadm, Sat May 3 10:11:37 2025 UTC Revision 1.30 by sysadm, Sun May 4 14:54:55 2025 UTC
# Line 76  void clearscr() Line 76  void clearscr()
76    
77  int press_any_key()  int press_any_key()
78  {  {
         igetch(1);  
   
79          moveto(screen_rows, 0);          moveto(screen_rows, 0);
80          clrtoeol();          clrtoeol();
81    
# Line 106  void set_input_echo(int echo) Line 104  void set_input_echo(int echo)
104    
105  static int _str_input(char *buffer, int buffer_length, int echo_mode)  static int _str_input(char *buffer, int buffer_length, int echo_mode)
106  {  {
107          char buf[256], ch;          int c, offset = 0, i, hz = 0;
         int c, offset = 0, len, loop = 1, i, hz = 0;  
108    
109          for (i = 0; i < buffer_length && buffer[i] != '\0'; i++)          for (i = 0; i < buffer_length && buffer[i] != '\0'; i++)
110          {          {
111                  offset++;                  offset++;
112          }          }
113    
114          igetch(1);          while ((c = igetch_t(60)))
   
         while (c = igetch_t(60))  
115          {          {
116                  if (c == KEY_NULL || c == KEY_TIMEOUT || c == CR)                  if (c == KEY_NULL || c == KEY_TIMEOUT || c == CR)
117                  {                  {
118                            igetch(1); // Cleanup remaining '\n' in the buffer
119                          break;                          break;
120                  }                  }
121                  if (c == LF)                  if (c == LF)
# Line 229  int display_file(const char *filename) Line 225  int display_file(const char *filename)
225  int display_file_ex(const char *filename, int begin_line, int wait)  int display_file_ex(const char *filename, int begin_line, int wait)
226  {  {
227          char buffer[LINE_BUFFER_LEN];          char buffer[LINE_BUFFER_LEN];
         char temp[LINE_BUFFER_LEN];  
228          int ch = 0;          int ch = 0;
229          int input_ok, line, max_lines;          int input_ok, line, max_lines;
230          long int c_line_current = 0, c_line_total = 0;          long int c_line_current = 0, c_line_total = 0;
231          FILE *fin;          FILE *fin;
         struct stat f_stat;  
232          long *p_line_offsets;          long *p_line_offsets;
233          int len;          int len;
234          int percentile;          int percentile;
# Line 256  int display_file_ex(const char *filename Line 250  int display_file_ex(const char *filename
250    
251          while (loop)          while (loop)
252          {          {
253                  if (c_line_current >= c_line_total)                  if (c_line_current >= c_line_total && c_line_total <= screen_rows - 2)
254                  {                  {
255                          if (wait)                          if (wait)
256                          {                          {
# Line 271  int display_file_ex(const char *filename Line 265  int display_file_ex(const char *filename
265                          break;                          break;
266                  }                  }
267    
268                  if (line >= max_lines)                  if (c_line_current >= c_line_total || line >= max_lines)
269                  {                  {
270                          if (c_line_current - (line - 1) + (screen_rows - 2) < c_line_total)                          if (c_line_current - (line - 1) + (screen_rows - 2) < c_line_total)
271                          {                          {
# Line 279  int display_file_ex(const char *filename Line 273  int display_file_ex(const char *filename
273                          }                          }
274                          else                          else
275                          {                          {
                                 log_error("P100 reached\n");  
276                                  percentile = 100;                                  percentile = 100;
277                          }                          }
278    
279                          moveto(screen_rows, 0);                          moveto(screen_rows, 0);
280                          prints("\033[1;44;32m下面还有喔 (%d%%)\033[33m   │ 结束 ← <q> │ ↑/↓/PgUp/PgDn 移动 │ ? 辅助说明 │     \033[m",                          prints("\033[1;44;32m%s (%d%%)%s\033[33m  │ 结束 ← <q> │ ↑/↓/PgUp/PgDn 移动 │ ? 辅助说明 │     \033[m",
281                                     percentile);                                     (percentile < 100 ? "下面还有喔" : "没有更多了"), percentile,
282                                       (percentile < 10 ? "  " : (percentile < 100 ? " " : "")));
283                          iflush();                          iflush();
284    
285                          input_ok = 0;                          input_ok = 0;
# Line 303  int display_file_ex(const char *filename Line 297  int display_file_ex(const char *filename
297                                          c_line_current -= line;                                          c_line_current -= line;
298                                          line = begin_line;                                          line = begin_line;
299                                          max_lines = begin_line + 1;                                          max_lines = begin_line + 1;
300                                          prints("\033[1T"); // Scroll down 1 line                                          prints("\033[T"); // Scroll down 1 line
301                                            // max_lines = screen_rows - 1; // Legacy Fterm only works with this line
302                                          break;                                          break;
303                                  case KEY_DOWN:                                  case KEY_DOWN:
304                                  case CR:                                  case CR:
# Line 316  int display_file_ex(const char *filename Line 311  int display_file_ex(const char *filename
311                                          max_lines = screen_rows - 1;                                          max_lines = screen_rows - 1;
312                                          moveto(screen_rows, 0);                                          moveto(screen_rows, 0);
313                                          clrtoeol();                                          clrtoeol();
314                                          prints("\033[1S"); // Scroll up 1 line                                          prints("\033[S"); // Scroll up 1 line
315                                          break;                                          break;
316                                  case KEY_PGUP:                                  case KEY_PGUP:
317                                  case Ctrl('B'):                                  case Ctrl('B'):
# Line 361  int display_file_ex(const char *filename Line 356  int display_file_ex(const char *filename
356                                  case 'h':                                  case 'h':
357                                  case 'H':                                  case 'H':
358                                          // Display help information                                          // Display help information
359                                          strcpy(temp, app_home_dir);                                          display_file_ex(DATA_READ_HELP, begin_line, 1);
                                         strcat(temp, "data/read_help.txt");  
                                         display_file_ex(temp, begin_line, 1);  
360    
361                                          // Refresh after display help information                                          // Refresh after display help information
362                                          c_line_current -= (line - 1);                                          c_line_current -= (line - 1);
# Line 424  int show_top(char *status) Line 417  int show_top(char *status)
417  int show_bottom(char *msg)  int show_bottom(char *msg)
418  {  {
419          char str_time[LINE_BUFFER_LEN];          char str_time[LINE_BUFFER_LEN];
         char str_time_onine[20];  
420          char buffer[LINE_BUFFER_LEN];          char buffer[LINE_BUFFER_LEN];
421          time_t time_online;          time_t time_online;
422          struct tm *tm_online;          struct tm *tm_online;
# Line 456  int show_active_board() Line 448  int show_active_board()
448          int len;          int len;
449          int end_of_line;          int end_of_line;
450    
         sprintf(filename, "%sdata/active_board.txt", app_home_dir);  
   
451          clrline(3, 2 + ACTIVE_BOARD_HEIGHT);          clrline(3, 2 + ACTIVE_BOARD_HEIGHT);
452    
453          if ((fin = fopen(filename, "r")) == NULL)          if ((fin = fopen(DATA_ACTIVE_BOARD, "r")) == NULL)
454          {          {
455                  log_error("Unable to open file %s\n", filename);                  log_error("Unable to open file %s\n", filename);
456                  return -1;                  return -1;


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1