Subject: [Vim-vms] RE: VIM on OpenVMS

From: Arpadffy Zoltan <[email-masked]>
Date: Mon, 10 Nov 2003 10:02:59 +0100

hi,

Frank's code works very well... and it is superior indeed.

Unfortunately, I could not test on older VMS versions than 7.2 (I just lost
my VAX that runs 6.2), but I assume that Frank did it.

I would have two notes:
1. #ifdef __GNV is not needed - Frank do you have some special reason to use
this define?
2. #include <trmdef.h> should be included - it defines all TRM$Ms

Regards, 
Z

-----Original Message-----
From: Bram Moolenaar [mailto:[email-masked]]
Sent: den 8 november 2003 14:28
To: Ries, Frank
Cc: [email-masked]
Subject: Re: VIM on OpenVMS

Frank -

Good to see you help making Vim available for more people.

We just fixed this vms_read() function for another reason, it could not
be compiled on older systems.  That means we do need to keep in mind
that there are various VMS systems out there.

Did Zoltan already reply to you about this change?

> The idea of this routine appears to be to wait for any input from the
> terminal, and return as soon as any input is received. Currently, the
> routine does a read with timeout, with a timeout value of 0. This will
> return any data in the terminals type ahead buffer, else return
> immediately if there is no data. If there was no data, the routine waits
> for 0.05 seconds, and then tries the read again.

Right.

> The problem is that occasionally, the routine will not fully read a
> complete escape sequence when keys such as the arrow keys are typed.
> When this happens, the escape sequence is split across two reads, and
> VIM then does not interpret the sequence correctly, most of the time
> resulting in the key being ignored. It also consumes considerable system
> resources since it continuously polls for input. I have included with
> this email the routine in question with an alternate method of doing the
> input. The code I have provided will return immediately after any input
> is entered, and will also return complete escape sequences. It does this
> by specifying that all characters be treated as break characters. This
> method does not require a timeout, and does not need to poll. Using this
> code, VIM has no problem dealing with type ahead, or escape sequences.

That sounds like a good improvement.  The only question I have is for
which systems this will work.  You now used #ifdef __GNV, I suppose the
__GNV symbol must be defined explicitly.  Can we use something that will
work for more people?

Once this has been tried out on a few different systems I'll include the
code in Vim, so that more people will profit from the improvement.

> /*
>  * vms_read()
>  * function for low level char input
>  *
>  * Returns: input length
>  */
>     int
> vms_read(char *inbuf, size_t nbytes)
> {
> #ifdef __GNV
>     int     status, function, len;
>     TT_MODE tt_mode;
>     ITEM    itmlst[2];
>     static long trm_mask[8] = {-1, -1, -1, -1, -1, -1, -1, -1};
>  
>     /* whatever happened earlier we need an iochan here */
>     if (!iochan)
>        tt_mode = get_tty();
>  
>     vul_item(&itmlst[0], 0, TRM$_MODIFIERS,
>      (char *)(TRM$M_TM_ESCAPE | TRM$M_TM_NOECHO | TRM$M_TM_NOEDIT |
>                   TRM$M_TM_NOFILTR | TRM$M_TM_NORECALL |
TRM$M_TM_TRMNOECHO), 0);
>     vul_item(&itmlst[1], sizeof(trm_mask), TRM$_TERM, (char *)&trm_mask,
0);
>  
>     function = (IO$_READLBLK | IO$M_EXTEND);
>     memset(inbuf, 0, nbytes);
>  
>     while (1)
>     {
>             status =
sys$qiow(0,iochan,function,&iosb,0,0,inbuf,nbytes-1,0,0,&itmlst,sizeof(itmls
t));
>             len = strlen(inbuf);
>             if (len > 0)
>                 break;
>     }
>     return len;
> #else
[...]

- Bram

-- 
Eye have a spelling checker, it came with my PC;
It plainly marks four my revue mistakes I cannot sea.
I've run this poem threw it, I'm sure your please to no,
It's letter perfect in it's weigh, my checker tolled me sew!

 /// Bram Moolenaar -- [email-masked] -- http://www.Moolenaar.net   \\\
///          Creator of Vim - Vi IMproved -- http://www.Vim.org          \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\  Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html  ///

---

From: Arpadffy Zoltan <[email-masked]>
Date: Mon, 10 Nov 2003 10:48:00 +0100

Bram, 

>I'm glad the suggested code works well for you.

Me too... this character input was pain for long time... seems we are
approaching the best solution.

>Where would trmdef.h need to be included, just above vms_read()?
>For other/older VMS systems: We use "#ifdef VAXC" in os_unix.h.  Does
>that make sense here as well?

Seems both DECC and VAXC have trmdef.h
Therefore #ifdef VMS section in os_unix.h would be the best place to
include.

Frank: could you please verify that it works on older systems as well?

Regards, 
Z

---

From: Bram Moolenaar <[email-masked]>
Date: Mon, 10 Nov 2003 10:22:43 +0100

Zoltan -

- Bram

-- 
Our job was to build a computer information system for the branch banks.  We
were the perfect people for the job: Dean had seen a computer once, and I had
heard Dean talk about it.
				(Scott Adams - The Dilbert principle)