tGenerate interrupt key (according to terminal settings) when user presses DEL. - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 38897b2053f81eb7f46d936159c8f29ecb5c4e99
 (DIR) parent ae89363c306de4540f403fc9f205a1e8f3be6674
 (HTM) Author: rsc <devnull@localhost>
       Date:   Thu, 11 Aug 2005 16:43:37 +0000
       
       Generate interrupt key (according to terminal settings)
       when user presses DEL.
       
       Diffstat:
         M src/cmd/9term/9term.c               |      14 +++++++++++---
         M src/cmd/9term/SunOS.c               |       9 +++++++++
         M src/cmd/9term/bsdpty.c              |       9 +++++++++
         M src/cmd/9term/term.h                |       1 +
       
       4 files changed, 30 insertions(+), 3 deletions(-)
       ---
 (DIR) diff --git a/src/cmd/9term/9term.c b/src/cmd/9term/9term.c
       t@@ -946,13 +946,16 @@ key(Rune r)
                }
        
                if(r == 0x7F){        /* DEL: send interrupt; what a mess */
       +                char rubout[1];
       +                
                        if(holdon){
                                holdon = 0;
                                drawhold(holdon);
                        }
                        t.qh = t.q0 = t.q1 = t.nr;
                        show(t.q0);
       -                write(rcfd, "\x7F", 1);
       +                rubout[0] = getintr(sfd);
       +                write(rcfd, rubout, 1);
                        return;
                }
        
       t@@ -1031,7 +1034,7 @@ consready(void)
                /* look to see if there is a complete line */
                for(i=t.qh; i<t.nr; i++){
                        c = t.r[i];
       -                if(c=='\n' || c=='\004' || c=='\x7F')
       +                if(c=='\n' || c=='\004' || c==0x7F)
                                return 1;
                }
                return 0;
       t@@ -1062,7 +1065,12 @@ consread(void)
                                c = *p;
                                p += width;
                                n -= width;
       -                        if(!raw && (c == '\n' || c == '\004' || c == '\x7F'))
       +                        if(c == 0x7F){
       +                                *(p-1) = getintr(sfd);
       +                                if(!raw)
       +                                        break;
       +                        }
       +                        if(!raw && (c == '\n' || c == '\004'))
                                        break;
                        }
                        n = p-buf;
 (DIR) diff --git a/src/cmd/9term/SunOS.c b/src/cmd/9term/SunOS.c
       t@@ -95,3 +95,12 @@ setecho(int fd, int newe)
                }
                return old;
        }
       +
       +int
       +getintr(int fd)
       +{
       +        if((tcgetattr(fd, &ttmode) < 0)
       +                return 0x7F;
       +        return ttmode.c_cc[VINTR];
       +}
       +
 (DIR) diff --git a/src/cmd/9term/bsdpty.c b/src/cmd/9term/bsdpty.c
       t@@ -117,3 +117,12 @@ setecho(int fd, int newe)
                }
                return old;
        }
       +
       +int
       +getintr(int fd)
       +{
       +        if(tcgetattr(fd, &ttmode) < 0)
       +                return 0x7F;
       +        return ttmode.c_cc[VINTR];
       +}
       +
 (DIR) diff --git a/src/cmd/9term/term.h b/src/cmd/9term/term.h
       t@@ -6,3 +6,4 @@ extern int rcstart(int, char*[], int*, int*);
        extern int isecho(int);
        extern int setecho(int, int);
        extern int noecho;
       +extern int getintr(int);