/[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.66 by sysadm, Mon Nov 3 07:14:25 2025 UTC Revision 1.68 by sysadm, Tue Nov 4 06:36:52 2025 UTC
# Line 61  enum select_cmd_t Line 61  enum select_cmd_t
61          UNSET_FAVOR_ARTICLE,          UNSET_FAVOR_ARTICLE,
62          FIRST_TOPIC_ARTICLE,          FIRST_TOPIC_ARTICLE,
63          LAST_TOPIC_ARTICLE,          LAST_TOPIC_ARTICLE,
64            LAST_SECTION_ARTICLE,
65          SCAN_NEW_ARTICLE,          SCAN_NEW_ARTICLE,
66          SCAN_ARTICLE_BACKWARD_BY_USER,          SCAN_ARTICLE_BACKWARD_BY_USER,
67          SCAN_ARTICLE_FORWARD_BY_USER,          SCAN_ARTICLE_FORWARD_BY_USER,
# Line 368  static enum select_cmd_t section_list_se Line 369  static enum select_cmd_t section_list_se
369                          break;                          break;
370                  case '$':                  case '$':
371                  case KEY_END:                  case KEY_END:
372                            if (*p_page_id + 1 == total_page && *p_selected_index + 1 == item_count) // Press END at end of list
373                            {
374                                    return LAST_SECTION_ARTICLE;
375                            }
376                          if (total_page > 0)                          if (total_page > 0)
377                          {                          {
378                                  *p_page_id = total_page - 1;                                  *p_page_id = total_page - 1;
# Line 710  int section_list_display(const char *sna Line 715  int section_list_display(const char *sna
715                          // Update current aid location                          // Update current aid location
716                          if (p_articles[selected_index] != NULL)                          if (p_articles[selected_index] != NULL)
717                          {                          {
718                                  section_aid_locations[section_index] = p_articles[selected_index]->aid;                                  if (selected_index >= ontop_start_offset)
719                          }                                  {
720                          else                                          ret = last_article_in_section(p_section, &p_article_locate);
721                          {                                          if (ret < 0)
722                                  log_error("p_articles[selected_index=%d] is NULL when exit section [%s]\n", selected_index, sname);                                          {
723                                                    log_error("last_article_in_section(sid=%d) error\n", p_section->sid);
724                                                    return -3;
725                                            }
726                                            else if (ret == 0)
727                                            {
728                                                    section_aid_locations[section_index] = 0;
729                                            }
730                                            else // ret > 0
731                                            {
732                                                    section_aid_locations[section_index] = p_article_locate->aid;
733                                            }
734                                    }
735                                    else
736                                    {
737                                            section_aid_locations[section_index] = (p_articles[selected_index]->visible ? p_articles[selected_index]->aid : 0);
738                                    }
739                          }                          }
740                          return 0;                          return 0;
741                  case CHANGE_PAGE:                  case CHANGE_PAGE:
# Line 860  int section_list_display(const char *sna Line 881  int section_list_display(const char *sna
881                                          {                                          {
882                                                  log_error("article_reply(aid=%d) error\n", p_articles[selected_index]->aid);                                                  log_error("article_reply(aid=%d) error\n", p_articles[selected_index]->aid);
883                                          }                                          }
884                                            else if (ret > 0) // Article replied
885                                            {
886                                                    ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count, &ontop_start_offset);
887                                                    if (ret < 0)
888                                                    {
889                                                            log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id);
890                                                            return -3;
891                                                    }
892                                            }
893                                          loop = 1;                                          loop = 1;
894                                          break;                                          break;
895                                  case '=':  // First topic article                                  case '=':  // First topic article
# Line 923  int section_list_display(const char *sna Line 953  int section_list_display(const char *sna
953                                  ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count, &ontop_start_offset);                                  ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count, &ontop_start_offset);
954                                  if (ret < 0)                                  if (ret < 0)
955                                  {                                  {
956                                          log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id);                                          log_error("query_section_articles(sid=%d, page_id=%d) error: %d\n", p_section->sid, page_id, ret);
957                                          return -3;                                          return -3;
958                                  }                                  }
959                          }                          }
# Line 949  int section_list_display(const char *sna Line 979  int section_list_display(const char *sna
979                          {                          {
980                                  log_error("article_modify(aid=%d) error\n", p_articles[selected_index]->aid);                                  log_error("article_modify(aid=%d) error\n", p_articles[selected_index]->aid);
981                          }                          }
982                            else if (ret > 0) // Article modified
983                            {
984                                    ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count, &ontop_start_offset);
985                                    if (ret < 0)
986                                    {
987                                            log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id);
988                                            return -3;
989                                    }
990                            }
991                          if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)                          if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)
992                          {                          {
993                                  log_error("section_list_draw_screen() error\n");                                  log_error("section_list_draw_screen() error\n");
# Line 967  int section_list_display(const char *sna Line 1006  int section_list_display(const char *sna
1006                          }                          }
1007                          else if (ret > 0) // Article deleted                          else if (ret > 0) // Article deleted
1008                          {                          {
1009                                  ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count, &ontop_start_offset);                                  do
                                 if (ret < 0)  
1010                                  {                                  {
1011                                          log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id);                                          ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count, &ontop_start_offset);
1012                                          return -3;                                          if (ret >= 0 && selected_index > article_count - 1)
1013                                  }                                          {
1014                                                    selected_index = article_count - 1;
1015                                                    break;
1016                                            }
1017                                            else if (ret < 0 && page_id > 0)
1018                                            {
1019                                                    page_id--;
1020                                                    selected_index = BBS_article_limit_per_page - 1;
1021                                            }
1022                                            else if (ret < 0 && page_id <= 0)
1023                                            {
1024                                                    selected_index = 0;
1025                                                    break;
1026                                            }
1027                                    } while (ret < 0);
1028                          }                          }
1029                          if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)                          if (section_list_draw_screen(sname, stitle, master_list, display_nickname) < 0)
1030                          {                          {
# Line 1049  int section_list_display(const char *sna Line 1101  int section_list_display(const char *sna
1101                                  return -3;                                  return -3;
1102                          }                          }
1103                          else if (ret > 0 && page_id != page_id_cur) // found and page changed                          else if (ret > 0 && page_id != page_id_cur) // found and page changed
1104                            {
1105                                    ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count, &ontop_start_offset);
1106                                    if (ret < 0)
1107                                    {
1108                                            log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id);
1109                                            return -3;
1110                                    }
1111                            }
1112                            break;
1113                    case LAST_SECTION_ARTICLE:
1114                            page_id_cur = page_id;
1115                            ret = last_article_in_section(p_section, &p_article_locate);
1116                            if (ret < 0)
1117                            {
1118                                    log_error("last_article_in_section(sid=%d) error\n", p_section->sid);
1119                                    return -3;
1120                            }
1121                            else if (ret == 0)
1122                            {
1123                                    break;
1124                            }
1125                            ret = locate_article_in_section(p_section, p_article_locate, 0, 0,
1126                                                                                            &page_id, &selected_index, &article_count);
1127                            if (ret < 0)
1128                            {
1129                                    log_error("locate_article_in_section(sid=%d, aid=%d, direction=0, step=0) error\n",
1130                                                      p_section->sid, p_article_locate->aid);
1131                                    return -3;
1132                            }
1133                            else if (ret > 0 && page_id != page_id_cur) // found and page changed
1134                          {                          {
1135                                  ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count, &ontop_start_offset);                                  ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count, &ontop_start_offset);
1136                                  if (ret < 0)                                  if (ret < 0)


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

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