summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-09-08 13:33:38 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-09-08 13:33:38 +0800
commita6f6f4baddbdaf0979ccdfe47f5710797df1bb55 (patch)
tree49787a00dc48c9220fd8ccca1a60cb2603013092
parentf6fabc3faa9e9886cdfd21899bc11544e3c8c131 (diff)
downloadpttbbs-a6f6f4baddbdaf0979ccdfe47f5710797df1bb55.tar
pttbbs-a6f6f4baddbdaf0979ccdfe47f5710797df1bb55.tar.gz
pttbbs-a6f6f4baddbdaf0979ccdfe47f5710797df1bb55.tar.bz2
pttbbs-a6f6f4baddbdaf0979ccdfe47f5710797df1bb55.tar.lz
pttbbs-a6f6f4baddbdaf0979ccdfe47f5710797df1bb55.tar.xz
pttbbs-a6f6f4baddbdaf0979ccdfe47f5710797df1bb55.tar.zst
pttbbs-a6f6f4baddbdaf0979ccdfe47f5710797df1bb55.zip
name complete enhanced
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3140 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--mbbsd/more.c6
-rw-r--r--mbbsd/name.c113
-rw-r--r--mbbsd/stuff.c14
3 files changed, 86 insertions, 47 deletions
diff --git a/mbbsd/more.c b/mbbsd/more.c
index fed6e878..192f1aae 100644
--- a/mbbsd/more.c
+++ b/mbbsd/more.c
@@ -1,9 +1,11 @@
/* $Id$ */
#include "bbs.h"
-#ifdef USE_PIAIP_MORE
+#ifndef USE_TRADITIONAL_MORE
-/* use new pager */
+#define USE_PIAIP_MORE
+
+/* use new pager: piaip's more. */
int more(char *fpath, int promptend)
{
return pmore(fpath, promptend);
diff --git a/mbbsd/name.c b/mbbsd/name.c
index aa45d089..b20c5bdc 100644
--- a/mbbsd/name.c
+++ b/mbbsd/name.c
@@ -18,6 +18,9 @@ UserMaxLen(char cwlist[][IDLEN + 1], int cwnum, int morenum,
if (len > max)
max = len;
}
+ /* assert max IDLEN */
+ if(max > IDLEN)
+ max = IDLEN+1;
return max;
}
@@ -29,6 +32,7 @@ UserSubArray(char cwbuf[][IDLEN + 1], char cwlist[][IDLEN + 1],
int n, ch;
key = chartoupper(key);
+
if (key >= 'A' && key <= 'Z')
key2 = key | 0x20;
else
@@ -302,7 +306,7 @@ namecomplete(const char *prompt, char *data)
len = MaxLen(morelist, p_lines);
move(2, 0);
clrtobot();
- printdash("相關資訊一覽表");
+ printdash("相關資訊一覽表", 0);
while (len + col < 80) {
int i;
@@ -398,6 +402,7 @@ usercomplete(const char *prompt, char *data)
origy = y; origx = x;
while ((ch = igetch()) != EOF) {
+
if (ch == '\n' || ch == '\r') {
int i;
char *ptr;
@@ -415,10 +420,49 @@ usercomplete(const char *prompt, char *data)
if (i == cwnum)
data[0] = '\0';
break;
- } else if (ch == ' ') {
+
+ } else if (ch == '\177' || ch == '\010') {
+ if (temp == data)
+ continue;
+ temp--;
+ count--;
+ *temp = '\0';
+ cwlist = u_namearray((arrptr) cwbuf, &cwnum, data);
+ morenum = 0;
+ x--;
+ move(y, x);
+ outc(' ');
+ move(y, x);
+ continue;
+
+ } else if (ch != ' ' && count < STRLEN && isprint((int)ch)) {
+
+ int n;
+
+ *temp++ = ch;
+ *temp = '\0';
+ n = UserSubArray((arrptr) cwbuf, (arrptr) cwlist, cwnum, ch, count);
+
+ if (n > 0) {
+ /* found something */
+ cwlist = cwbuf;
+ count++;
+ cwnum = n;
+ morenum = 0;
+ move(y, x);
+ outc(ch);
+ x++;
+
+ continue;
+ }
+ /* no break, no continue, list later. */
+ }
+
+ /* finally, list available users. */
+ {
int col, len;
- if (cwnum == 1) {
+ if (ch == ' ' && cwnum == 1) {
strcpy(data, cwlist);
move(y, x);
outs(data + count);
@@ -427,18 +471,34 @@ usercomplete(const char *prompt, char *data)
getyx(&y, &x);
continue;
}
+
clearbot = YEA;
col = 0;
+
len = UserMaxLen((arrptr) cwlist, cwnum, morenum, p_lines);
move(2, 0);
clrtobot();
- printdash("使用者代號一覽表");
- while (len + col < 79) {
- int i;
+ printdash("使用者代號一覽表", 0);
+
+ if(ch != ' ')
+ {
+ /* no such user */
+ move(2,0);
+ outs("無此使用者: ");
+ outs(data);
+ outs(" ");
+ temp--;
+ *temp = '\0';
+ }
+
+ while (len + col < t_columns-1) {
+
+ int i;
for (i = 0; morenum < cwnum && i < p_lines; i++) {
move(3 + i, col);
- prints("%s ", cwlist + (IDLEN + 1) * morenum++);
+ prints("%.*s ", IDLEN,
+ cwlist + (IDLEN + 1) * morenum++);
}
col += len + 2;
if (morenum >= cwnum)
@@ -446,42 +506,15 @@ usercomplete(const char *prompt, char *data)
len = UserMaxLen((arrptr) cwlist, cwnum, morenum, p_lines);
}
if (morenum < cwnum) {
- vmsg(msg_more);
+ move(b_lines, 0); clrtobot();
+ outs(msg_more);
+ // vmsg(msg_more);
} else
morenum = 0;
- move(y, x);
- continue;
- } else if (ch == '\177' || ch == '\010') {
- if (temp == data)
- continue;
- temp--;
- count--;
- *temp = '\0';
- cwlist = u_namearray((arrptr) cwbuf, &cwnum, data);
- morenum = 0;
- x--;
- move(y, x);
- outc(' ');
- move(y, x);
- continue;
- } else if (count < STRLEN && isprint((int)ch)) {
- int n;
- *temp++ = ch;
- *temp = '\0';
- n = UserSubArray((arrptr) cwbuf, (arrptr) cwlist, cwnum, ch, count);
- if (n == 0) {
- temp--;
- *temp = '\0';
- continue;
- }
- cwlist = cwbuf;
- count++;
- cwnum = n;
- morenum = 0;
move(y, x);
- outc(ch);
- x++;
+
+ continue;
}
}
free(cwbuf);
@@ -635,7 +668,7 @@ generalnamecomplete(const char *prompt, char *data, int len, size_t nmemb,
clearbot = YEA;
move(2, 0);
clrtobot();
- printdash("相關資訊一覽表");
+ printdash("相關資訊一覽表", 0);
col = 0;
while (len + col < 79) {
diff --git a/mbbsd/stuff.c b/mbbsd/stuff.c
index f5ecafa3..1c6c3941 100644
--- a/mbbsd/stuff.c
+++ b/mbbsd/stuff.c
@@ -812,25 +812,29 @@ cursor_key(int row, int column)
}
void
-printdash(const char *mesg)
+printdash(const char *mesg, int msglen)
{
int head = 0, tail;
+ if(msglen <= 0)
+ msglen = strlen(mesg);
+
if (mesg)
- head = (strlen(mesg) + 1) >> 1;
+ head = (msglen + 1) >> 1;
tail = head;
- while (head++ < 38)
+ while (head++ < t_columns/2-2)
outc('-');
if (tail) {
outc(' ');
- outs(mesg);
+ if(mesg) outs(mesg);
outc(' ');
}
- while (tail++ < 38)
+ while (tail++ < t_columns/2-2)
outc('-');
+
outc('\n');
}