File: lattr.h

package info (click to toggle)
joe 3.7-2.3
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 3,304 kB
  • sloc: ansic: 34,071; sh: 3,426; makefile: 138
file content (71 lines) | stat: -rw-r--r-- 3,017 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
 *	Line attribute cache
 *	Copyright
 *		(C) 2006 Joseph H. Allen
 *
 *	This file is part of JOE (Joe's Own Editor)
 */

struct lattr_db
  {
  struct lattr_db *next;	/* Linked list of attribute databases owned by a B */
  struct high_syntax *syn;	/* This database is for this syntax */
  B *b;				/* This database is for this buffer */

  /* Use a gap buffer for the attribute records */

  HIGHLIGHT_STATE *buffer;	/* Address of buffer */
  long hole;			/* Offset to hole */
  long ehole;			/* Offset to end of hole */
  long end;			/* Malloc() size of buffer */

  long first_invalid;		/* Lines beginning with this are invalid */
  long invalid_window;		/* Lines beyond first_invalid+invalid_window might be valid */
                                /* -1 means all lines are valid */
  };

struct lattr_db *mk_lattr_db PARAMS((B *new_b, struct high_syntax *new_syn));
                                /* Create database structure */

void rm_lattr_db PARAMS((struct lattr_db *db));
                                /* Delete database structure */

void rm_all_lattr_db PARAMS((struct lattr_db *db));
                                /* Delete linked-list of databases */

void reset_all_lattr_db PARAMS((struct lattr_db *db));
                                /* Delete linked-list of databases */

struct lattr_db *find_lattr_db PARAMS((B *b, struct high_syntax *y));
                                /* Find database for a particular syntax.  If one doesn't
                                   exist, create it and add it to the list for the B */

void drop_lattr_db PARAMS((B *b, struct lattr_db *db));
                                /* Drop a database if it's no longer needed. This checks through all BWs on a B
                                   to see if any of them refer to db.  If none, the db is dropped. */

#define lattr_size(db) ((db)->end - ((db)->ehole - (db)->hole))

void lattr_hole PARAMS((struct lattr_db *db, long pos));
  /* Set hole position */

void lattr_check PARAMS((struct lattr_db *db, long size));
  /* Make sure we have enough space for insert.  If not, expand buffer. */

void lattr_ins PARAMS((struct lattr_db *db,long line,long size));
  /* An insert occured, beginning on specified line.  'size' lines were inserted.
     Adjust invalid window to cover inserted area.
  */

void lattr_del PARAMS((struct lattr_db *db,long line,long size));
  /* A deletion occured, beginning on specified line.  'size' lines were deleted.
     Adjust invalid window to cover deleted area.
  */

HIGHLIGHT_STATE lattr_get PARAMS((struct lattr_db *db,struct high_syntax *y,P *p,long line));
  /* Get state for specified line.  If we don't have it, compute it.
     Records results of any computation so that we don't have to do it again.
     If first_invalid is < number of lines we have, compute forward until we
     start matching again as this is a very common case. */

#define lattr_lvalue(db, line) ((line) >= (db)->hole ? (db)->buffer[(line) - (db)->hole + (db)->ehole] : (db)->buffer[line])