/[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.26 by sysadm, Sat May 3 06:24:54 2025 UTC Revision 1.27 by sysadm, Sat May 3 10:11:37 2025 UTC
# Line 238  int display_file_ex(const char *filename Line 238  int display_file_ex(const char *filename
238          long *p_line_offsets;          long *p_line_offsets;
239          int len;          int len;
240          int percentile;          int percentile;
241            int loop = 1;
242    
243          if ((fin = fopen(filename, "r")) == NULL)          if ((fin = fopen(filename, "r")) == NULL)
244          {          {
# Line 253  int display_file_ex(const char *filename Line 254  int display_file_ex(const char *filename
254          line = begin_line;          line = begin_line;
255          max_lines = screen_rows - 1;          max_lines = screen_rows - 1;
256    
257          while (c_line_current < c_line_total)          while (loop)
258          {          {
259                    if (c_line_current >= c_line_total)
260                    {
261                            if (wait)
262                            {
263                                    ch = press_any_key();
264                            }
265                            else
266                            {
267                                    iflush();
268                            }
269    
270                            loop = 0;
271                            break;
272                    }
273    
274                  if (line >= max_lines)                  if (line >= max_lines)
275                  {                  {
276                          percentile = (c_line_current - (line - 1) + (screen_rows - 2)) * 100 / c_line_total;                          if (c_line_current - (line - 1) + (screen_rows - 2) < c_line_total)
277                            {
278                                    percentile = (c_line_current - (line - 1) + (screen_rows - 2)) * 100 / c_line_total;
279                            }
280                            else
281                            {
282                                    log_error("P100 reached\n");
283                                    percentile = 100;
284                            }
285    
286                          moveto(screen_rows, 0);                          moveto(screen_rows, 0);
287                          prints("\033[1;44;32m下面还有喔 (%d%%)\033[33m   │ 结束 ← <q> │ ↑/↓/PgUp/PgDn 移动 │ ? 辅助说明 │     \033[m",                          prints("\033[1;44;32m下面还有喔 (%d%%)\033[33m   │ 结束 ← <q> │ ↑/↓/PgUp/PgDn 移动 │ ? 辅助说明 │     \033[m",
# Line 331  int display_file_ex(const char *filename Line 355  int display_file_ex(const char *filename
355                                  case KEY_LEFT:                                  case KEY_LEFT:
356                                  case 'q':                                  case 'q':
357                                  case 'Q':                                  case 'Q':
358                                          c_line_current = c_line_total;                                          loop = 0;
                                         wait = 0;  
359                                          break;                                          break;
360                                  case '?':                                  case '?':
361                                  case 'h':                                  case 'h':
# Line 376  int display_file_ex(const char *filename Line 399  int display_file_ex(const char *filename
399                  line++;                  line++;
400          }          }
401    
         iflush();  
   
         if (wait)  
         {  
                 ch = press_any_key();  
         }  
   
402          free(p_line_offsets);          free(p_line_offsets);
403          fclose(fin);          fclose(fin);
404    


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

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