Make use of logger to replace sequences of TTbeep-mlwrite-return.

This commit is contained in:
Renaud 2015-01-20 22:34:28 +08:00
parent 36f24332c2
commit 4ca3f53385
5 changed files with 27 additions and 44 deletions

View File

@ -123,11 +123,10 @@ depend: ${SRC}
# DO NOT DELETE THIS LINE -- make depend uses it
ansi.o: ansi.c estruct.h
basic.o: basic.c basic.h buffer.h crypt.h line.h utf8.h display.h \
estruct.h input.h bind.h random.h terminal.h defines.h retcode.h \
window.h
basic.o: basic.c basic.h buffer.h crypt.h line.h utf8.h estruct.h input.h \
bind.h log.h retcode.h random.h terminal.h defines.h window.h
bindable.o: bindable.c bindable.h defines.h buffer.h crypt.h line.h \
utf8.h display.h estruct.h file.h retcode.h input.h bind.h lock.h \
utf8.h display.h estruct.h file.h retcode.h input.h bind.h log.h lock.h \
terminal.h
bind.o: bind.c bind.h estruct.h bindable.h buffer.h crypt.h line.h utf8.h \
display.h ebind.h exec.h retcode.h file.h flook.h input.h names.h \
@ -148,7 +147,7 @@ exec.o: exec.c exec.h retcode.h buffer.h crypt.h line.h utf8.h bind.h \
display.h estruct.h eval.h file.h flook.h input.h random.h window.h \
defines.h
execute.o: execute.c execute.h estruct.h bind.h random.h display.h file.h \
buffer.h crypt.h line.h utf8.h retcode.h terminal.h defines.h window.h
buffer.h crypt.h line.h utf8.h retcode.h log.h window.h defines.h
file.o: file.c file.h buffer.h crypt.h line.h utf8.h retcode.h defines.h \
estruct.h execute.h fileio.h input.h bind.h lock.h log.h window.h
fileio.o: fileio.c fileio.h crypt.h retcode.h defines.h

29
basic.c
View File

@ -19,10 +19,10 @@
#include <stdlib.h>
#include "buffer.h"
#include "display.h"
#include "estruct.h"
#include "input.h"
#include "line.h"
#include "log.h"
#include "random.h"
#include "terminal.h"
#include "utf8.h"
@ -94,17 +94,16 @@ int gotoeol(int f, int n)
*/
int gotoline(int f, int n)
{
int status;
char arg[NSTRING]; /* Buffer to hold argument. */
int status ;
char arg[ NSTRING] ; /* Buffer to hold argument. */
/* Get an argument if one doesnt exist. */
if (f == FALSE) {
if ((status =
mlreply("Line to GOTO: ", arg, NSTRING)) != TRUE) {
mlwrite("(Aborted)");
return status;
}
n = atoi(arg);
if( f == FALSE) {
status = mlreply( "Line to GOTO: ", arg, sizeof arg) ;
if( status != TRUE)
return logger( status, FALSE, "(Aborted)") ;
n = atoi( arg) ;
}
/* Handle the case where the user may be passed something like this:
* em filename +
@ -314,8 +313,7 @@ int setmark(int f, int n)
{
curwp->w_markp = curwp->w_dotp;
curwp->w_marko = curwp->w_doto;
mlwrite("(Mark set)");
return TRUE;
return logger( TRUE, FALSE, "(Mark set)") ;
}
/*
@ -329,10 +327,9 @@ int swapmark(int f, int n)
struct line *odotp;
int odoto;
if (curwp->w_markp == NULL) {
mlwrite("No mark in this window");
return FALSE;
}
if( curwp->w_markp == NULL)
return logger( FALSE, FALSE, "No mark in this window") ;
odotp = curwp->w_dotp;
odoto = curwp->w_doto;
curwp->w_dotp = curwp->w_markp;

View File

@ -10,6 +10,7 @@
#include "estruct.h"
#include "file.h"
#include "input.h"
#include "log.h"
#include "lock.h"
#include "terminal.h"
@ -147,12 +148,9 @@ int ctlxe(int f, int n)
* Beep the beeper. Kill off any keyboard macro, etc., that is in progress.
* Sometimes called as a routine, to do general aborting of stuff.
*/
int ctrlg(int f, int n)
{
TTbeep();
kbdmode = STOP;
mlwrite("(Aborted)");
return ABORT;
int ctrlg( int f, int n) {
kbdmode = STOP ;
return logger( ABORT, TRUE, "(Aborted)") ;
}
/* user function that does NOTHING */

View File

@ -8,7 +8,7 @@
#include "random.h"
#include "display.h"
#include "file.h"
#include "terminal.h"
#include "log.h"
#include "window.h"
int gasave = 256 ; /* global ASAVE size */
@ -100,9 +100,8 @@ int execute(int c, int f, int n)
lastflag = thisflag;
return status;
}
TTbeep();
mlwrite("(Key not bound)"); /* complain */
lastflag = 0; /* Fake last flags. */
return FALSE;
lastflag = 0 ; /* Fake last flags. */
return logger( FALSE, TRUE, "(Key not bound)") ; /* Complain */
}

14
log.c
View File

@ -15,23 +15,13 @@ boolean (*logger)( boolean, boolean, const char *, ...) = logit ;
* tell the user that this command is illegal while we are in
* VIEW (read-only) mode
*/
boolean rdonly(void)
{
/* TTbeep();
mlwrite("(Key illegal in VIEW mode)");
return FALSE;
*/
boolean rdonly( void) {
return logger( FALSE, TRUE, "(Key illegal in VIEW mode)");
}
boolean resterr(void)
{
/* TTbeep();
mlwrite("(That command is RESTRICTED)");
return FALSE;
*/
boolean resterr( void) {
return logger( FALSE, TRUE, "(That command is RESTRICTED)");
}