]> gitweb.factorcode.org Git - factor.git/blob - basis/ui/gadgets/editors/editors-docs.factor
Change a throw to rethrow so that we don't lose the original stack trace
[factor.git] / basis / ui / gadgets / editors / editors-docs.factor
1 USING: documents help.markup help.syntax ui.gadgets
2 ui.gadgets.scrollers models strings ui.commands ;
3 IN: ui.gadgets.editors
4
5 HELP: editor
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> } "."
7 $nl
8 "Editors have the following slots:"
9 { $list
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." }
17 } } ;
18
19 HELP: <editor>
20 { $values { "editor" "a new " { $link editor } } }
21 { $description "Creates a new " { $link editor } " with an empty document." } ;
22
23 { editor-caret* editor-mark* } related-words
24
25 HELP: editor-caret*
26 { $values { "editor" editor } { "loc" "a pair of integers" } }
27 { $description "Outputs the current caret location as a line/column number pair." } ;
28
29 HELP: editor-mark*
30 { $values { "editor" editor } { "loc" "a pair of integers" } }
31 { $description "Outputs the current mark location as a line/column number pair." } ;
32
33 HELP: change-caret
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." } ;
36
37 { change-caret change-caret&mark mark>caret } related-words
38
39 HELP: mark>caret
40 { $values { "editor" editor } }
41 { $description "Moves the mark to the caret location, effectively deselecting any selected text." } ;
42
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." } ;
46
47 HELP: point>loc
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." } ;
50
51 HELP: scroll>caret
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 } "." } ;
54
55 HELP: remove-selection
56 { $values { "editor" editor } }
57 { $description "Removes currently selected text from the editor's " { $link document } "." } ;
58
59 HELP: editor-string
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" } "." } ;
62
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." } ;
66
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." ;
82
83 ARTICLE: "gadgets-editors" "Editor gadgets"
84 "An editor edits a multi-line passage of text."
85 { $command-map editor "general" }
86 { $command-map editor "caret-motion" }
87 { $command-map editor "selection" }
88 { $heading "Editor words" }
89 { $subsection editor }
90 { $subsection <editor> }
91 { $subsection editor-string }
92 { $subsection set-editor-string }
93 { $subsection "gadgets-editors-selection" }
94 { $subsection "documents" }
95 { $subsection "document-locs-elts" } ;
96
97 ABOUT: "gadgets-editors"