/[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.42 by sysadm, Tue Sep 30 14:56:51 2025 UTC Revision 1.45 by sysadm, Sat Oct 4 03:21:59 2025 UTC
# Line 49  enum select_cmd_t Line 49  enum select_cmd_t
49          QUERY_ARTICLE,          QUERY_ARTICLE,
50          FIRST_TOPIC_ARTICLE,          FIRST_TOPIC_ARTICLE,
51          LAST_TOPIC_ARTICLE,          LAST_TOPIC_ARTICLE,
52            SCAN_NEW_ARTICLE,
53          VIEW_EX_DIR,          VIEW_EX_DIR,
54  };  };
55    
# Line 144  static int section_list_draw_items(int p Line 145  static int section_list_draw_items(int p
145                          prints("   \033[1;33m[提示]\033[m %c %s%*s %s %s%s\033[m",                          prints("   \033[1;33m[提示]\033[m %c %s%*s %s %s%s\033[m",
146                                     article_flag,                                     article_flag,
147                                     (display_nickname ? p_articles[i]->nickname : p_articles[i]->username),                                     (display_nickname ? p_articles[i]->nickname : p_articles[i]->username),
148                                     (display_nickname ? BBS_nickname_max_len - (int)strnlen(p_articles[i]->nickname, sizeof(p_articles[i]->nickname))                                     (display_nickname ? BBS_nickname_max_len / 2 - str_length(p_articles[i]->nickname, 1)
149                                                                           : BBS_username_max_len - (int)strnlen(p_articles[i]->username, sizeof(p_articles[i]->username))),                                                                           : BBS_username_max_len - str_length(p_articles[i]->username, 1)),
150                                     "",                                     "",
151                                     str_time,                                     str_time,
152                                     (p_articles[i]->aid == section_topic_view_tid                                     (p_articles[i]->aid == section_topic_view_tid
# Line 166  static int section_list_draw_items(int p Line 167  static int section_list_draw_items(int p
167                                     p_articles[i]->aid,                                     p_articles[i]->aid,
168                                     article_flag,                                     article_flag,
169                                     (display_nickname ? p_articles[i]->nickname : p_articles[i]->username),                                     (display_nickname ? p_articles[i]->nickname : p_articles[i]->username),
170                                     (display_nickname ? BBS_nickname_max_len - (int)strnlen(p_articles[i]->nickname, sizeof(p_articles[i]->nickname))                                     (display_nickname ? BBS_nickname_max_len / 2 - str_length(p_articles[i]->nickname, 1)
171                                                                           : BBS_username_max_len - (int)strnlen(p_articles[i]->username, sizeof(p_articles[i]->username))),                                                                           : BBS_username_max_len - str_length(p_articles[i]->username, 1)),
172                                     "",                                     "",
173                                     str_time,                                     str_time,
174                                     (p_articles[i]->aid == section_topic_view_tid                                     (p_articles[i]->aid == section_topic_view_tid
# Line 291  static enum select_cmd_t section_list_se Line 292  static enum select_cmd_t section_list_se
292                                          (*p_page_id)--;                                          (*p_page_id)--;
293                                          *p_selected_index = BBS_article_limit_per_page - 1;                                          *p_selected_index = BBS_article_limit_per_page - 1;
294                                  }                                  }
295                                    else if (ch == KEY_UP || ch == 'k') // Rotate to the tail of section list
296                                    {
297                                            if (total_page > 0)
298                                            {
299                                                    *p_page_id = total_page - 1;
300                                            }
301                                            if (item_count > 0)
302                                            {
303                                                    *p_selected_index = item_count - 1;
304                                            }
305                                    }
306                          }                          }
307                          else                          else
308                          {                          {
# Line 318  static enum select_cmd_t section_list_se Line 330  static enum select_cmd_t section_list_se
330                                          (*p_page_id)++;                                          (*p_page_id)++;
331                                          *p_selected_index = 0;                                          *p_selected_index = 0;
332                                  }                                  }
333                                  else // end of last page                                  else if (ch == KEY_DOWN || ch == 'j') // Rotate to the head of section list
334                                  {                                  {
335                                          return CHANGE_PAGE; // force refresh pages                                          *p_page_id = 0;
336                                            *p_selected_index = 0;
337                                  }                                  }
338                          }                          }
339                          else                          else
# Line 340  static enum select_cmd_t section_list_se Line 353  static enum select_cmd_t section_list_se
353                                  return LAST_TOPIC_ARTICLE;                                  return LAST_TOPIC_ARTICLE;
354                          }                          }
355                          break;                          break;
356                    case 'S':
357                            if (item_count > 0)
358                            {
359                                    return SCAN_NEW_ARTICLE;
360                            }
361                            break;
362                  case 'h':                  case 'h':
363                          return SHOW_HELP;                          return SHOW_HELP;
364                  case 'x':                  case 'x':
# Line 486  int section_list_display(const char *sna Line 505  int section_list_display(const char *sna
505          int direction;          int direction;
506          ARTICLE article_new;          ARTICLE article_new;
507          int page_id_cur;          int page_id_cur;
508            const ARTICLE *p_article_unread;
509    
510          p_section = section_list_find_by_name(sname);          p_section = section_list_find_by_name(sname);
511          if (p_section == NULL)          if (p_section == NULL)
# Line 842  int section_list_display(const char *sna Line 862  int section_list_display(const char *sna
862                                  return -3;                                  return -3;
863                          }                          }
864                          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
865                            {
866                                    ret = query_section_articles(p_section, page_id, p_articles, &article_count, &page_count, &ontop_start_offset);
867                                    if (ret < 0)
868                                    {
869                                            log_error("query_section_articles(sid=%d, page_id=%d) error\n", p_section->sid, page_id);
870                                            return -3;
871                                    }
872                            }
873                            break;
874                    case SCAN_NEW_ARTICLE:
875                            ret = scan_unread_article_in_section(p_section, p_articles[selected_index], &p_article_unread);
876                            if (ret < 0)
877                            {
878                                    log_error("scan_unread_article_in_section(sid=%d, aid=%d) error\n",
879                                                      p_section->sid, p_articles[selected_index]->aid);
880                                    return -3;
881                            }
882                            else if (ret == 0) // not found
883                            {
884                                    break;
885                            }
886                            page_id_cur = page_id;
887                            ret = locate_article_in_section(p_section, p_article_unread, 0, 0,
888                                                                                            &page_id, &selected_index, &article_count);
889                            if (ret < 0)
890                            {
891                                    log_error("locate_article_in_section(sid=%d, aid=%d, direction=0, step=0) error\n",
892                                                      p_section->sid, p_article_unread->aid);
893                                    return -3;
894                            }
895                            else if (ret > 0 && page_id != page_id_cur) // found and page changed
896                          {                          {
897                                  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);
898                                  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