teco

Check-in [52a94f34e9]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix compile errors, add :fu ops to control undo versioning. Refactor errors through common function.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256:52a94f34e93e9cfbf172a22bdfb095c899f3c80146bbdade0a23cf8c29b51f96
User & Date: ajv-899-334-8894@vsta.org 2013-12-18 21:51:28
Context
2013-12-18
21:52
Ignore generated tecorc check-in: b9c6e3a94b user: ajv-899-334-8894@vsta.org tags: master, trunk
21:51
Fix compile errors, add :fu ops to control undo versioning. Refactor errors through common function. check-in: 52a94f34e9 user: ajv-899-334-8894@vsta.org tags: master, trunk
20:29
Undo/redo bringup check-in: 60afa1285f user: ajv-899-334-8894@vsta.org tags: master, trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to data.c.

86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
struct exp_entry *esp;			/* expression stack pointer */

/* global variables, etc. */

int char_count = 0;	/* char count for tab typer */
char lastc = ' ';	/* last char read */
int ttyerr;		/* error return from ioctl */
jmp_buf xxx;		/* preserved environment for error restart */
int terr;		/* local error code */
struct qp t_qp;		/* temporary buffer pointer */
struct qp aa, bb, cc;	/* more temporaries */
struct buffcell t_bcell; /* temporary bcell */
int tabmask = 7;	/* mask for typing tabs */
int exitflag;		/* flag for ending command str exec */
char term_char = ESC;	/* terminator for insert, search, etc. */







<







86
87
88
89
90
91
92

93
94
95
96
97
98
99
struct exp_entry *esp;			/* expression stack pointer */

/* global variables, etc. */

int char_count = 0;	/* char count for tab typer */
char lastc = ' ';	/* last char read */
int ttyerr;		/* error return from ioctl */

int terr;		/* local error code */
struct qp t_qp;		/* temporary buffer pointer */
struct qp aa, bb, cc;	/* more temporaries */
struct buffcell t_bcell; /* temporary bcell */
int tabmask = 7;	/* mask for typing tabs */
int exitflag;		/* flag for ending command str exec */
char term_char = ESC;	/* terminator for insert, search, etc. */

Changes to defs.h.

12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
...
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
...
430
431
432
433
434
435
436
437
438
439
440
441
#ifdef DEBUG
extern void fatal(const char *);
#define ASSERT(e) ((e) ? 0 : fatal("assertion failed"))
#else
#define ASSERT(d)
#endif

#include <setjmp.h>
#define ERROR(e) longjmp(xxx, (e))

#define CTL(x) ((x) & 0x1f)	/* for control chars */
#define BLOCKSIZE (0x10000 - 8)	/* size of memory block to allocate */
#define CELLSIZE 256		/* number of characters per cell */
#define CSTACKSIZE 64		/* size of command stack */
#define MSTACKSIZE 64		/* size of macro stack */
#define QSTACKSIZE 64		/* size of q register stack */
................................................................................
/* define global variables, etc. */

extern int char_count;	/* char count for tab typer */
extern char lastc;	/* last char read */
extern int ttyerr;	/* error return from ioctl */
extern int inp_noterm;	/* nonzero if standard in is not a terminal */
extern int out_noterm;	/* nonzero if standard out is not a term. */
extern jmp_buf xxx;	/* preserved environment for error restart */
extern int terr;	/* local error code */
extern struct qp t_qp;	/* temporary buffer pointer */

/* more temporaries */
extern struct qp aa, bb, cc;

/* temporary bcell */
................................................................................
extern int do_fb(void);
extern int read_cmdstr(void);
extern void set_term_par(int lines, int cols);
extern void recalc_tsize(int);
extern int backc(struct qp *arg);

/* Stuff from undo.c */
extern void rev_undo(void);
extern void undo_insert(int, int), undo_del(int, int);
extern void roll_back(void), roll_forward(void);

#endif /* TE_DEFS_H */







|
|







 







<







 







|




12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
...
282
283
284
285
286
287
288

289
290
291
292
293
294
295
...
429
430
431
432
433
434
435
436
437
438
439
440
#ifdef DEBUG
extern void fatal(const char *);
#define ASSERT(e) ((e) ? 0 : fatal("assertion failed"))
#else
#define ASSERT(d)
#endif

extern void teco_error(int);
#define ERROR(e) (teco_error(e))

#define CTL(x) ((x) & 0x1f)	/* for control chars */
#define BLOCKSIZE (0x10000 - 8)	/* size of memory block to allocate */
#define CELLSIZE 256		/* number of characters per cell */
#define CSTACKSIZE 64		/* size of command stack */
#define MSTACKSIZE 64		/* size of macro stack */
#define QSTACKSIZE 64		/* size of q register stack */
................................................................................
/* define global variables, etc. */

extern int char_count;	/* char count for tab typer */
extern char lastc;	/* last char read */
extern int ttyerr;	/* error return from ioctl */
extern int inp_noterm;	/* nonzero if standard in is not a terminal */
extern int out_noterm;	/* nonzero if standard out is not a term. */

extern int terr;	/* local error code */
extern struct qp t_qp;	/* temporary buffer pointer */

/* more temporaries */
extern struct qp aa, bb, cc;

/* temporary bcell */
................................................................................
extern int do_fb(void);
extern int read_cmdstr(void);
extern void set_term_par(int lines, int cols);
extern void recalc_tsize(int);
extern int backc(struct qp *arg);

/* Stuff from undo.c */
extern void rev_undo(int);
extern void undo_insert(int, int), undo_del(int, int);
extern void roll_back(void), roll_forward(void);

#endif /* TE_DEFS_H */

Changes to exec2.c.

1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392







1393
1394
1395
1396
1397
1398
1399
1400
1401
        ctrl_s = -ins_count;		/* save string length */
        esp->flag1 = esp->flag2 = 0;	/* and consume arguments */
        esp->op = OP_START;
        break;

    case 'u':		/* Control undo */

	/* Unexpected modifiers */
	if (esp->flag2 || colonflag) {
            ERROR(E_UND);
	}








	/* fu, -1fu -- roll back one level */
	if ((!esp->flag1) || (esp->val1 == -1)) {
	    roll_back();

	/* 1fu -- roll forward one previously undone level */
	} else if (esp->val1 == 1) {
	    roll_forward();

	/* Unknown */







|
|



>
>
>
>
>
>
>

|







1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
        ctrl_s = -ins_count;		/* save string length */
        esp->flag1 = esp->flag2 = 0;	/* and consume arguments */
        esp->op = OP_START;
        break;

    case 'u':		/* Control undo */

	/* Unexpected modifier */
	if (esp->flag2) {
            ERROR(E_UND);
	}

	/* Modify overall undo state */
	if (colonflag) {
	    if (esp->flag1 || esp->flag2) {
		ERROR(E_UND);
	    }
	    rev_undo(colonflag);

	/* fu, -1fu -- roll back one level */
	} else if ((!esp->flag1) || (esp->val1 == -1)) {
	    roll_back();

	/* 1fu -- roll forward one previously undone level */
	} else if (esp->val1 == 1) {
	    roll_forward();

	/* Unknown */

Changes to lib/tecorc.head.

1
2
3
4
5
6
7
8
9
10
!A startup file for TECO.  Provides: !
! +line to start up at a line number !
! "tecon" invokation to inhibit startup file !
! -n to inhibit visual mode !
! Appropriate handling for read-only files !

@ei// hk 64ez
gz j
<::s ;>



|







1
2
3
4
5
6
7
8
9
10
!A startup file for TECO.  Provides: !
! +line to start up at a line number !
! "tecon" invocation to inhibit startup file !
! -n to inhibit visual mode !
! Appropriate handling for read-only files !

@ei// hk 64ez
gz j
<::s ;>

Changes to lib/tecorc.tail.

1
2
3



4
!Tail portion of tecorc.  Embed desired macro definitions between !
! teco.head and teco.tail !
!done!







>
>
>

1
2
3
4
5
6
7
!Tail portion of tecorc.  Embed desired macro definitions between !
! teco.head and teco.tail !
!done!

!Shed undo records for tecorc setup!
::fu


Changes to main.c.

40
41
42
43
44
45
46

47
48
49
50
51



52
53
54
55
56
57
58
..
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
...
283
284
285
286
287
288
289









*
* window.c		display window and display special functions
*
* These routines should be compiled and linked to form the TECO executable.
*/
#include <stdlib.h>
#include <termcap.h>

#include "defs.h"

static void save_args(int argc, char **argv, struct qh *q);
static void read_startup(void), get_term_par(void);
static void print_string(int arg), cleanup(void);




int
main(int argc, char **argv)
{
#ifdef DEBUG
    ASSERT(sizeof(struct is) <= sizeof(struct qp));
    ASSERT(sizeof(struct undo) <= sizeof(struct qp));
................................................................................
    /* initialize screen-image buffer */
    window(WIN_INIT);

    /* set terminal screen-size parameters */
    get_term_par();

    /* set up error restart */
    if ( (terr = setjmp(xxx)) ) {
        /* EOF from standard input - clean up and exit */
        if (terr == E_EFI) {
            goto quit;
        }
        printf("\015\012?  %s", errors[terr-1]);

        /* print unfulfilled search string */
................................................................................
    }

#ifdef SIGWINCH
    /* Let SIGWINCH-type handler have a shot at it */
    recalc_tsize(SIGWINCH);
#endif
}
















>





>
>
>







 







|







 







>
>
>
>
>
>
>
>
>
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
..
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
...
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
*
* window.c		display window and display special functions
*
* These routines should be compiled and linked to form the TECO executable.
*/
#include <stdlib.h>
#include <termcap.h>
#include <setjmp.h>
#include "defs.h"

static void save_args(int argc, char **argv, struct qh *q);
static void read_startup(void), get_term_par(void);
static void print_string(int arg), cleanup(void);

/* Error recovery vector */
static jmp_buf err_jump;

int
main(int argc, char **argv)
{
#ifdef DEBUG
    ASSERT(sizeof(struct is) <= sizeof(struct qp));
    ASSERT(sizeof(struct undo) <= sizeof(struct qp));
................................................................................
    /* initialize screen-image buffer */
    window(WIN_INIT);

    /* set terminal screen-size parameters */
    get_term_par();

    /* set up error restart */
    if ( (terr = setjmp(err_jump)) ) {
        /* EOF from standard input - clean up and exit */
        if (terr == E_EFI) {
            goto quit;
        }
        printf("\015\012?  %s", errors[terr-1]);

        /* print unfulfilled search string */
................................................................................
    }

#ifdef SIGWINCH
    /* Let SIGWINCH-type handler have a shot at it */
    recalc_tsize(SIGWINCH);
#endif
}

/*
 * Jump out on teco error code
 */
void
teco_error(int why)
{
    longjmp(err_jump, why);
}

Changes to rdcmd.c.

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

int
read_cmdstr(void)
{
    int c;				/* temporary character */
    int i;				/* temporary */

    rev_undo();
    goto prompt;

    /* prompt again: new line */
restart:

    /* if input not from a file */
    if (!eisw && !inp_noterm) {







|







13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

int
read_cmdstr(void)
{
    int c;				/* temporary character */
    int i;				/* temporary */

    rev_undo(1);
    goto prompt;

    /* prompt again: new line */
restart:

    /* if input not from a file */
    if (!eisw && !inp_noterm) {

Changes to subs.c.

333
334
335
336
337
338
339


340
341
342
343
344
345
346
            return (FILBUF);
        }
        if (c == '%') {
            return (SYSBUF);
        }
    }
    ERROR(E_IQN);


}

/*
 * routines to do insert operations
 * insert1() copies current cell up to dot into a new cell
 * leaves bb pointing to end of that text
 * insert2() copies rest of buffer







>
>







333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
            return (FILBUF);
        }
        if (c == '%') {
            return (SYSBUF);
        }
    }
    ERROR(E_IQN);
    /*NOTREACHED*/
    return(0);
}

/*
 * routines to do insert operations
 * insert1() copies current cell up to dot into a new cell
 * leaves bb pointing to end of that text
 * insert2() copies rest of buffer

Changes to undo.c.

94
95
96
97
98
99
100




101
102
103
104
105
106
107
108
109
110













111
112
113
114
115
116
117
/*
 * rev_undo()
 *	Bump revision number of undo transactions
 *
 * Undo/redo is done at the granularity of transactions, by default
 *  the changes between one teco prompt and the next.  teco macros
 *  can also bump this value, useful for editor macros.




 */
void
rev_undo(void)
{
    struct undo *t;

    /* No undo state, so no need */
    if (undo == NULL) {
	return;
    }














    /* Nothing has happened since the last rev, no need */
    if (undo->grpid != grpid) {
	return;
    }

    /* Ok, advance by one */







>
>
>
>


|







>
>
>
>
>
>
>
>
>
>
>
>
>







94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
 * rev_undo()
 *	Bump revision number of undo transactions
 *
 * Undo/redo is done at the granularity of transactions, by default
 *  the changes between one teco prompt and the next.  teco macros
 *  can also bump this value, useful for editor macros.
 *
 * When passed a value of 1, advance to next generation of
 *  changes.  When passed 2, clear all undo state and start
 *  from scratch.
 */
void
rev_undo(int op)
{
    struct undo *t;

    /* No undo state, so no need */
    if (undo == NULL) {
	return;
    }

    /* Clear undo state */
    if (op == 2) {
	free_undo(undo_head);
	undo_head = undo = NULL;
	grpid = 0;
	return;
    }

    /* Rev undo state forward */
    if (op != 1) {
	ERROR(E_UND);
    }

    /* Nothing has happened since the last rev, no need */
    if (undo->grpid != grpid) {
	return;
    }

    /* Ok, advance by one */