回精華區
作者itoc, 信區: itoc
標題[功能] menu.c xover.c 變動游標 (使用者自定)
時間03/08/17
作者: itoc (拯救一個靈魂) 看板: plan
標題: [功能] menu.c xover.c 動態游標
時間: Thu Jul  4 16:38:27 2002                          Updated: 2005/04/12

  把游標 > 換成會變的,由使用者自定

: global.h

VAR char hunt[32];
+ VAR int cursor_count;              /* 目前是用第幾個游標 */
+ VAR int cursor_max;                /* 全部有幾個游標 */
+ VAR char cursor_table[10][3];      /* 游標 */

: acct.c u_xfile()

+   "自定游標",
    "暫存檔.1",
  ...
  ...
+   "cursor",
    "buf.1",

: bbsd.c:get_cursor_table() 在 tn_motd() 前面新增此函式

static void
get_cursor_table()
{
  FILE *fp;
  char fpath[64], *str;
  int i;

  /* 預設的游標 */
  strcpy(cursor_table[0], "→");
  strcpy(cursor_table[1], "♂");
  strcpy(cursor_table[2], "♀");
  cursor_max = 3;
  cursor_count = 0;

  usr_fpath(fpath, cuser.userid, "cursor");
  if (!(fp = fopen(fpath, "r")))
    return;

  if (fgets(fpath, 25, fp))
  {
    for (i = 0; i < 10; i++)
    {
      str = fpath + i * 2;
      if (!*str || *str == '\n')
        break;
      str_ncpy(cursor_table[i], str, 3);
    }
    cursor_max = i;
  }
}

: bbsd.c:tn_motd()

+ get_cursor_table();

#ifdef HAVE_FORCE_BOARD
  brd_force();  /* itoc.000319: 強制閱讀公告板 */
#endif
}

: menu.c:menu()

      move(MENU_XPOS + cc, MENU_YPOS);
      mptr = table[cc];
      str = mptr->desc;
-     prints(COLOR4 "> (%c)%s \033[m", *str, str + 1);
+     prints(COLOR4 "%s(%c)%s \033[m",
+       cursor_table[++cursor_count%cursor_max], *str, str + 1);
      cx = cc;
#else           /* 沒有 CURSOR_BAR */
      if (cx >= 0)
      {
        move(MENU_XPOS + cx, MENU_YPOS);
-       outc(' ');
+       outs("  ");
      }
      move(MENU_XPOS + cc, MENU_YPOS);
-     outc('>');
+     outs(cursor_table[++cursor_count % cursor_max]);
+     move(MENU_XPOS + cc, MENU_YPOS + 1);  /* itoc.020105: 避免左鍵全形偵測 */
      cx = cc;
#endif
    }
    else                /* 若游標的位置沒有變 */
    {
#ifdef CURSOR_BAR
      move(MENU_XPOS + cc, MENU_YPOS);
      mptr = table[cc];
      str = mptr->desc;
-     prints(COLOR4 "> (%c)%s \033[m", *str, str + 1);
+     prints(COLOR4 "%s(%c)%s \033[m",
+       cursor_table[++cursor_count%cursor_max], *str, str + 1);
#else
      move(MENU_XPOS + cc, MENU_YPOS + 1);
#endif
    }

menu_key:

   cmd = vkey();
  }
}

: xover.c:xover()

        else
        {
          move(3 + cmd - num, 0);
-         outc(' ');
+         outs("  ");

          break;                /* 只移動游標 */
        }

  ...
  ...

    pos = xo->pos;

    if (xo->max > 0)            /* Thor:若是無東西就不show了 */
    {
      num = 3 + pos - xo->top;
      move(num, 0);
-     outc('>');
+     outs(cursor_table[++cursor_count % cursor_max]);
+     move(num, 1);     /* itoc.020105: 避免左鍵全形偵測 */
    }

    cmd = vkey();

  ...
  ...

          if (cmd < 0)          /* 在本頁找到 match */
          {
            move(num, 0);
-           outc(' ');
+           outs("  ");
            /* cmd = XO_NONE; */
            /* itoc.010913: 某些搜尋要把 b_lines 填上 feeter */
            cmd = cmd == -1 ? XO_NONE : XO_FOOT;
          }

: ------------------------------------------------------

  usr/_/_/cursor 的格式是

→←%

  一列十個游標,可以不到十個,超過十個沒用

--
□ 本文章由 itocapple.Dorm3.NCTU.edu.tw 發表
精華選讀←離開[主題上]主題下(k)上篇(j)下篇S/a搜尋 G串列 TAB精華 ↑↓捲 Pg/Space翻