/[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.81 by sysadm, Fri May 30 05:28:41 2025 UTC Revision 1.84 by sysadm, Sat May 31 01:58:22 2025 UTC
# Line 233  int get_data(int row, int col, char *pro Line 233  int get_data(int row, int col, char *pro
233          return len;          return len;
234  }  }
235    
236  int display_data(const void *p_data, long line_total, const long *p_line_offsets, int begin_line, int wait,  int display_data(const void *p_data, long line_total, const long *p_line_offsets, int begin_line, int eof_exit,
237                                   display_data_key_handler key_handler, const char *help_filename)                                   display_data_key_handler key_handler, const char *help_filename)
238  {  {
239          static int show_help = 1;          static int show_help = 1;
# Line 260  int display_data(const void *p_data, lon Line 260  int display_data(const void *p_data, lon
260          loop = 1;          loop = 1;
261          while (!SYS_server_exit && loop)          while (!SYS_server_exit && loop)
262          {          {
263                  if (line_current >= line_total && line_total <= SCREEN_ROWS - 2)                  if (eof_exit > 0 && line_current >= line_total && line_total <= SCREEN_ROWS - 2)
264                  {                  {
265                          if (wait)                          if (eof_exit == 1)
266                          {                          {
267                                  ch = press_any_key();                                  ch = press_any_key();
268                          }                          }
269                          else                          else // if (eof_exit == 2)
270                          {                          {
271                                  iflush();                                  iflush();
272                          }                          }
# Line 322  int display_data(const void *p_data, lon Line 322  int display_data(const void *p_data, lon
322                                  case KEY_TIMEOUT:                                  case KEY_TIMEOUT:
323                                          goto cleanup;                                          goto cleanup;
324                                  case KEY_HOME:                                  case KEY_HOME:
325                                            if (line_current - line < 0) // Reach top
326                                            {
327                                                    break;
328                                            }
329                                          line_current = 0;                                          line_current = 0;
330                                          line = begin_line;                                          line = begin_line;
331                                          max_lines = SCREEN_ROWS - 1;                                          max_lines = SCREEN_ROWS - 1;
332                                          clrline(begin_line, SCREEN_ROWS);                                          clrline(begin_line, SCREEN_ROWS);
333                                          break;                                          break;
334                                  case KEY_END:                                  case KEY_END:
335                                            if (line_total < SCREEN_ROWS - 2)
336                                            {
337                                                    break;
338                                            }
339                                          line_current = line_total - (SCREEN_ROWS - 2);                                          line_current = line_total - (SCREEN_ROWS - 2);
340                                          line = begin_line;                                          line = begin_line;
341                                          max_lines = SCREEN_ROWS - 1;                                          max_lines = SCREEN_ROWS - 1;
# Line 445  cleanup: Line 453  cleanup:
453    
454  static int display_file_key_handler(int *key, char *msg, size_t msg_len)  static int display_file_key_handler(int *key, char *msg, size_t msg_len)
455  {  {
         static int topic_view = 0;  
   
456          switch (*key)          switch (*key)
457          {          {
458          case 0: // Set msg          case 0: // Set msg
# Line 455  static int display_file_key_handler(int Line 461  static int display_file_key_handler(int
461                                   "移动[\033[32m↑\033[33m/\033[32m↓\033[33m/\033[32mPgUp\033[33m/\033[32mPgDn\033[33m] │ "                                   "移动[\033[32m↑\033[33m/\033[32m↓\033[33m/\033[32mPgUp\033[33m/\033[32mPgDn\033[33m] │ "
462                                   "帮助[\033[32mh\033[33m] |");                                   "帮助[\033[32mh\033[33m] |");
463                  break;                  break;
         case 'p':  
                 break;  
                 topic_view = !topic_view;  
                 if (topic_view)  
                 {  
                         snprintf(msg, msg_len,  
                                          "| 返回[\033[32m←\033[33m,\033[32mESC\033[33m] │ "  
                                          "同主题阅读[\033[32m↑\033[33m/\033[32m↓\033[33m] │ "  
                                          "帮助[\033[32mh\033[33m] |");  
                 }  
                 else  
                 {  
                         snprintf(msg, msg_len,  
                                          "| 返回[\033[32m←\033[33m,\033[32mESC\033[33m] │ "  
                                          "移动[\033[32m↑\033[33m/\033[32m↓\033[33m/\033[32mPgUp\033[33m/\033[32mPgDn\033[33m] │ "  
                                          "帮助[\033[32mh\033[33m] |");  
                 }  
                 *key = 0;  
                 break;  
464          case 'H':          case 'H':
465                  *key = 'h';                  *key = 'h';
466                  return 0;                  return 0;
# Line 482  static int display_file_key_handler(int Line 469  static int display_file_key_handler(int
469          return 0;          return 0;
470  }  }
471    
472  int display_file(const char *filename, int begin_line, int wait)  int display_file(const char *filename, int begin_line, int eof_exit)
473  {  {
474          int ret;          int ret;
475          const void *p_shm;          const void *p_shm;
# Line 497  int display_file(const char *filename, i Line 484  int display_file(const char *filename, i
484                  return KEY_NULL;                  return KEY_NULL;
485          }          }
486    
487          ret = display_data(p_data, line_total, p_line_offsets, begin_line, wait, display_file_key_handler, DATA_READ_HELP);          ret = display_data(p_data, line_total, p_line_offsets, begin_line, eof_exit, display_file_key_handler, DATA_READ_HELP);
488    
489          if (detach_file_shm(p_shm) < 0)          if (detach_file_shm(p_shm) < 0)
490          {          {


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

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