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.devel Subject: Re: Obtain X / HPOS with move_it_to at eol when buffer-display-table line-feed Date: Tue, 29 Aug 2017 11:51:07 -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 1504032691 27301 195.159.176.226 (29 Aug 2017 18:51:31 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 29 Aug 2017 18:51:31 +0000 (UTC) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Aug 29 20:51:24 2017 Return-path: Envelope-to: ged-emacs-devel@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 1dmlbV-0006Cb-2t for ged-emacs-devel@m.gmane.org; Tue, 29 Aug 2017 20:51:13 +0200 Original-Received: from localhost ([::1]:46532 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmlbc-0005AE-12 for ged-emacs-devel@m.gmane.org; Tue, 29 Aug 2017 14:51:20 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52560) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmlbV-0005A9-RQ for emacs-devel@gnu.org; Tue, 29 Aug 2017 14:51:14 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmlbS-0006R0-On for emacs-devel@gnu.org; Tue, 29 Aug 2017 14:51:13 -0400 Original-Received: from gateway22.websitewelcome.com ([192.185.47.48]:49099) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmlbS-0006Mz-GK for emacs-devel@gnu.org; Tue, 29 Aug 2017 14:51:10 -0400 Original-Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway22.websitewelcome.com (Postfix) with ESMTP id 3297911B04 for ; Tue, 29 Aug 2017 13:51:09 -0500 (CDT) Original-Received: from gator3053.hostgator.com ([50.87.144.69]) by cmsmtp with SMTP id mlakdKWGbc72gmlakd9clI; Tue, 29 Aug 2017 13:50:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lawlist.com ; s=default; h=Content-Type:MIME-Version:Subject:Cc:To:From:Message-ID:Date: Sender:Reply-To: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=7T2I2vZBM3bT6D+eRMz0ZQK5ZIGSmE94YHzqI/a9Unw=; b=i/wndPuJh9n28Dus/kTY0yBEZy MYJRK7RyFVVy7Tkfm1YXAEDaR+nw1tn6b0iN1jbNtm8g8j6uF9iC3Po1PulFXLQYWjCj//YuraXxQ kYnp3mJ5QUFMxdB/AJIhpbrhuQzcTpenU5gzM/51MeWC/v8aFJd25J6Tg25fK/DmFGnKuGtuijHu+ vpf/QrdYptOdxM4E0ILhWRuSivb+fCVSmVWq0UrewyBc20HFdgsDLQ5rq1mzRGjyZK+cpoOfYpQLo CSDF7eDZSfoFOtdxpxf+4TpgValV64N7UXBJYPmv9v6VfxysEAnteDOvaFxC2lUGgRU70hnoWreFj 2XN0g2Qw==; Original-Received: from cpe-45-48-239-195.socal.res.rr.com ([45.48.239.195]:50193 helo=server.private) by gator3053.hostgator.com with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.87) (envelope-from ) id 1dmlbP-0045UY-SV; Tue, 29 Aug 2017 13:51:07 -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-Exim-ID: 1dmlbP-0045UY-SV X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: cpe-45-48-239-195.socal.res.rr.com (server.private) [45.48.239.195]:50193 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-Received-From: 192.185.47.48 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:217883 Archived-At: Thank you, Eli, for looking at this particular thread. I am creating pilcrows at the end of each line using the following code: (let ((face (face-id 'font-lock-warning-face))) (aset (or buffer-display-table (setq buffer-display-table (make-display-table))) ?\n `[(182 . ,face) ?\n])) Using POS, I would like to obtain X/Y/HPOS/VPOS for any particular eol pilcrow. If I search for POS at the end of the line using move_it_to, then it.current_x and it.current_hpos are not the values that I need. In that situation, I have to subtract frame-char-width from it.current_x, and I have to subtract 1 from it.current_hpos. it.current_x and it.current_hpos are essentially off to a tune of one character to the right of the pilcrow. I would like to come up with a more sophisticated test for when IT is at the end of the line looking at a pilcrow as described above, and when that situation exists, then return the X and HPOS to the left of the pilcrow (instead of to the right of the pilcrow). [I am then going to place a fake cursor on the pilcrow, which is beyond the scope of the current issue.] Lisp_Object get_x_y_hpos_vpos (struct window *w, ptrdiff_t start, ptrdiff_t position) { struct it it; void *itdata = bidi_shelve_cache (); struct text_pos start_text_position; int x, y, hpos, vpos; struct frame *f = XFRAME (w->frame); int frame_char_width = FRAME_COLUMN_WIDTH (f); ptrdiff_t pt_original = PT; ptrdiff_t pt_byte_original = PT_BYTE; /* marker_position (w->start) is NOT reliable here. */ if (position >= start) { SET_TEXT_POS_FROM_MARKER (start_text_position, w->start); start_display (&it, w, start_text_position); /* Move IT to POSINT, but no farther than the lower right-hand corner of the visible window. */ move_it_to (&it, position, it.last_visible_x, it.last_visible_y - 1, -1, MOVE_TO_POS | MOVE_TO_X | MOVE_TO_Y); if (IT_CHARPOS (it) != position) goto done; y = it.current_y; if (WINDOW_HEADER_LINE_HEIGHT (w) > 0) vpos = it.vpos + 1; else vpos = it.vpos; if (FETCH_BYTE (IT_BYTEPOS (it)) == '\n' /* && (aref buffer-display-table ?\n) == [(182 . 127) 10] */ ) { x = it.current_x - frame_char_width; hpos = it.hpos - 1; } else { x = it.current_x; hpos = it.hpos; } } else { done: x = -1; y = -1; hpos = -1; vpos = -1; } bidi_unshelve_cache (itdata, false); return listn (CONSTYPE_HEAP, 4, make_number (x), make_number (y), make_number (hpos), make_number (vpos)); }