]> gitweb.factorcode.org Git - factor.git/blob - extra/readline/readline-docs.factor
f1082de9547bfed06acea08af7ff7d43ecccdcfb
[factor.git] / extra / readline / readline-docs.factor
1 ! Copyright (C) 2011 Erik Charlebois.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: arrays help.markup help.syntax math
4 sequences.private vectors strings kernel math.order layouts
5 quotations generic.single ;
6 IN: readline
7
8 HELP: readline
9 { $values
10     { "prompt" string }
11     { "str" string }
12 }
13 { $description "Read a line from using readline." } ;
14
15 HELP: set-completion
16 { $values
17     { "quot" "a quotation with stack effect ( str n -- str )"}
18 }
19 { $description "Set the given quotation as the completion hook for readline. The quotation is called with the string to complete and the index in the completion list to return. When all completions have been returned, returning " { $snippet "f" } " terminates the loop." }
20 { $examples
21     { $example "USING: readline sequences combinators kernel ;"
22                "[ nip [ \"keep\" \"dip\" ] ?nth ] set-completion"
23                ""
24     }
25 } ;
26
27 ARTICLE: "readline" "Readline"
28 "The " { $vocab-link "readline" } " vocabulary binds to the C readline library and provides Emacs-style key bindings for editing text. Currently, it only works from the non-graphical UI." $nl
29
30 "To read a line:"
31 { $subsections readline }
32 "To set a completion hook:"
33 { $subsections set-completion } ;
34
35 ABOUT: "readline"