/[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.106 by sysadm, Sun Jul 20 02:04:21 2025 UTC Revision 1.135 by sysadm, Thu Dec 18 02:56:01 2025 UTC
# Line 1  Line 1 
1  /***************************************************************************  /* SPDX-License-Identifier: GPL-3.0-or-later */
2                                                    screen.c  -  description  /*
3                                                           -------------------   * screen
4          Copyright            : (C) 2004-2025 by Leaflet   *   - advanced telnet-based user interactive input / output features
5          Email                : leaflet@leafok.com   *
6   ***************************************************************************/   * Copyright (C) 2004-2025  Leaflet <leaflet@leafok.com>
7     */
8  /***************************************************************************  
9   *                                                                         *  #ifdef HAVE_CONFIG_H
10   *   This program is free software; you can redistribute it and/or modify  *  #include "config.h"
11   *   it under the terms of the GNU General Public License as published by  *  #endif
  *   the Free Software Foundation; either version 3 of the License, or     *  
  *   (at your option) any later version.                                   *  
  *                                                                         *  
  ***************************************************************************/  
12    
13  #include "bbs.h"  #include "bbs.h"
14  #include "common.h"  #include "common.h"
# Line 29  Line 25 
25  #include <string.h>  #include <string.h>
26  #include <stdlib.h>  #include <stdlib.h>
27  #include <unistd.h>  #include <unistd.h>
28    #include <wchar.h>
29  #include <sys/param.h>  #include <sys/param.h>
30  #include <sys/stat.h>  #include <sys/stat.h>
 #include <sys/shm.h>  
31  #include <sys/types.h>  #include <sys/types.h>
32    
33  #define ACTIVE_BOARD_HEIGHT 8  const char CTRL_SEQ_CLR_LINE[] = "\033[K";
34    
35    static const int ACTIVE_BOARD_HEIGHT = 8;
36    
37    static const int STR_TOP_LEFT_MAX_LEN = 80;
38    static const int STR_TOP_MIDDLE_MAX_LEN = 40;
39    static const int STR_TOP_RIGHT_MAX_LEN = 80;
40    
41  #define STR_TOP_LEFT_MAX_LEN 80  static size_t get_time_str(char *s, size_t len)
42  #define STR_TOP_MIDDLE_MAX_LEN 40  {
43  #define STR_TOP_RIGHT_MAX_LEN 40          time_t curtime;
44            struct tm local_tm;
45    
46            time(&curtime);
47            localtime_r(&curtime, &local_tm);
48            size_t j = strftime(s, len, "%m/%d %H:%M %Z", &local_tm);
49    
50            return j;
51    }
52    
53  void moveto(int row, int col)  void moveto(int row, int col)
54  {  {
# Line 78  void clrtobot(int line_begin) Line 88  void clrtobot(int line_begin)
88  void clearscr()  void clearscr()
89  {  {
90          prints("\033[2J");          prints("\033[2J");
91          moveto(0, 0);          moveto(1, 1);
92  }  }
93    
94  int press_any_key()  inline int press_any_key()
95  {  {
96            return press_any_key_ex("                           \033[1;33m按任意键继续...\033[m", 60);
97    }
98    
99    int press_any_key_ex(const char *msg, int sec)
100    {
101            int ch = 0;
102            int duration = 0;
103            time_t t_begin = time(NULL);
104    
105          moveto(SCREEN_ROWS, 0);          moveto(SCREEN_ROWS, 0);
106          clrtoeol();          clrtoeol();
107    
108          prints("                           \033[1;33m按任意键继续...\033[0;37m");          prints(msg);
109          iflush();          iflush();
110    
111          return igetch_t(MIN(MAX_DELAY_TIME, 60));          igetch_reset();
112    
113            do
114            {
115                    ch = igetch_t(sec - duration);
116                    duration = (int)(time(NULL) - t_begin);
117            } while (!SYS_server_exit && ch == 0 && duration < 60);
118    
119            return ch;
120  }  }
121    
122  void set_input_echo(int echo)  void set_input_echo(int echo)
# Line 97  void set_input_echo(int echo) Line 124  void set_input_echo(int echo)
124          if (echo)          if (echo)
125          {          {
126                  outc('\x83'); // ASCII code 131                  outc('\x83'); // ASCII code 131
                 iflush();  
127          }          }
128          else          else
129          {          {
130                  //    outc ('\x85'); // ASCII code 133                  // outc ('\x85'); // ASCII code 133
131                  prints("\xff\xfb\x01\xff\xfb\x03");                  prints("\xff\xfb\x01\xff\xfb\x03");
                 iflush();  
                 igetch(0);  
                 igetch_reset();  
132          }          }
133            iflush();
134  }  }
135    
136  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, enum io_echo_t echo_mode)
137  {  {
138          int ch;          int ch;
139          int offset = 0;          int offset = 0;
140          int eol;          int eol;
141          int display_len;          int display_len;
142          char input_str[4];          char input_str[5];
143          int str_len = 0;          int str_len = 0;
144            wchar_t wcs[2];
145          char c;          char c;
146    
147          buffer[buf_size - 1] = '\0';          buffer[buf_size - 1] = '\0';
# Line 126  static int _str_input(char *buffer, int Line 151  static int _str_input(char *buffer, int
151    
152          while (!SYS_server_exit)          while (!SYS_server_exit)
153          {          {
154                  ch = igetch_t(MIN(MAX_DELAY_TIME, 60));                  ch = igetch_t(MIN(BBS_max_user_idle_time, 60));
155    
156                  if (ch == CR)                  if (ch == CR)
157                  {                  {
                         igetch_reset();  
158                          break;                          break;
159                  }                  }
160                  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 148  static int _str_input(char *buffer, int Line 172  static int _str_input(char *buffer, int
172                                  offset--;                                  offset--;
173                                  if (buffer[offset] < 0 || buffer[offset] > 127) // UTF8                                  if (buffer[offset] < 0 || buffer[offset] > 127) // UTF8
174                                  {                                  {
175                                          while (offset > 0 && (buffer[offset] & 0b11000000) != 0b11000000)                                          while (offset > 0 && (buffer[offset] & 0xc0) != 0xc0)
176                                          {                                          {
177                                                  offset--;                                                  offset--;
178                                          }                                          }
# Line 169  static int _str_input(char *buffer, int Line 193  static int _str_input(char *buffer, int
193                  else if ((ch & 0xff80) == 0x80) // head of multi-byte character                  else if ((ch & 0xff80) == 0x80) // head of multi-byte character
194                  {                  {
195                          str_len = 0;                          str_len = 0;
196                          c = (char)(ch & 0b11110000);                          c = (char)(ch & 0xf0);
197                          while (c & 0b10000000)                          while (c & 0x80)
198                          {                          {
199                                  input_str[str_len] = (char)(ch - 256);                                  input_str[str_len] = (char)(ch - 256);
200                                  str_len++;                                  str_len++;
201                                  c = (c & 0b01111111) << 1;                                  c = (c & 0x7f) << 1;
202    
203                                  if ((c & 0b10000000) == 0) // Input completed                                  if ((c & 0x80) == 0) // Input completed
204                                  {                                  {
205                                          break;                                          break;
206                                  }                                  }
# Line 185  static int _str_input(char *buffer, int Line 209  static int _str_input(char *buffer, int
209                                  ch = igetch(100);                                                // 0.1 second                                  ch = igetch(100);                                                // 0.1 second
210                                  if (ch == KEY_NULL || ch == KEY_TIMEOUT) // Ignore received bytes if no futher input                                  if (ch == KEY_NULL || ch == KEY_TIMEOUT) // Ignore received bytes if no futher input
211                                  {                                  {
212  #ifdef _DEBUG                                          log_debug("Ignore %d bytes of incomplete UTF8 character\n", str_len);
                                         log_error("Ignore %d bytes of incomplete UTF8 character\n", str_len);  
 #endif  
213                                          str_len = 0;                                          str_len = 0;
214                                          break;                                          break;
215                                  }                                  }
216                          }                          }
217                            input_str[str_len] = '\0';
218    
219                          if (str_len == 0) // Incomplete input                          if (str_len == 0) // Incomplete input
220                          {                          {
221                                  continue;                                  continue;
222                          }                          }
223    
224                          if (offset + str_len > buf_size - 1 || display_len + 2 > max_display_len) // No enough space for Chinese character                          if (mbstowcs(wcs, input_str, 1) == (size_t)-1)
225                            {
226                                    log_error("mbstowcs() error\n");
227                            }
228                            if (offset + str_len > buf_size - 1 || display_len + (UTF8_fixed_width ? 2 : wcwidth(wcs[0])) > max_display_len) // No enough space for Chinese character
229                          {                          {
230                                  outc('\a');                                  outc('\a');
231                                  iflush();                                  iflush();
# Line 254  static int _str_input(char *buffer, int Line 281  static int _str_input(char *buffer, int
281          return offset;          return offset;
282  }  }
283    
284  int str_input(char *buffer, int buf_size, int echo_mode)  int str_input(char *buffer, int buf_size, enum io_echo_t echo_mode)
285  {  {
286          int len;          int len;
287    
# Line 266  int str_input(char *buffer, int buf_size Line 293  int str_input(char *buffer, int buf_size
293          iflush();          iflush();
294    
295          return len;          return len;
296  };  }
297    
298  int get_data(int row, int col, char *prompt, char *buffer, int buf_size, int max_display_len, int echo_mode)  int get_data(int row, int col, char *prompt, char *buffer, int buf_size, int max_display_len)
299  {  {
300          int len;          int len = 0;
301            int col_cur = 0;
302            int ch;
303            int offset = 0;
304            int eol;
305            int display_len;
306            char input_str[5];
307            int str_len = 0;
308            wchar_t wcs[2];
309            int wc_len;
310            char c;
311    
312            buffer[buf_size - 1] = '\0';
313            offset = split_line(buffer, max_display_len, &eol, &display_len, 0);
314            buffer[offset] = '\0';
315            len = offset;
316            col_cur = col + str_length(prompt, 1) + display_len;
317    
318          moveto(row, col);          moveto(row, col);
319          prints("%s", prompt);          prints("%s", prompt);
320          prints("%s", buffer);          prints("%s", buffer);
321            prints("%*s", max_display_len - display_len, "");
322            moveto(row, col_cur);
323          iflush();          iflush();
324    
325          len = _str_input(buffer, buf_size, max_display_len, echo_mode);          igetch_reset();
326    
327            while (!SYS_server_exit)
328            {
329                    ch = igetch_t(MIN(BBS_max_user_idle_time, 60));
330    
331                    if (ch == CR)
332                    {
333                            break;
334                    }
335                    else if (ch == KEY_TIMEOUT || ch == KEY_NULL) // timeout or broken pipe
336                    {
337                            return -1;
338                    }
339                    else if (ch == LF || ch == '\0')
340                    {
341                            continue;
342                    }
343                    else if (ch == BACKSPACE)
344                    {
345                            if (offset > 0)
346                            {
347                                    str_len = 1;
348                                    offset--;
349                                    if (buffer[offset] < 0 || buffer[offset] > 127) // UTF8
350                                    {
351                                            while (offset > 0 && (buffer[offset] & 0xc0) != 0xc0)
352                                            {
353                                                    str_len++;
354                                                    offset--;
355                                            }
356    
357                                            if (mbstowcs(wcs, buffer + offset, 1) == (size_t)-1)
358                                            {
359                                                    log_error("mbstowcs() error\n");
360                                            }
361                                            wc_len = (UTF8_fixed_width ? 2 : wcwidth(wcs[0]));
362    
363                                            if (wc_len == 2)
364                                            {
365                                                    display_len--;
366                                                    col_cur--;
367                                            }
368                                    }
369    
370                                    memmove(buffer + offset, buffer + offset + str_len, (size_t)(len - offset - str_len));
371                                    len -= str_len;
372                                    buffer[len] = '\0';
373                                    display_len--;
374                                    col_cur--;
375    
376                                    moveto(row, col_cur);
377                                    prints("%s", buffer + offset);
378                                    prints("%*s", max_display_len - display_len, "");
379                                    moveto(row, col_cur);
380                                    iflush();
381                            }
382                            continue;
383                    }
384                    else if (ch == KEY_DEL)
385                    {
386                            if (offset < len)
387                            {
388                                    if ((buffer[offset] & 0x80) == 0x80) // head of multi-byte character
389                                    {
390                                            str_len = 0;
391                                            c = (char)(buffer[offset] & 0xf0);
392                                            while (c & 0x80)
393                                            {
394                                                    str_len++;
395                                                    c = (c & 0x7f) << 1;
396                                            }
397                                            display_len--;
398                                    }
399                                    else
400                                    {
401                                            str_len = 1;
402                                    }
403    
404                                    memmove(buffer + offset, buffer + offset + str_len, (size_t)(len - offset - str_len));
405                                    len -= str_len;
406                                    buffer[len] = '\0';
407                                    display_len--;
408    
409                                    moveto(row, col_cur);
410                                    prints("%s", buffer + offset);
411                                    prints("%*s", max_display_len - display_len, "");
412                                    moveto(row, col_cur);
413                                    iflush();
414                            }
415                            continue;
416                    }
417                    else if (ch == KEY_LEFT)
418                    {
419                            if (offset > 0)
420                            {
421                                    str_len = 1;
422                                    offset--;
423                                    if (buffer[offset] < 0 || buffer[offset] > 127) // UTF8
424                                    {
425                                            while (offset > 0 && (buffer[offset] & 0xc0) != 0xc0)
426                                            {
427                                                    str_len++;
428                                                    offset--;
429                                            }
430    
431                                            if (mbstowcs(wcs, buffer + offset, 1) == (size_t)-1)
432                                            {
433                                                    log_error("mbstowcs() error\n");
434                                            }
435                                            wc_len = (UTF8_fixed_width ? 2 : wcwidth(wcs[0]));
436    
437                                            if (wc_len == 2)
438                                            {
439                                                    col_cur--;
440                                            }
441                                    }
442                                    col_cur--;
443    
444                                    moveto(row, col_cur);
445                                    iflush();
446                            }
447                            continue;
448                    }
449                    else if (ch == KEY_RIGHT)
450                    {
451                            if (offset < len)
452                            {
453                                    str_len = 0;
454                                    if ((buffer[offset] & 0x80) == 0x80) // head of multi-byte character
455                                    {
456                                            c = (char)(buffer[offset] & 0xf0);
457                                            while (c & 0x80)
458                                            {
459                                                    str_len++;
460                                                    c = (c & 0x7f) << 1;
461                                            }
462    
463                                            if (mbstowcs(wcs, buffer + offset, 1) == (size_t)-1)
464                                            {
465                                                    log_error("mbstowcs() error\n");
466                                            }
467                                            wc_len = (UTF8_fixed_width ? 2 : wcwidth(wcs[0]));
468    
469                                            if (wc_len == 2)
470                                            {
471                                                    col_cur++;
472                                            }
473                                    }
474                                    else
475                                    {
476                                            str_len = 1;
477                                    }
478    
479                                    col_cur++;
480                                    offset += str_len;
481    
482                                    moveto(row, col_cur);
483                                    iflush();
484                            }
485                            continue;
486                    }
487                    else if (ch == KEY_HOME || ch == KEY_UP)
488                    {
489                            if (offset > 0)
490                            {
491                                    offset = 0;
492                                    col_cur = col + str_length(prompt, 1);
493    
494                                    moveto(row, col_cur);
495                                    iflush();
496                            }
497                            continue;
498                    }
499                    else if (ch == KEY_END || ch == KEY_DOWN)
500                    {
501                            if (offset < len)
502                            {
503                                    offset = len;
504                                    col_cur = col + str_length(prompt, 1) + display_len;
505    
506                                    moveto(row, col_cur);
507                                    iflush();
508                            }
509                            continue;
510                    }
511                    else if (ch > 255 || iscntrl(ch))
512                    {
513                            continue;
514                    }
515                    else if ((ch & 0xff80) == 0x80) // head of multi-byte character
516                    {
517                            str_len = 0;
518                            c = (char)(ch & 0xf0);
519                            while (c & 0x80)
520                            {
521                                    input_str[str_len] = (char)(ch - 256);
522                                    str_len++;
523                                    c = (c & 0x7f) << 1;
524    
525                                    if ((c & 0x80) == 0) // Input completed
526                                    {
527                                            break;
528                                    }
529    
530                                    // Expect additional bytes of input
531                                    ch = igetch(100);                                                // 0.1 second
532                                    if (ch == KEY_NULL || ch == KEY_TIMEOUT) // Ignore received bytes if no futher input
533                                    {
534                                            log_debug("Ignore %d bytes of incomplete UTF8 character\n", str_len);
535                                            str_len = 0;
536                                            break;
537                                    }
538                            }
539                            input_str[str_len] = '\0';
540    
541                            if (str_len == 0) // Incomplete input
542                            {
543                                    continue;
544                            }
545    
546                            if (mbstowcs(wcs, input_str, 1) == (size_t)-1)
547                            {
548                                    log_error("mbstowcs() error\n");
549                            }
550                            wc_len = (UTF8_fixed_width ? 2 : wcwidth(wcs[0]));
551    
552                            if (len + str_len > buf_size - 1 ||
553                                    display_len + wc_len > max_display_len) // No enough space for Chinese character
554                            {
555                                    outc('\a');
556                                    iflush();
557                                    continue;
558                            }
559    
560                            memmove(buffer + offset + str_len, buffer + offset, (size_t)(len - offset));
561                            memcpy(buffer + offset, input_str, (size_t)str_len);
562                            len += str_len;
563                            buffer[len] = '\0';
564                            display_len += wc_len;
565    
566                            moveto(row, col_cur);
567                            prints("%s", buffer + offset);
568                            prints("%*s", max_display_len - display_len, "");
569    
570                            col_cur += wc_len;
571    
572                            moveto(row, col_cur);
573                            iflush();
574    
575                            offset += str_len;
576                    }
577                    else if (ch >= 32 && ch < 127) // Printable character
578                    {
579                            if (len + 1 > buf_size - 1 || display_len + 1 > max_display_len)
580                            {
581                                    outc('\a');
582                                    iflush();
583                                    continue;
584                            }
585    
586                            memmove(buffer + offset + 1, buffer + offset, (size_t)(len - offset));
587                            buffer[offset] = (char)ch;
588                            len++;
589                            buffer[len] = '\0';
590                            display_len++;
591    
592                            moveto(row, col_cur);
593                            prints("%s", buffer + offset);
594                            prints("%*s", max_display_len - display_len, "");
595    
596                            col_cur++;
597    
598                            moveto(row, col_cur);
599                            iflush();
600    
601                            offset++;
602                    }
603                    else // Invalid character
604                    {
605                            continue;
606                    }
607            }
608    
609          return len;          return len;
610  }  }
# Line 311  int display_data(const void *p_data, lon Line 638  int display_data(const void *p_data, lon
638          loop = 1;          loop = 1;
639          while (!SYS_server_exit && loop)          while (!SYS_server_exit && loop)
640          {          {
641                  if (eof_exit > 0 && line_current >= display_line_total && display_line_total <= screen_row_total)                  if (eof_exit > 0 && line_current >= display_line_total)
642                  {                  {
643                          if (eof_exit == 1)                          if (eof_exit == 1)
644                          {                          {
# Line 366  int display_data(const void *p_data, lon Line 693  int display_data(const void *p_data, lon
693                          input_ok = 0;                          input_ok = 0;
694                          while (!SYS_server_exit && !input_ok)                          while (!SYS_server_exit && !input_ok)
695                          {                          {
696                                  ch = igetch_t(MAX_DELAY_TIME);                                  ch = igetch_t(BBS_max_user_idle_time);
697                                  input_ok = 1;                                  input_ok = 1;
698    
699                                    if (ch != KEY_NULL && ch != KEY_TIMEOUT)
700                                    {
701                                            BBS_last_access_tm = time(NULL);
702    
703                                            // Refresh current action
704                                            if (user_online_update(NULL) < 0)
705                                            {
706                                                    log_error("user_online_update(NULL) error\n");
707                                            }
708                                    }
709    
710                                  // extended key handler                                  // extended key handler
711                                  if (key_handler(&ch, &ctx) != 0)                                  if (key_handler(&ch, &ctx) != 0)
712                                  {                                  {
# Line 378  int display_data(const void *p_data, lon Line 716  int display_data(const void *p_data, lon
716                                  switch (ch)                                  switch (ch)
717                                  {                                  {
718                                  case KEY_NULL:                                  case KEY_NULL:
719                                            log_debug("KEY_NULL\n");
720                                            goto cleanup;
721                                  case KEY_TIMEOUT:                                  case KEY_TIMEOUT:
722                                            log_error("User input timeout\n");
723                                          goto cleanup;                                          goto cleanup;
724                                  case KEY_HOME:                                  case KEY_HOME:
725                                          if (line_current - output_current_row < 0) // Reach begin                                          if (line_current - output_current_row < 0) // Reach begin
# Line 412  int display_data(const void *p_data, lon Line 753  int display_data(const void *p_data, lon
753                                          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
754                                          break;                                          break;
755                                  case CR:                                  case CR:
                                         igetch_reset();  
                                 case KEY_SPACE:  
756                                  case KEY_DOWN:                                  case KEY_DOWN:
757                                          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
758                                          {                                          {
# Line 441  int display_data(const void *p_data, lon Line 780  int display_data(const void *p_data, lon
780                                          output_end_row = SCREEN_ROWS - 1;                                          output_end_row = SCREEN_ROWS - 1;
781                                          clrline(output_current_row, SCREEN_ROWS);                                          clrline(output_current_row, SCREEN_ROWS);
782                                          break;                                          break;
783                                    case KEY_SPACE:
784                                  case KEY_PGDN:                                  case KEY_PGDN:
785                                          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
786                                          {                                          {
# Line 481  int display_data(const void *p_data, lon Line 821  int display_data(const void *p_data, lon
821                                          input_ok = 0;                                          input_ok = 0;
822                                          break;                                          break;
823                                  }                                  }
   
                                 BBS_last_access_tm = time(NULL);  
824                          }                          }
825    
826                          continue;                          continue;
# Line 516  cleanup: Line 854  cleanup:
854          return ch;          return ch;
855  }  }
856    
857  static int display_file_key_handler(int *p_key, DISPLAY_CTX *p_ctx)  int display_file_key_handler(int *p_key, DISPLAY_CTX *p_ctx)
858  {  {
859          switch (*p_key)          switch (*p_key)
860          {          {
# Line 534  static int display_file_key_handler(int Line 872  static int display_file_key_handler(int
872  int display_file(const char *filename, int eof_exit)  int display_file(const char *filename, int eof_exit)
873  {  {
874          int ret;          int ret;
875          const void *p_shm;          void *p_shm;
876          size_t data_len;          size_t data_len;
877          long line_total;          long line_total;
878          const void *p_data;          const void *p_data;
# Line 599  int show_top(const char *str_left, const Line 937  int show_top(const char *str_left, const
937  int show_bottom(const char *msg)  int show_bottom(const char *msg)
938  {  {
939          char str_time[LINE_BUFFER_LEN];          char str_time[LINE_BUFFER_LEN];
940            int len_str_time;
941          time_t time_online;          time_t time_online;
942          struct tm *tm_online;          struct tm *tm_online;
943          char msg_f[LINE_BUFFER_LEN];          char msg_f[LINE_BUFFER_LEN];
944          int eol;          int eol;
945          int msg_len;          int len_msg;
946          int len;          int len;
947          int len_username;          int len_username;
948          char str_tm_online[LINE_BUFFER_LEN];          char str_tm_online[LINE_BUFFER_LEN];
949            int len_str_tm_online;
950    
951          get_time_str(str_time, sizeof(str_time));          len_str_time = (int)get_time_str(str_time, sizeof(str_time));
952    
953          msg_f[0] = '\0';          msg_f[0] = '\0';
954          msg_len = 0;          len_msg = 0;
955          if (msg != NULL)          if (msg != NULL)
956          {          {
957                  strncpy(msg_f, msg, sizeof(msg_f) - 1);                  strncpy(msg_f, msg, sizeof(msg_f) - 1);
958                  msg_f[sizeof(msg_f) - 1] = '\0';                  msg_f[sizeof(msg_f) - 1] = '\0';
959                  len = split_line(msg_f, 23, &eol, &msg_len, 1);                  len = split_line(msg_f, 23, &eol, &len_msg, 1);
960                  msg_f[len] = '\0';                  msg_f[len] = '\0';
961          }          }
962    
# Line 627  int show_bottom(const char *msg) Line 967  int show_bottom(const char *msg)
967          if (tm_online->tm_mday > 1)          if (tm_online->tm_mday > 1)
968          {          {
969                  snprintf(str_tm_online, sizeof(str_tm_online),                  snprintf(str_tm_online, sizeof(str_tm_online),
970                                   "\033[36m%2d\033[33m天\033[36m%2d\033[33m时",                                   "\033[36m%d\033[33md \033[36m%d\033[33m:\033[36m%.2d",
971                                   tm_online->tm_mday - 1, tm_online->tm_hour);                                   tm_online->tm_mday - 1, tm_online->tm_hour, tm_online->tm_min);
972          }          }
973          else          else
974          {          {
975                  snprintf(str_tm_online, sizeof(str_tm_online),                  snprintf(str_tm_online, sizeof(str_tm_online),
976                                   "\033[36m%2d\033[33m时\033[36m%2d\033[33m分",                                   "\033[36m%d\033[33m:\033[36m%.2d",
977                                   tm_online->tm_hour, tm_online->tm_min);                                   tm_online->tm_hour, tm_online->tm_min);
978          }          }
979            len_str_tm_online = str_length(str_tm_online, 1);
980    
981          moveto(SCREEN_ROWS, 0);          moveto(SCREEN_ROWS, 0);
982          clrtoeol();          clrtoeol();
983          prints("\033[1;44;33m时间[\033[36m%s\033[33m]%s%*s \033[33m帐号[\033[36m%s\033[33m][%s\033[33m]\033[m",          prints("\033[1;44;33m时间[\033[36m%s\033[33m]%s%*s \033[33m用户[\033[36m%s\033[33m][%s\033[33m]\033[m",
984                     str_time, msg_f, 38 - msg_len - len_username, "", BBS_username, str_tm_online);                     str_time, msg_f, 65 - len_str_time - len_msg - len_username - len_str_tm_online,
985                       "", BBS_username, str_tm_online);
986    
987          return 0;          return 0;
988  }  }


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

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