Subject: Re: goto a line number in pico

From: Barry Landy <[email-masked]>
Date: Thu, 1 Aug 1996 12:45:53 +0100

On 31 Jul 1996, Tim Mooney wrote:

:>
:>Thanks for the info.  I had tried the +n command line option and it did work,
:>but I have users that know only pico as a Unix editor and need to be able to
:>move around in source files and make modifications (perhaps fixing errors
:>while trying to get something to compile).  If there are 10 errors on
:>various lines in a large file, it's a PITA to have to make a change, save
:>your change, quit pico, and then resart with some new +N linenumber to go
:>to the next error.  A number of users had asked if there was a better way.
:>Now I can tell them definitively, "Not with pico."
:>

Surely the control-W command to scan for text gives them what they want?

-------------------------------------------------------------------------------
Barry Landy                        Computer Laboratory:+44 1223 334600
Head of Systems and Development    Direct line:        +44 1223 334713
University of Cambridge Computing Service
New Museums Site                   Email:[email-masked]
Pembroke Street, Cambridge CB2 3QG

---

From: "Hiram Lester Jr." <[email-masked]>
Date: Thu, 1 Aug 1996 08:46:14 -0500 (CDT)

> Surely the control-W command to scan for text gives them what they want?

Provided you know what you are looking for.  An extra option on the
Control-W command to enter a line number would be a nice addition though.

   +------------------------------------+-------------------------------+
   | Hiram W. Lester, Jr.               | E-Mail: [email-masked]    |
   | Computer Science                   | Homepage:                     |
   | Middle Tennessee State University  |   http://pobox.com/~hwlester/ |
   +------------------------------------+-------------------------------+

---

From: [email-masked] (Evelyn Albrecht)
Date: 1 Aug 1996 11:32:24 -0700

[email-masked] (Tim Mooney) writes:

>Thanks for the info.  I had tried the +n command line option and it did work,
>but I have users that know only pico as a Unix editor and need to be able to
>move around in source files and make modifications (perhaps fixing errors
>while trying to get something to compile).  If there are 10 errors on
>various lines in a large file, it's a PITA to have to make a change, save
>your change, quit pico, and then resart with some new +N linenumber to go
>to the next error.  A number of users had asked if there was a better way.
>Now I can tell them definitively, "Not with pico."

   But the search command (^W), can be used in many cases, particularly when
   you're correcting typos, which tend to be unique.

   Evelyn
-- 
|Evelyn Albrecht                      Ph:  (360) 650-3239                 |
|Academic Computing Services          Internet: [email-masked]  |
|Western Washington Univ.                                                 |
|Bellingham, WA  98225-9094                                               |

---

From: ADAM Sulmicki <[email-masked]>
Date: Fri, 2 Aug 1996 01:08:17 -0400 (EDT)

->[email-masked] (Tim Mooney) writes:
->
->>Thanks for the info.  I had tried the +n command line option and it did work,
->>but I have users that know only pico as a Unix editor and need to be able to
->>move around in source files and make modifications (perhaps fixing errors
->>while trying to get something to compile).  If there are 10 errors on
->>various lines in a large file, it's a PITA to have to make a change, save
->>your change, quit pico, and then resart with some new +N linenumber to go
->>to the next error.  A number of users had asked if there was a better way.
->>Now I can tell them definitively, "Not with pico."
->
->   But the search command (^W), can be used in many cases, particularly when
->   you're correcting typos, which tend to be unique.

yes, but not when compiler flames at you that there is err in your source
code at line 243.. yeah u can get to desired line using ^V ^C but go to
nevertheess would be better. 

-Adam

---

From: Mike Brudenell <[email-masked]>
Date: Fri, 2 Aug 1996 09:03:56 +0100 (BST)

But not if you are using Pico to edit your C program, which the C compiler
has just spat back at you saying there was a syntax error on line 306.

Cheers,

Mike Brudenell                                         <[email-masked]>
------------------------------------------------------------------------
The Computing Service, University of York, Heslington, York, YO1 5DD, UK
Tel: +44-1904-433811  FAX: +44-1904-433740  http://www.york.ac.uk/~pmb1/

---

From: Richard Gering <[email-masked]>
Date: Fri, 2 Aug 1996 16:37:16 +0100 (WET)

> Control-W command to enter a line number would be a nice addition though.

Yes, this would be a nice addition indeed.

The great thing about Pine is that it comes with the sources, so I've
tried to implement the "goto line" feature as an option to the search
command. This is how it turned out:

Once you have pressed Ctrl-W, you can enter the number of the line you
want to go to at the "Search:" prompt. Then, instead of pressing Return
you can press Ctrl-N (as in Number) and Pico will use the text at the
prompt as the number of the line to go to. When text or a line number
smaller than 1 is entered, the goto action will be (silently) canceled.

The interface might be a little funny, but it kept the amount of code
changes to a minimum and it saved the user from having to press an extra
key. I've found that you can quickly get used to it. 

The number entered does not affect the text used in a previous search
action. This text continues to be stored for future searches. 

The result is attached to this message for you to take a look at. Both a
patch file and the entire changed pico/search.c (Unix compressed) were
included to make it easy (it was small enough). 

Two final notes:

- Please be aware that the source files are from Pico 2.9
  (the one that is also shipped with Pine 3.95).

- This patch only affects Pico and the composer part of Pine.
  It has NO effect on the search facilities in the mail viewer or
  in the on-line help (other code, but could be changed as well :-) )

I hope that you find this addition useful. Feedback is welcomed.

Kind regards,

- Richard Gering.

+-----------------------------------------------------------------------------+
| Richard Gering ([email-masked]) | Let me make one thing perfectly clear:  |
| CI International B.V. Netherlands | I never explain anything! (Mary Poppins)| 
+-----------------------------------------------------------------------------+
*** pine3.95/pico/search.c.org	Fri Mar 15 08:42:29 1996
--- pine3.95/pico/search.c	Thu Aug  1 23:50:25 1996
***************
*** 84,95 ****
--- 84,102 ----
  "  ",
  "\tShould the search fail, a message will be displayed.",
  "  ",
+ "~\tYou can also jump to a specific line by entering the number of",
+ "~\tthat line and pressing ~^~N instead of ~R~e~t~u~r~n.  The cursor will",
+ "\tthen be located at the beginning of that line.",
+ "  ",
  "End of Search Help.",
  "  ",
  NULL
  };

+ static int linenum;	/* The number of the line to jump to */
+ 
+ 
  /*
   * Compare two characters. The "bc" comes from the buffer. It has it's case
   * folded out. The "pc" is from the pattern.
***************
*** 150,155 ****
--- 157,170 ----
  		mlerase();
  		curwp->w_flag |= WFMODE;
  		return(TRUE);
+ 	      case (CTRL|'N'):
+ 		if(linenum > 0){
+ 		  gotobob(0, 1);
+ 		  forwline(0, linenum - 1);
+ 		  mlerase();
+ 		  curwp->w_flag |= WFMODE;
+ 		  return(TRUE);
+ 		}
  	      default:
  		curwp->w_flag |= WFMODE;
  		if(status == ABORT)
***************
*** 219,225 ****
  {
  	register int s;
  	char	     tpat[NPAT+20];
! 	EXTRAKEYS    menu_pat[3];
  
  	menu_pat[0].name  = "^Y";
  	menu_pat[0].label = "FirstLine";
--- 234,240 ----
  {
  	register int s;
  	char	     tpat[NPAT+20];
! 	EXTRAKEYS    menu_pat[4];
  
  	menu_pat[0].name  = "^Y";
  	menu_pat[0].label = "FirstLine";
***************
*** 229,235 ****
  	menu_pat[1].label = "LastLine";
  	menu_pat[1].key   = (CTRL|'V');
  	KS_OSDATASET(&menu_pat[1], KS_NONE);
! 	menu_pat[2].name  = NULL;
  
  	strcpy(tpat, prompt);	/* copy prompt to output string */
          if(pat[0] != '\0'){
--- 244,254 ----
  	menu_pat[1].label = "LastLine";
  	menu_pat[1].key   = (CTRL|'V');
  	KS_OSDATASET(&menu_pat[1], KS_NONE);
! 	menu_pat[2].name  = "^N";
! 	menu_pat[2].label = "LineNumber";
! 	menu_pat[2].key   = (CTRL|'N');
! 	KS_OSDATASET(&menu_pat[2], KS_NONE);
! 	menu_pat[3].name  = NULL;
  
  	strcpy(tpat, prompt);	/* copy prompt to output string */
          if(pat[0] != '\0'){
***************
*** 245,250 ****
--- 264,271 ----
  		strcpy(pat, tpat);
  	else if (s == FALSE && pat[0] != 0)	/* CR, but old one */
  		s = TRUE;
+ 	else if (s == (CTRL|'N'))
+ 		linenum = atoi(tpat);		/* Line number */
  
  	return(s);
  }

---

From: [email-masked] (Tim Mooney)
Date: 3 Aug 1996 00:08:04 -0500

In article <[email-masked]>,
Evelyn Albrecht <[email-masked]> wrote:
> >If there are 10 errors on

As a couple of people have pointed out, not every compiler gives a good
indication of the text surrounding the line(s) in error, so searching for
the text may be impossible since it's not indicated.  FORTRAN compilers
appear to be particularly bad about not saying on which line an error occurs,
based on the questions I've fielded from users.

There is yet another reason for wanting the `goto line' feature, though, and
that's pure simplicity.  Pico is, after all, designed to be simple to use.
Though many users could use the Control-W and search for text pointed out
by the compiler (if it does that kind of thing with errors),  I suspect many
would find that method to be needlessly difficult.  Given enough time, I
could probably come up with quite a few examples where even given the text
of the error message it takes several repititions of a text search to
find the desired instance of that text in the file (though your argument
that typos tend to be unique is a good one, it certainly isn't always the
case).  If you know the line number, it's just *much* simpler to be able to 
go directly to that line.

Again, I don't even use pico; the initial question I asked was on behalf of
the large number of pico-users that I support.  I was just hoping that my
inability to find the magic key sequence in pico to `goto-line' was just
ignorance of pico's capabilities on my part.

We've already seen one patch posted to this thread that implements the 
desired feature.  If it rains here this weekend I may come up with my own
patch to add the same feature, but with `Goto-line = ^N' listed as one of
the options right in the ^W menu, so it's no secret to the neophyte users.

Tim
-- 
Tim Mooney                              [email-masked]
Information Technology Services         (701) 231-1076 (Voice)
Room 242-J1, IACC Bldg.                 (701) 231-8541 (FAX)
North Dakota State University, Fargo, ND 58105

---

From: [email-masked] (Tim Mooney)
Date: 31 Jul 1996 19:11:43 -0500

In article <[email-masked]>,
Hiram Lester Jr. <[email-masked]> wrote:
> On Wed, 31 Jul 1996, Mike Brudenell wrote:
> 
> > Ummmmm... The original question was about how to jump to a specific line
> > within the Pico editor (and hence by implication I suspect also within
> > Pine's internal composer).
> 
> I don't think there is a way to jump once in the editor, but if Pico is
> called with a +n where n is a number, it will start with the cursor on
> that line.

Tim
-- 
Tim Mooney                              [email-masked]
Information Technology Services         (701) 231-1076 (Voice)
Room 242-J6, IACC Bldg.                 (701) 231-8541 (FAX)
North Dakota State University, Fargo, ND 58105

---

From: Richard Gering <[email-masked]>
Date: Tue, 6 Aug 1996 16:45:20 +0100 (WET)

> the options right in the ^W menu, so it's no secret to the neophyte users.

Just for the record, the patch posted DID have the goto feature mentioned
right in the ^W menu. The only "secret" was in the way the goto feature
worked, but an explanation of this was added to the context sensitive help
(^G). With this, even neophyte users should be able to figure it out.

Regards,

- Richard Gering.