{ $values { "loc""a pair of integers" } { "n"integer } { "newloc""a pair of integers" } }
{ $description "Adds an integer to the column number of a line/column pair." } ;
{ +col +line =col =line } related-words
HELP:+line
{ $values { "loc""a pair of integers" } { "n"integer } { "newloc""a pair of integers" } }
{ $description "Adds an integer to the line number of a line/column pair." } ;
HELP:=col
{ $values { "loc""a pair of integers" } { "n"integer } { "newloc""a pair of integers" } }
{ $description "Sets the column number of a line/column pair." } ;
HELP:=line
{ $values { "loc""a pair of integers" } { "n"integer } { "newloc""a pair of integers" } }
{ $description "Sets the line number of a line/column pair." } ;
HELP:lines-equal?
{ $values { "loc1""a pair of integers" } { "loc2""a pair of integers" } { "?""a boolean" } }
{ $description "Tests if both line/column pairs have the same line number." } ;
HELP:document
{ $class-description "A document is a " { $link model } " containing editable text, stored as an array of lines. Documents are created by calling " { $link <document> } ". Documents can be edited with editor gadgets; see " { $vocab-link "ui.gadgets.editors" } "." } ;
{ $description "Replaces all text between two line/column number pairs with " { $snippet "string" } ". The string may use either " { $snippet "\\n" } ", " { $snippet "\\r\\n" } " or " { $snippet "\\r" } " line separators." }
{ $errors "Throws an error if " { $snippet "from" } " or " { $snippet "to" } " is out of bounds." }
{ $side-effects "document" } ;
HELP:remove-doc-range
{ $values { "from""a pair of integers" } { "to""a pair of integers" } { "document" document } }
{ $description "Removes all text between two line/column number pairs." }
{ $errors "Throws an error if " { $snippet "from" } " or " { $snippet "to" } " is out of bounds." }
{ $side-effects "document" } ;
HELP:validate-loc
{ $values { "loc""a pair of integers" } { "document" document } { "newloc""a pair of integers" } }
{ $description "Ensures that the line and column numbers in " { $snippet "loc" } " are valid, clamping them to the permitted range if they are not." } ;
{ $description "Sets the contents of the document to a string, which may use either " { $snippet "\\n" } ", " { $snippet "\\r\\n" } " or " { $snippet "\\r" } " line separators." }
{ $side-effects "document" } ;
HELP:clear-doc
{ $values { "document" document } }
{ $description "Removes all text from the document." }
{ $contract "Outputs the location of the first occurrence of the element following " { $snippet "loc" } "." } ;
HELP:char-elt
{ $class-description "An element representing a single character." } ;
HELP:one-word-elt
{ $class-description "An element representing a single word. The " { $link prev-elt } " and " { $link next-elt } " words return the location of the beginning and the end of the word at the current location." } ;
{ one-word-elt word-elt } related-words
HELP:word-elt
{ $class-description "An element representing a single word. The " { $link prev-elt } " and " { $link next-elt } " words return the location of the previous and next word from the current location." } ;
HELP:one-line-elt
{ $class-description "An element representing a single line. The " { $link prev-elt } " and " { $link next-elt } " words return the location of the beginning and the end of the line at the current location." } ;
{ one-line-elt line-elt } related-words
HELP:line-elt
{ $class-description "An element representing a single line. The " { $link prev-elt } " and " { $link next-elt } " words return the location of the previous and next line from the current location." } ;
HELP:doc-elt
{ $class-description "An element representing the entire document. The " { $link prev-elt } " word outputs the start of the document and the " { $link next-elt } " word outputs the end of the document." } ;
ARTICLE: "documents""Documents"
{ $subsection document }
{ $subsection <document> }
"Getting and setting the contents of the entire document:"
{ $subsection doc-string }
{ $subsection set-doc-string }
{ $subsection clear-doc }
"Getting and setting subranges:"
{ $subsection doc-line }
{ $subsection doc-lines }
{ $subsection doc-range }
{ $subsection set-doc-range }
{ $subsection remove-doc-range }
"A combinator:"
{ $subsection each-line }
{ $see-also "gadgets-editors" } ;
ARTICLE: "document-locs-elts""Locations and elements"
"Locations in the document are represented as a line/column number pair, with both indices being zero-based. There are some words for manipulating locations:"
{ $subsection +col }
{ $subsection +line }
{ $subsection =col }
{ $subsection =line }
"New locations can be created out of existing ones by finding the start or end of a document element nearest to a given location."
{ $subsection prev-elt }
{ $subsection next-elt }
"The different types of document elements correspond to the standard editing taxonomy:"