回精華區
作者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 來讓使用者選擇要不要這功能

--
□ 本文章由 itocitoc.Dorm11.NCTU.edu.tw 發表
精華選讀←離開[主題上]主題下(k)上篇(j)下篇S/a搜尋 G串列 TAB精華 ↑↓捲 Pg/Space翻