Article View: news.software.readers
Article #55077[slrn] Distinguishing between header versus article mode
From: Dawn Owens-Nicholson
Date: Fri, 10 Dec 1999 00:00
Date: Fri, 10 Dec 1999 00:00
84 lines
5006 bytes
5006 bytes
Stephane Gibier wrote:
> The main problem is that slrn does not separate header and article mode.
What, exactly, are you looking for in this distinction that isn't supplied
by is_article_visible()?
> [ed. note: I've edited the quote slightly to conserve vertical space.]
> % SmartUp : [Up arrow]
> define article_smartup()
> {
> if( is_article_visible() ) call( "article_lineup" );
> else call( "up" );
> }
> definekey( "article_smartup", "\e[A", "article" );
[You like "smart" programs, eh?]
I'm pretty sure this is not what you intended--it looks like you wanted to
say "If *any* article is visible, the up arrow key scrolls the article body
up, otherwise the cursor moves up one entry in the header list". What
you've got will only do the first half of this if the cursor is on the
article being shown (i.e., is_article_visible() returns 3). If the cursor
is on an article not being shown (is_article_visible() returns 1), you'll
bump into the action another poster complains about--call("article_lineup")
will download the the article at the cursor and show it to you (probably not
what you wanted to do *in this case*). I think you should change your code
to read:
if( is_article_visible() == 3 ) call( "article_lineup" );
so you only scroll the article body when the cursor is at the current
article. This will make for a weird action if you are looking at an article
in the middle of the header list and you move the cursor to the bottom of
the header list and hold down the up arrow key--the cursor will move up
until it hits the article being shown then the *article* will scroll up.
But it's a lot simpler than one alternative I'll describe below:
implements ("my");
private variable current_article = NULL;
static define article_smartup ()
{
switch (is_article_visible ())
{ case (0): % NO article is visible
call ("up");
return ();
}
{ case (1): % DIFFERENT article is visible
if (current_article == NULL) return ();
% variable cursor = extract_article_header ("Message-ID");
() = locate_header_by_msgid (current_article, 0);
call ("article_lineup");
% () = locate_header_by_msgid (cursor, 0);
}
{ case (3): % CURRENT article is visible
current_article = extract_article_header ("Message-ID");
call ("article_lineup");
}
}
static define group_mode_hook () { current_article = NULL; }
I'll let you replicate this for the other movement commands, but you can see
what happens in each of the three possible cases in article mode. Add
my->group_mode_hook() to your global group_mode_hook() so the current
article pointer gets updated properly when you leave article mode. Also,
you'll need to update my->current_article for reading articles and any other
action where the cursor moves from one article to another (this is quite a
lot of intrinsic wrapping to do). Personally, I don't think it's really
worth being able to make the arrow/home/end/etc. keys do the right thing no
matter where the cursor is.
Please note--there is a bug preventing this macro from doing all I wanted it
to do. I wanted the cursor to move to the article you *intended* to scroll
up, perform the scroll, then move back to where it was when you ran
article_smartup()[1]. You can see I try to do that with the two commented out
lines. If you uncomment them it won't do what you expect; I'm speculating
there's some sort of cursor movement optimization going on that prevents
doing certain actions quickly. This does something fairly close to what I
think you intended to do. Let the flaming begin.
[1] If I get some time, I'll work on a workaround and a thread-display
preserving version that'll look much more "smart".
Technical Details
Message-ID:
<slrn851bl9.t3j.bluemoon@ux6.cso.uiuc.edu>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!not-for-mailReferences:
<slrn847vtl.e03.cgreen@shell.x-1.net> <slrn84atjf.nq7.bluemoon@ux6.cso.uiuc.edu> <slrn84d5t3.lns.cgreen@shell.x-1.net> <slrn84dpsa.7fh.bluemoon@ux6.cso.uiuc.edu> <slrn84fhm9.osf.cgreen@shell.x-1.net> <slrn84gau1.5q3.bluemoon@ux6.cso.uiuc.edu> <slrn84n652.8qh.cgreen@shell.x-1.net> <slrn84o3vd.qo0.bluemoon@ux6.cso.uiuc.edu> <slrn84obh8.dam.cgreen@shell.x-1.net> <slrn84qlat.ojl.bluemoon@ux6.cso.uiuc.edu> <slrn84satm.j2i.cgreen@shell.x-1.net> <slrn850690.cv.sgibier@hermes.olympus.fr>Show Full Headers
Complete Article Headers
Message-ID: <slrn851bl9.t3j.bluemoon@ux6.cso.uiuc.edu> Subject: [slrn] Distinguishing between header versus article mode Date: Fri, 10 Dec 1999 00:00:00 +0000 From: bluemoon@ux6.cso.uiuc.edu (Dawn Owens-Nicholson) References: <slrn847vtl.e03.cgreen@shell.x-1.net> <slrn84atjf.nq7.bluemoon@ux6.cso.uiuc.edu> <slrn84d5t3.lns.cgreen@shell.x-1.net> <slrn84dpsa.7fh.bluemoon@ux6.cso.uiuc.edu> <slrn84fhm9.osf.cgreen@shell.x-1.net> <slrn84gau1.5q3.bluemoon@ux6.cso.uiuc.edu> <slrn84n652.8qh.cgreen@shell.x-1.net> <slrn84o3vd.qo0.bluemoon@ux6.cso.uiuc.edu> <slrn84obh8.dam.cgreen@shell.x-1.net> <slrn84qlat.ojl.bluemoon@ux6.cso.uiuc.edu> <slrn84satm.j2i.cgreen@shell.x-1.net> <slrn850690.cv.sgibier@hermes.olympus.fr> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!not-for-mail X-Deja-AN: 558902953 Organization: University of Illinois at Urbana-Champaign User-Agent: slrn/0.9.5.7 (UNIX) Newsgroups: news.software.readers