作者guessi.bbs@bbs.wretch.cc (沒) 看板: plan
標題[問題] 控制碼去除
時間無名小站 (2006/05/30 Tue 17:16:50) Updated: 2006/06/01
想做一個功能 "閱讀時"切換顯示有無控制碼
以下是我改的內容 麻煩各位指教 謝謝 <(_ _)>
:/src/include/ufo.h
+ #define UFO_NOANSI BFLAG(22) /* more()去除顏色 */
..
..
+ "閱\讀文字顏色 (去除/保留)", /* UFO_NOANSI */
:/src/maple/more.c
static uschar *fimage;
static uschar *fend;
static uschar *foff;
+ static int noansi;
:/src/maple/more.c:more()
+ noansi = (footer == FOOTER_POST || footer == FOOTER_MAILER);
clear();
:/src/maple/more.c:outs_line()
+ if (noansi)
+ {
+ ansi = 0;
+ str_ansi(str, str, ANSILINELEN);
+ outx(str);
+ return;
+ }
ch1 = str[0];
ch2 = str[1];
:/src/maple/more.c:outs_header()
+ char linebuf[ANSILINELEN]; /* UFO_NOANSI */
..
..
if ((ptr = strstr(word, str_post1)) || (ptr = strstr(word, str_post2)))
{
ptr[-1] = ptr[4] = '\0';
- prints(" .... ");
+ sprintf(linebuf, " .... ");
}
else
{
/* 少看板這欄 */
- prints(" .... ");
+ sprintf(linebuf, " .... ");
}
+ outs_line(linebuf);
return;
}
..
..
/* 其他檔頭都只有一欄 */
word = str + header_len;
- prints(" .... ");
+ sprintf(linebuf, " .... ");
+ outs_line(linebuf);
:/src/maple/more.c:outs_footer()
- outs(buf);
+ outs_line(buf);
:/src/maple/more.c:more()
if (footer != (char *) -1)
- outf(footer);
+ outs_line(footer);
以下是做按鍵切換的設定
:/src/maple/more.c:more()
+ else if (key == 'W')
+ {
+ cuser.ufo ^= UFO_NOANSI;
+ /* 會跳回line 1 */
+ if (lino <= b_lines) /* 已經在最開始了 */
+ shift = 0;
+ else
+ shift = -PAGE_SCROLL - 1;
+ }
else if (key == 'h')
{
:/src/maple/post.c:post_browse()
+ case 'W':
+ cuser.ufo ^= UFO_NOANSI;
+ more(fpath, FOOTER_POST);
+ goto re_key; /* 會跳回line 1 */
--
夫兵者不祥之器物或惡之故有道者不處君子居則貴左用兵則貴右兵者不祥之器非君子
之器不得已而用之恬淡為上勝而不美而美之者是樂殺人夫樂殺人者則不可得志於天下
矣吉事尚左凶事尚右偏將軍居左上將軍居右言以喪禮處之殺人之眾以哀悲泣之戰勝以
喪禮處之道常無名樸雖小天下莫能臣侯王若能守之萬物將自賓天地相合以降甘露民莫
之令而自均始制有名名亦既有夫亦將知止知止 61-231-196-70.dynamic.hinet.net海精華選讀←離開[主題上]主題下(k)上篇(j)下篇S/a搜尋 G串列 TAB精華 ↑↓捲 Pg/Space翻