xref: /netbsd-src/external/bsd/nvi/docs/internals/structures (revision 4391d5e9d4f291db41e3b3ba26a01b5e51364aae)
1*4391d5e9Schristos#	@(#)structures	5.4 (Berkeley) 10/4/95
2*4391d5e9Schristos
3*4391d5e9SchristosThere are three major data structures in this package, plus a single data
4*4391d5e9Schristosstructure per screen type.  The first is a single global structure (GS)
5*4391d5e9Schristoswhich contains information common to all files and screens.  It hold
6*4391d5e9Schristosglobal things like the input key queues, and functions as a single place
7*4391d5e9Schristosto hang things.  For example, interrupt routines have to be able to find
8*4391d5e9Schristosscreen structures, and they can only do this if they have a starting
9*4391d5e9Schristospoint.  The number of globals in nvi is dependent on the screen type, but
10*4391d5e9Schristosevery screen type will have at least one global, __global_list, which
11*4391d5e9Schristosreferences the GS structure.
12*4391d5e9Schristos
13*4391d5e9SchristosThe GS structure contains linked lists of screen (SCR) structures.
14*4391d5e9SchristosEach SCR structure normally references a file (EXF) structure.
15*4391d5e9Schristos
16*4391d5e9SchristosThe GS structure has a set of functions which update the screen and/or
17*4391d5e9Schristosreturn information about the screen from the underlying screen package.
18*4391d5e9SchristosThe GS structure never goes away.  The SCR structure persists over
19*4391d5e9Schristosinstances of screens, and the EXF structure persists over references to
20*4391d5e9Schristosfiles.
21*4391d5e9Schristos
22*4391d5e9SchristosFile names have different properties than files themselves, so the name
23*4391d5e9Schristosinformation for a file is held in an FREF structure which is chained from
24*4391d5e9Schristosthe SCR structure.
25*4391d5e9Schristos
26*4391d5e9SchristosIn general, functions are always passed an SCR structure, which usually
27*4391d5e9Schristosreferences an underlying EXF structure.  The SCR structure is necessary
28*4391d5e9Schristosfor any routine that wishes to talk to the screen, the EXF structure is
29*4391d5e9Schristosnecessary for any routine that wants to modify the file.  The relationship
30*4391d5e9Schristosbetween an SCR structure and its underlying EXF structure is not fixed,
31*4391d5e9Schristosand various ex commands will substitute a new EXF in place of the current
32*4391d5e9Schristosone, and there's no way to detect this.
33*4391d5e9Schristos
34*4391d5e9SchristosThe naming of the structures is consistent across the program.  (Macros
35*4391d5e9Schristoseven depend on it, so don't try and change it!)  The global structure is
36*4391d5e9Schristos"gp", the screen structure is "sp", and the file structure is "ep".
37*4391d5e9Schristos
38*4391d5e9SchristosA few other data structures:
39*4391d5e9Schristos
40*4391d5e9SchristosTEXT	In nvi/cut.h.  This structure describes a portion of a line,
41*4391d5e9Schristos	and is used by the input routines and as the "line" part of a
42*4391d5e9Schristos	cut buffer.
43*4391d5e9Schristos
44*4391d5e9SchristosCB	In nvi/cut.h.	A cut buffer.  A cut buffer is a place to
45*4391d5e9Schristos	hang a list of TEXT structures.
46*4391d5e9Schristos
47*4391d5e9SchristosCL	The curses screen private data structure.  Everything to
48*4391d5e9Schristos	do standalone curses screens.
49*4391d5e9Schristos
50*4391d5e9SchristosMARK	In nvi/mark.h.  A cursor position, consisting of a line number
51*4391d5e9Schristos	and a column number.
52*4391d5e9Schristos
53*4391d5e9SchristosMSG	In nvi/msg.h.  A chain of messages for the user.
54*4391d5e9Schristos
55*4391d5e9SchristosSEQ	In nvi/seq.h.  An abbreviation or a map entry.
56*4391d5e9Schristos
57*4391d5e9SchristosTK	The Tcl/Tk screen private data structure.  Everything to
58*4391d5e9Schristos	do standalone Tcl/Tk screens.
59*4391d5e9Schristos
60*4391d5e9SchristosEXCMD   In nvi/ex/ex.h.  The structure that gets passed around to the
61*4391d5e9Schristos	functions that implement the ex commands.  (The main ex command
62*4391d5e9Schristos	loop (see nvi/ex/ex.c) builds this up and then passes it to the
63*4391d5e9Schristos	ex functions.)
64*4391d5e9Schristos
65*4391d5e9SchristosVICMD	In nvi/vi/vi.h.  The structure that gets passed around to the
66*4391d5e9Schristos	functions that implement the vi commands.  (The main vi command
67*4391d5e9Schristos	loop (see nvi/vi/vi.c) builds this up and then passes it to the
68*4391d5e9Schristos	vi functions.)
69