summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/proto.h3
-rw-r--r--mbbsd/bbs.c11
-rw-r--r--mbbsd/name.c170
3 files changed, 180 insertions, 4 deletions
diff --git a/include/proto.h b/include/proto.h
index 70c40fe1..a65293f4 100644
--- a/include/proto.h
+++ b/include/proto.h
@@ -1,4 +1,4 @@
-/* $Id: proto.h,v 1.11 2002/05/08 14:11:26 lwms Exp $ */
+/* $Id: proto.h,v 1.12 2002/05/10 16:15:47 in2 Exp $ */
#ifndef INCLUDE_PROTO_H
#define INCLUDE_PROTO_H
@@ -295,6 +295,7 @@ int InNameList(char *name);
void ShowNameList(int row, int column, char *prompt);
int RemoveNameList(char *name);
void ToggleNameList(int *reciper, char *listfile, char *msg);
+void allboardcomplete(char *prompt, char *data, int len);
/* osdep */
int cpuload(char *str);
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c
index e8a2431b..2a340e73 100644
--- a/mbbsd/bbs.c
+++ b/mbbsd/bbs.c
@@ -1,4 +1,4 @@
-/* $Id: bbs.c,v 1.5 2002/05/01 04:42:16 in2 Exp $ */
+/* $Id: bbs.c,v 1.6 2002/05/10 16:15:50 in2 Exp $ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -247,8 +247,11 @@ static int do_select(int ent, fileheader_t *fhdr, char *direct) {
move(0, 0);
clrtoeol();
+ allboardcomplete(MSG_SELECT_BOARD, bname, sizeof(bname));
+ /*
make_blist();
namecomplete(MSG_SELECT_BOARD, bname);
+ */
if(bname[0]=='\0' || !(i = getbnum(bname)))
return FULLUPDATE;
bh = getbcache(i);
@@ -725,7 +728,6 @@ static int cross_post(int ent, fileheader_t *fhdr, char *direct) {
char genbuf[200];
char genbuf2[4];
boardheader_t *bp;
- make_blist();
move(2, 0);
clrtoeol();
move(3, 0);
@@ -734,7 +736,12 @@ static int cross_post(int ent, fileheader_t *fhdr, char *direct) {
bp = getbcache(currbid);
if (bp && (bp->brdattr & BRD_VOTEBOARD))
return FULLUPDATE;
+ allboardcomplete("轉錄本文章於看板:", xboard, sizeof(xboard));
+ /*
+ make_blist();
+ namecomplete(MSG_SELECT_BOARD, bname);
namecomplete("轉錄本文章於看板:", xboard);
+ */
if(*xboard == '\0' || !haspostperm(xboard))
return FULLUPDATE;
diff --git a/mbbsd/name.c b/mbbsd/name.c
index 2f84a1fe..1e37db2b 100644
--- a/mbbsd/name.c
+++ b/mbbsd/name.c
@@ -1,4 +1,4 @@
-/* $Id: name.c,v 1.1 2002/03/07 15:13:48 in2 Exp $ */
+/* $Id: name.c,v 1.2 2002/05/10 16:15:50 in2 Exp $ */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -10,6 +10,7 @@
#include "common.h"
#include "proto.h"
+extern struct bcache_t *brdshm;
extern char *str_space;
extern int p_lines; /* a Page of Screen line numbers: tlines-4 */
extern int b_lines; /* Screen bottom line number: t_lines-1 */
@@ -471,3 +472,170 @@ void usercomplete(char *prompt, char *data) {
outc('\n');
}
}
+
+int ab_findbound(char *str, int *START, int *END)
+{
+ int start, end, mid, cmp, strl;
+ strl = strlen(str);
+ start = 0, end = brdshm->number - 1;
+ while( start != end && ((mid = (start + end) / 2) != start) ){
+ cmp = strncasecmp(brdshm->sorted[0][mid]->brdname, str, strl);
+ if( cmp >= 0 )
+ end = mid;
+ else
+ start = mid;
+ }
+ ++start;
+ if( strncasecmp(brdshm->sorted[0][start]->brdname, str, strl) != 0 ){
+ *START = *END = -1;
+ return -1;
+ }
+ *START = start;
+
+ end = brdshm->number - 1;
+ while( start != end && ((mid = (start + end) / 2) != start) ){
+ cmp = strncasecmp(brdshm->sorted[0][mid]->brdname, str, strl);
+ if( cmp <= 0 )
+ start = mid;
+ else
+ end = mid;
+ }
+ *END = start;
+ return 0;
+}
+
+#define ab_havepermission(where) \
+ Ben_Perm(brdshm->sorted[0][where])
+
+int ab_completeone(char *data, int start, int end)
+{
+ int i, count, at;
+ for( i = start, at = count = 0 ; i <= end && count < 2 ; ++i )
+ if( ab_havepermission(i) ){
+ at = i;
+ ++count;
+ }
+ if( count == 1 ){
+ strcpy(data, brdshm->sorted[0][at]->brdname);
+ return 1;
+ }
+ return 0;
+}
+
+void allboardcomplete(char *prompt, char *data, int len)
+{
+ int x, y, origx, origy, ch, i, morelist = -1, col;
+ int start, end, ptr;
+ int clearbot = NA;
+
+ outs(prompt);
+ clrtoeol();
+ getyx(&y, &x);
+ getyx(&origy, &origx);
+ standout();
+ prints("%*s", IDLEN + 1, "");
+ standend();
+ move(y, x);
+ refresh();
+ ptr = 0;
+ data[ptr] = 0;
+
+ while( (ch = igetch()) != EOF ){
+ if( ch == '\n' || ch == '\r' ){
+ data[ptr] = 0;
+ outc('\n');
+ if( ptr != 0 ){
+ ab_findbound(data, &start, &end);
+ ab_completeone(data, start, end);
+ }
+ break;
+ }
+ else if( ch == ' ' ){
+ if( ptr == 0 )
+ continue;
+
+ if( morelist == -1 ){
+ if( ab_findbound(data, &start, &end) == -1 )
+ continue;
+ if( ab_completeone(data, start, end) ){
+ move(origy, origx);
+ outs(data);
+ ptr = strlen(data);
+ getyx(&y, &x);
+ continue;
+ }
+
+ morelist = start;
+ }
+ else if( morelist > end )
+ continue;
+ clearbot = YEA;
+ move(2, 0);
+ clrtobot();
+ printdash("相關資訊一覽表");
+
+ col = 0;
+ while(len + col < 79) {
+ for( i = 0 ; morelist <= end && i < p_lines ; ++morelist){
+ if( ab_havepermission(morelist) ){
+ move(3 + i, col);
+ prints("%s ", brdshm->sorted[0][morelist]->brdname);
+ ++i;
+ }
+ }
+
+ col += len + 2;
+ }
+ if( morelist != end + 1 ){
+ move(b_lines, 0);
+ outs(msg_more);
+ }
+ move(y, x);
+ continue;
+
+ }
+ else if(ch == '\177' || ch == '\010') { /* backspace */
+ if( ptr == 0 )
+ continue;
+ morelist = -1;
+ --ptr; --x;
+ data[ptr] = 0;
+ move(y, x);
+ outc(' ');
+ move(y, x);
+ continue;
+ }
+ else if( isprint(ch) && ptr <= (len - 2) ){
+ morelist = -1;
+ data[ptr] = ch;
+ ++ptr;
+ data[ptr] = 0;
+ if( ab_findbound(data, &start, &end) < 0 )
+ data[--ptr] = 0;
+ else{
+ for( i = start ; i <= end ; ++i )
+ if( ab_havepermission(i) )
+ break;
+ if( i == end + 1 )
+ data[--ptr] = 0;
+ else{
+ move(y, x);
+ outc(ch);
+ x++;
+ }
+ }
+ }
+ }
+
+ outc('\n');
+ refresh();
+ if(clearbot) {
+ move(2, 0);
+ clrtobot();
+ }
+ if(*data) {
+ move(origy, origx);
+ outs(data);
+ outc('\n');
+ }
+}