I have written a vedtermcapkeys.p file, to go in $usepop/pop/lib/ved/term, for making plain, non-x, ved work with terminal types that have a description in the terminfo database but no specially written ved<termname>.p file in that directory. If it works as intended, new users running terminals that haven't been explicitly catered for, but which are sufficiently standard to be described in the terminfo database, should not have the frustrating experience in getting at the poplog documentation that Bill Wood recently reported.

Vedtermcapkeys.p is based on vedxtermkeys.p. If xved uses a key, and that key is listed in the terminfo database for a given terminal, then the key is supposed to function in the same way for that terminal under plain ved that it does in xved. (That should make it easier for me to write the help file when I get around to it.)

I needed to make a small addition to the function veduseterm in $usepop/pop/ved/src/vdinitseq.p to get the vedtermcapkeys.p file invoked.

I also made an edit to $usepop/pop/ved/src/vdtermcap.p, which plays the role that the ved<termname>screen.p file does for terminals that have one, to disable use of the terminal's own character insert facility if it is detected. In testing with an rxvt-unicode terminal, I found that extra spaces were appearing on the screen after inserted characters. The spaces were only on the screen, not in the ved buffer, and doing vedrefresh made them go away. I don't know whether the problem lies with rxvt or vedcharinsert, but ignoring the terminal's character insertion facility and letting ved insert the character "by hand" shouldn't be too much of a performance hit. Terminals in the xterm family don't list a character insertion capability in the terminfo database, so ved does its own character insertion for them anyway.

There is still a role for special ved<termname>.p files because not all terminal properties are listed in the terminfo database. For instance, the database entry for xterm-new doesn't say what character sequences are produced by the function keys, so the function keys won't work by default for that terminal, although the page up, page down and arrow keys will.

My laptop, which is all that I have access to at the moment, doesn't have a keypad, so I haven't been able to test any functions bound to keypad keys.

The vedtermcapkeys.p file and a patch file for vdinitseq.p and vdtermcap.p are attached to this message.

I would of course be interested to know the results of any tests that other people are able to do. You need to rebuild poplog with $usepop/build_all.sh to incorporate the patched vdinitseq.p and vdtermcap.p. (Or maybe build_pop2 is enough, but build_all is pretty quick, even on a five year old laptop).

Steve Isard
diff --git a/pop/ved/src/vdinitseq.p b/pop/ved/src/vdinitseq.p
index 222fffb..e4d2fff 100644
--- a/pop/ved/src/vdinitseq.p
+++ b/pop/ved/src/vdinitseq.p
@@ -343,6 +343,7 @@ define veduseterm(name);
         valof(pdr_name)();
     elseif testdef vedtermcapscreen then
         weakref vedtermcapscreen(name);
+        'termcap' -> root;
     else
         return(false);
     endif;
@@ -597,6 +598,9 @@ endsection;     /* $-Sys$-Ved */
 
 
 /* --- Revision History ---------------------------------------------------
+--- Steve Isard, 29 Aug 2020
+    Set 'termcap' -> root after invoking vedtermcapscreen so that settings
+        in (new file, added at same time) vedtermcapkeys.p will be picked up.
 --- Aaron Sloman, 8 Nov 2011 (25 Sep 2012)
     Override old settings for terminal_can_scroll: just make it false
     Added new active variable with updater in vdscroll.p
diff --git a/pop/ved/src/vdtermcap.p b/pop/ved/src/vdtermcap.p
index c6d7013..b38208a 100644
--- a/pop/ved/src/vdtermcap.p
+++ b/pop/ved/src/vdtermcap.p
@@ -169,17 +169,18 @@ define vedtermcapscreen(name);
 
         ;;; character insert
         if termcap_getstring(IM) ->> x then
-            false -> vednocharinsert;
+            ;;; false -> vednocharinsert;
             tc1(x) -> vvedscreeninsertmode;
             if termcap_getstring(EI) ->> x then tc1(x) -> vvedscreenovermode 
endif;
             unless vvedscreeninsertmode = nullstring or termcap_getflag('MI') 
then
                 true -> vednomoveinsert;
             endunless;
         endif;
-        if termcap_getstring(IC) ->> x then
+        /* if termcap_getstring(IC) ->> x then
             false -> vednocharinsert;
             tc1(x) -> vvedscreeninsertchar;
         endif;
+        */
 
         ;;; character delete
         if termcap_getstring(DC) ->> x then
@@ -263,6 +264,16 @@ endsection;     /* $-Sys$-Ved */
 
 
 /* --- Revision History ---------------------------------------------------
+--- Steve Isard
+        Disabled use of vvedscreeninsertchar.  With rxvt-unicode terminal it
+        was putting extra spaces after inserted characters on the screen,
+        requiring a vedrefresh.  Don't know whether the problem lies with
+        rxvt or poplog, but bypassing the use of the insert capability for
+        terminals that have it shouldn't be much of a hit to performance.
+        Xterm variants don't list an insert character capability in their
+        terminfo descriptions.
+--- ??? (Noted by Steve Isard) As of 21 Aug 2020
+        Disabling below appears to have been reversed
 --- Aaron Sloman, 15 Mar 2004
         Disabled use of termcap on Linux systems
 --- Robert Duncan, Aug 14 1997
/* --- Copyright University of Birmingham 2003. All rights reserved. ------
 > --- Copyright University of Sussex 2003. All rights reserved. ----------
 > File:            C.all/pop/lib/ved/term/vedtermcapkeys.p
 > Purpose:         Minimal function key bindings for terminal type
 >                      detected by termcap/terminfo
 > Author:          Steve Isard, based on vedxtermkeys.p
 > Documentation:   not yet
 > Related Files:   VEDXTERMKEYS.P
 */


/* This file defines the procedure -vedtermcapkeys- to provide bindings for
    function keys when poplog has no custom file for the terminal specified in
    the linux TERM variable, but there is an entry in the termcap or terminfo
    database.

    In order to use the keys marked "Home" and "End" in VED, the following
    key translations must be added to they user's .Xdefaults file, or to
    some system-wide file setting Xterm defaults, e.g.
        /usr/X11R6/lib/X11/app-defaults/XTerm
    or possibly
        /usr/lib/X11/app-defaults/XTerm

    ! xterm translations to make VED work
    XTerm*VT100*Translations: #override \
        <Key>KP_0: string(0x1b) string("Op") \n\
        <Key>KP_Insert: string(0x1b) string("Op") \n\
        <Key>KP_Decimal: string(0x1b) string("On") \n\
        <Key>KP_Delete: string(0x1b) string("On") \n\
        <Key>KP_Home: string(0x1b) string("Ow") \n\
        <Key>KP_7: string(0x1b) string("Ow") \n\
        <Key>KP_Prior: string(0x1b) string("Oy") \n\
        <Key>KP_9: string(0x1b) string("Oy") \n\
        <Key>KP_Next: string(0x1b) string("Os") \n\
        <Key>KP_1: string(0x1b) string("Oq") \n\
        <Key>KP_End: string(0x1b) string("Oq") \n\
        <Key>KP_3: string(0x1b) string("Os")
    XTerm*deleteIsDEL: true

    The Keypad 0 and . keys will transmit Op and On respectively,
    and other numeric keypad keys that default to the same settings as
    central keypad keys are now given different strings to transmit,
    modelled on vt100 keys.

    Delete will transmit the delete character.

Invoke the following with
        vedtermcapkeys();
*/

section;

;;; vedexpandchar is defined in vdprocess.p and defaults to false
;;; Make it work as in HELP VEDEXPAND for XVed users.

`^` -> vedexpandchar;

uses vedvt100keys;

define global vedtermcapkeys();
    lvars s;
    vedvt100keys();
    vedset keys

        ;;; Two utility functions that probably should be provided in the
        ;;; system sources, i.e. in vedescapetable in SRC vdkeys.p
        ;;; Mnemonic: ESC -  keep one copy of marked range and move it here
        ;;;           ESC =  make two copies, by copying to here

        "ENTER m"           = esc -             ;;; ESC -
        "ENTER t"           = esc =             ;;; ESC =
    endvedset

        ;;; Function key mappings follow:


        ;;; Arrow keys
   if termcap_getstring('ku') ->> s then vedsetkey(s,"vedcharup") endif;        
   ;;; UP
   if termcap_getstring('kd') ->> s then vedsetkey(s,"vedchardown") endif;      
     ;;; DOWN
   if termcap_getstring('kl') ->> s then vedsetkey(s,"vedcharleft") endif;      
    ;;; LEFT
   if termcap_getstring('kr') ->> s then vedsetkey(s,"vedcharright") endif;     
    ;;; RIGHT

   if termcap_getstring('ku') ->> s then vedsetkey('\e'><s,"vedcharuplots") 
endif;       ;;; ESC UP
   if termcap_getstring('kd') ->> s then vedsetkey('\e'><s,"vedchardownlots") 
endif;     ;;; ESC DOWN
   if termcap_getstring('kl') ->> s then vedsetkey('\e'><s,"vedcharleftlots") 
endif;     ;;; ESC LEFT
   if termcap_getstring('kr') ->> s then vedsetkey('\e'><s,"vedcharrightlots") 
endif;     ;;; ESC RIGHT

        ;;; Function keys F1 to F12

   if termcap_getstring('k1') ->> s then vedsetkey(s,"vedmarklo") endif;       
;;; F1
   if termcap_getstring('k2') ->> s then vedsetkey(s,"vedmarkhi") endif;       
;;; F2
   if termcap_getstring('k3') ->> s then vedsetkey(s,"vedclearhead") endif;     
  ;;; F3
   if termcap_getstring('k4') ->> s then vedsetkey(s,"vedlinedelete") endif;    
   ;;; F4

   if termcap_getstring('k5') ->> s then vedsetkey(s,"vedcleartail") endif;     
  ;;; F5
   if termcap_getstring('k6') ->> s then vedsetkey(s,"vedwordleftdelete") 
endif;       ;;; F6
   if termcap_getstring('k7') ->> s then vedsetkey(s,"vedwordrightdelete") 
endif;       ;;; F7
   if termcap_getstring('k8') ->> s then vedsetkey(s,"vedved_m") endif;       
;;; F8

   if termcap_getstring('k9') ->> s then vedsetkey(s,"ved_t") endif;       ;;; 
F9
   if termcap_getstring('k;') ->> s then vedsetkey(s,"vedxrefresh") endif;      
 ;;; F10
   if termcap_getstring('F1') ->> s then vedsetkey(s,"vedpushkey") endif;       
;;; F11
   if termcap_getstring('F2') ->> s then vedsetkey(s,"vedexchangeposition") 
endif;       ;;; F12

   if termcap_getstring('k1') ->> s then vedsetkey('\e'><s,"ved_mbf") endif;   
;;; ESC F1
   if termcap_getstring('k2') ->> s then vedsetkey('\e'><s,"ved_mef") endif;   
;;; ESC F2
   if termcap_getstring('k3') ->> s then vedsetkey('\e'><s,"ved_yankw") endif;  
 ;;; ESC F3
   if termcap_getstring('k4') ->> s then vedsetkey('\e'><s,"ved_yankl") endif;  
 ;;; ESC F4

   if termcap_getstring('k5') ->> s then vedsetkey('\e'><s,"ved_yankw") endif;  
 ;;; ESC F5
   if termcap_getstring('k6') ->> s then vedsetkey('\e'><s,"ved_yankw") endif;  
 ;;; ESC F6
   if termcap_getstring('k7') ->> s then vedsetkey('\e'><s,"ved_yankw") endif;  
 ;;; ESC F7
   if termcap_getstring('k8') ->> s then vedsetkey('\e'><s,"ved_mi") endif;   
;;; ESC F8

   if termcap_getstring('k9') ->> s then vedsetkey('\e'><s,"ved_ti") endif;   
;;; ESC F9
   if termcap_getstring('k;') ->> s then vedsetkey('\e'><s,"ved_mo") endif;   
;;; ESC F10
   if termcap_getstring('F1') ->> s then vedsetkey('\e'><s,"vedpopkey") endif;  
 ;;; ESC F11
   if termcap_getstring('F2') ->> s then vedsetkey('\e'><s,"ved_cps") endif;   
;;; ESC F12

        ;;; Middle function keypad
   if termcap_getstring('dc') ->> s then vedsetkey('\e'><s,"vedjoinline") 
endif;            ;;; ESC Delete
   if termcap_getstring('bs') ->> s then vedsetkey('\e'><s,"vedjoinline") 
endif;            ;;; ESC Backspace
        ;;; see HELP vedxtermkeys
   if termcap_getstring('kI') ->> s then vedsetkey(s,"ved_static") endif;     
;;; INSERT
   if termcap_getstring('kI') ->> s then vedsetkey('\e'><s,"vedlineabove") 
endif;    ;;; ESC INSERT

   if termcap_getstring('kh') ->> s then vedsetkey(s,"vedtopfile") endif;       
   ;;; HOME
   if termcap_getstring('@7') ->> s then vedsetkey(s,"vedendfile") endif;       
  ;;; END
   if termcap_getstring('kh') ->> s then vedsetkey('\e'><s,"vedmarkfind") 
endif;       ;;; ESC HOME
   if termcap_getstring('@7') ->> s then vedsetkey('\e'><s,"vedendrange") 
endif;     ;;; ESC END

   if termcap_getstring('kP') ->> s then vedsetkey(s,"vedprevscreen") endif;    
     ;;; PAGE UP (Prior)
   if termcap_getstring('kN') ->> s then vedsetkey(s,"vednextscreen") endif;    
     ;;; PAGE DOWN (Next)

   if termcap_getstring('kP') ->> s then vedsetkey('\e'><s,"ved_xup") endif;    
 ;;; ESC PAGE UP
   if termcap_getstring('kN') ->> s then vedsetkey('\e'><s,"ved_xdn") endif;    
 ;;; ESC PAGE DOWN


        ;;; Numeric keypad keys
   if termcap_getstring('@8') ->> s then vedsetkey(s,"vedenter") endif;         
  ;;; ENTER key on right
/* Names of these keys not clear from termcap/terminfo man pages
   vedsetkey('\eOk',"statusswitch");           ;;; Keypad +

   vedsetkey('\eOm',"vedredocommand");          ;;; Keypad *

   vedsetkey('\eOo',"vedhelpkey");           ;;; Keypad / (Invokes ENTER hkeys)
   vedsetkey('\e\eOo',"ved_hkey");        ;;; ESC Keypad /
*/
        ;;; unusable sequences because they duplicate the central keypad
        ;;; esc [ 2 ~  ;;; Keypad 0 key (Duplicates Central Insert key)
        ;;; esc [ 3 ~  ;;; Keypad Del key (Duplicates central Delete key)
        ;;; esc [ 4 ~  ;;; Keypad 1  End
        ;;; esc [ B    ;;; Keypad 2  Down
        ;;; esc [ 6 ~  ;;; Keypad 3  PageDown (Next)
        ;;; esc [ D    ;;; Keypad 4  Left
        ;;; esc [ C    ;;; Keypad 6  Right
        ;;; esc [ 1 ~  ;;; Keypad 7  Home
        ;;; esc [ A    ;;; Keypad 8  Up
        ;;; esc [ 5 ~  ;;; Keypad 9  PageUp (Prior)

        ;;; These MAY work in some Xterm configurations
        ;;; Especially if .Xdefaults is set right
   if termcap_getstring('K1') ->> s then vedsetkey(s,"vedcharupleft") endif;    
       ;;; Keypad 7
   if termcap_getstring('K1') ->> s then vedsetkey('\e'><s,"vedcharupleftlots") 
endif; ;;; ESC Keypad 7

        ;;; These depend on entries in .Xdefaults
   if termcap_getstring('K3') ->> s then vedsetkey(s,"vedcharupright") endif;   
        ;;; Keypad 9
   if termcap_getstring('K3') ->> s then 
vedsetkey('\e'><s,"vedcharuprightlots") endif; ;;; ESC Keypad 9
   if termcap_getstring('K5') ->> s then vedsetkey(s,"vedchardownright") endif; 
          ;;; Keypad 3
   if termcap_getstring('K5') ->> s then 
vedsetkey('\e'><s,"vedchardownrightlots") endif; ;;; ESC Keypad 9

   if termcap_getstring('K2') ->> s then vedsetkey(s,"vedmidwindow") endif;     
      ;;; Keypad 5
   if termcap_getstring('K5') ->> s then vedsetkey(s,"vedchardownleft") endif;  
       ;;; Keypad 1
   if termcap_getstring('K5') ->> s then 
vedsetkey('\e'><s,"vedchardownleftlots") endif; ;;; ESC Keypad 1
/* Don't know termcap names
   vedsetkey('\e[Op',"vedwordleft");         ;;; Keypad 0 key (Ins)
   vedsetkey('\e[On',"vedwordright");         ;;; Keypad . key (Del)

   vedsetkey('\eOj',"vedloadline");           ;;; Keypad *
   vedsetkey('\e\eOj',"ved_lmr");       ;;; ESC Keypad *
*/


/* Don't know what keys these refer to.  Who is going to run ved from the
    linux console these days?

    if systranslate('LINUX') then
            ;;; Stuff for linux console
   vedsetkey('\^[[[A',"vedmarklo");
   vedsetkey('\^[[[B',"vedmarkhi");
   vedsetkey('\^[[[C',"vedclearhead");
   vedsetkey('\^[[[D',"veddeleteline");
   vedsetkey('\^[[[E',"vedcleartail");
   vedsetkey('\^[[1~',"vedenter");
   vedsetkey('\^[[2~',"vedtopfile");
   vedsetkey('\^[[3~',"vedchardelete");
   vedsetkey('\^[[4~',"vedendfile");
    endif;

    vedsetkey('\^L', "vedxrefresh");
    vedsetkey('\^H', "vedchardelete");
*/
    ;;; this is used by ENTER hkeys
    'vedtermcap' -> vedkeymapname;
enddefine;



endsection;


/* --- Revision History ---------------------------------------------------
--- Aaron Sloman, 27 Jul 2003
    A large collection of changes partly to make this and LIB VEDXVEDKEYS
    more similar, partly to rationalise things that don't work in xterms
    on linux PCs because of different keysym names e.g. KP_Home rather than
    KP_7. This made it necessary to revise the .Xdefault settings required,
    as explained above. New keybindings documented in HELP VEDXTERMKEYS

--- Aaron Sloman, Jan 11 2003
        Made backspace chardelete by default
--- Aaron Sloman, Sep 26 2002
        Put in more options for linux+PC
--- Aaron Sloman, Jun 19 1997
    Set CTRL-L to vedxrefresh
--- Aaron Sloman, Dec 24 1996
    Extended for NCD keyboard type N-123UK
--- Aaron Sloman, Sep  9 1996
    Alas, had to make keypad and big pad arrows both move in small
    steps, for DEC Alpha
--- Aaron Sloman, Oct 1995
    Put all procedure names in quotes. Also added Motif Xved bindings.
    Removed top leve call of vedxtermkeys.
--- Aaron Sloman, Oct 1992
--- Aaron Sloman, Aug 19 1992
        Made More consistent with SunKeys, by changing
        F1 to F12 mappings
--- John Williams, Aug 18 1992
        Added key mappings for the HOME and END keys
--- John Williams, Oct 12 1990
        -vedkeymapname- instead of -vedkeyboardname-
--- John Williams, Oct  5 1990
        Now uses -vedhelpkey-, and sets -vedkeyboardname-
--- John Williams & Rob Duncan, Nov  8 1989
        Function key definitions changed to be more similar to
        LIB VEDVT220KEYS
--- Rob Duncan, Oct 9 1989
        Sectionised; added call to -vedvt100keys-
--- Andreas Schoter Sep 1989
        Modified to use the -vedset- notation
 */

Reply via email to