作者itoc, 信區: itoc
標題[功能] edit.c 回文自動移動游標到最下面
時間04/01/12
作者: itoc (League) 看板: plan
標題: [功能] 回文自動移動游標到最下面
時間: 2004/01/12 Mon 10:49:08 Updated: 2004/06/10
※ 引述《qazq.bbs@bbs.cs.nchu.edu.tw (Maple-itoc)》之銘言:
> 回文自動移動游標到最下面
> 不知道要怎麼寫才可以勒?
: edit.c:ve_quote()
- static void
+ static int
ve_quote(this)
textline *this;
{
int fd, op;
+ int quote_lines = 0;
FILE *fp;
...
...
if (op == 'a')
{
while (fgets(str, ANSILINELEN - 2, fp)) /* 留空間給 "> " */
+ {
this = ve_line(this, buf);
+ quote_lines++;
+ }
}
else
{
while (fgets(str, ANSILINELEN - 2, fp)) /* 留空間給 "> " */
{
if (is_quoted(str)) /* "--\n" */
break;
if (quote_line(str, op))
+ {
this = ve_line(this, buf);
+ quote_lines++;
+ }
}
}
...
...
this->next = next;
if (next)
next->prev = this;
+ return quote_lines;
}
: edit.c:vedit()
textline *vln, *tmp;
int cc, col, mode, margin, pos;
+ int quote_lines = 0;
...
...
if (ve_op > 0) /* itoc.010301: 新增 ve_op = -1 時不能儲存 */
{
- ve_quote(vln);
+ quote_lines = ve_quote(vln);
}
...
...
ve_key:
+ if (quote_lines)
+ {
+ quote_lines--;
+ cc = KEY_DOWN;
+ }
+ else
cc = vkey();
if (isprint2(cc))
--
當然,你可以新增個 UFO_XXXX 來讓使用者選擇要不要這功能
--
□ 本文章由 itoc 從 itoc.Dorm11.NCTU.edu.tw 發表