Common Lisp Package: TEXT-QUERY

README:

FUNCTION

Public

QUERY (OPTIONS &OPTIONAL FORMAT-STRING &REST FORMAT-ARGUMENTS)

QUERY is used for asking questions of the user. OPTIONS is a property-list containing the following keywords: :TYPE :char or :line (how *query-io* is read) :CHOICES A list containing entries of the form (<value> . <key>*) or ((<value> <print>) . <key>*), where <value> is the value to be returned, <key> is a character or string, as the case may be, that is used to select the <value>, and <print> is printed when the value is selected. :BEEP Specifies whether to ring the bell. :CLEAR-INPUT If T, does a clear-input before querying. :FRESH-LINE If T, starts on a fresh line before printing the prompt. :LIST-CHOICES If T, prints a list of the choices after the prompt. :HELP-STRING A string to be printed if the user asks for help. :TIMEOUT The number of seconds to wait, if using timeouts. :TIMEOUT-DEFAULT The default value to use if the query times out. :STREAM The stream to use. Defaults to *query-io* :SIGNAL-CONDITION If T, will signal a condition of type QUERY-ERROR before proceeding. If non-NIL but not T, uses the value as the name of the condition. :EOF-ERROR-P If T (the default), signals an error if eof is reached. If NIL, returns EOF-VALUE upon reaching eof :EOF-VALUE Value returned if eof is reached and eof-error-p is NIL.

Y-OR-N-P (&OPTIONAL FORMAT-STRING &REST FORMAT-ARGUMENTS)

Y-OR-N-P prints the message, if supplied, and reads a character from *QUERY-IO* until the user types a Y or an N, returning T and NIL, respectively. Repeats the request if the user typed anything else. Also, if a H or ? is enterred, prints a brief help message. If you want a question mark at the end of the message, you must put it there yourself; Y-OR-N-P will not add it.

Y-OR-N-P-WAIT (&OPTIONAL (DEFAULT *Y-OR-N-P-WAIT-DEFAULT*) (TIMEOUT *TIMEOUT*) FORMAT-STRING &REST FORMAT-ARGUMENTS)

Y-OR-N-P-WAIT is like Y-OR-N-P, but will timeout after TIMEOUT seconds with DEFAULT as the default value.

YES-OR-NO-P (&OPTIONAL FORMAT-STRING &REST FORMAT-ARGUMENTS)

YES-OR-NO-P prints the message, if supplied, rings the bell, and reads a line from *QUERY-IO* (ignoring whitespace) until the user types YES or NO, returning T and NIL, respectively. Repeats the request if the user typed anything else. Also, if HELP, H or ? is enterred, prints a brief help message. If you want a question mark at the end of the message, you must put it there yourself; YES-OR-NO-P will not add it.

YES-OR-NO-P-WAIT (&OPTIONAL (DEFAULT *YES-OR-NO-P-WAIT-DEFAULT*) (TIMEOUT *TIMEOUT*) FORMAT-STRING &REST FORMAT-ARGUMENTS)

YES-OR-NO-P-WAIT is like YES-OR-NO-P, but will timeout after TIMEOUT seconds with DEFAULT as the default value.

Private

Undocumented

INTERNAL-REAL-TIME-IN-SECONDS

QUERY-INTERNAL (&KEY FORMAT-STRING FORMAT-ARGUMENTS (TYPE CHAR) (CHOICES *Y-OR-N-P-CHOICES*) (BEEP NIL) (CLEAR-INPUT NIL) (FRESH-LINE NIL FRESH-LINE-P) (LIST-CHOICES T) (HELP-STRING NIL) TIMEOUT TIMEOUT-DEFAULT (STREAM *QUERY-IO*) (SIGNAL-CONDITION NIL) (EOF-ERROR-P T) (EOF-VALUE NIL))

READ-CHAR-WAIT (&OPTIONAL (TIMEOUT 20) INPUT-STREAM (EOF-ERROR-P T) EOF-VALUE &AUX PEEK)

READ-LINE-WAIT (&OPTIONAL (TIMEOUT 20) INPUT-STREAM (EOF-ERROR-P T) EOF-VALUE &AUX PEEK)

VARIABLE

Private

*SLEEP-AMOUNT*

Amount of time to sleep between checking query-io. In multiprocessing Lisps, this allows other processes to continue while we busy-wait. If 0, skips call to SLEEP.

Undocumented

*TIMEOUT*

*Y-OR-N-P-CHOICES*

*Y-OR-N-P-WAIT-DEFAULT*

*YES-OR-NO-P-CHOICES*

*YES-OR-NO-P-WAIT-DEFAULT*