/[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.35 by sysadm, Tue May 6 05:12:29 2025 UTC Revision 1.39 by sysadm, Tue May 6 13:34:28 2025 UTC
# Line 1  Line 1 
1  /***************************************************************************  /***************************************************************************
2                                                    screen.c  -  description                                                    screen.c  -  description
3                                                           -------------------                                                           -------------------
4          begin                : Mon Oct 18 2004          Copyright            : (C) 2004-2025 by Leaflet
5          copyright            : (C) 2004 by Leaflet          Email                : leaflet@leafok.com
         email                : leaflet@leafok.com  
6   ***************************************************************************/   ***************************************************************************/
7    
8  /***************************************************************************  /***************************************************************************
9   *                                                                         *   *                                                                         *
10   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
11   *   it under the terms of the GNU General Public License as published by  *   *   it under the terms of the GNU General Public License as published by  *
12   *   the Free Software Foundation; either version 2 of the License, or     *   *   the Free Software Foundation; either version 3 of the License, or     *
13   *   (at your option) any later version.                                   *   *   (at your option) any later version.                                   *
14   *                                                                         *   *                                                                         *
15   ***************************************************************************/   ***************************************************************************/
# Line 102  void set_input_echo(int echo) Line 101  void set_input_echo(int echo)
101          }          }
102  }  }
103    
104  static int _str_input(char *buffer, int buffer_length, int echo_mode)  static int _str_input(char *buffer, int buf_size, int echo_mode)
105  {  {
106          int c, offset = 0, i, hz = 0;          int c;
107            int offset = 0;
108            int hz = 0;
109    
110          for (i = 0; i < buffer_length && buffer[i] != '\0'; i++)          buffer[buf_size - 1] = '\0';
111          {          for (offset = 0; offset < buf_size - 1 && buffer[offset] != '\0'; offset++);
                 offset++;  
         }  
112    
113          while ((c = igetch_t(60)))          while ((c = igetch_t(60)))
114          {          {
# Line 149  static int _str_input(char *buffer, int Line 148  static int _str_input(char *buffer, int
148                  }                  }
149                  if (c > 127 && c <= 255)                  if (c > 127 && c <= 255)
150                  {                  {
151                          if (!hz && offset + 2 > buffer_length) // No enough space for Chinese character                          if (!hz && offset + 2 > buf_size - 1) // No enough space for Chinese character
152                          {                          {
153                                  igetch(1); // Cleanup remaining input                                  igetch(1); // Cleanup remaining input
154                                  outc('\a');                                  outc('\a');
# Line 158  static int _str_input(char *buffer, int Line 157  static int _str_input(char *buffer, int
157                          }                          }
158                          hz = (!hz);                          hz = (!hz);
159                  }                  }
160                  if (offset >= buffer_length)                  if (offset + 1 > buf_size - 1)
161                  {                  {
162                          outc('\a');                          outc('\a');
163                          iflush();                          iflush();
# Line 184  static int _str_input(char *buffer, int Line 183  static int _str_input(char *buffer, int
183          return offset;          return offset;
184  }  }
185    
186  int str_input(char *buffer, int buffer_length, int echo_mode)  int str_input(char *buffer, int buf_size, int echo_mode)
187  {  {
188          int len;          int len;
189    
190          buffer[0] = '\0';          buffer[0] = '\0';
191    
192          len = _str_input(buffer, buffer_length, echo_mode);          len = _str_input(buffer, buf_size, echo_mode);
193    
194          prints("\r\n");          prints("\r\n");
195          iflush();          iflush();
# Line 198  int str_input(char *buffer, int buffer_l Line 197  int str_input(char *buffer, int buffer_l
197          return len;          return len;
198  };  };
199    
200  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 buf_size, int echo_mode)
201  {  {
202          int len;          int len;
203    
# Line 209  int get_data(int row, int col, char *pro Line 208  int get_data(int row, int col, char *pro
208          prints(buffer);          prints(buffer);
209          iflush();          iflush();
210    
211          len = _str_input(buffer, buffer_length, echo_mode);          len = _str_input(buffer, buf_size, echo_mode);
212    
213          return len;          return len;
214  }  }
# Line 244  int display_file(const char *filename) Line 243  int display_file(const char *filename)
243    
244  int display_file_ex(const char *filename, int begin_line, int wait)  int display_file_ex(const char *filename, int begin_line, int wait)
245  {  {
246            static int show_help = 1;
247          char buffer[LINE_BUFFER_LEN];          char buffer[LINE_BUFFER_LEN];
248          int ch = 0;          int ch = 0;
249          int input_ok, line, max_lines;          int input_ok, line, max_lines;
# Line 317  int display_file_ex(const char *filename Line 317  int display_file_ex(const char *filename
317                                          }                                          }
318                                          c_line_current -= line;                                          c_line_current -= line;
319                                          line = begin_line;                                          line = begin_line;
320                                          max_lines = begin_line + 1;                                          // max_lines = begin_line + 1;
321                                          prints("\033[T"); // Scroll down 1 line                                          // prints("\033[T"); // Scroll down 1 line
322                                          // max_lines = screen_rows - 1; // Legacy Fterm only works with this line                                          max_lines = screen_rows - 1; // Legacy Fterm only works with this line
323                                          break;                                          break;
324                                  case KEY_DOWN:                                  case KEY_DOWN:
325                                  case CR:                                  case CR:
# Line 376  int display_file_ex(const char *filename Line 376  int display_file_ex(const char *filename
376                                  case '?':                                  case '?':
377                                  case 'h':                                  case 'h':
378                                  case 'H':                                  case 'H':
379                                            if (!show_help)
380                                            {
381                                                    break;
382                                            }
383    
384                                          // Display help information                                          // Display help information
385                                            show_help = 0;
386                                          display_file_ex(DATA_READ_HELP, begin_line, 1);                                          display_file_ex(DATA_READ_HELP, begin_line, 1);
387                                            show_help = 1;
388    
389                                          // Refresh after display help information                                          // Refresh after display help information
390                                          c_line_current -= (line - 1);                                          c_line_current -= (line - 1);


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

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