Article View: comp.sys.sun
Article #10064Re: Text Subwindow line number
From: Rich Salz
Date: Wed, 04 Jan 1989 20:14
Date: Wed, 04 Jan 1989 20:14
71 lines
2739 bytes
2739 bytes
This little piece of code does it...
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of shell archive."
# Contents: line.c
# Wrapped by rsalz@fig.bbn.com on Fri Dec 23 10:19:22 1988
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'line.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'line.c'\"
else
echo shar: Extracting \"'line.c'\" \(1144 characters\)
sed "s/^X//" >'line.c' <<'END_OF_FILE'
X/*
X*/
X#include <suntool/sunview.h>
X#include <suntool/textsw.h>
X#include <suntool/selection.h>
X#include <suntool/selection_svc.h>
X#include <suntool/selection_attributes.h>
X
Xextern Textsw KWICArea;
X
X/*
X** Get the line number of the current selection, or -1 if not in the
X** index window.
X*/
Xint
Xget_line_number()
X{
X static int Saved = -1;
X Seln_request *Sbuffer;
X Seln_holder Hold;
X int *p;
X
X /* Get primary selection, see if it is in our window. */
X Hold = seln_inquire(SELN_PRIMARY);
X if (Hold.state == SELN_NONE || !seln_holder_same_client(&Hold, KWICArea))
X /* Nope, get the old one. */
X return(Saved);
X
X /* Get the first line of the current selection. */
X Sbuffer = seln_ask(&Hold, SELN_REQ_FAKE_LEVEL, SELN_LEVEL_LINE,
X SELN_REQ_FIRST_UNIT, 0, 0);
X if (Sbuffer->status == SELN_FAILED) {
X Message("Can't get current selection!");
X return(-1);
X }
X
X /* The data we asked for comes back in words. */
X p = (int *)Sbuffer->data;
X
X /* Make sure we got what we asked for. */
X if (p[0] != (int)SELN_REQ_FAKE_LEVEL || p[2] != (int)SELN_REQ_FIRST_UNIT)
X return(-1);
X
X return(Saved = p[3]);
X}
END_OF_FILE
if test 1144 -ne `wc -c <'line.c'`; then
echo shar: \"'line.c'\" unpacked with wrong size!
fi
# end of 'line.c'
fi
echo shar: End of shell archive.
exit 0
--
Please send comp.sources.unix-related mail to rsalz@uunet.uu.net.
Technical Details
Message-ID:
<1322@fig.bbn.com>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!lll-winken!lll-lcc!ames!mailrus!cornell!uw-beaver!rice!sun-spots-requestReferences:
<8812151804.AA06341@MATH.Tau.Ac.IL>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!lll-winken!lll-lcc!ames!mailrus!cornell!uw-beaver!rice!sun-spots-request From: rsalz@bbn.com (Rich Salz) Newsgroups: comp.sys.sun Subject: Re: Text Subwindow line number Message-ID: <1322@fig.bbn.com> Date: 4 Jan 89 20:14:23 GMT References: <8812151804.AA06341@MATH.Tau.Ac.IL> Sender: usenet@rice.edu Organization: Sun-Spots Lines: 71 Approved: Sun-Spots@rice.edu Original-Date: 23 Dec 88 15:21:02 GMT X-Sun-Spots-Digest: Volume 7, Issue 88, message 2 of 9