/[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.29 by sysadm, Sun May 4 01:44:00 2025 UTC Revision 1.33 by sysadm, Mon May 5 11:11:06 2025 UTC
# Line 104  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          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                  {                  {
# Line 127  static int _str_input(char *buffer, int Line 126  static int _str_input(char *buffer, int
126                  {                  {
127                          if (offset > 0)                          if (offset > 0)
128                          {                          {
129                                  buffer[--offset] = '\0';                                  offset--;
130                                  prints("\b \b");                                  if (buffer[offset] < 0 || buffer[offset] > 127)
131                                  //            clrtoeol ();                                  {
132                                            prints("\033[D \033[D");
133                                            offset--;
134                                            if (offset < 0) // should not happen
135                                            {
136                                                    log_error("Offset of buffer is negative\n");
137                                                    offset = 0;
138                                            }
139                                    }
140                                    buffer[offset] = '\0';
141                                    prints("\033[D \033[D");
142                                  iflush();                                  iflush();
143                          }                          }
144                          continue;                          continue;
# Line 140  static int _str_input(char *buffer, int Line 149  static int _str_input(char *buffer, int
149                  }                  }
150                  if (c > 127 && c <= 255)                  if (c > 127 && c <= 255)
151                  {                  {
152                            if (!hz && offset + 2 > buffer_length) // No enough space for Chinese character
153                            {
154                                    igetch(1); // Cleanup remaining input
155                                    outc('\a');
156                                    iflush();
157                                    continue;
158                            }
159                          hz = (!hz);                          hz = (!hz);
160                  }                  }
161                  if (offset >= buffer_length)                  if (offset >= buffer_length)
162                  {                  {
163                          outc('\a');                          outc('\a');
164                            iflush();
165                          continue;                          continue;
166                  }                  }
167                  buffer[offset++] = (char)c;                  buffer[offset++] = (char)c;
# Line 164  static int _str_input(char *buffer, int Line 181  static int _str_input(char *buffer, int
181                  }                  }
182          }          }
183    
         prints("\r\n");  
         iflush();  
   
184          return offset;          return offset;
185  }  }
186    
187  int str_input(char *buffer, int buffer_length, int echo_mode)  int str_input(char *buffer, int buffer_length, int echo_mode)
188  {  {
189          int offset;          int len;
190    
191          memset(buffer, '\0', buffer_length);          buffer[0] = '\0';
192    
193          offset = _str_input(buffer, buffer_length, echo_mode);          len = _str_input(buffer, buffer_length, echo_mode);
194    
195          return offset;          prints("\r\n");
196            iflush();
197    
198            return len;
199  };  };
200    
201  int get_data(int row, int col, char *prompt, char *buffer, int buffer_length, int echo_mode)  int get_data(int row, int col, char *prompt, char *buffer, int buffer_length, int echo_mode)
# Line 226  int display_file(const char *filename) Line 243  int display_file(const char *filename)
243  int display_file_ex(const char *filename, int begin_line, int wait)  int display_file_ex(const char *filename, int begin_line, int wait)
244  {  {
245          char buffer[LINE_BUFFER_LEN];          char buffer[LINE_BUFFER_LEN];
         char temp[LINE_BUFFER_LEN];  
246          int ch = 0;          int ch = 0;
247          int input_ok, line, max_lines;          int input_ok, line, max_lines;
248          long int c_line_current = 0, c_line_total = 0;          long int c_line_current = 0, c_line_total = 0;
249          FILE *fin;          FILE *fin;
         struct stat f_stat;  
250          long *p_line_offsets;          long *p_line_offsets;
251          int len;          int len;
252          int percentile;          int percentile;
# Line 359  int display_file_ex(const char *filename Line 374  int display_file_ex(const char *filename
374                                  case 'h':                                  case 'h':
375                                  case 'H':                                  case 'H':
376                                          // Display help information                                          // Display help information
377                                          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);  
378    
379                                          // Refresh after display help information                                          // Refresh after display help information
380                                          c_line_current -= (line - 1);                                          c_line_current -= (line - 1);
# Line 407  int show_top(char *status) Line 420  int show_top(char *status)
420  {  {
421          char buffer[LINE_BUFFER_LEN];          char buffer[LINE_BUFFER_LEN];
422    
423          str_space(buffer, 20 - strlen(BBS_current_section_name));          str_space(buffer, 20 - strnlen(BBS_current_section_name, sizeof(BBS_current_section_name)));
424    
425          moveto(1, 0);          moveto(1, 0);
426          clrtoeol();          clrtoeol();
# Line 422  int show_top(char *status) Line 435  int show_top(char *status)
435  int show_bottom(char *msg)  int show_bottom(char *msg)
436  {  {
437          char str_time[LINE_BUFFER_LEN];          char str_time[LINE_BUFFER_LEN];
         char str_time_onine[20];  
438          char buffer[LINE_BUFFER_LEN];          char buffer[LINE_BUFFER_LEN];
439          time_t time_online;          time_t time_online;
440          struct tm *tm_online;          struct tm *tm_online;
441    
442          get_time_str(str_time, sizeof(str_time));          get_time_str(str_time, sizeof(str_time));
443          str_space(buffer, 33 - strlen(BBS_username));          str_space(buffer, 33 - strnlen(BBS_username, sizeof(BBS_username)));
444    
445          time_online = time(0) - BBS_login_tm;          time_online = time(0) - BBS_login_tm;
446          tm_online = gmtime(&time_online);          tm_online = gmtime(&time_online);
# Line 454  int show_active_board() Line 466  int show_active_board()
466          int len;          int len;
467          int end_of_line;          int end_of_line;
468    
         sprintf(filename, "%sdata/active_board.txt", app_home_dir);  
   
469          clrline(3, 2 + ACTIVE_BOARD_HEIGHT);          clrline(3, 2 + ACTIVE_BOARD_HEIGHT);
470    
471          if ((fin = fopen(filename, "r")) == NULL)          if ((fin = fopen(DATA_ACTIVE_BOARD, "r")) == NULL)
472          {          {
473                  log_error("Unable to open file %s\n", filename);                  log_error("Unable to open file %s\n", filename);
474                  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