/[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.113 by sysadm, Fri Oct 17 11:23:30 2025 UTC Revision 1.118 by sysadm, Fri Oct 24 10:53:08 2025 UTC
# Line 104  void clearscr() Line 104  void clearscr()
104    
105  inline int press_any_key()  inline int press_any_key()
106  {  {
107          return press_any_key_ex("                           \033[1;33m按任意键继续...\033[m");          return press_any_key_ex("                           \033[1;33m按任意键继续...\033[m", 60);
108  }  }
109    
110  int press_any_key_ex(const char *msg)  int press_any_key_ex(const char *msg, int sec)
111  {  {
112          int ch = 0;          int ch = 0;
         int wait_seconds = 60;  
113          int duration = 0;          int duration = 0;
114          time_t t_begin = time(NULL);          time_t t_begin = time(NULL);
115    
# Line 120  int press_any_key_ex(const char *msg) Line 119  int press_any_key_ex(const char *msg)
119          prints(msg);          prints(msg);
120          iflush();          iflush();
121    
122            igetch_reset();
123    
124          do          do
125          {          {
126                  ch = igetch_t(wait_seconds - duration);                  ch = igetch_t(sec - duration);
127                  duration = (int)(time(NULL) - t_begin);                  duration = (int)(time(NULL) - t_begin);
128          } while (!SYS_server_exit && ch == 0 && duration < 60);          } while (!SYS_server_exit && ch == 0 && duration < 60);
129    
# Line 181  static int _str_input(char *buffer, int Line 182  static int _str_input(char *buffer, int
182                                  offset--;                                  offset--;
183                                  if (buffer[offset] < 0 || buffer[offset] > 127) // UTF8                                  if (buffer[offset] < 0 || buffer[offset] > 127) // UTF8
184                                  {                                  {
185                                          while (offset > 0 && (buffer[offset] & 0b11000000) != 0b11000000)                                          while (offset > 0 && (buffer[offset] & 0xc0) != 0xc0)
186                                          {                                          {
187                                                  offset--;                                                  offset--;
188                                          }                                          }
# Line 202  static int _str_input(char *buffer, int Line 203  static int _str_input(char *buffer, int
203                  else if ((ch & 0xff80) == 0x80) // head of multi-byte character                  else if ((ch & 0xff80) == 0x80) // head of multi-byte character
204                  {                  {
205                          str_len = 0;                          str_len = 0;
206                          c = (char)(ch & 0b11110000);                          c = (char)(ch & 0xf0);
207                          while (c & 0b10000000)                          while (c & 0x80)
208                          {                          {
209                                  input_str[str_len] = (char)(ch - 256);                                  input_str[str_len] = (char)(ch - 256);
210                                  str_len++;                                  str_len++;
211                                  c = (c & 0b01111111) << 1;                                  c = (c & 0x7f) << 1;
212    
213                                  if ((c & 0b10000000) == 0) // Input completed                                  if ((c & 0x80) == 0) // Input completed
214                                  {                                  {
215                                          break;                                          break;
216                                  }                                  }
# Line 299  int str_input(char *buffer, int buf_size Line 300  int str_input(char *buffer, int buf_size
300          iflush();          iflush();
301    
302          return len;          return len;
303  };  }
304    
305  int get_data(int row, int col, char *prompt, char *buffer, int buf_size, int max_display_len)  int get_data(int row, int col, char *prompt, char *buffer, int buf_size, int max_display_len)
306  {  {
# Line 352  int get_data(int row, int col, char *pro Line 353  int get_data(int row, int col, char *pro
353                                  offset--;                                  offset--;
354                                  if (buffer[offset] < 0 || buffer[offset] > 127) // UTF8                                  if (buffer[offset] < 0 || buffer[offset] > 127) // UTF8
355                                  {                                  {
356                                          while (offset > 0 && (buffer[offset] & 0b11000000) != 0b11000000)                                          while (offset > 0 && (buffer[offset] & 0xc0) != 0xc0)
357                                          {                                          {
358                                                  str_len++;                                                  str_len++;
359                                                  offset--;                                                  offset--;
# Line 382  int get_data(int row, int col, char *pro Line 383  int get_data(int row, int col, char *pro
383                                  if ((buffer[offset] & 0x80) == 0x80) // head of multi-byte character                                  if ((buffer[offset] & 0x80) == 0x80) // head of multi-byte character
384                                  {                                  {
385                                          str_len = 0;                                          str_len = 0;
386                                          c = (char)(buffer[offset] & 0b11110000);                                          c = (char)(buffer[offset] & 0xf0);
387                                          while (c & 0b10000000)                                          while (c & 0x80)
388                                          {                                          {
389                                                  str_len++;                                                  str_len++;
390                                                  c = (c & 0b01111111) << 1;                                                  c = (c & 0x7f) << 1;
391                                          }                                          }
392                                          display_len--;                                          display_len--;
393                                  }                                  }
# Line 416  int get_data(int row, int col, char *pro Line 417  int get_data(int row, int col, char *pro
417                                  offset--;                                  offset--;
418                                  if (buffer[offset] < 0 || buffer[offset] > 127) // UTF8                                  if (buffer[offset] < 0 || buffer[offset] > 127) // UTF8
419                                  {                                  {
420                                          while (offset > 0 && (buffer[offset] & 0b11000000) != 0b11000000)                                          while (offset > 0 && (buffer[offset] & 0xc0) != 0xc0)
421                                          {                                          {
422                                                  str_len++;                                                  str_len++;
423                                                  offset--;                                                  offset--;
# Line 437  int get_data(int row, int col, char *pro Line 438  int get_data(int row, int col, char *pro
438                                  str_len = 0;                                  str_len = 0;
439                                  if ((buffer[offset] & 0x80) == 0x80) // head of multi-byte character                                  if ((buffer[offset] & 0x80) == 0x80) // head of multi-byte character
440                                  {                                  {
441                                          c = (char)(buffer[offset] & 0b11110000);                                          c = (char)(buffer[offset] & 0xf0);
442                                          while (c & 0b10000000)                                          while (c & 0x80)
443                                          {                                          {
444                                                  str_len++;                                                  str_len++;
445                                                  c = (c & 0b01111111) << 1;                                                  c = (c & 0x7f) << 1;
446                                          }                                          }
447                                          col_cur++;                                          col_cur++;
448                                  }                                  }
# Line 489  int get_data(int row, int col, char *pro Line 490  int get_data(int row, int col, char *pro
490                  else if ((ch & 0xff80) == 0x80) // head of multi-byte character                  else if ((ch & 0xff80) == 0x80) // head of multi-byte character
491                  {                  {
492                          str_len = 0;                          str_len = 0;
493                          c = (char)(ch & 0b11110000);                          c = (char)(ch & 0xf0);
494                          while (c & 0b10000000)                          while (c & 0x80)
495                          {                          {
496                                  input_str[str_len] = (char)(ch - 256);                                  input_str[str_len] = (char)(ch - 256);
497                                  str_len++;                                  str_len++;
498                                  c = (c & 0b01111111) << 1;                                  c = (c & 0x7f) << 1;
499    
500                                  if ((c & 0b10000000) == 0) // Input completed                                  if ((c & 0x80) == 0) // Input completed
501                                  {                                  {
502                                          break;                                          break;
503                                  }                                  }
# Line 715  int display_data(const void *p_data, lon Line 716  int display_data(const void *p_data, lon
716                                          output_end_row = SCREEN_ROWS - 1; // Legacy Fterm only works with this line                                          output_end_row = SCREEN_ROWS - 1; // Legacy Fterm only works with this line
717                                          break;                                          break;
718                                  case CR:                                  case CR:
                                 case KEY_SPACE:  
719                                  case KEY_DOWN:                                  case KEY_DOWN:
720                                          if (line_current + (screen_row_total - (output_current_row - screen_begin_row)) >= display_line_total) // Reach end                                          if (line_current + (screen_row_total - (output_current_row - screen_begin_row)) >= display_line_total) // Reach end
721                                          {                                          {
# Line 743  int display_data(const void *p_data, lon Line 743  int display_data(const void *p_data, lon
743                                          output_end_row = SCREEN_ROWS - 1;                                          output_end_row = SCREEN_ROWS - 1;
744                                          clrline(output_current_row, SCREEN_ROWS);                                          clrline(output_current_row, SCREEN_ROWS);
745                                          break;                                          break;
746                                    case KEY_SPACE:
747                                  case KEY_PGDN:                                  case KEY_PGDN:
748                                          if (line_current + screen_row_total - (output_current_row - screen_begin_row) >= display_line_total) // Reach end                                          if (line_current + screen_row_total - (output_current_row - screen_begin_row) >= display_line_total) // Reach end
749                                          {                                          {


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

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