📄 00000002.htm
字号:
<HTML><HEAD> <TITLE>BBS水木清华站∶精华区</TITLE></HEAD><BODY><CENTER><H1>BBS水木清华站∶精华区</H1></CENTER>发信人: <A HREF="mailto:yes.bbs@firebird.cs.ccu.edu.tw">yes.bbs@firebird.cs.ccu.edu.tw</A> (□), 看板 linux <BR>标 题: 使 NcFTP 2.3.0 可以看彩色与中文 <BR>发信站: 中正大学四百年来第一站 (Sun Jan 28 23:01:02 1996) <BR>转信站: <BR> <BR>如何让 NcFTP 2.3.0 在 Visual Mode 下也可以看到含彩色控制码与中文的画面 <BR> <BR>*此修改版本使用 NcFTP 2.3.0 与 ncurses 1.9.8a。作业系统 Linux, kernel <BR> 版本 1.2.13。 <BR> <BR>需要修改的档案: <BR>NcFTP: Util.c Win.c <BR>ncurses: lib_addch.c lib_addstr.c <BR> <BR>由於 ncurses 本身的 waddstr 等 function 会过滤控制字元,使得即使我们修 <BR>改 NcFTP 的原始程式使其不过滤控制码,到了 ncurses 的层次仍会被滤掉。底 <BR>下所说明的修改法便是同时修改这两套软体的原始程式,使我们在使用 NcFTP时 <BR>即使在 visual mode 下也可以看到正常的彩色字。 <BR> <BR>修改 NcFTP 的部份只要是使其不过滤中文字与 ESC 这个控制字元,以及在输出 <BR>时改成呼叫我们增加的 esc_waddnstr() 这个 function。 <BR> <BR>修改 ncurses 的部份主要是增加了 esc_waddnstr() 这个 function,以及其所 <BR>使用的两个 function,使其不过滤 ESC。 <BR> <BR>修改之处如下: <BR>Util.c:(改 MakeStringPrintable()) <BR>while ((i < siz) && (*src != '\0')) { <BR> c = *src++; <BR> if (isprint(c) || (c == '\n') || (c == '\t') <BR> || (c & 0x80) || (c == 0x1b)) { /* 不过滤中文与 ESC */ <BR> *dst++ = c; <BR> ++i; <BR> } else if (iscntrl(c) && (c != 0x7f)) { <BR> <BR>Win.c:(改 PrintToListWindow()) <BR> /* Weird things happened if I did wprintw(gListWin, "%s", startp). */ <BR> /* 原本呼叫 waddstr() */ <BR> esc_waddnstr(gListWin, startp, -1); <BR> <BR> /* May need to gCurRow++ if line wraps around other side... */ <BR> if (haveNL) { <BR> gCurRow++; <BR> <BR>lib_addch.c:(增加以下的 function) <BR>/* 取消对 ESC 的过滤 */ <BR>/* 加在 waddch_nosync() 之後,#undef DO_NEWLINE 之前 */ <BR>static inline <BR>int esc_waddch_nosync(WINDOW *win, const chtype c) <BR>/* the workhorse function -- add a character to the given window */ <BR>{ <BR>register chtype ch = c; <BR>register int x, y; <BR>int newx; <BR> <BR> x = win->_curx; <BR> y = win->_cury; <BR> <BR> CHECK_POSITION(win, x, y); <BR> <BR> if (ch & A_ALTCHARSET) <BR> goto noctrl; <BR> <BR> switch (ch&A_CHARTEXT) { <BR> case '\t': <BR> if (win->_flags & _NEED_WRAP) { <BR> x = 0; <BR> newx = min(TABSIZE, win->_maxx+1); <BR> } else <BR> newx = min(x + (TABSIZE-(x%TABSIZE)), win->_maxx+1); <BR> while (win->_curx < newx) { <BR> if (waddch_literal(win, ' ' | (ch&A_ATTRIBUTES)) == ERR) <BR> <BR> return(ERR); <BR> } <BR> return(OK); <BR> case '\n': <BR> wclrtoeol(win); <BR> DO_NEWLINE <BR> break; <BR> case '\r': <BR> x = 0; <BR> win->_flags &= ~_NEED_WRAP; <BR> break; <BR> case '\b': <BR> if (win->_flags & _NEED_WRAP) <BR> win->_flags &= ~_NEED_WRAP; <BR> else if (--x < 0) <BR> x = 0; <BR> break; <BR> default: <BR> if (is7bits(ch & A_CHARTEXT) && iscntrl(ch & A_CHARTEXT) <BR> && ((ch & A_CHARTEXT) != 0x1b)) /* 不过滤 ESC */ <BR> return(waddstr(win, unctrl((unsigned char)ch))); <BR> <BR> /* FALL THROUGH */ <BR> noctrl: <BR> waddch_literal(win, ch); <BR> return(OK); <BR> } <BR> <BR> win->_curx = x; <BR> win->_cury = y; <BR> <BR> return(OK); <BR>} <BR> <BR>/* 加在档案最後即可 */ <BR>int _esc_nc_waddch_nosync(WINDOW *win, const chtype c) <BR>/* export copy of waddch_nosync() so the string-put functions can use it */ <BR>{ <BR> return(esc_waddch_nosync(win, c)); <BR>} <BR> <BR>lib_addstr.c:(增加以下的 function) <BR>/* 加在档案最後即可 */ <BR>int <BR>esc_waddnstr(WINDOW *win, const char *astr, int n) <BR>{ <BR>unsigned char *str = (unsigned char *)astr; <BR>int code = ERR; <BR> <BR> T(("esc_waddnstr(%p,\"%s\",%d) called %s", win, _nc_visbuf(astr), n, _tr <BR>aceattr(win->_attrs))); <BR> <BR> if (str != NULL) { <BR> <BR> TR(TRACE_VIRTPUT, ("str is not null")); <BR> code = OK; <BR> if (n < 0) <BR> n = strlen(astr); <BR> <BR> while((n-- > 0) && (*str != '\0')) { <BR> TR(TRACE_VIRTPUT, ("*str = %x", *str)); <BR> if (_esc_nc_waddch_nosync(win, (unsigned char)*str++) == <BR> ERR) { <BR> code = ERR; <BR> break; <BR> } <BR> } <BR> } <BR> _nc_synchook(win); <BR> TR(TRACE_VIRTPUT, ("esc_waddnstr returns %d", code)); <BR> return code; <BR>} <BR> <BR> <BR><CENTER><H1>BBS水木清华站∶精华区</H1></CENTER></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -