/[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.108 by sysadm, Thu Oct 9 12:20:31 2025 UTC Revision 1.113 by sysadm, Fri Oct 17 11:23:30 2025 UTC
# Line 38  Line 38 
38    
39  #define STR_TOP_LEFT_MAX_LEN 80  #define STR_TOP_LEFT_MAX_LEN 80
40  #define STR_TOP_MIDDLE_MAX_LEN 40  #define STR_TOP_MIDDLE_MAX_LEN 40
41  #define STR_TOP_RIGHT_MAX_LEN 40  #define STR_TOP_RIGHT_MAX_LEN 80
42    
43  static const char *get_time_str(char *s, size_t len)  static const char *get_time_str(char *s, size_t len)
44  {  {
# Line 102  void clearscr() Line 102  void clearscr()
102          moveto(0, 0);          moveto(0, 0);
103  }  }
104    
105  int press_any_key()  inline int press_any_key()
106  {  {
107            return press_any_key_ex("                           \033[1;33m按任意键继续...\033[m");
108    }
109    
110    int press_any_key_ex(const char *msg)
111    {
112            int ch = 0;
113            int wait_seconds = 60;
114            int duration = 0;
115            time_t t_begin = time(NULL);
116    
117          moveto(SCREEN_ROWS, 0);          moveto(SCREEN_ROWS, 0);
118          clrtoeol();          clrtoeol();
119    
120          prints("                           \033[1;33m按任意键继续...\033[0;37m");          prints(msg);
121          iflush();          iflush();
122    
123          return igetch_t(MIN(MAX_DELAY_TIME, 60));          do
124            {
125                    ch = igetch_t(wait_seconds - duration);
126                    duration = (int)(time(NULL) - t_begin);
127            } while (!SYS_server_exit && ch == 0 && duration < 60);
128    
129            return ch;
130  }  }
131    
132  void set_input_echo(int echo)  void set_input_echo(int echo)
# Line 118  void set_input_echo(int echo) Line 134  void set_input_echo(int echo)
134          if (echo)          if (echo)
135          {          {
136                  outc('\x83'); // ASCII code 131                  outc('\x83'); // ASCII code 131
                 iflush();  
137          }          }
138          else          else
139          {          {
140                  //    outc ('\x85'); // ASCII code 133                  // outc ('\x85'); // ASCII code 133
141                  prints("\xff\xfb\x01\xff\xfb\x03");                  prints("\xff\xfb\x01\xff\xfb\x03");
                 iflush();  
                 igetch(0);  
                 igetch_reset();  
142          }          }
143            iflush();
144  }  }
145    
146  static int _str_input(char *buffer, int buf_size, int max_display_len, int echo_mode)  static int _str_input(char *buffer, int buf_size, int max_display_len, int echo_mode)
# Line 151  static int _str_input(char *buffer, int Line 164  static int _str_input(char *buffer, int
164    
165                  if (ch == CR)                  if (ch == CR)
166                  {                  {
                         igetch_reset();  
167                          break;                          break;
168                  }                  }
169                  else if (ch == KEY_TIMEOUT || ch == KEY_NULL) // timeout or broken pipe                  else if (ch == KEY_TIMEOUT || ch == KEY_NULL) // timeout or broken pipe
# Line 322  int get_data(int row, int col, char *pro Line 334  int get_data(int row, int col, char *pro
334    
335                  if (ch == CR)                  if (ch == CR)
336                  {                  {
                         igetch_reset();  
337                          break;                          break;
338                  }                  }
339                  else if (ch == KEY_TIMEOUT || ch == KEY_NULL) // timeout or broken pipe                  else if (ch == KEY_TIMEOUT || ch == KEY_NULL) // timeout or broken pipe
# Line 653  int display_data(const void *p_data, lon Line 664  int display_data(const void *p_data, lon
664                                  ch = igetch_t(MAX_DELAY_TIME);                                  ch = igetch_t(MAX_DELAY_TIME);
665                                  input_ok = 1;                                  input_ok = 1;
666    
667                                    if (ch != KEY_NULL && ch != KEY_TIMEOUT)
668                                    {
669                                            BBS_last_access_tm = time(NULL);
670                                    }
671    
672                                  // extended key handler                                  // extended key handler
673                                  if (key_handler(&ch, &ctx) != 0)                                  if (key_handler(&ch, &ctx) != 0)
674                                  {                                  {
# Line 662  int display_data(const void *p_data, lon Line 678  int display_data(const void *p_data, lon
678                                  switch (ch)                                  switch (ch)
679                                  {                                  {
680                                  case KEY_NULL:                                  case KEY_NULL:
681                                            log_error("KEY_NULL\n");
682                                            goto cleanup;
683                                  case KEY_TIMEOUT:                                  case KEY_TIMEOUT:
684                                            log_error("User input timeout\n");
685                                          goto cleanup;                                          goto cleanup;
686                                  case KEY_HOME:                                  case KEY_HOME:
687                                          if (line_current - output_current_row < 0) // Reach begin                                          if (line_current - output_current_row < 0) // Reach begin
# Line 696  int display_data(const void *p_data, lon Line 715  int display_data(const void *p_data, lon
715                                          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
716                                          break;                                          break;
717                                  case CR:                                  case CR:
                                         igetch_reset();  
718                                  case KEY_SPACE:                                  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
# Line 765  int display_data(const void *p_data, lon Line 783  int display_data(const void *p_data, lon
783                                          input_ok = 0;                                          input_ok = 0;
784                                          break;                                          break;
785                                  }                                  }
   
                                 BBS_last_access_tm = time(NULL);  
786                          }                          }
787    
788                          continue;                          continue;


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

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