Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

feep()



-----BEGIN PGP SIGNED MESSAGE-----

This patch changes the behaviour of feep(), so that it just sets a flag,
rather than beeping.  The flag is then checked each time round the
command loop, and a beep emitted if it is set.  This means that several
functions can call feep(), each indicating an error, without actually
generating consecutive beeps.  A hack in getvirange(), used to ensure
this behaviour, is consequently made unnecessary.  The real value of
this mechanism will come with user-defined functions.

 -zefram

      *** Src/utils.c	1997/01/07 21:32:40	1.55
      --- Src/utils.c	1997/01/07 21:38:48
      ***************
      *** 1088,1094 ****
            nicezputs(s, shout);
            fputs(" [yn]? ", shout);
            fflush(shout);
      !     feep();
            return (getquery("ny") == 'y');
        }
        
      --- 1088,1094 ----
            nicezputs(s, shout);
            fputs(" [yn]? ", shout);
            fflush(shout);
      !     beep();
            return (getquery("ny") == 'y');
        }
        
      ***************
      *** 1131,1137 ****
        	    write(SHTTY, "\n", 1);
        	    break;
        	}
      ! 	feep();
        	if (icntrl(c))
        	    write(SHTTY, "\b \b", 3);
        	write(SHTTY, "\b \b", 3);
      --- 1131,1137 ----
        	    write(SHTTY, "\n", 1);
        	    break;
        	}
      ! 	beep();
        	if (icntrl(c))
        	    write(SHTTY, "\b \b", 3);
        	write(SHTTY, "\b \b", 3);
      ***************
      *** 1280,1286 ****
        	    fwrite(pptbuf, pptlen, 1, shout);
        	    free(pptbuf);
        	    fflush(shout);
      ! 	    feep();
        	    x = getquery("nyae ");
        	} else
        	    x = 'y';
      --- 1280,1286 ----
        	    fwrite(pptbuf, pptlen, 1, shout);
        	    free(pptbuf);
        	    fflush(shout);
      ! 	    beep();
        	    x = getquery("nyae ");
        	} else
        	    x = 'y';
      ***************
      *** 2219,2225 ****
        
        /**/
        void
      ! feep(void)
        {
            if (isset(BEEP))
        	write(SHTTY, "\07", 1);
      --- 2219,2225 ----
        
        /**/
        void
      ! beep(void)
        {
            if (isset(BEEP))
        	write(SHTTY, "\07", 1);
      *** Src/Zle/zle.h	1997/01/05 12:43:26	1.11
      --- Src/Zle/zle.h	1997/01/07 21:55:17
      ***************
      *** 187,192 ****
      --- 187,196 ----
        
        ZLEXTERN int prefixflag;
        
      + /* != 0 if there is a pending beep (usually indicating an error) */
      + 
      + ZLEXTERN int feepflag;
      + 
        /* undo event */
        
        struct undoent {
      *** Src/Zle/zle_hist.c	1997/01/05 10:34:40	1.7
      --- Src/Zle/zle_hist.c	1997/01/07 22:01:38
      ***************
      *** 861,866 ****
      --- 861,867 ----
        	    }
        	    sbuf[sbptr++] = c;
        	}
      + 	handlefeep();
            }
            if (sbptr) {
        	zfree(previous_search, previous_search_len);
      ***************
      *** 1017,1022 ****
      --- 1018,1024 ----
        	} else {
        	    feep();
        	}
      + 	handlefeep();
            }
            statusline = NULL;
            selectkeymap(okeymap, 1);
      *** Src/Zle/zle_main.c	1997/01/04 17:47:26	1.15
      --- Src/Zle/zle_main.c	1997/01/07 22:01:50
      ***************
      *** 394,399 ****
      --- 394,400 ----
        	errflag = retflag = 0;
        	initmodifier(&zmod);
        	prefixflag = 0;
      + 	feepflag = 0;
        	selectkeymap("main", 1);
        	refresh();
        	while (!done && !errflag) {
      ***************
      *** 448,453 ****
      --- 449,455 ----
        #endif
        		if (!kungetct)
        		    refresh();
      + 	    handlefeep();
        	}
        	statusline = NULL;
        	invalidatelist();
      *** Src/Zle/zle_misc.c	1997/01/04 17:47:27	1.6
      --- Src/Zle/zle_misc.c	1997/01/07 22:02:39
      ***************
      *** 691,695 ****
      --- 691,696 ----
        		    *ptr++ = c, len++;
        	    }
        	}
      + 	handlefeep();
            }
        }
      *** Src/Zle/zle_utils.c	1997/01/04 17:47:27	1.6
      --- Src/Zle/zle_utils.c	1997/01/07 22:01:20
      ***************
      *** 429,431 ****
      --- 429,449 ----
        	putc('\n', shout);
            showinglist = 0;
        }
      + 
      + /* handle the error flag */
      + 
      + /**/
      + void
      + feep(void)
      + {
      +     feepflag = 1;
      + }
      + 
      + /**/
      + void
      + handlefeep(void)
      + {
      +     if(feepflag)
      + 	beep();
      +     feepflag = 0;
      + }
      *** Src/Zle/zle_vi.c	1997/01/04 17:47:27	1.5
      --- Src/Zle/zle_vi.c	1997/01/07 21:54:23
      ***************
      *** 118,130 ****
        int
        getvirange(int wf)
        {
      !     int pos = cs, obeep = opts[BEEP];
            int mult1 = zmult, hist1 = histline;
            Thingy k2;
        
            virangeflag = 1;
            wordflag = wf;
      -     opts[BEEP] = 0;
            /* Now we need to execute the movement command, to see where it *
             * actually goes.  virangeflag here indicates to the movement   *
             * function that it should place the cursor at the end of the   *
      --- 118,129 ----
        int
        getvirange(int wf)
        {
      !     int pos = cs;
            int mult1 = zmult, hist1 = histline;
            Thingy k2;
        
            virangeflag = 1;
            wordflag = wf;
            /* Now we need to execute the movement command, to see where it *
             * actually goes.  virangeflag here indicates to the movement   *
             * function that it should place the cursor at the end of the   *
      ***************
      *** 144,150 ****
        	if (!(k2 = getkeycmd()) || (k2->flags & DISABLED) ||
        		k2 == Th(z_sendbreak)) {
        	    wordflag = 0;
      - 	    opts[BEEP] = obeep;
        	    virangeflag = 0;
        	    feep();
        	    return -1;
      --- 143,148 ----
      ***************
      *** 164,170 ****
        	lastcmd = k2->flags;
            } while(prefixflag);
            wordflag = 0;
      -     opts[BEEP] = obeep;
            virangeflag = 0;
        
            /* It is an error to use a non-movement command to delimit the *
      --- 162,167 ----
      ***************
      *** 178,186 ****
        	return -1;
            }
        
      !     /* Can't handle an empty file.  Also, if the movement command  *
      !      * failed, or didn't move, it is an error.  If it failed it    *
      !      * didn't feep, because we set NO_BEEP while it was executing. */
            if (!ll || (cs == pos && virangeflag != 2)) {
        	feep();
        	return -1;
      --- 175,182 ----
        	return -1;
            }
        
      !     /* Can't handle an empty file.  Also, if the movement command *
      !      * failed, or didn't move, it is an error.                    */
            if (!ll || (cs == pos && virangeflag != 2)) {
        	feep();
        	return -1;
      ***************
      *** 463,472 ****
            /* check argument range */
            if (zmult < 1 || zmult + cs > findeol()) {
        	if(vichgrepeat) {
      ! 	    int obeep = opts[BEEP];
      ! 	    opts[BEEP] = 0;
        	    vigetkey();
      ! 	    opts[BEEP] = obeep;
        	}
        	if(vichgflag) {
        	    free(vichgbuf);
      --- 459,467 ----
            /* check argument range */
            if (zmult < 1 || zmult + cs > findeol()) {
        	if(vichgrepeat) {
      ! 	    int ofeep = feepflag;
        	    vigetkey();
      ! 	    feepflag = ofeep;
        	}
        	if(vichgflag) {
        	    free(vichgbuf);
      ***************
      *** 794,800 ****
        void
        vicapslockpanic(void)
        {
      !     feep();
            statusline = "press a lowercase key to continue";
            statusll = strlen(statusline);
            refresh();
      --- 789,795 ----
        void
        vicapslockpanic(void)
        {
      !     beep();
            statusline = "press a lowercase key to continue";
            statusll = strlen(statusline);
            refresh();

-----BEGIN PGP SIGNATURE-----
Version: 2.6.2

iQCVAwUBMtLLI3D/+HJTpU/hAQFX9QP+ImC6SuJAQr4mJzOXNGN+hs39mQzJzXLA
lr/VnjWOvcUFw3AuG2MbxtOjYpD2wIUWo060DvkPwF1LbsJsjhBs1qB6griRB+eV
LV73IJhoqS+Kpb1B7kt3xJFLr2sAhqQrmX3xYMAtlwnh4EPhYGjcPmxkfcCEcZOq
pTnKP9CbJko=
=PB5e
-----END PGP SIGNATURE-----



Messages sorted by: Reverse Date, Date, Thread, Author