1 USING: documents help.markup help.syntax ui.gadgets
2 ui.gadgets.scrollers models strings ui.commands ;
6 { $class-description "An editor is a control for editing a multi-line passage of text stored in a " { $link document } " model. Editors are crated by calling " { $link <editor> } "."
8 "Editors have the following slots:"
10 { { $snippet "font" } " - a font specifier." }
11 { { $snippet "color" } " - text color specifier." }
12 { { $snippet "caret-color" } " - caret color specifier." }
13 { { $snippet "selection-color" } " - selection background color specifier." }
14 { { $snippet "caret" } " - a model storing a line/column pair." }
15 { { $snippet "mark" } " - a model storing a line/column pair. If there is no selection, the mark is equal to the caret, otherwise the mark is located at the opposite end of the selection from the caret." }
16 { { $snippet "focused?" } " - a boolean." }
20 { $values { "editor" "a new " { $link editor } } }
21 { $description "Creates a new " { $link editor } " with an empty document." } ;
23 { editor-caret* editor-mark* } related-words
26 { $values { "editor" editor } { "loc" "a pair of integers" } }
27 { $description "Outputs the current caret location as a line/column number pair." } ;
30 { $values { "editor" editor } { "loc" "a pair of integers" } }
31 { $description "Outputs the current mark location as a line/column number pair." } ;
34 { $values { "editor" editor } { "quot" { $quotation "( loc -- newloc )" } } }
35 { $description "Applies a quotation to the current caret location and moves the caret to the location output by the quotation." } ;
37 { change-caret change-caret&mark mark>caret } related-words
40 { $values { "editor" editor } }
41 { $description "Moves the mark to the caret location, effectively deselecting any selected text." } ;
43 HELP: change-caret&mark
44 { $values { "editor" editor } { "quot" { $quotation "( loc -- newloc )" } } }
45 { $description "Applies a quotation to the current caret location and moves the caret and the mark to the location output by the quotation." } ;
48 { $values { "point" "a pair of integers" } { "editor" editor } { "loc" "a pair of integers" } }
49 { $description "Converts a point to a line/column number pair." } ;
52 { $values { "editor" editor } }
53 { $description "Ensures that the caret becomes visible in a " { $link scroller } " containing the editor. Does nothing if no parent of " { $snippet "gadget" } " is a " { $link scroller } "." } ;
55 HELP: remove-selection
56 { $values { "editor" editor } }
57 { $description "Removes currently selected text from the editor's " { $link document } "." } ;
60 { $values { "editor" editor } { "string" string } }
61 { $description "Outputs the contents of the editor's " { $link document } " as a string. Lines are separated by " { $snippet "\\n" } "." } ;
63 HELP: set-editor-string
64 { $values { "string" string } { "editor" editor } }
65 { $description "Sets the contents of the editor's " { $link document } " to a string, which may use either " { $snippet "\\n" } ", " { $snippet "\\r\\n" } " or " { $snippet "\\r" } " line separators." } ;
67 ARTICLE: "gadgets-editors-selection" "The caret and mark"
68 "If there is no selection, the caret and the mark are at the same location; otherwise the mark delimits the end-point of the selection opposite the caret."
69 { $subsection editor-caret* }
70 { $subsection editor-mark* }
71 { $subsection change-caret }
72 { $subsection change-caret&mark }
73 { $subsection mark>caret }
74 "Getting the selected text:"
75 { $subsection gadget-selection? }
76 { $subsection gadget-selection }
77 "Removing selected text:"
78 { $subsection remove-selection }
79 "Scrolling to the caret location:"
80 { $subsection scroll>caret }
81 "Use " { $link user-input* } " to change selected text." ;
83 ARTICLE: "gadgets-editors" "Editor gadgets"
84 "The " { $vocab-link "ui.gadgets.editors" } " vocabulary implements editor gadgets. An editor edits a passage of text."
85 { $command-map editor "general" }
86 { $command-map editor "caret-motion" }
87 { $command-map editor "selection" }
88 { $command-map multiline-editor "multiline" }
89 { $heading "Editor words" }
90 { $subsection editor }
91 { $subsection <editor> }
92 { $subsection <multiline-editor> }
93 { $subsection editor-string }
94 { $subsection set-editor-string }
95 { $subsection "gadgets-editors-selection" }
96 { $subsection "documents" }
97 { $subsection "document-locs-elts" } ;
99 ABOUT: "gadgets-editors"