🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.sun
Article #9881

Re: Text Subwindow line number

#9881
From: zifrony
Date: Thu, 22 Dec 1988 18:58
26 lines
1742 bytes
In Sun-Spots Digest, v7n47, unido!infhil!sun1a!boeker@uunet.uu.net
(Michael Boeker) needed to know how to determine the line number of a
position.  As I have encountered a similar problem, needing to find the
line number clicked on by the user, I have the following method to solve
it:

 1. I have created a mapping of the text window, noting in which position
    each line starts by using textsw_index_for_file_line().

 2. I have determined the location of the cursor in the text (the place where
    the user clicked), by using window_get(src, TEXTSW_INSERTION_POINT, 0),
    where src is my Textsw subwindow.  Note that dbxtool does it in a smoother
    way, and keeps the Textsw subwindow readonly; alas, I do not have the
    source of dbxtool, and had to resort to these means to solve the problem.

 3. I looped through my mapping, finding the first line whose first character
    index is greater than my position, and voila, the line is found.

Please note that the file I am working with is not too big, thus the
search loop does not take too long.  For huge files, I suppose a better
way has to be sought to solve the problem.

 Doron Zifrony                  zifrony@taurus.bitnet || zifrony@Math.Tau.Ac.IL
 Msc. Student
 Tel Aviv University
 Israel
Technical Details
Message-ID: <8812151804.AA06341@MATH.Tau.Ac.IL>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!husc6!rice!sun-spots-request

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!husc6!rice!sun-spots-request
From: zifrony@TAURUS.BITNET
Newsgroups: comp.sys.sun
Subject: Re: Text Subwindow line number
Message-ID: <8812151804.AA06341@MATH.Tau.Ac.IL>
Date: 22 Dec 88 18:58:36 GMT
Sender: usenet@rice.edu
Organization: Sun-Spots
Lines: 26
Approved: Sun-Spots@rice.edu
Original-Date: Thu, 15 Dec 88 20:04:31 +0200
X-Sun-Spots-Digest: Volume 7, Issue 74, message 8 of 16
X-Issue-Reference: v7n47