1*d4e7c603Sniklas# $OpenBSD: structures,v 1.3 2001/01/29 01:58:39 niklas Exp $ 2*d4e7c603Sniklas 345f2ab88Sderaadt# @(#)structures 5.4 (Berkeley) 10/4/95 4df930be7Sderaadt 545f2ab88SderaadtThere are three major data structures in this package, plus a single data 645f2ab88Sderaadtstructure per screen type. The first is a single global structure (GS) 745f2ab88Sderaadtwhich contains information common to all files and screens. It hold 845f2ab88Sderaadtglobal things like the input key queues, and functions as a single place 945f2ab88Sderaadtto hang things. For example, interrupt routines have to be able to find 1045f2ab88Sderaadtscreen structures, and they can only do this if they have a starting 1145f2ab88Sderaadtpoint. The number of globals in nvi is dependent on the screen type, but 1245f2ab88Sderaadtevery screen type will have at least one global, __global_list, which 1345f2ab88Sderaadtreferences the GS structure. 14df930be7Sderaadt 1545f2ab88SderaadtThe GS structure contains linked lists of screen (SCR) structures. 1645f2ab88SderaadtEach SCR structure normally references a file (EXF) structure. 17df930be7Sderaadt 1845f2ab88SderaadtThe GS structure has a set of functions which update the screen and/or 1945f2ab88Sderaadtreturn information about the screen from the underlying screen package. 2045f2ab88SderaadtThe GS structure never goes away. The SCR structure persists over 2145f2ab88Sderaadtinstances of screens, and the EXF structure persists over references to 2245f2ab88Sderaadtfiles. 23df930be7Sderaadt 24df930be7SderaadtFile names have different properties than files themselves, so the name 25df930be7Sderaadtinformation for a file is held in an FREF structure which is chained from 26df930be7Sderaadtthe SCR structure. 27df930be7Sderaadt 2845f2ab88SderaadtIn general, functions are always passed an SCR structure, which usually 2945f2ab88Sderaadtreferences an underlying EXF structure. The SCR structure is necessary 3045f2ab88Sderaadtfor any routine that wishes to talk to the screen, the EXF structure is 3145f2ab88Sderaadtnecessary for any routine that wants to modify the file. The relationship 3245f2ab88Sderaadtbetween an SCR structure and its underlying EXF structure is not fixed, 3345f2ab88Sderaadtand various ex commands will substitute a new EXF in place of the current 3445f2ab88Sderaadtone, and there's no way to detect this. 35df930be7Sderaadt 36df930be7SderaadtThe naming of the structures is consistent across the program. (Macros 37df930be7Sderaadteven depend on it, so don't try and change it!) The global structure is 38df930be7Sderaadt"gp", the screen structure is "sp", and the file structure is "ep". 39df930be7Sderaadt 40df930be7SderaadtA few other data structures: 41df930be7Sderaadt 42df930be7SderaadtTEXT In nvi/cut.h. This structure describes a portion of a line, 43df930be7Sderaadt and is used by the input routines and as the "line" part of a 44df930be7Sderaadt cut buffer. 45df930be7Sderaadt 46df930be7SderaadtCB In nvi/cut.h. A cut buffer. A cut buffer is a place to 47df930be7Sderaadt hang a list of TEXT structures. 48df930be7Sderaadt 4945f2ab88SderaadtCL The curses screen private data structure. Everything to 5045f2ab88Sderaadt do standalone curses screens. 5145f2ab88Sderaadt 52df930be7SderaadtMARK In nvi/mark.h. A cursor position, consisting of a line number 53df930be7Sderaadt and a column number. 54df930be7Sderaadt 55df930be7SderaadtMSG In nvi/msg.h. A chain of messages for the user. 56df930be7Sderaadt 57df930be7SderaadtSEQ In nvi/seq.h. An abbreviation or a map entry. 58df930be7Sderaadt 5945f2ab88SderaadtTK The Tcl/Tk screen private data structure. Everything to 6045f2ab88Sderaadt do standalone Tcl/Tk screens. 61df930be7Sderaadt 6245f2ab88SderaadtEXCMD In nvi/ex/ex.h. The structure that gets passed around to the 6345f2ab88Sderaadt functions that implement the ex commands. (The main ex command 6445f2ab88Sderaadt loop (see nvi/ex/ex.c) builds this up and then passes it to the 6545f2ab88Sderaadt ex functions.) 6645f2ab88Sderaadt 6745f2ab88SderaadtVICMD In nvi/vi/vi.h. The structure that gets passed around to the 68df930be7Sderaadt functions that implement the vi commands. (The main vi command 69df930be7Sderaadt loop (see nvi/vi/vi.c) builds this up and then passes it to the 70df930be7Sderaadt vi functions.) 71