[Message Prev][Message Next][Thread Prev][Thread Next][Message Index][Thread Index]

[MD:4280] garbage under the cursor



buffer を切り替えたときに、切替前のカーソルの位置に、まれにゴミが
残ることがありました。

なかなか再現しなかったのですが、確実な再現方法が分かったので対応
しておきました。対応方法に自身がないので、おかしかったら修正をお
願いします。

(1)再現方法
src/ChangeLog.Meadow:
>        * mw32term.c (MW32_clear_frame): Clear whole of the frame.
                       ^

ここ(MW32 の M の上)にカーソルを移動して、`M-.'で、タグジャンプし
ます。当然 etags で TAGS を作っておく必要があります。

すると、ジャンプ後の buffer にゴミが表示されます。ゴミは、ジャン
プ前にカーソルがあった場所に発生します。

(2)変更部分
Emacs-21.2 の w32term.c から以下のコードを import しました。
Meadow と NTEmacs では notice_overwritten_cursor () の実装が異な
るため、NTEmacs の notice_overwritten_cursor () の中身を展開して
います。ここら辺に無駄がありそうです。

----------------------------------------------------------------------------
--- ./mw32term.c.orig	2003-03-04 21:22:35.000000000 +0900
+++ ./mw32term.c	2003-03-04 21:57:00.000000000 +0900
@@ -4973,6 +4973,33 @@
       RestoreDC (hdc, -1);
     }
 
+  if (area == TEXT_AREA
+      && !row->full_width_p
+      /* When drawing overlapping rows, only the glyph strings'
+	 foreground is drawn, which doesn't erase a cursor
+	 completely. */
+      && !overlaps_p)
+    {
+      int x0 = head ? head->x : x;
+      int x1 = tail ? tail->x + tail->background_width : x;
+      
+      x0 = FRAME_TO_WINDOW_PIXEL_X (w, x0);
+      x1 = FRAME_TO_WINDOW_PIXEL_X (w, x1);
+      
+      if (XFASTINT (w->left_margin_width) != 0)
+	{
+      	  int left_area_width = window_box_width (w, LEFT_MARGIN_AREA);
+	  x0 -= left_area_width;
+	  x1 -= left_area_width;
+	}
+      if (updated_area == TEXT_AREA
+	  && w->phys_cursor_on_p
+	  && output_cursor.vpos == w->phys_cursor.vpos
+	  && x0 <= w->phys_cursor.x
+	  && (x1 < 0 || x1 > w->phys_cursor.x))
+	w->phys_cursor_on_p = 0;
+    }
+  
   /* Value is the x-position up to which drawn, relative to AREA of W.
      This doesn't include parts drawn because of overhangs.  */
   x_reached = FRAME_TO_WINDOW_PIXEL_X (w, x_reached);
@@ -9169,10 +9196,13 @@
      glyphs and mini-buffer.  */
   if (w->phys_cursor.hpos < row->used[TEXT_AREA])
     {
+      int on_p = w->phys_cursor_on_p;
+      
       mw32_draw_glyphs (w, w->phys_cursor.x, row, TEXT_AREA,
 			w->phys_cursor.hpos, w->phys_cursor.hpos + 1,
 			hl, 0, 0, 0);
-
+      w->phys_cursor_on_p = on_p;
+      
       /* When we erase the cursor, and ROW is overlapped by other
 	 rows, make sure that these overlapping parts of other rows
 	 are redrawn.  */

--
三好 雅則 mailto:miyoshi@xxxxxxxxxxxxxxxx
          http://www.boreas.dti.ne.jp/~miyoshi/ (Meadow2 のページ始めました)