diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2013-03-09 22:47:47 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2013-03-09 22:47:47 +0800 |
commit | 1fc9fceecb38089fea450253e956eae0ac1462f5 (patch) | |
tree | 825adc46b9934bca68e976adf428ca96def028df | |
parent | a32c8fe3ae96d64c0509a19ac403532275684677 (diff) | |
download | pttbbs-1fc9fceecb38089fea450253e956eae0ac1462f5.tar pttbbs-1fc9fceecb38089fea450253e956eae0ac1462f5.tar.gz pttbbs-1fc9fceecb38089fea450253e956eae0ac1462f5.tar.bz2 pttbbs-1fc9fceecb38089fea450253e956eae0ac1462f5.tar.lz pttbbs-1fc9fceecb38089fea450253e956eae0ac1462f5.tar.xz pttbbs-1fc9fceecb38089fea450253e956eae0ac1462f5.tar.zst pttbbs-1fc9fceecb38089fea450253e956eae0ac1462f5.zip |
Improve category editing interface.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk@5797 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | pttbbs/mbbsd/board.c | 98 |
1 files changed, 63 insertions, 35 deletions
diff --git a/pttbbs/mbbsd/board.c b/pttbbs/mbbsd/board.c index 6b492008..e176508a 100644 --- a/pttbbs/mbbsd/board.c +++ b/pttbbs/mbbsd/board.c @@ -227,51 +227,79 @@ static int b_posttype() { boardheader_t *bp; - int i, aborted; - char filepath[PATHLEN], genbuf[60], title[5], posttype_f, posttype[33]=""; + int i, modified = 0, types = 0; + char filepath[PATHLEN], genbuf[60]; + char posttype_f, posttype[33]="", *p; - // if(!(currmode & MODE_BOARD)) return DONOTHING; - assert(0<=currbid-1 && currbid-1<MAX_BOARD); bp = getbcache(currbid); + posttype_f = bp->posttype_f; + memcpy(posttype, bp->posttype, sizeof(bp->posttype)); + vs_hdr("�]�w�峹���O"); - move(2,0); - clrtobot(); - posttype_f = bp->posttype_f; - for( i = 0 ; i < 8 ; ++i ){ - move(2+i,0); - outs("�峹����: "); - strlcpy(genbuf, bp->posttype + i * 4, 5); - sprintf(title, "%d.", i + 1); - if( !getdata_buf(2+i, 11, title, genbuf, 5, DOECHO) ) - break; - sprintf(posttype + i * 4, "%-4.4s", genbuf); - if( posttype_f & (1<<i) ){ - if( getdata(2+i, 20, "�]�w�d���榡�H(Y/n)", genbuf, 3, LCECHO) && - genbuf[0]=='n' ){ - posttype_f &= ~(1<<i); - continue; - } + do { + move(2, 0); + clrtobot(); + for (i = 0, p = posttype; *p && i < 8; i++, p += 4) { + strlcpy(genbuf, p, 5); + prints(" %d. %s %s\n", i + 1, genbuf, + posttype_f & (1 << i) ? "(���d��)": ""); } - else if ( !getdata(2+i, 20, "�]�w�d���榡�H(y/N)", genbuf, 3, LCECHO) || - genbuf[0] != 'y' ) - continue; - - setbnfile(filepath, bp->brdname, "postsample", i); - aborted = veditfile(filepath); - if (aborted == -1) { - clear(); - posttype_f &= ~(1<<i); + types = i; + if (!getdata(15, 0, + "�п�J�n�]�w�����ؽs���A�� c �]�w�`��,�� ENTER ���}:", + genbuf, 3, LCECHO)) + break; + + if (genbuf[0] == 'c') { + getdata(15, 0, "�n�O�d�X�����O�O�H [0-8�� ENTER ���}]: ", genbuf, 3, + NUMECHO); + if (!isdigit(genbuf[0])) + continue; + i = atoi(genbuf); + if (i < 0 || i >= 8) + continue; + while (i > types++) + strlcat(posttype, " ", sizeof(posttype)); + posttype[i * 4] = 0; continue; } - posttype_f |= (1<<i); - } - bp->posttype_f = posttype_f; - strlcpy(bp->posttype, posttype, sizeof(bp->posttype)); /* �o�����ӭn��race condition */ + i = atoi(genbuf) - 1; + if (i < 0 || i >= 8) + continue; + strlcpy(genbuf, posttype + i * 4, 5); + if(getdata_str(16, 0, "���O�W��: ", genbuf, 5, DOECHO, genbuf)) { + snprintf(posttype + i * 4, 4, "%-4.4s", genbuf); + } + getdata(17, 0, "�n�ϥνd����? [y/n/K(������)]: ", genbuf, 2, LCECHO); + if (genbuf[0] == 'y') + posttype_f |= 1 << i; + else if (genbuf[0] == 'n') { + posttype_f &= ~(1 << i); + continue; + } + getdata(18, 0, "�n�s��d���ɮ�? [y/N]: ", genbuf, 2, LCECHO); + if (genbuf[0] == 'y') { + setbnfile(filepath, bp->brdname, "postsample", i); + veditfile(filepath); + } + } while (1); + + // TODO last chance to confirm. assert(0<=currbid-1 && currbid-1<MAX_BOARD); - substitute_record(fn_board, bp, sizeof(boardheader_t), currbid); + if (bp->posttype_f != posttype_f) { + bp->posttype_f = posttype_f; + modified = 1; + } + if (strcmp(bp->posttype, posttype) != 0) { + /* �o�����ӭn��race condition */ + strlcpy(bp->posttype, posttype, sizeof(bp->posttype)); + modified = 1; + } + if (modified) + substitute_record(fn_board, bp, sizeof(boardheader_t), currbid); return FULLUPDATE; } |