From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Keith David Bershatsky Newsgroups: gmane.emacs.bugs Subject: bug#31716: move_it_in_display_line / horizontal scrolling / tab stretch Date: Mon, 04 Jun 2018 17:38:17 -0700 Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Trace: blaine.gmane.org 1528159055 562 195.159.176.226 (5 Jun 2018 00:37:35 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 5 Jun 2018 00:37:35 +0000 (UTC) To: 31716@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Jun 05 02:37:31 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fPzyc-0008S5-3c for geb-bug-gnu-emacs@m.gmane.org; Tue, 05 Jun 2018 02:37:30 +0200 Original-Received: from localhost ([::1]:42487 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQ00h-0001oz-Qa for geb-bug-gnu-emacs@m.gmane.org; Mon, 04 Jun 2018 20:39:39 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45761) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQ00A-0001V1-6Y for bug-gnu-emacs@gnu.org; Mon, 04 Jun 2018 20:39:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQ007-0006U2-2b for bug-gnu-emacs@gnu.org; Mon, 04 Jun 2018 20:39:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:54075) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fQ006-0006Ty-TO for bug-gnu-emacs@gnu.org; Mon, 04 Jun 2018 20:39:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fQ006-0005Mh-KC for bug-gnu-emacs@gnu.org; Mon, 04 Jun 2018 20:39:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Keith David Bershatsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 05 Jun 2018 00:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 31716 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: Emacs Bug Reports Original-Received: via spool by submit@debbugs.gnu.org id=B.152815912720599 (code B ref -1); Tue, 05 Jun 2018 00:39:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 5 Jun 2018 00:38:47 +0000 Original-Received: from localhost ([127.0.0.1]:33739 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fPzzr-0005MA-2t for submit@debbugs.gnu.org; Mon, 04 Jun 2018 20:38:47 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:54744) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fPzzo-0005Ls-NT for submit@debbugs.gnu.org; Mon, 04 Jun 2018 20:38:45 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fPzzh-0006Qa-UJ for submit@debbugs.gnu.org; Mon, 04 Jun 2018 20:38:39 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:39630) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fPzzh-0006QT-Qa for submit@debbugs.gnu.org; Mon, 04 Jun 2018 20:38:37 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45708) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fPzzf-0001Sg-Ue for bug-gnu-emacs@gnu.org; Mon, 04 Jun 2018 20:38:37 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fPzzc-0006PP-Qh for bug-gnu-emacs@gnu.org; Mon, 04 Jun 2018 20:38:35 -0400 Original-Received: from gateway21.websitewelcome.com ([192.185.45.212]:31820) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fPzzc-0006M9-G3 for bug-gnu-emacs@gnu.org; Mon, 04 Jun 2018 20:38:32 -0400 Original-Received: from cm12.websitewelcome.com (cm12.websitewelcome.com [100.42.49.8]) by gateway21.websitewelcome.com (Postfix) with ESMTP id 10349400CBF9F for ; Mon, 4 Jun 2018 19:38:19 -0500 (CDT) Original-Received: from gator3053.hostgator.com ([50.87.144.69]) by cmsmtp with SMTP id PzzOfHh6KSjJAPzzOfs0JZ; Mon, 04 Jun 2018 19:38:19 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lawlist.com ; s=default; h=Content-Type:MIME-Version:Subject:To:From:Message-ID:Date: Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=4ItycCEeYeet8QuSTpR434Sk7uaPqzvjC5liav7tJ1o=; b=gCe+SdPb9sLxAgRrZs8XG23aZy jyFf4iNwI103dwoXOCwX0C18jUAoWCttsHlH6Qgs0g24rRplSmOTHxDn5Y/h2QFViNagjMvnmlfoE K05vCB6acJyzMhid1/v+LR/QFhv6bjMd9az5TG8jkW9q3M0LAokkew+gz1yCSgN3KhnVJ97t4MB5b /eXihkKsweZHk9JrxMw5SR3YvvogysWJ/c2whSuBiqUGsssL/uvy46wuWVWGZabaziLkjpIv2EPdL RSkiZcbicyHHnmewopJdyYM8VinirNtccK16roBymFl2dBDjebiEF8BBGqQCTx14tvvGsQ71+ie3/ I0XZgn3g==; Original-Received: from cpe-45-48-239-195.socal.res.rr.com ([45.48.239.195]:52975 helo=server.local) by gator3053.hostgator.com with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.89_1) (envelope-from ) id 1fPzzO-000rOT-0s for bug-gnu-emacs@gnu.org; Mon, 04 Jun 2018 19:38:18 -0500 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator3053.hostgator.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lawlist.com X-BWhitelist: no X-Source-IP: 45.48.239.195 X-Source-L: No X-Exim-ID: 1fPzzO-000rOT-0s X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: cpe-45-48-239-195.socal.res.rr.com (server.local) [45.48.239.195]:52975 X-Source-Auth: lawlist X-Email-Count: 1 X-Source-Cap: bGF3bGlzdDtsYXdsaXN0O2dhdG9yMzA1My5ob3N0Z2F0b3IuY29t X-Local-Domain: yes X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:146981 Archived-At: Step 1. Build a new Emacs (master branch) with the function bug-christmas-ghost (below). [E.g., place the new function somewhere appropriate inside of xdisp.c.] Step 2. Launch the newly built Emacs from the terminal so that we can see the STDERR output. Step 3. Paste the following Lisp code into a scratch buffer and evaluate the code. (setq display-line-numbers t) (setq buffer-display-table (make-display-table)) (aset buffer-display-table ?\t (vector (make-glyph-code ?\u00BB 'font-lock-warning-face) (make-glyph-code ?\t 'highlight))) (setq tab-width 8) Step 4. On a new line in the scratch buffer type: C-q TAB Hello Step 5. Place the cursor somewhere on the word "Hello". Step 6. Evaluate: (scroll-left 2) Step 7. Evaluate: (bug-christmas-ghost) OBSERVATIONS: A. When w->hscroll is >= 2 and IT is within the tab STRETCH, move_it_in_display_line_to reports an erroneous it.hpos subsequent to the line numbers. In this example, it.hpos is reported as being either 0 or 5, even though the tab STRETCH visibly begins at an it.hpos of 4 when line numbers are 2 digits wide. B. When w->hscroll is >= 2 and IT is within the tab STRETCH, the latter portion contains one or more it.c ghosts of Christmas future. I.e., the letter "H" gets returned at several locations along the tab STRETCH. EXPECTATIONS / DESIRED BEHAVIOR. i. Loops 7 to 12 should report an it.hpos of 4. ii. Loops 7 to 12 should report an it.c of 9 (aka a tab character). Here is an excerpt from the STDERR output after calling (scroll-left 2) and moving IT by X -- incrementing each loop by font->space_width. [ * * * BEGIN excerpt of STDERR output] [IT.HPOS IS 4, NOT 0.] 7. TAB STRETCH it.c (9) char ( ) it.first_visible_x (14) w->hscroll (2) it.hpos (0) it.first_visible_x (14) it.current_x (7) relative_x (28) new_x (42) font->space_width (7) it.pixel_width (49) it.lnum_pixel_width (28) rc (MOVE_X_REACHED) [IT.HPOS IS 4, NOT 0.] 8. TAB STRETCH it.c (9) char ( ) it.first_visible_x (14) w->hscroll (2) it.hpos (0) it.first_visible_x (14) it.current_x (7) relative_x (35) new_x (49) font->space_width (7) it.pixel_width (49) it.lnum_pixel_width (28) rc (MOVE_X_REACHED) [IT.C IS 9, NOT 72; AND, IT.HPOS IS 4, NOT 5.] 9. TEXT it.c (72) char (H) it.first_visible_x (14) w->hscroll (2) it.hpos (5) it.first_visible_x (14) it.current_x (84) relative_x (42) new_x (56) font->space_width (7) it.pixel_width (7) it.lnum_pixel_width (28) rc (MOVE_X_REACHED) [IT.C IS 9, NOT 72; AND, IT.HPOS IS 4, NOT 5.] 10. TEXT it.c (72) char (H) it.first_visible_x (14) w->hscroll (2) it.hpos (5) it.first_visible_x (14) it.current_x (84) relative_x (49) new_x (63) font->space_width (7) it.pixel_width (7) it.lnum_pixel_width (28) rc (MOVE_X_REACHED) [IT.C IS 9, NOT 72; AND, IT.HPOS IS 4, NOT 5.] 11. TEXT it.c (72) char (H) it.first_visible_x (14) w->hscroll (2) it.hpos (5) it.first_visible_x (14) it.current_x (84) relative_x (56) new_x (70) font->space_width (7) it.pixel_width (7) it.lnum_pixel_width (28) rc (MOVE_X_REACHED) [IT.C IS 9, NOT 72; AND, IT.HPOS IS 4, NOT 5.] 12. TEXT it.c (72) char (H) it.first_visible_x (14) w->hscroll (2) it.hpos (5) it.first_visible_x (14) it.current_x (84) relative_x (63) new_x (77) font->space_width (7) it.pixel_width (7) it.lnum_pixel_width (28) rc (MOVE_X_REACHED) [THIS IS THE REAL LETTER "H"] 13. TEXT it.c (72) char (H) it.first_visible_x (14) w->hscroll (2) it.hpos (5) it.first_visible_x (14) it.current_x (84) relative_x (70) new_x (84) font->space_width (7) it.pixel_width (7) it.lnum_pixel_width (28) rc (MOVE_X_REACHED) [ * * * END excerpt of STDERR output] DEFUN ("bug-christmas-ghost", Fbug_christmas_ghost, Sbug_christmas_ghost, 0, 0, 0, doc: /* Debug the Ghost of Christmas Future. */) (void) { /* ****************************************************************************** PRELIMINARY STUFF ****************************************************************************** */ struct window *w = decode_live_window (selected_window); struct frame *f = XFRAME (w->frame); struct it it; void *itdata = bidi_shelve_cache (); enum move_it_result rc = MOVE_X_REACHED; struct text_pos start_text_position; int count = 0; int new_x = 0; int relative_x = 0; /* ****************************************************************************** START DISPLAY -- w->start ****************************************************************************** */ /* Begin the journey at w->start. */ SET_TEXT_POS_FROM_MARKER (start_text_position, w->start); start_display (&it, w, start_text_position); struct face *face = FACE_FROM_ID (it.f, it.face_id); struct font *font = face->font; /* ****************************************************************************** GO TO THE BEGINNING OF THE CURRENT LINE. ****************************************************************************** */ /* Place the IT on the current line containing PT. */ int voffset = (WINDOW_HEADER_LINE_HEIGHT (w) > 0 && w->output_cursor.vpos > 0) ? w->output_cursor.vpos - 1 : w->output_cursor.vpos; if (voffset > 0) move_it_by_lines (&it, voffset); struct glyph_row *glyph_row = MATRIX_ROW (w->current_matrix, it.vpos); /* ****************************************************************************** MOVE IT OVER EACH CHARACTER ON THE CURRENT LINE. ****************************************************************************** */ while (true) { count += 1; if (new_x > 0) relative_x = new_x - it.first_visible_x; if (ITERATOR_AT_END_OF_LINE_P (&it) || FETCH_BYTE (IT_BYTEPOS (it)) == '\n' || rc == MOVE_POS_MATCH_OR_ZV) break; /* ****************************************************************************** DUMP RELEVANT GLYPH INFORMATION ****************************************************************************** */ if (w->hscroll > 0) { int w_hscroll = w->hscroll; fprintf (stderr, "\n%d. %s\n\ it.c (%d)\n\ char (%s)\n\ it.first_visible_x (%d)\n\ w->hscroll (%d)\n\ it.hpos (%d)\n\ it.first_visible_x (%d)\n\ it.current_x (%d)\n\ relative_x (%d)\n\ new_x (%d)\n\ font->space_width (%d)\n\ it.pixel_width (%d)\n\ it.lnum_pixel_width (%d)\n\ rc (%s)\n", count, (it.c == 0 ? "NOTHING" : it.c == 187 ? "TAB CHARACTER" : it.c == '\t' ? "TAB STRETCH" : "TEXT"), it.c, SSDATA (Fchar_to_string (make_number (it.c))), it.first_visible_x, w_hscroll, it.hpos, it.first_visible_x, it.current_x, relative_x, new_x, font->space_width, it.pixel_width, it.lnum_pixel_width, (rc == MOVE_UNDEFINED ? "MOVE_UNDEFINED" : rc == MOVE_POS_MATCH_OR_ZV ? "MOVE_POS_MATCH_OR_ZV" : rc == MOVE_X_REACHED ? "MOVE_X_REACHED" : rc == MOVE_LINE_CONTINUED ? "MOVE_LINE_CONTINUED" : rc == MOVE_LINE_TRUNCATED ? "MOVE_LINE_TRUNCATED" : rc == MOVE_NEWLINE_OR_CR ? "MOVE_NEWLINE_OR_CR" : "OOPS")); } /* ****************************************************************************** MOVE IT -- INCREMENT == FONT->SPACE_WIDTH ****************************************************************************** */ new_x += font->space_width; rc = move_it_in_display_line_to (&it, ZV, new_x, MOVE_TO_POS | MOVE_TO_X); if (rc == MOVE_LINE_CONTINUED) break; if (it.current_x - it.first_visible_x + font->space_width >= window_box_width (w, TEXT_AREA)) break; } /* ****************************************************************************** REDISPLAY AND DUMP_GLPYH_ROW ****************************************************************************** */ redisplay_internal (); fprintf (stderr, "\n"); dump_glyph_row (glyph_row, it.vpos, 2); bidi_unshelve_cache (itdata, false); return Qnil; }