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: How to calculate X when dealing with truncate-lines non-nil. Date: Sat, 30 Sep 2017 09:32:37 -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 1506789223 16656 195.159.176.226 (30 Sep 2017 16:33:43 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 30 Sep 2017 16:33:43 +0000 (UTC) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Sep 30 18:33:38 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 1dyKht-0003ue-Px for ged-emacs-devel@m.gmane.org; Sat, 30 Sep 2017 18:33:38 +0200 Original-Received: from localhost ([::1]:39812 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dyKi1-0002d0-9F for ged-emacs-devel@m.gmane.org; Sat, 30 Sep 2017 12:33:45 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39695) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dyKhH-0002cv-Mh for emacs-devel@gnu.org; Sat, 30 Sep 2017 12:33:00 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dyKhC-0004eV-NS for emacs-devel@gnu.org; Sat, 30 Sep 2017 12:32:59 -0400 Original-Received: from gateway36.websitewelcome.com ([50.116.125.2]:21506) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dyKhC-0004UQ-Fa for emacs-devel@gnu.org; Sat, 30 Sep 2017 12:32:54 -0400 Original-Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway36.websitewelcome.com (Postfix) with ESMTP id 6EFBD4014E2C0 for ; Sat, 30 Sep 2017 11:32:38 -0500 (CDT) Original-Received: from gator3053.hostgator.com ([50.87.144.69]) by cmsmtp with SMTP id yKg3dFjI2pOTvyKg3dA1m6; Sat, 30 Sep 2017 11:31:43 -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=yM28/i+dQ3v0OxPIOVM2LFV9SZkUyuOVUWgrzUGPkCw=; b=Pm7xgmB6VgFuOEk05DgwRF9x/2 Wba5lZ2OWFNroz7u07oj9rcFGUkClzV+YMgi67Borkzym2CdggeeJ4jYA0V70SnZNG4/vQCtjupSm uTvSx0nMHpwIxCBryaSF/DSF1wptv9P7WjT/U4t/vftD9F7rz5gg0cVI8xW6Ol118La7GRJcZRPAt z06Z3yIjqIYrR4XQCZhyuQiR0yxMbqa7qt1FDLYrxk56QuOcJl8Fb2nsTqJ2KAKR8o5JklD/dvNo5 N0WCydkKmhV4rqtIeqm5YxwaM1Xpbt7jgWT7kv+WXq8sq0V6ZatwPZ8bGqzbsfOLla0wNZqwARD8I SkGsj0fg==; Original-Received: from cpe-45-48-239-195.socal.res.rr.com ([45.48.239.195]:50538 helo=server.private) by gator3053.hostgator.com with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.87) (envelope-from ) id 1dyKgv-000AhY-Oy; Sat, 30 Sep 2017 11:32:37 -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: 1dyKgv-000AhY-Oy 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]:50538 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: 50.116.125.2 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:218970 Archived-At: Thank you, Eli, for helping me to simplify the code for the window-relative X coordinate. I have implemented the suggested revision. I now have a working draft of crosshairs for all three situations (i.e., TRUNCATE, WINDOW_WRAP, and WORD_WRAP) by using a combination of window-relative X *and* the absolute IT X. Drawing/erasing multiple fake cursors is done with the former, whereas decision making is based on the latter. Keith ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; DATE: [09-29-2017 09:25:44] <29 Sep 2017 19:25:44 +0300> FROM: Eli Zaretskii > > > Date: Thu, 28 Sep 2017 10:31:58 -0700 > > From: Keith David Bershatsky > > > > I believe this issue is resolvable mathematically as follows: > > > > int x; > > if (it.line_wrap == TRUNCATE) > > x = it.current_x - it.first_visible_x; > > else > > x = it.current_x; > > > > Unless anyone sees a problem with this method, the issue is resolved. > > This could be a solution in some cases. The real answer depends on > what exactly does your code do, something that you didn't disclose. > > In any case, I think that the 'it.line_wrap == TRUNCATE' condition is > not needed: if you want the window-relative X coordinate, you should > always subtract the first_visible_x value: if it's zero, no harm will > be done.