Buffer contents, Buffer name, buffer id and file name, The carriage-return flag – Crunch CRiSP File Editor 6 User Manual

Page 35: Current cursor position, Modified flag, Permissions & read-only flag

Advertising
background image

Page 35

these files, CRiSP breaks up binary files into lines containing only 32 characters. To avoid problems if the
file is modified and written away, CRiSP sets the binary flag. This flag means that the newline character
normally written at the end of each line is not saved for binary files, and therefore the edited binary is what
the user expects. If this flag were not set or if the user macro turns it off, then newline characters would
appear at 32 character intervals in the output file.

Buffer Contents

A buffer may be considered as an array of lines, where a line is stored internally using a length + data. This
means that each line can contain an unlimited amount of data and that any characters may appear within a
line, even newlines (for example with binary files). CRiSP does not suffer the problem that vi(1) does of
stripping out unprintable control characters.

CRiSP has no limit on the number of lines in a buffer (subject only to memory and disk space limitations).
You can tweak CRiSP's memory utilization for large or pathologically shaped files using the
Options

Memory configuration menu.

Buffer name, buffer ID and File name

Each buffer is identified by an integer number internally. Macros which manipulate buffers or switch between
buffers use the buffer ID. Buffer IDs are not normally visible to users. Instead, they see a buffer name and a
file name.

The filename is the name of the file stored in a buffer. Buffers don't necessarily have to have a file stored in
them. Some buffers are used internally to store information about the current editing session, e.g. the scrap
buffer. The filename is used by users to distinguish one buffer from another.

The buffer name is a sort of shorthand name for a buffer. Normally when a file is read into a buffer, the
actual filename of the file is used as the buffer name. Different buffers may contain the same buffer name.
For example, if the user edits the file /usr/fox/test.doc and /usr/fox/backup/test.doc, there will be two buffers
called test.doc. The full-filename associated with each buffer allows the user to distinguish them. This full-
filename is the file written to when the buffer is saved. The buffer name is the string printed at the top of the
window when it is attached.

The Carriage-Return flag

This flag indicates whether the carriage-returns (CR) characters should be appended to the end of each line
on output. This would typically be used for editing DOS text files which use the CR-LF sequence to
terminate files, rather than the Unix standard of just plain LF.

When a file is read in, if CR characters are found before the LF at the end of the line, then this attribute will
be set automatically.

Current cursor position

CRiSP maintains two separate cursor for each buffer - the normal cursor, as displayed on the screen, and a
parallel cursor for process buffers. (See below for a description of process buffers).

If a buffer is not being displayed in a window, then the cursor position changes as a result of text insertions,
deletions, pattern searches, etc. When the buffer is attached to a window, the cursor is copied into the
windows data structure. This allows each window to maintain a separate view of a buffer.

When a buffer is detached from a window, the cursor is copied into the buffers data structure.

Modified Flag

Each buffer has a flag called the modified flag. This flag is set whenever a change is made to the buffer, e.g.
an insertion or deletion. The flag is used to indicate that the buffer needs to be saved before terminating
CRiSP, and is used, for example, by the autosave macro.

Permissions & Read-only Flag

When a file is read into a buffer, a note is made of the original protection bits on that file. This is needed so
that when the file is written away, it can give the output file the same protection bits as the original file. For
example, when editing an executable shell script, the execute bits are turned on for the modified file so that
it is still executable.

If a read-only file is edited, then CRiSP does not allow any changes to be made to the buffer. This stops the
user making changes and then finding out at the end of the editing session that they cannot be saved (a

Advertising