/[LeafOK_CVS]/lbbs/src/section_list_display.c
ViewVC logotype

Diff of /lbbs/src/section_list_display.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.14 by sysadm, Sat May 31 12:46:08 2025 UTC Revision 1.21 by sysadm, Fri Jun 13 12:01:27 2025 UTC
# Line 17  Line 17 
17  #include "section_list_display.h"  #include "section_list_display.h"
18  #include "section_list_loader.h"  #include "section_list_loader.h"
19  #include "article_cache.h"  #include "article_cache.h"
20    #include "article_post.h"
21  #include "common.h"  #include "common.h"
22  #include "io.h"  #include "io.h"
23  #include "screen.h"  #include "screen.h"
24  #include "log.h"  #include "log.h"
25    #include "user_priv.h"
26    #include "article_view_log.h"
27  #include "str_process.h"  #include "str_process.h"
28  #include <time.h>  #include <time.h>
29  #include <sys/param.h>  #include <sys/param.h>
# Line 37  enum select_cmd_t Line 40  enum select_cmd_t
40          CHANGE_PAGE = 2,          CHANGE_PAGE = 2,
41          REFRESH_SCREEN = 3,          REFRESH_SCREEN = 3,
42          CHANGE_NAME_DISPLAY = 4,          CHANGE_NAME_DISPLAY = 4,
43            POST_ARTICLE = 5,
44            EDIT_ARTICLE = 6,
45  };  };
46    
47  static int section_list_draw_items(int page_id, ARTICLE *p_articles[], int article_count, int display_nickname)  static int section_list_draw_items(int page_id, ARTICLE *p_articles[], int article_count, int display_nickname)
# Line 49  static int section_list_draw_items(int p Line 54  static int section_list_draw_items(int p
54          int len;          int len;
55          int i;          int i;
56          char article_flag;          char article_flag;
57            int is_viewed;
58          time_t tm_now;          time_t tm_now;
59    
60          time(&tm_now);          time(&tm_now);
# Line 57  static int section_list_draw_items(int p Line 63  static int section_list_draw_items(int p
63    
64          for (i = 0; i < article_count; i++)          for (i = 0; i < article_count; i++)
65          {          {
66                  article_flag = ' ';                  if (p_articles[i]->uid == BBS_priv.uid)
67                    {
68                            is_viewed = 1;
69                    }
70                    else
71                    {
72                            is_viewed = article_view_log_is_viewed(p_articles[i]->aid, &BBS_article_view_log);
73                            if (is_viewed < 0)
74                            {
75                                    log_error("article_view_log_is_viewed(aid=%d) error\n", p_articles[i]->aid);
76                                    is_viewed = 0;
77                            }
78                    }
79    
80                    article_flag = (is_viewed ? ' ' : 'N');
81    
82                  if (p_articles[i]->excerption)                  if (p_articles[i]->excerption)
83                  {                  {
84                          article_flag = 'm';                          article_flag = (is_viewed ? 'm' : 'M');
85                  }                  }
86                  else if (p_articles[i]->lock)                  else if (p_articles[i]->lock && is_viewed)
87                  {                  {
88                          article_flag = 'x';                          article_flag = 'x';
89                  }                  }
# Line 176  static enum select_cmd_t section_list_se Line 196  static enum select_cmd_t section_list_se
196                                  return VIEW_ARTICLE;                                  return VIEW_ARTICLE;
197                          }                          }
198                          break;                          break;
199                    case Ctrl('P'):
200                            return POST_ARTICLE;
201                    case 'E':
202                            return EDIT_ARTICLE;
203                  case KEY_HOME:                  case KEY_HOME:
204                          *p_page_id = 0;                          *p_page_id = 0;
205                  case KEY_PGUP:                  case KEY_PGUP:
# Line 259  static int display_article_key_handler(i Line 283  static int display_article_key_handler(i
283                  if (section_topic_view_mode)                  if (section_topic_view_mode)
284                  {                  {
285                          snprintf(p_ctx->msg, sizeof(p_ctx->msg),                          snprintf(p_ctx->msg, sizeof(p_ctx->msg),
286                                           "| 返回[\033[32m←\033[33m,\033[32mESC\033[33m] │ "                                           "| 返回[\033[32m←\033[33m,\033[32mESC\033[33m] | "
287                                           "同主题阅读[\033[32m↑\033[33m/\033[32m↓\033[33m] │ "                                           "同主题阅读[\033[32m↑\033[33m/\033[32m↓\033[33m] | "
288                                           "模式[\033[32mp\033[33m] | 帮助[\033[32mh\033[33m] |");                                           "模式[\033[32mp\033[33m] | 帮助[\033[32mh\033[33m] |");
289                  }                  }
290                  else                  else
291                  {                  {
292                          snprintf(p_ctx->msg, sizeof(p_ctx->msg),                          snprintf(p_ctx->msg, sizeof(p_ctx->msg),
293                                           "| 返回[\033[32m←\033[33m,\033[32mESC\033[33m] │ "                                           "| 返回[\033[32m←\033[33m,\033[32mESC\033[33m] | "
294                                           "移动[\033[32m↑\033[33m/\033[32m↓\033[33m/\033[32mPgUp\033[33m/\033[32mPgDn\033[33m] │ "                                           "移动[\033[32m↑\033[33m/\033[32m↓\033[33m/\033[32mPgUp\033[33m/\033[32mPgDn\033[33m] | "
295                                           "模式[\033[32mp\033[33m] | 帮助[\033[32mh\033[33m] |");                                           "模式[\033[32mp\033[33m] | 帮助[\033[32mh\033[33m] |");
296                  }                  }
297                  *p_key = 0;                  *p_key = 0;
298                  break;                  break;
299            case 'r': // Reply article
300                    return 1;
301          case KEY_UP:          case KEY_UP:
302            case KEY_PGUP:
303            case KEY_HOME:
304                  if (p_ctx->reach_begin)                  if (p_ctx->reach_begin)
305                  {                  {
306                          if (section_topic_view_mode)                          if (section_topic_view_mode)
307                          {                          {
308                                  *p_key = KEY_PGUP;                                  *p_key = KEY_PGUP;
309                          }                          }
310                            else
311                            {
312                                    *p_key = KEY_UP;
313                            }
314                          return 1;                          return 1;
315                  }                  }
316                  break;                  break;
317          case KEY_DOWN:          case KEY_DOWN:
318            case KEY_PGDN:
319            case KEY_END:
320                  if (p_ctx->reach_end)                  if (p_ctx->reach_end)
321                  {                  {
322                          if (section_topic_view_mode)                          if (section_topic_view_mode)
323                          {                          {
324                                  *p_key = KEY_PGDN;                                  *p_key = KEY_PGDN;
325                          }                          }
326                            else
327                            {
328                                    *p_key = KEY_DOWN;
329                            }
330                          return 1;                          return 1;
331                  }                  }
332                  break;                  break;
# Line 405  int section_list_display(const char *sna Line 443  int section_list_display(const char *sna
443                                          break;                                          break;
444                                  }                                  }
445    
446                                  ret = display_data(cache.p_data, cache.line_total, cache.line_offsets, 1, 0,                                  ret = display_data(cache.p_data, cache.line_total, cache.line_offsets, 0,
447                                                                     display_article_key_handler, DATA_READ_HELP);                                                                     display_article_key_handler, DATA_READ_HELP);
448    
449                                  if (article_cache_unload(&cache) < 0)                                  if (article_cache_unload(&cache) < 0)
# Line 414  int section_list_display(const char *sna Line 452  int section_list_display(const char *sna
452                                          break;                                          break;
453                                  }                                  }
454    
455                                    // Update article_view_log
456                                    if (article_view_log_set_viewed(p_articles[selected_index]->aid, &BBS_article_view_log) < 0)
457                                    {
458                                            log_error("article_view_log_set_viewed(aid=%d) error\n", p_articles[selected_index]->aid);
459                                    }
460    
461                                  switch (ret)                                  switch (ret)
462                                  {                                  {
463                                  case KEY_UP:                                  case KEY_UP:
# Line 499  int section_list_display(const char *sna Line 543  int section_list_display(const char *sna
543                                                  loop = 1;                                                  loop = 1;
544                                          }                                          }
545                                          break;                                          break;
546                                    case 'r': // Reply article
547                                            if (article_reply(p_section, p_articles[selected_index]) < 0)
548                                            {
549                                                    log_error("article_post(aid=%d, REPLY) error\n", p_articles[selected_index]->aid);
550                                            }
551                                            loop = 1;
552                                            break;
553                                  }                                  }
554                          } while (loop);                          } while (loop);
555    
# Line 516  int section_list_display(const char *sna Line 567  int section_list_display(const char *sna
567                          if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)                          if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)
568                          {                          {
569                                  log_error("section_list_draw_screen() error\n");                                  log_error("section_list_draw_screen() error\n");
570                                    return -2;
571                            }
572                            break;
573                    case POST_ARTICLE:
574                            if (article_post(p_section) < 0)
575                            {
576                                    log_error("article_post(sid=%d, NEW) error\n", p_section->sid);
577                            }
578                            if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)
579                            {
580                                    log_error("section_list_draw_screen() error\n");
581                                    return -2;
582                            }
583                            break;
584                    case EDIT_ARTICLE:
585                            if (p_articles[selected_index]->uid != BBS_priv.uid)
586                            {
587                                    break;
588                            }
589                            if (article_modify(p_section, p_articles[selected_index]) < 0)
590                            {
591                                    log_error("article_post(aid=%d, EDIT) error\n", p_articles[selected_index]->aid);
592                            }
593                            if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)
594                            {
595                                    log_error("section_list_draw_screen() error\n");
596                                  return -2;                                  return -2;
597                          }                          }
598                          break;                          break;


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

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