components/libtecla/files/gl_get_line.3tecla
author John Beck <John.Beck@Oracle.COM>
Wed, 08 Feb 2012 16:47:41 -0800
changeset 681 7c568e880861
child 5810 76203f2cf39d
permissions -rw-r--r--
7143177 move libtecla from ON to Userland (Userland portion)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
681
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     1
'\" te
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     2
.\" Copyright (c) 2000, 2001, 2002, 2003, 2004 by Martin C. Shepherd. All Rights Reserved.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     3
.\" Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, provided that the above copyright notice(s) and this permission notice appear in all copies of the Software and that both the above copyright notice(s) and this permission notice appear in supporting documentation.  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.  Except as contained in this notice, the name of a copyright holder shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization of the copyright holder.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     4
.\" Portions Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     5
.TH gl_get_line 3TECLA "28 Nov 2007" "SunOS 5.11" "Interactive Command-line Input Library Functions"
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     6
.SH NAME
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     7
gl_get_line, new_GetLine, del_GetLine, gl_customize_completion, gl_change_terminal, gl_configure_getline, gl_load_history, gl_save_history, gl_group_history, gl_show_history, gl_watch_fd, gl_inactivity_timeout, gl_terminal_size, gl_set_term_size, gl_resize_history, gl_limit_history, gl_clear_history, gl_toggle_history, gl_lookup_history, gl_state_of_history, gl_range_of_history, gl_size_of_history, gl_echo_mode, gl_replace_prompt, gl_prompt_style, gl_ignore_signal, gl_trap_signal, gl_last_signal, gl_completion_action, gl_register_action, gl_display_text, gl_return_status, gl_error_message, gl_catch_blocked, gl_list_signals, gl_bind_keyseq, gl_erase_terminal, gl_automatic_history, gl_append_history, gl_query_char, gl_read_char \- allow the user to compose an input line
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     8
.SH SYNOPSIS
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
     9
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    10
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    11
cc [ \fIflag\fR\&.\|.\|. ] \fIfile\fR\&.\|.\|. \fB-ltecla\fR [ \fIlibrary\fR\&.\|.\|. ] 
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    12
#include <stdio.h>
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    13
#include <libtecla.h>
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    14
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    15
\fBGetLine *\fR\fBnew_GetLine\fR(\fBsize_t\fR \fIlinelen\fR, \fBsize_t\fR \fIhistlen\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    16
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    17
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    18
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    19
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    20
\fBGetLine *\fR\fBdel_GetLine\fR(\fBGetLine *\fR\fIgl\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    21
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    22
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    23
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    24
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    25
\fBchar *\fR\fBgl_get_line\fR(\fBGetLine *\fR\fIgl\fR, \fBconst char *\fR\fIprompt\fR,
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    26
     \fBconst char *\fR\fIstart_line\fR, \fBint\fR \fIstart_pos\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    27
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    28
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    29
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    30
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    31
\fBint\fR \fBgl_query_char\fR(\fBGetLine *\fR\fIgl\fR, \fBconst char *\fR\fIprompt\fR, \fBchar\fR \fIdefchar\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    32
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    33
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    34
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    35
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    36
\fBint\fR \fBgl_read_char\fR(\fBGetLine *\fR\fIgl\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    37
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    38
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    39
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    40
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    41
\fBint\fR \fBgl_customize_completion\fR(\fBGetLine *\fR\fIgl\fR, \fBvoid *\fR\fIdata\fR,
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    42
     \fBCplMatchFn *\fR\fImatch_fn\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    43
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    44
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    45
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    46
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    47
\fBint\fR \fBgl_change_terminal\fR(\fBGetLine *\fR\fIgl\fR, \fBFILE *\fR\fIinput_fp\fR,
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    48
     \fBFILE *\fR\fIoutput_fp\fR, \fBconst char *\fR\fIterm\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    49
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    50
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    51
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    52
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    53
\fBint\fR \fBgl_configure_getline\fR(\fBGetLine *\fR\fIgl\fR, \fBconst char *\fR\fIapp_string\fR,
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    54
     \fBconst char *\fR\fIapp_file\fR,\ \fBconst char *\fR\fIuser_file\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    55
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    56
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    57
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    58
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    59
\fBint\fR \fBgl_bind_keyseq\fR(\fBGetLine *\fR\fIgl\fR, \fBGlKeyOrigin\fR \fIorigin\fR,
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    60
     \fBconst char *\fR\fIkeyseq\fR, \fBconst char *\fR\fIaction\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    61
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    62
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    63
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    64
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    65
\fBint\fR \fBgl_save_history\fR(\fBGetLine *\fR\fIgl\fR, \fBconst char *\fR\fIfilename\fR,
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    66
     \fBconst char *\fR\fIcomment\fR, \fBint\fR \fImax_lines\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    67
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    68
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    69
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    70
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    71
\fBint\fR \fBgl_load_history\fR(\fBGetLine *\fR\fIgl\fR, \fBconst char *\fR\fIfilename\fR,
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    72
     \fBconst char *\fR\fIcomment\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    73
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    74
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    75
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    76
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    77
\fBint\fR \fBgl_watch_fd\fR(\fBGetLine *\fR\fIgl\fR, \fBint\fR \fIfd\fR, \fBGlFdEvent\fR \fIevent\fR,
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    78
     \fBGlFdEventFn *\fR\fIcallback\fR, \fBvoid *\fR\fIdata\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    79
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    80
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    81
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    82
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    83
\fBint\fR \fBgl_inactivity_timeout\fR(\fBGetLine *\fR\fIgl\fR, \fBGlTimeoutFn *\fR\fIcallback\fR,
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    84
     \fBvoid *\fR\fIdata\fR, \fBunsigned long\fR \fIsec\fR, \fBunsigned long\fR \fInsec\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    85
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    86
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    87
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    88
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    89
\fBint\fR \fBgl_group_history\fR(\fBGetLine *\fR\fIgl\fR, \fBunsigned\fR \fIstream\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    90
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    91
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    92
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    93
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    94
\fBint\fR \fBgl_show_history\fR(\fBGetLine *\fR\fIgl\fR, \fBFILE *\fR\fIfp\fR, \fBconst char *\fR\fIfmt\fR,
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    95
     \fBint\fR \fIall_groups\fR, \fBint\fR \fImax_lines\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    96
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    97
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    98
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
    99
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   100
\fBint\fR \fBgl_resize_history\fR(\fBGetLine *\fR\fIgl\fR, \fBsize_t\fR \fIbufsize\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   101
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   102
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   103
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   104
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   105
\fBvoid\fR \fBgl_limit_history\fR(\fBGetLine *\fR\fIgl\fR, \fBint\fR \fImax_lines\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   106
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   107
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   108
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   109
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   110
\fBvoid\fR \fBgl_clear_history\fR(\fBGetLine *\fR\fIgl\fR, \fBint\fR \fIall_groups\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   111
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   112
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   113
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   114
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   115
\fBvoid\fR \fBgl_toggle_history\fR(\fBGetLine *\fR\fIgl\fR, \fBint\fR \fIenable\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   116
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   117
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   118
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   119
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   120
\fBGlTerminalSize\fR \fBgl_terminal_size\fR(\fBGetLine *\fR\fIgl\fR, \fBint\fR \fIdef_ncolumn\fR,
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   121
     \fBint\fR \fIdef_nline\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   122
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   123
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   124
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   125
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   126
\fBint\fR \fBgl_set_term_size\fR(\fBGetLine *\fR\fIgl\fR, \fBint\fR \fIncolumn\fR, \fBint\fR \fInline\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   127
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   128
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   129
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   130
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   131
\fBint\fR \fBgl_lookup_history\fR(\fBGetLine *\fR\fIgl\fR, \fBunsigned long\fR \fIid\fR,
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   132
     \fBGlHistoryLine *\fR\fIhline\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   133
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   134
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   135
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   136
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   137
\fBvoid\fR \fBgl_state_of_history\fR(\fBGetLine *\fR\fIgl\fR, \fBGlHistoryState *\fR\fIstate\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   138
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   139
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   140
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   141
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   142
\fBvoid\fR \fBgl_range_of_history\fR(\fBGetLine *\fR\fIgl\fR, \fBGlHistoryRange *\fR\fIrange\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   143
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   144
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   145
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   146
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   147
\fBvoid\fR \fBgl_size_of_history\fR(\fBGetLine *\fR\fIgl\fR, \fBGlHistorySize *\fR\fIsize\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   148
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   149
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   150
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   151
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   152
\fBvoid\fR \fBgl_echo_mode\fR(\fBGetLine *\fR\fIgl\fR, \fBint\fR \fIenable\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   153
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   154
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   155
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   156
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   157
\fBvoid\fR \fBgl_replace_prompt\fR(\fBGetLine *\fR\fIgl\fR, \fBconst char *\fR\fIprompt\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   158
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   159
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   160
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   161
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   162
\fBvoid\fR \fBgl_prompt_style\fR(\fBGetLine *\fR\fIgl\fR, \fBGlPromptStyle\fR \fIstyle\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   163
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   164
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   165
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   166
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   167
\fBint\fR \fBgl_ignore_signal\fR(\fBGetLine *\fR\fIgl\fR, \fBint\fR \fIsigno\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   168
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   169
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   170
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   171
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   172
\fBint\fR \fBgl_trap_signal\fR(\fBGetLine *\fR\fIgl\fR, \fBint\fR \fIsigno\fR, \fBunsigned\fR \fIflags\fR,
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   173
     \fBGlAfterSignal\fR \fIafter\fR, \fBint\fR \fIerrno_value\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   174
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   175
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   176
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   177
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   178
\fBint\fR \fBgl_last_signal\fR(\fBGetLine *\fR\fIgl\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   179
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   180
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   181
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   182
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   183
\fBint\fR \fBgl_completion_action\fR(\fBGetLine *\fR\fIgl\fR, \fBvoid *\fR\fIdata\fR,
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   184
     \fBCplMatchFn *\fR\fImatch_fn\fR, \fBint\fR \fIlist_only\fR, \fBconst char *\fR\fIname\fR,
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   185
     \fBconst char *\fR\fIkeyseq\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   186
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   187
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   188
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   189
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   190
\fBint\fR \fBgl_register_action\fR(\fBGetLine *\fR\fIgl\fR, \fBvoid *\fR\fIdata\fR, \fBGlActionFn *\fR\fIfn\fR,
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   191
     \fBconst char *\fR\fIname\fR, \fBconst char *\fR\fIkeyseq\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   192
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   193
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   194
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   195
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   196
\fBint\fR \fBgl_display_text\fR(\fBGetLine *\fR\fIgl\fR, \fBint\fR \fIindentation\fR,
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   197
     \fBconst char *\fR\fIprefix\fR, \fBconst char *\fR\fIsuffix\fR, \fBint\fR \fIfill_char\fR,
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   198
     \fBint\fR \fIdef_width\fR, \fBint\fR \fIstart\fR, \fBconst char *\fR\fIstring\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   199
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   200
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   201
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   202
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   203
\fBGlReturnStatus\fR \fBgl_return_status\fR(\fBGetLine *\fR\fIgl\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   204
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   205
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   206
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   207
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   208
\fBconst char *\fR\fBgl_error_message\fR(\fBGetLine *\fR\fIgl\fR, \fBchar *\fR\fIbuff\fR, \fBsize_t\fR \fIn\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   209
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   210
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   211
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   212
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   213
\fBvoid\fR \fBgl_catch_blocked\fR(\fBGetLine *\fR\fIgl\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   214
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   215
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   216
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   217
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   218
\fBint\fR \fBgl_list_signals\fR(\fBGetLine *\fR\fIgl\fR, \fBsigset_t *\fR\fIset\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   219
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   220
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   221
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   222
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   223
\fBint\fR \fBgl_append_history\fR(\fBGetLine *\fR\fIgl\fR, \fBconst char *\fR\fIline\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   224
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   225
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   226
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   227
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   228
\fBint\fR \fBgl_automatic_history\fR(\fBGetLine *\fR\fIgl\fR, \fBint\fR \fIenable\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   229
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   230
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   231
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   232
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   233
\fBint\fR \fBgl_erase_terminal\fR(\fBGetLine *\fR\fIgl\fR);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   234
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   235
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   236
.SH DESCRIPTION
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   237
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   238
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   239
The \fBgl_get_line()\fR function is part of the \fBlibtecla\fR(3LIB) library. If the user is typing at a terminal, each call prompts them for an line of input, then provides interactive editing facilities, similar to those of the UNIX \fBtcsh\fR shell. In addition to simple command-line editing, it supports recall of previously entered command lines, TAB completion of file names, and in-line wild-card expansion of filenames. Documentation of both the user-level command-line editing features and all user configuration options can be found on the \fBtecla\fR(5) manual page.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   240
.SS "An Example"
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   241
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   242
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   243
The following shows a complete example of how to use the \fBgl_get_line()\fR function to get input from the user:
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   244
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   245
.in +2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   246
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   247
#include <stdio.h>
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   248
#include <locale.h>
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   249
#include <libtecla.h>
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   250
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   251
int main(int argc, char *argv[])
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   252
{
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   253
  char *line;    /* The line that the user typed */
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   254
  GetLine *gl;   /* The gl_get_line() resource object */
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   255
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   256
  setlocale(LC_CTYPE, ""); /* Adopt the user's choice */
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   257
                           /* of character set. */
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   258
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   259
  gl = new_GetLine(1024, 2048);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   260
  if(!gl)
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   261
    return 1;
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   262
  while((line=gl_get_line(gl, "$ ", NULL, -1)) != NULL &&
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   263
         strcmp(line, "exit\en") != 0)
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   264
    printf("You typed: %s\en", line);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   265
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   266
  gl = del_GetLine(gl);
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   267
  return 0;
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   268
}
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   269
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   270
.in -2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   271
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   272
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   273
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   274
In the example, first the resources needed by the \fBgl_get_line()\fR function are created by calling \fBnew_GetLine()\fR. This allocates the memory used in subsequent calls to the \fBgl_get_line()\fR function, including the history buffer for recording previously entered lines. Then one or more lines are read from the user, until either an error occurs, or the user types exit. Then finally the resources that were allocated by \fBnew_GetLine()\fR, are returned to the system by calling \fBdel_GetLine()\fR. Note the use of the \fINULL\fR return value of \fBdel_GetLine()\fR to make \fIgl\fR \fINULL\fR. This is a safety precaution. If the program subsequently attempts to pass \fIgl\fR to \fBgl_get_line()\fR, said function will complain, and return an error, instead of attempting to use the deleted resource object.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   275
.SS "The Functions Used In The Example"
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   276
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   277
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   278
The \fBnew_GetLine()\fR function creates the resources used by the \fBgl_get_line()\fR function and returns an opaque pointer to the object that contains them. The maximum length of an input line is specified by the \fIlinelen\fR argument, and the number of bytes to allocate for storing history lines is set by the \fIhistlen\fR argument. History lines are stored back-to-back in a single buffer of this size. Note that this means that the number of history lines that can be stored at any given time, depends on the lengths of the individual lines. If you want to place an upper limit on the number of lines that can be stored, see the description of the \fBgl_limit_history()\fR function. If you do not want history at all, specify \fIhistlen\fR as zero, and no history buffer will be allocated.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   279
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   280
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   281
On error, a message is printed to \fBstderr\fR and \fINULL\fR is returned.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   282
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   283
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   284
The \fBdel_GetLine()\fR function deletes the resources that were returned by a previous call to \fBnew_GetLine()\fR. It always returns \fINULL\fR (for example, a deleted object). It does nothing if the \fIgl\fR argument is \fINULL\fR.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   285
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   286
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   287
The \fBgl_get_line()\fR function can be called any number of times to read input from the user. The gl argument must have been previously returned by a call to \fBnew_GetLine()\fR. The \fIprompt\fR argument should be a normal null-terminated string, specifying the prompt to present the user with. By default prompts are displayed literally, but if enabled with the \fBgl_prompt_style()\fR function, prompts can contain directives to do underlining, switch to and from bold fonts, or turn highlighting on and off.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   288
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   289
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   290
If you want to specify the initial contents of the line for the user to edit, pass the desired string with the \fIstart_line\fR argument. You can then specify which character of this line the cursor is initially positioned over by using the \fIstart_pos\fR argument. This should be -1 if you want the cursor to follow the last character of the start line. If you do not want to preload the line in this manner, send \fIstart_line\fR as \fINULL\fR, and set \fIstart_pos\fR to -1.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   291
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   292
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   293
The \fBgl_get_line()\fR function returns a pointer to the line entered by the user, or \fINULL\fR on error or at the end of the input. The returned pointer is part of the specified \fIgl\fR resource object, and thus should not be freed by the caller, or assumed to be unchanging from one call to the next. When reading from a user at a terminal, there will always be a newline character at the end of the returned line. When standard input is being taken from a pipe or a file, there will similarly be a newline unless the input line was too long to store in the internal buffer. In the latter case you should call \fBgl_get_line()\fR again to read the rest of the line. Note that this behavior makes \fBgl_get_line()\fR similar to \fBfgets\fR(3C). When \fBstdin\fR is not connected to a terminal, \fBgl_get_line()\fR simply calls \fBfgets()\fR.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   294
.SS "The Return Status Of \fBgl_get_line()\fR"
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   295
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   296
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   297
The \fBgl_get_line()\fR function has two possible return values: a pointer to the completed input line, or \fINULL\fR. Additional information about what caused \fBgl_get_line()\fR to return is available both by inspecting \fBerrno\fR and by calling the \fBgl_return_status()\fR function.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   298
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   299
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   300
The following are the possible enumerated values returned by \fBgl_return_status()\fR:
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   301
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   302
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   303
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   304
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   305
\fB\fBGLR_NEWLINE\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   306
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   307
.RS 15n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   308
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   309
The last call to \fBgl_get_line()\fR successfully returned a completed input line.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   310
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   311
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   312
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   313
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   314
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   315
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   316
\fB\fBGLR_BLOCKED\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   317
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   318
.RS 15n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   319
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   320
The \fBgl_get_line()\fR function was in non-blocking server mode, and returned early to avoid blocking the process while waiting for terminal I/O. The \fBgl_pending_io()\fR function can be used to see what type of I/O \fBgl_get_line()\fR was waiting for. See the \fBgl_io_mode\fR(3TECLA).
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   321
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   322
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   323
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   324
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   325
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   326
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   327
\fB\fBGLR_SIGNAL\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   328
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   329
.RS 15n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   330
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   331
A signal was caught by \fBgl_get_line()\fR that had an after-signal disposition of \fBGLS_ABORT\fR. See \fBgl_trap_signal()\fR.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   332
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   333
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   334
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   335
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   336
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   337
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   338
\fB\fBGLR_TIMEOUT\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   339
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   340
.RS 15n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   341
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   342
The inactivity timer expired while \fBgl_get_line()\fR was waiting for input, and the timeout callback function returned \fBGLTO_ABORT\fR. See \fBgl_inactivity_timeout()\fR for information about timeouts.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   343
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   344
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   345
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   346
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   347
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   348
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   349
\fB\fBGLR_FDABORT\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   350
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   351
.RS 15n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   352
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   353
An application I/O callback returned \fBGLFD_ABORT\fR. Ssee \fBgl_watch_fd()\fR.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   354
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   355
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   356
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   357
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   358
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   359
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   360
\fB\fBGLR_EOF\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   361
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   362
.RS 15n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   363
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   364
End of file reached. This can happen when input is coming from a file or a pipe, instead of the terminal. It also occurs if the user invokes the list-or-eof or del-char-or-list-or-eof actions at the start of a new line.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   365
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   366
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   367
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   368
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   369
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   370
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   371
\fB\fBGLR_ERROR\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   372
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   373
.RS 15n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   374
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   375
An unexpected error caused \fBgl_get_line()\fR to abort (consult \fBerrno\fR and/or \fBgl_error_message()\fR for details.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   376
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   377
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   378
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   379
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   380
When \fBgl_return_status()\fR returns \fBGLR_ERROR\fR and the value of \fBerrno\fR is not sufficient to explain what happened, you can use the \fBgl_error_message()\fR function to request a description of the last error that occurred.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   381
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   382
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   383
The return value of \fBgl_error_message()\fR is a pointer to the message that occurred. If the \fIbuff\fR argument is \fINULL\fR, this will be a pointer to a buffer within \fIgl\fR whose value will probably change on the next call to any function associated with \fBgl_get_line()\fR. Otherwise, if a non-null \fIbuff\fR argument is provided, the error message, including a '\e0' terminator, will be written within the first \fIn\fR elements of this buffer, and the return value will be a pointer to the first element of this buffer. If the message will not fit in the provided buffer, it will be truncated to fit.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   384
.SS "Optional Prompt Formatting"
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   385
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   386
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   387
Whereas by default the prompt string that you specify is displayed literally without any special interpretation of the characters within it, the \fBgl_prompt_style()\fR function can be used to enable optional formatting directives within the prompt.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   388
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   389
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   390
The \fIstyle\fR argument, which specifies the formatting style, can take any of the following values:
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   391
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   392
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   393
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   394
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   395
\fB\fBGL_FORMAT_PROMPT\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   396
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   397
.RS 21n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   398
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   399
In this style, the formatting directives described below, when included in prompt strings, are interpreted as follows:
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   400
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   401
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   402
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   403
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   404
\fB\fB%B\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   405
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   406
.RS 6n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   407
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   408
Display subsequent characters with a bold font.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   409
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   410
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   411
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   412
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   413
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   414
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   415
\fB\fB%b\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   416
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   417
.RS 6n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   418
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   419
Stop displaying characters with the bold font.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   420
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   421
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   422
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   423
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   424
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   425
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   426
\fB\fB%F\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   427
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   428
.RS 6n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   429
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   430
Make subsequent characters flash.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   431
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   432
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   433
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   434
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   435
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   436
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   437
\fB\fB%f\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   438
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   439
.RS 6n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   440
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   441
Turn off flashing characters.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   442
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   443
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   444
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   445
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   446
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   447
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   448
\fB\fB%U\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   449
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   450
.RS 6n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   451
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   452
Underline subsequent characters.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   453
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   454
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   455
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   456
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   457
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   458
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   459
\fB\fB%u\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   460
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   461
.RS 6n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   462
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   463
Stop underlining characters.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   464
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   465
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   466
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   467
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   468
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   469
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   470
\fB\fB%P\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   471
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   472
.RS 6n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   473
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   474
Switch to a pale (half brightness) font.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   475
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   476
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   477
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   478
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   479
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   480
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   481
\fB\fB%p\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   482
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   483
.RS 6n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   484
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   485
Stop using the pale font.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   486
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   487
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   488
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   489
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   490
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   491
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   492
\fB\fB%S\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   493
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   494
.RS 6n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   495
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   496
Highlight subsequent characters (also known as standout mode).
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   497
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   498
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   499
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   500
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   501
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   502
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   503
\fB\fB%s\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   504
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   505
.RS 6n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   506
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   507
Stop highlighting characters.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   508
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   509
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   510
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   511
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   512
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   513
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   514
\fB\fB%V\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   515
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   516
.RS 6n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   517
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   518
Turn on reverse video.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   519
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   520
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   521
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   522
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   523
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   524
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   525
\fB\fB%v\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   526
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   527
.RS 6n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   528
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   529
Turn off reverse video.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   530
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   531
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   532
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   533
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   534
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   535
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   536
\fB\fB%%\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   537
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   538
.RS 6n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   539
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   540
Display a single % character.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   541
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   542
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   543
For example, in this mode, a prompt string like "%UOK%u$" would display the prompt "OK$", but with the OK part underlined.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   544
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   545
Note that although a pair of characters that starts with a % character, but does not match any of the above directives is displayed literally, if a new directive is subsequently introduced which does match, the displayed prompt will change, so it is better to always use %% to display a literal %.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   546
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   547
Also note that not all terminals support all of these text attributes, and that some substitute a different attribute for missing ones.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   548
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   549
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   550
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   551
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   552
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   553
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   554
\fB\fBGL_LITERAL_PROMPT\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   555
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   556
.RS 21n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   557
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   558
In this style, the prompt string is printed literally. This is the default style.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   559
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   560
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   561
.SS "Alternate Configuration Sources"
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   562
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   563
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   564
By default users have the option of configuring the behavior of \fBgl_get_line()\fR with a configuration file called \fB\&.teclarc\fR in their home directories. The fact that all applications share this same configuration file is both an advantage and a disadvantage. In most cases it is an advantage, since it encourages uniformity, and frees the user from having to configure each application separately. In some applications, however, this single means of configuration is a problem. This is particularly true of embedded software, where there's no filesystem to read a configuration file from, and also in applications where a radically different choice of keybindings is needed to emulate a legacy keyboard interface. To cater for such cases, the \fBgl_configure_getline()\fR function allows the application to control where configuration information is read from.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   565
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   566
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   567
The \fBgl_configure_getline()\fR function allows the configuration commands that would normally be read from a user's \fB~/.teclarc\fR file, to be read from any or none of, a string, an application specific configuration file, and/or a user-specific configuration file. If this function is called before the first call to \fBgl_get_line()\fR, the default behavior of reading \fB~/.teclarc\fR on the first call to \fBgl_get_line()\fR is disabled, so all configurations must be achieved using the configuration sources specified with this function.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   568
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   569
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   570
If \fIapp_string\fR != \fINULL\fR, then it is interpreted as a string containing one or more configuration commands, separated from each other in the string by embedded newline  characters. If \fIapp_file\fR != \fINULL\fR then it is interpreted as the full pathname of an application-specific configuration file. If user_file != \fINULL\fR then it is interpreted as the full path name of a user-specific configuration file, such as \fB~/.teclarc\fR. For example, in the call
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   571
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   572
.in +2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   573
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   574
gl_configure_getline(gl, "edit-mode vi \n nobeep",
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   575
                     "/usr/share/myapp/teclarc", "~/.teclarc");
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   576
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   577
.in -2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   578
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   579
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   580
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   581
The \fIapp_string\fR argument causes the calling application to start in \fBvi\fR(1) edit-mode, instead of the default \fBemacs\fR mode, and turns off the use of the terminal bell by the library. It then attempts to read system-wide configuration commands from an optional file called \fB/usr/share/myapp/teclarc\fR, then finally reads user-specific configuration commands from an optional \fB\&.teclarc\fR file in the user's home directory. Note that the arguments are listed in ascending order of priority, with the contents of \fIapp_string\fR being potentially over riden by commands in \fIapp_file\fR, and commands in \fIapp_file\fR potentially being overriden by commands in \fIuser_file\fR.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   582
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   583
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   584
You can call this function as many times as needed, the results being cumulative, but note that copies of any file names specified with the \fIapp_file\fR and \fIuser_file\fR arguments are recorded internally for subsequent use by the read-init-files key-binding function, so if you plan to call this function multiple times, be sure that the last call specifies the filenames that you want re-read when the user requests that the configuration files be re-read.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   585
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   586
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   587
Individual key sequences can also be bound and unbound using the \fBgl_bind_keyseq()\fR function. The \fIorigin\fR argument specifies the priority of the binding, according to whom it is being established for, and must be one of the following two values.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   588
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   589
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   590
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   591
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   592
\fB\fBGL_USER_KEY\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   593
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   594
.RS 15n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   595
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   596
The user requested this key-binding.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   597
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   598
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   599
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   600
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   601
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   602
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   603
\fB\fBGL_APP_KEY\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   604
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   605
.RS 15n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   606
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   607
This is a default binding set by the application.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   608
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   609
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   610
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   611
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   612
When both user and application bindings for a given key sequence have been specified, the user binding takes precedence. The application's binding is subsequently reinstated if the user's binding is later unbound with either another call to this function, or a call to \fBgl_configure_getline()\fR.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   613
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   614
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   615
The \fIkeyseq\fR argument specifies the key sequence to be bound or unbound, and is expressed in the same way as in a \fB~/.teclarc\fR configuration file. The \fIaction\fR argument must either be a string containing the name of the action to bind the key sequence to, or it must be \fINULL\fR or \fB""\fR to unbind the key sequence.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   616
.SS "Customized Word Completion"
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   617
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   618
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   619
If in your application you would like to have TAB completion complete other things in addition to or instead of filenames, you can arrange this by registering an alternate completion callback function with a call to the \fBgl_customize_completion()\fR function.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   620
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   621
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   622
The \fIdata\fR argument provides a way for your application to pass arbitrary, application-specific information to the callback function. This is passed to the callback every time that it is called. It might for example point to the symbol table from which possible completions are to be sought. The \fImatch_fn\fR argument specifies the callback function to be called. The \fICplMatchFn\fR function type is defined in <\fBlibtecla.h\fR>, as is a \fBCPL_MATCH_FN()\fR macro that you can use to declare and prototype callback functions. The declaration and responsibilities of callback functions are described in depth on the \fBcpl_complete_word\fR(3TECLA) manual page.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   623
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   624
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   625
The callback function is responsible for looking backwards in the input line from the point at which the user pressed TAB, to find the start of the word being completed. It then must lookup possible completions of this word, and record them one by one in the \fBWordCompletion\fR object that is passed to it as an argument, by calling the \fBcpl_add_completion()\fR function. If the callback function wants to provide filename completion in addition to its own specific completions, it has the option of itself calling the builtin filename completion callback. This also is documented on the \fBcpl_complete_word\fR(3TECLA) manual page.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   626
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   627
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   628
If you would like \fBgl_get_line()\fR to return the current input line when a successful completion is been made, you can arrange this when you call \fBcpl_add_completion()\fR by making the last character of the continuation suffix a newline character. The input line will be updated to display the completion, together with any contiuation suffix up to the newline character, and \fBgl_get_line()\fR will return this input line.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   629
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   630
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   631
If your callback function needs to write something to the terminal, it must call \fBgl_normal_io()\fR before doing so. This will start a new line after the input line that is currently being edited, reinstate normal terminal I/O, and notify \fBgl_get_line()\fR that the input line will need to be redrawn when the callback returns.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   632
.SS "Adding Completion Actions"
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   633
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   634
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   635
In the previous section the ability to customize the behavior of the only default completion action, complete-word, was described. In this section the ability to install additional action functions, so that different types of word completion can be bound to different key sequences, is described. This is achieved by using the \fBgl_completion_action()\fR function.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   636
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   637
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   638
The \fIdata\fR and \fImatch_fn\fR arguments are as described on the \fBcpl_complete_word\fR(3TECLA) manual page, and specify the callback function that should be invoked to identify possible completions. The \fIlist_only\fR argument determines whether the action that is being defined should attempt to complete the word as far as possible in the input line before displaying any possible ambiguous completions, or whether it should simply display the list of possible completions without touching the input line. The former option is selected by specifying a value of 0, and the latter by specifying a value of 1. The \fIname\fR argument specifies the name by which configuration files and future invocations of this function should refer to the action. This must either be the name of an existing completion action to be changed, or be a new unused name for a new action. Finally, the \fIkeyseq\fR argument specifies the default key sequence to bind the action to. If this is \fINULL\fR, no new key sequence will be bound to the action.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   639
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   640
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   641
Beware that in order for the user to be able to change the key sequence that is bound to actions that are installed in this manner, you shouldcall \fBgl_completion_action()\fR to install a given action for the first time between calling \fBnew_GetLine()\fR and the first call to \fBgl_get_line()\fR. Otherwise, when the user's configuration file is read on the first call to \fBgl_get_line()\fR, the name of the your additional action will not be known, and any reference to it in the configuration file will generate an error.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   642
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   643
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   644
As discussed for \fBgl_customize_completion()\fR, if your callback function needs to write anything to the terminal, it must call \fBgl_normal_io()\fR before doing so.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   645
.SS "Defining Custom Actions"
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   646
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   647
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   648
Although the built-in key-binding actions are sufficient for the needs of most applications, occasionally a specialized application may need to define one or more custom actions, bound to application-specific key sequences. For example, a sales application would benefit from having a key sequence that displayed the part name that corresponded to a part number preceding the cursor. Such a feature is clearly beyond the scope of the built-in action functions. So for such special cases, the \fBgl_register_action()\fR function is provided.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   649
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   650
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   651
The \fBgl_register_action()\fR function lets the application register an external function, \fIfn\fR, that will thereafter be called whenever either the specified key sequence, \fIkeyseq\fR, is entered by the user, or the user enters any other key sequence that the user subsequently binds to the specified action name, \fIname\fR, in their configuration file. The \fIdata\fR argument can be a pointer to anything that the application wants to have passed to the action function, \fIfn\fR, whenever that function is invoked.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   652
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   653
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   654
The action function, \fIfn\fR, should be declared using the \fBGL_ACTION_FN()\fR macro, which is defined in <\fBlibtecla.h\fR>.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   655
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   656
.in +2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   657
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   658
#define GL_ACTION_FN(fn) GlAfterAction (fn)(GetLine *gl, \e
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   659
                       void *data, int count, size_t curpos, \e
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   660
                       const char *line)
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   661
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   662
.in -2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   663
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   664
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   665
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   666
The \fIgl\fR and \fIdata\fR arguments are those that were previously passed to \fBgl_register_action()\fR when the action function was registered. The \fIcount\fR argument is a numeric argument which the user has the option of entering using the digit-argument action, before invoking the action. If the user does not enter a number, then the \fIcount\fR argument is set to 1. Nominally this argument is interpreted as a repeat count, meaning that the action should be repeated that many times. In practice however, for some actions a repeat count makes little sense. In such cases, actions can either simply ignore the \fIcount\fR argument, or use its value for a different purpose.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   667
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   668
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   669
A copy of the current input line is passed in the read-only \fIline\fR argument. The current cursor position within this string is given by the index contained in the \fIcurpos\fR argument. Note that direct manipulation of the input line and the cursor position is not permitted because the rules dictated by various modes (such as \fBvi\fR mode versus \fBemacs\fR mode, no-echo mode, and insert mode versus overstrike mode) make it too complex for an application writer to write a conforming editing action, as well as constrain future changes to the internals of \fBgl_get_line()\fR. A potential solution to this dilemma would be to allow the action function to edit the line using the existing editing actions. This is currently under consideration.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   670
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   671
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   672
If the action function wishes to write text to the terminal without this getting mixed up with the displayed text of the input line, or read from the terminal without having to handle raw terminal I/O, then before doing either of these operations, it must temporarily suspend line editing by calling the \fBgl_normal_io()\fR function. This function flushes any pending output to the terminal, moves the cursor to the start of the line that follows the last terminal line of the input line, then restores the terminal to a state that is suitable for use with the C \fBstdio\fR facilities. The latter includes such things as restoring the normal mapping of \en to \er\en, and, when in server mode, restoring the normal blocking form of terminal I/O. Having called this function, the action function can read from and write to the terminal without the fear of creating a mess. It is not necessary for the action function to restore the original editing environment before it returns. This is done automatically by \fBgl_get_line()\fR after the action function returns. The following is a simple example of an action function which writes the sentence "Hello world" on a new terminal line after the line being edited. When this function returns, the input line is redrawn on the line that follows the "Hello world" line, and line editing resumes.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   673
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   674
.in +2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   675
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   676
static GL_ACTION_FN(say_hello_fn)
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   677
{
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   678
    if(gl_normal_io(gl))   /* Temporarily suspend editing */
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   679
        return GLA_ABORT;
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   680
    printf("Hello world\en");
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   681
    return GLA_CONTINUE;
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   682
}
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   683
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   684
.in -2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   685
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   686
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   687
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   688
Action functions must return one of the following values, to tell \fBgl_get_line()\fR how to proceed.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   689
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   690
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   691
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   692
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   693
\fB\fBGLA_ABORT\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   694
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   695
.RS 16n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   696
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   697
Cause \fBgl_get_line()\fR to return \fINULL\fR.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   698
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   699
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   700
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   701
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   702
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   703
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   704
\fB\fBGLA_RETURN\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   705
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   706
.RS 16n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   707
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   708
Cause \fBgl_get_line()\fR to return the completed input line
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   709
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   710
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   711
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   712
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   713
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   714
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   715
\fB\fBGLA_CONTINUE\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   716
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   717
.RS 16n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   718
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   719
Resume command-line editing.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   720
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   721
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   722
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   723
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   724
Note that the \fIname\fR argument of \fBgl_register_action()\fR specifies the name by which a user can refer to the action in their configuration file. This allows them to re-bind the action to an alternate key-seqeunce. In order for this to work, it is necessary to call \fBgl_register_action()\fR between calling \fBnew_GetLine()\fR and the first call to \fBgl_get_line()\fR.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   725
.SS "History Files"
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   726
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   727
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   728
To save the contents of the history buffer before quitting your application and subsequently restore them when you next start the application, the \fBgl_save_history()\fR and \fBgl_load_history()\fR functions are provided.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   729
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   730
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   731
The \fIfilename\fR argument specifies the name to give the history file when saving, or the name of an existing history file, when loading. This may contain home directory and environment variable expressions, such as \fB~/.myapp_history\fR or \fB$HOME/.myapp_history\fR.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   732
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   733
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   734
Along with each history line, additional information about it, such as its nesting level and when it was entered by the user, is recorded as a comment preceding the line in the history file. Writing this as a comment allows the history file to double as a command file, just in case you wish to replay a whole session using it. Since comment prefixes differ in different languages, the comment argument is provided for specifying the comment prefix. For example, if your application were a UNIX  shell, such as the Bourne shell, you would specify "#" here. Whatever you choose for the comment character, you must specify the same prefix to \fBgl_load_history()\fR that you used when you called \fBgl_save_history()\fR to write the history file.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   735
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   736
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   737
The \fImax_lines\fR argument must be either -1 to specify that all lines in the history list be saved, or a positive number specifying a ceiling on how many of the most recent lines should be saved.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   738
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   739
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   740
Both fuctions return non-zero on error, after writing an error message to \fBstderr\fR. Note that \fBgl_load_history()\fR does not consider the non-existence of a file to be an error.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   741
.SS "Multiple History Lists"
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   742
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   743
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   744
If your application uses a single \fBGetLine\fR object for entering many different types of input lines, you might want \fBgl_get_line()\fR to distinguish the different types of lines in the history list, and only recall lines that match the current type of line. To support this requirement, \fBgl_get_line()\fR marks lines being recorded in the history list with an integer identifier chosen by the application. Initially this identifier is set to 0 by \fBnew_GetLine()\fR, but it can be changed subsequently by calling \fBgl_group_history()\fR.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   745
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   746
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   747
The integer identifier ID can be any number chosen by the application, but note that \fBgl_save_history()\fR and \fBgl_load_history()\fR preserve the association between identifiers and historical input lines between program invocations, so you should choose fixed identifiers for the different types of input line used by your application.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   748
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   749
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   750
Whenever \fBgl_get_line()\fR appends a new input line to the history list, the current history identifier is recorded with it, and when it is asked to recall a historical input line, it only recalls lines that are marked with the current identifier.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   751
.SS "Displaying History"
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   752
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   753
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   754
The history list can be displayed by calling \fBgl_show_history()\fR. This function displays the current contents of the history list to the \fBstdio\fR output stream \fIfp\fR. If the \fImax_lines\fR argument is greater than or equal to zero, then no more than this number of  the most recent lines will be displayed. If the \fIall_groups\fR argument is non-zero, lines from all history groups are displayed. Otherwise only those of the currently selected history group are displayed. The format string argument, \fIfmt\fR, determines how the line is displayed. This can contain arbitrary characters which are written verbatim, interleaved with any of the following format directives:
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   755
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   756
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   757
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   758
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   759
\fB\fB%D\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   760
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   761
.RS 6n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   762
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   763
The date on which the line was originally entered, formatted like 2001-11-20.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   764
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   765
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   766
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   767
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   768
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   769
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   770
\fB\fB%T\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   771
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   772
.RS 6n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   773
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   774
The time of day when the line was entered, formatted like 23:59:59.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   775
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   776
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   777
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   778
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   779
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   780
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   781
\fB\fB%N\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   782
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   783
.RS 6n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   784
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   785
The sequential entry number of the line in the history buffer.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   786
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   787
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   788
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   789
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   790
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   791
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   792
\fB\fB%G\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   793
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   794
.RS 6n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   795
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   796
The number of the history group which the line belongs to.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   797
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   798
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   799
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   800
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   801
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   802
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   803
\fB\fB%%\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   804
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   805
.RS 6n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   806
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   807
A literal % character.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   808
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   809
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   810
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   811
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   812
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   813
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   814
\fB\fB%H\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   815
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   816
.RS 6n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   817
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   818
The history line itself.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   819
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   820
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   821
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   822
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   823
Thus a format string like "%D %T %H0" would output something like:
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   824
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   825
.in +2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   826
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   827
2001-11-20 10:23:34  Hello world
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   828
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   829
.in -2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   830
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   831
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   832
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   833
Note the inclusion of an explicit newline character in the format string.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   834
.SS "Looking Up History"
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   835
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   836
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   837
The \fBgl_lookup_history()\fR function allows the calling application to look up lines in the history list.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   838
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   839
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   840
The \fIid\fR argument indicates which line to look up, where the first line that was entered in the history list after \fBnew_GetLine()\fR was called is denoted by 0, and subsequently entered lines are denoted with successively higher numbers. Note that the range of lines currently preserved in the history list can be queried by calling the \fBgl_range_of_history()\fR function. If the requested line is in the history list, the details of the line are recorded in the variable pointed to by the \fIhline\fR argument, and 1 is returned. Otherwise 0 is returned, and the variable pointed to by \fIhline\fR is left unchanged.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   841
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   842
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   843
Beware that the string returned in \fIhline\fR->\fIline\fR is part of the history buffer, so it must not be modified by the caller, and will be recycled on the next call to any function that takes \fIgl\fR as its argument. Therefore you should make a private copy of this string if you need to keep it.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   844
.SS "Manual History Archival"
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   845
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   846
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   847
By default, whenever a line is entered by the user, it is automatically appended to the history list, just before \fBgl_get_line()\fR returns the line to the caller. This is convenient for the majority of applications, but there are also applications that need finer-grained control over what gets added to the history list. In such cases, the automatic addition of entered lines to the history list can be turned off by calling the \fBgl_automatic_history()\fR function.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   848
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   849
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   850
If this function is called with its \fIenable\fR argument set to 0, \fBgl_get_line()\fR will not automatically archive subsequently entered lines. Automatic archiving can be reenabled at a later time by calling this function again, with its \fIenable\fR argument set to 1. While automatic history archiving is disabled, the calling application can use the \fBgl_append_history()\fR to append lines to the history list as needed.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   851
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   852
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   853
The \fIline\fR argument specifies the line to be added to the history list. This must be a normal '\e0 ' terminated string. If this string contains any newline characters, the line that gets archived in the history list will be terminated by the first of these. Otherwise it will be terminated by the '\e0 ' terminator. If the line is longer than the maximum input line length that was specified when \fBnew_GetLine()\fR was called, it will be truncated to the actual \fBgl_get_line()\fR line length when the line is recalled.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   854
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   855
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   856
If successful, \fBgl_append_history()\fR returns 0. Otherwise it returns non-zero and sets \fBerrno\fR to one of the following values.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   857
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   858
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   859
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   860
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   861
\fB\fBEINVAL\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   862
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   863
.RS 10n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   864
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   865
One of the arguments passed to \fBgl_append_history()\fR was \fINULL\fR.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   866
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   867
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   868
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   869
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   870
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   871
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   872
\fB\fBENOMEM\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   873
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   874
.RS 10n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   875
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   876
The specified line was longer than the allocated size of the history buffer (as specified when \fBnew_GetLine()\fR was called), so it could not be archived.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   877
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   878
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   879
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   880
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   881
A textual description of the error can optionally be obtained by calling \fBgl_error_message()\fR. Note that after such an error, the history list remains in a valid state to receive new history lines, so there is little harm in simply ignoring the return status of \fBgl_append_history()\fR.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   882
.SS "Miscellaneous History Configuration"
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   883
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   884
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   885
If you wish to change the size of the history buffer that was originally specified in the call to \fBnew_GetLine()\fR, you can do so with the \fBgl_resize_history()\fR function.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   886
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   887
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   888
The \fIhistlen\fR argument specifies the new size in bytes, and if you specify this as 0, the buffer will be deleted.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   889
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   890
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   891
As mentioned in the discussion of \fBnew_GetLine()\fR, the number of lines that can be stored in the history buffer, depends on the lengths of the individual lines. For example, a 1000 byte buffer could equally store 10 lines of average length 100 bytes, or 20 lines of average length 50 bytes. Although the buffer is never expanded when new lines are added, a list of pointers into the buffer does get expanded when needed to accomodate the number of lines currently stored in the buffer. To place an upper limit on the number of lines in the buffer, and thus a ceiling on the amount of memory used in this list, you can call the \fBgl_limit_history()\fR function.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   892
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   893
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   894
The \fImax_lines\fR should either be a positive number >= 0, specifying an upper limit on the number of lines in the buffer, or be -1 to cancel any previously specified limit. When a limit is in effect, only the \fImax_lines\fR most recently appended lines are kept in the buffer. Older lines are discarded.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   895
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   896
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   897
To discard lines from the history buffer, use the \fBgl_clear_history()\fR function.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   898
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   899
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   900
The \fIall_groups\fR argument tells the function whether to delete just the lines associated with the current history group (see \fBgl_group_history()\fR) or all historical lines in the buffer.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   901
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   902
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   903
The \fBgl_toggle_history()\fR function allows you to toggle history on and off without losing the current contents of the history list.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   904
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   905
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   906
Setting the \fIenable\fR argument to 0 turns off the history mechanism, and setting it to 1 turns it back on. When history is turned off, no new lines will be added to the history list, and history lookup key-bindings will act as though there is nothing in the history buffer.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   907
.SS "Querying History Information"
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   908
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   909
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   910
The configured state of the history list can be queried with the \fBgl_history_state()\fR function. On return, the status information is recorded in the variable pointed to by the \fIstate\fR argument.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   911
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   912
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   913
The \fBgl_range_of_history()\fR function returns the number and range of lines in the history list. The return values are recorded in the variable pointed to by the range argument. If the \fInlines\fR member of this structure is greater than zero, then the oldest and newest members report the range of lines in the list, and \fInewest\fR=\fIoldest\fR+\fInlines\fR-1. Otherwise they are both zero.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   914
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   915
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   916
The \fBgl_size_of_history()\fR function returns the total size of the history buffer and the amount of the buffer that is currently occupied.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   917
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   918
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   919
On return, the size information is recorded in the variable pointed to by the \fIsize\fR argument.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   920
.SS "Changing Terminals"
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   921
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   922
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   923
The \fBnew_GetLine()\fR constructor function assumes that input is to be read from \fBstdin\fR and output written to \fBstdout\fR. The following function allows you to switch to different input and output streams.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   924
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   925
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   926
The \fIgl\fR argument is the object that was returned by \fBnew_GetLine()\fR. The \fIinput_fp\fR argument specifies the stream to read from, and \fIoutput_fp\fR specifies the stream to be written to. Only if both of these refer to a terminal, will interactive terminal input be enabled. Otherwise \fBgl_get_line()\fR will simply call \fBfgets()\fR to read command input. If both streams refer to a terminal, then they must refer to the same terminal, and the type of this terminal must be specified with the \fIterm\fR argument. The value of the \fIterm\fR argument is looked up in the terminal information database (\fBterminfo\fR or \fBtermcap\fR), in order to determine which special control sequences are needed to control various aspects of the terminal. \fBnew_GetLine()\fR for example, passes the return value of \fBgetenv\fR("TERM") in this argument. Note that if one or both of \fIinput_fp\fR and \fIoutput_fp\fR do not refer to a terminal, then it is legal to pass \fINULL\fR instead of a terminal type.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   927
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   928
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   929
Note that if you want to pass file descriptors to \fBgl_change_terminal()\fR, you can do this by creating \fBstdio\fR stream wrappers using the POSIX \fBfdopen\fR(3C) function.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   930
.SS "External Event Handling"
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   931
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   932
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   933
By default, \fBgl_get_line()\fR does not return until either a complete input line has been entered by the user, or an error occurs. In programs that need to watch for I/O from other sources than the terminal, there are two options.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   934
.RS +4
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   935
.TP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   936
.ie t \(bu
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   937
.el o
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   938
Use the functions described in the \fBgl_io_mode\fR(3TECLA) manual page to switch \fBgl_get_line()\fR into non-blocking server mode. In this mode, \fBgl_get_line()\fR becomes a non-blocking, incremental line-editing function that can safely be called from an external event loop. Although this is a very versatile method, it involves taking on some responsibilities that are normally performed behind the scenes by \fBgl_get_line()\fR.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   939
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   940
.RS +4
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   941
.TP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   942
.ie t \(bu
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   943
.el o
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   944
While \fBgl_get_line()\fR is waiting for keyboard input from the user, you can ask it to also watch for activity on arbitrary file descriptors, such as network sockets or pipes, and have it call functions of your choosing when activity is seen. This works on any system that has the select system call, which is most, if not all flavors of UNIX.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   945
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   946
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   947
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   948
Registering a file descriptor to be watched by \fBgl_get_line()\fR involves calling the \fBgl_watch_fd()\fR function. If this returns non-zero, then it means that either your arguments are invalid, or that this facility is not supported on the host system.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   949
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   950
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   951
The \fIfd\fR argument is the file descriptor to be watched. The event argument specifies what type of activity is of interest, chosen from the following enumerated values:
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   952
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   953
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   954
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   955
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   956
\fB\fBGLFD_READ\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   957
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   958
.RS 15n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   959
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   960
Watch for the arrival of data to be read.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   961
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   962
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   963
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   964
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   965
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   966
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   967
\fB\fBGLFD_WRITE\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   968
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   969
.RS 15n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   970
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   971
Watch for the ability to write to the file descriptor without blocking.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   972
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   973
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   974
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   975
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   976
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   977
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   978
\fB\fBGLFD_URGENT\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   979
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   980
.RS 15n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   981
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   982
Watch for the arrival of urgent out-of-band data on the file descriptor.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   983
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   984
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   985
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   986
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   987
The \fIcallback\fR argument is the function to call when the selected activity is seen. It should be defined with the following macro, which is defined in libtecla.h.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   988
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   989
.in +2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   990
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   991
#define GL_FD_EVENT_FN(fn) GlFdStatus (fn)(GetLine *gl, \
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   992
                                   void *data, int fd, GlFdEvent event)
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   993
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   994
.in -2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   995
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   996
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   997
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   998
The data argument of the \fBgl_watch_fd()\fR function is passed to the callback function for its own use, and can point to anything you like, including \fINULL\fR. The file descriptor and the event argument are also passed to the callback function, and this potentially allows the same callback function to be registered to more than one type of event and/or more than one file descriptor. The return value of the callback function should be one of the following values.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
   999
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1000
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1001
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1002
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1003
\fB\fBGLFD_ABORT\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1004
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1005
.RS 17n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1006
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1007
Tell \fBgl_get_line()\fR to abort. When this happens, \fBgl_get_line()\fR returns \fINULL\fR, and a following call to \fBgl_return_status()\fR will return \fBGLR_FDABORT\fR. Note that if the application needs \fBerrno\fR always to have a meaningful value when \fBgl_get_line()\fR returns \fINULL\fR, the callback function should set \fBerrno\fR appropriately.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1008
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1009
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1010
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1011
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1012
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1013
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1014
\fB\fBGLFD_REFRESH\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1015
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1016
.RS 17n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1017
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1018
Redraw the input line  then continue waiting for input. Return this if your callback wrote to the terminal.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1019
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1020
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1021
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1022
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1023
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1024
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1025
\fB\fBGLFD_CONTINUE\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1026
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1027
.RS 17n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1028
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1029
Continue to wait for input, without redrawing the line.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1030
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1031
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1032
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1033
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1034
Note that before calling the callback, \fBgl_get_line()\fR blocks most signals and leaves its own signal handlers installed, so if you need to catch a particular signal you will need to both temporarily install your own signal handler, and unblock the signal. Be sure to re-block the signal (if it was originally blocked) and reinstate the original signal handler, if any, before returning.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1035
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1036
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1037
Your callback should not try to read from the terminal, which is left in raw mode as far as input is concerned. You can write to the terminal as usual, since features like conversion of newline to carriage-return/linefeed are re-enabled while the callback is running. If your callback function does write to the terminal, be sure to output a newline first, and when your callback returns, tell \fBgl_get_line()\fR that the input line needs to be redrawn, by returning the \fBGLFD_REFRESH\fR status code.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1038
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1039
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1040
To remove a callback function that you previously registered for a given file descriptor and event, simply call \fBgl_watch_fd()\fR with the same \fIfd\fR and \fIevent\fR arguments, but with a \fIcallback\fR argument of 0. The \fIdata\fR argument is ignored in this case.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1041
.SS "Setting An Inactivity Timeout"
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1042
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1043
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1044
The \fBgl_inactivity_timeout()\fR function can be used to set or cancel an inactivity timeout. Inactivity in this case refers both to keyboard input, and to I/O on any file descriptors registered by prior and subsequent calls to \fBgl_watch_fd()\fR.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1045
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1046
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1047
The timeout is specified in the form of an integral number of seconds and an integral number of nanoseconds, specified by the \fIsec\fR and \fInsec\fR arguments, respectively. Subsequently, whenever no activity is seen for this time period, the function specified by the \fIcallback\fR argument is called. The \fIdata\fR argument of \fBgl_inactivity_timeout()\fR is passed to this callback function whenever it is invoked, and can thus be used to pass arbitrary application-specific information to the callback. The following macro is provided in <\fBlibtecla.h\fR> for applications to use to declare and prototype timeout callback functions.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1048
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1049
.in +2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1050
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1051
#define GL_TIMEOUT_FN(fn) GlAfterTimeout (fn)(GetLine *gl, void *data)
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1052
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1053
.in -2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1054
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1055
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1056
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1057
On returning, the application's callback is expected to return one of the following enumerators to tell \fBgl_get_line()\fR how to procede after the timeout has been handled by the callback.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1058
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1059
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1060
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1061
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1062
\fB\fBGLTO_ABORT\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1063
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1064
.RS 17n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1065
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1066
Tell \fBgl_get_line()\fR to abort. When this happens, \fBgl_get_line()\fR will return \fINULL\fR, and a following call to \fBgl_return_status()\fR will return \fBGLR_TIMEOUT\fR. Note that if the application needs \fBerrno\fR always to have a meaningful value when \fBgl_get_line()\fR returns \fINULL\fR, the callback function should set \fBerrno\fR appropriately.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1067
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1068
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1069
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1070
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1071
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1072
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1073
\fB\fBGLTO_REFRESH\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1074
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1075
.RS 17n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1076
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1077
Redraw the input line, then continue waiting for input. You should return this value if your callback wrote to the terminal.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1078
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1079
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1080
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1081
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1082
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1083
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1084
\fB\fBGLTO_CONTINUE\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1085
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1086
.RS 17n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1087
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1088
In normal blocking-I/O mode, continue to wait for input, without redrawing the user's input line. In non-blocking server I/O mode (see \fBgl_io_mode\fR(3TECLA)), \fBgl_get_line()\fR acts as though I/O blocked. This means that \fBgl_get_line()\fR will immediately return \fINULL\fR, and a following call to \fBgl_return_status()\fR will return \fBGLR_BLOCKED\fR.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1089
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1090
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1091
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1092
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1093
Note that before calling the callback, \fBgl_get_line()\fR blocks most signals and leaves its own signal handlers installed, so if you need to catch a particular signal you will need to both temporarily install your own signal handler and unblock the signal. Be sure to re-block the signal (if it was originally blocked) and reinstate the original signal handler, if any, before returning.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1094
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1095
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1096
Your callback should not try to read from the terminal, which is left in raw mode as far as input is concerned. You can however write to the terminal as usual, since features like conversion of newline to carriage-return/linefeed are re-enabled while the callback is running. If your callback function does write to the terminal, be sure to output a newline first, and when your callback returns, tell \fBgl_get_line()\fR that the input line needs to be redrawn, by returning the \fBGLTO_REFRESH\fR status code.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1097
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1098
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1099
Finally, note that although the timeout arguments include a nanosecond component, few computer clocks presently have resolutions that are finer than a few milliseconds, so asking for less than a few milliseconds is equivalent to requesting zero seconds on many systems. If this would be a problem, you should base your timeout selection on the actual resolution of the host clock (for example, by calling \fBsysconf\fR(\fB_SC_CLK_TCK\fR)).
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1100
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1101
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1102
To turn off timeouts, simply call \fBgl_inactivity_timeout()\fR with a \fIcallback\fR argument of 0. The \fIdata\fR argument is ignored in this case.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1103
.SS "Signal Handling Defaults"
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1104
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1105
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1106
By default, the \fBgl_get_line()\fR function intercepts a number of signals. This is particularly important for signals that would by default terminate the process, since the terminal needs to be restored to a usable state before this happens. This section describes the signals that are trapped by default and how \fBgl_get_line()\fR responds to them. Changing these defaults is the topic of the following section.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1107
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1108
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1109
When the following subset of signals are caught, \fBgl_get_line()\fR first restores the terminal settings and signal handling to how they were before \fBgl_get_line()\fR was called, resends the signal to allow the calling application's signal handlers to handle it, then, if the process still exists, returns \fINULL\fR and sets \fBerrno\fR as specified below.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1110
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1111
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1112
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1113
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1114
\fB\fBSIGINT\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1115
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1116
.RS 11n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1117
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1118
This signal is generated both by the keyboard interrupt key (usually \fB^C\fR), and the keyboard break key. The \fBerrno\fR value is \fBEINTR\fR.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1119
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1120
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1121
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1122
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1123
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1124
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1125
\fB\fBSIGHUP\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1126
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1127
.RS 11n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1128
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1129
This signal is generated when the controlling terminal exits. The \fBerrno\fR value is \fBENOTTY\fR.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1130
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1131
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1132
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1133
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1134
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1135
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1136
\fB\fBSIGPIPE\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1137
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1138
.RS 11n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1139
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1140
This signal is generated when a program attempts to write to a pipe whose remote end is not being read by any process. This can happen for example if you have called \fBgl_change_terminal()\fR to redirect output to a pipe hidden under a pseudo terminal. The \fBerrno\fR value is \fBEPIPE\fR.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1141
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1142
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1143
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1144
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1145
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1146
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1147
\fB\fBSIGQUIT\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1148
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1149
.RS 11n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1150
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1151
This signal is generated by the keyboard quit key (usually \fB^\\fR). The \fBerrno\fR value is \fBEINTR\fR.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1152
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1153
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1154
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1155
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1156
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1157
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1158
\fB\fBSIGABRT\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1159
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1160
.RS 11n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1161
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1162
This signal is generated by the standard C, abort function. By default it both terminates the process and generates a core dump. The \fBerrno\fR value is \fBEINTR\fR.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1163
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1164
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1165
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1166
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1167
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1168
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1169
\fB\fBSIGTERM\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1170
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1171
.RS 11n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1172
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1173
This is the default signal that the UNIX kill command sends to processes. The \fBerrno\fR value is \fBEINTR\fR.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1174
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1175
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1176
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1177
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1178
Note that in the case of all of the above signals, POSIX mandates that by default the process is terminated, with the addition of a core dump in the case of the \fBSIGQUIT\fR signal. In other words, if the calling application does not override the default handler by supplying its own signal handler, receipt of the corresponding signal will terminate the application before \fBgl_get_line()\fR returns.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1179
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1180
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1181
If \fBgl_get_line()\fR aborts with \fBerrno\fR set to \fBEINTR\fR, you can find out what signal caused it to abort, by calling the \fBgl_last_signal()\fR function. This returns the numeric code (for example, \fBSIGINT\fR) of the last signal that was received during the most recent call to \fBgl_get_line()\fR, or -1 if no signals were received.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1182
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1183
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1184
On systems that support it, when a \fBSIGWINCH\fR (window change) signal is received, \fBgl_get_line()\fR queries the terminal to find out its new size, redraws the current input line to accomodate the new size, then returns to waiting for keyboard input from the user. Unlike other signals, this signal is not resent to the application.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1185
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1186
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1187
Finally, the following signals cause \fBgl_get_line()\fR to first restore the terminal and signal environment to that which prevailed before \fBgl_get_line()\fR was called, then resend the signal to the application. If the process still exists after the signal has been delivered, then \fBgl_get_line()\fR then re-establishes its own signal handlers, switches the terminal back to raw mode, redisplays the input line, and goes back to awaiting terminal input from the user.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1188
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1189
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1190
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1191
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1192
\fB\fBSIGCONT\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1193
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1194
.RS 13n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1195
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1196
This signal is generated when a suspended process is resumed.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1197
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1198
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1199
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1200
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1201
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1202
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1203
\fB\fBSIGPOLL\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1204
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1205
.RS 13n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1206
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1207
On SVR4 systems, this signal notifies the process of an asynchronous I/O event. Note that under 4.3+BSD, \fBSIGIO\fR and \fBSIGPOLL\fR are the same. On other systems, \fBSIGIO\fR is ignored by default, so \fBgl_get_line()\fR does not trap it by default.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1208
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1209
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1210
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1211
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1212
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1213
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1214
\fB\fBSIGPWR\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1215
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1216
.RS 13n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1217
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1218
This signal is generated when a power failure occurs (presumably when the system is on a UPS).
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1219
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1220
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1221
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1222
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1223
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1224
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1225
\fB\fBSIGALRM\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1226
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1227
.RS 13n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1228
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1229
This signal is generated when a timer expires.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1230
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1231
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1232
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1233
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1234
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1235
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1236
\fB\fBSIGUSR1\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1237
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1238
.RS 13n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1239
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1240
An application specific signal.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1241
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1242
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1243
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1244
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1245
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1246
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1247
\fB\fBSIGUSR2\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1248
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1249
.RS 13n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1250
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1251
Another application specific signal.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1252
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1253
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1254
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1255
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1256
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1257
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1258
\fB\fBSIGVTALRM\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1259
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1260
.RS 13n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1261
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1262
This signal is generated when a virtual timer expires. See \fBsetitimer\fR(2).
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1263
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1264
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1265
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1266
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1267
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1268
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1269
\fB\fBSIGXCPU\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1270
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1271
.RS 13n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1272
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1273
This signal is generated when a process exceeds its soft CPU time limit.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1274
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1275
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1276
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1277
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1278
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1279
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1280
\fB\fBSIGXFSZ\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1281
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1282
.RS 13n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1283
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1284
This signal is generated when a process exceeds its soft file-size limit.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1285
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1286
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1287
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1288
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1289
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1290
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1291
\fB\fBSIGTSTP\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1292
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1293
.RS 13n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1294
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1295
This signal is generated by the terminal suspend key, which is usually \fB^Z\fR, or the delayed terminal suspend key, which is usually \fB^Y\fR.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1296
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1297
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1298
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1299
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1300
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1301
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1302
\fB\fBSIGTTIN\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1303
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1304
.RS 13n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1305
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1306
This signal is generated if the program attempts to read from the terminal while the program is running in the background.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1307
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1308
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1309
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1310
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1311
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1312
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1313
\fB\fBSIGTTOU\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1314
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1315
.RS 13n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1316
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1317
This signal is generated if the program attempts to write to the terminal while the program is running in the background.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1318
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1319
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1320
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1321
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1322
Obviously not all of the above signals are supported on all systems, so code to support them is conditionally compiled into the tecla library.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1323
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1324
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1325
Note that if \fBSIGKILL\fR or \fBSIGPOLL\fR, which by definition cannot be caught, or any of the hardware generated exception signals, such as \fBSIGSEGV\fR, \fBSIGBUS\fR, and \fBSIGFPE\fR, are received and unhandled while \fBgl_get_line()\fR has the terminal in raw mode, the program will be terminated without the terminal having been restored to a usable state. In practice, job-control shells usually reset the terminal settings when a process relinquishes the controlling terminal, so this is only a problem with older shells.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1326
.SS "Customized Signal Handling"
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1327
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1328
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1329
The previous section listed the signals that \fBgl_get_line()\fR traps by default, and described how it responds to them. This section describes how to both add and remove signals from the list of trapped signals, and how to specify how \fBgl_get_line()\fR should respond to a given signal.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1330
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1331
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1332
If you do not need \fBgl_get_line()\fR to do anything in response to a signal that it normally traps, you can tell to \fBgl_get_line()\fR to ignore that signal by calling \fBgl_ignore_signal()\fR.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1333
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1334
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1335
The \fIsigno\fR argument is the number of the signal (for example, \fBSIGINT\fR) that you want to have ignored. If the specified signal is not currently one of those being trapped, this function does nothing.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1336
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1337
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1338
The \fBgl_trap_signal()\fR function allows you to either add a new signal to the list that \fBgl_get_line()\fR traps or modify how it responds to a signal that it already traps.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1339
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1340
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1341
The \fIsigno\fR argument is the number of the signal that you want to have trapped. The \fIflags\fR argument is a set of flags that determine the environment in which the application's signal handler is invoked. The \fIafter\fR argument tells \fBgl_get_line()\fR what to do after the application's signal handler returns. The \fIerrno_value\fR tells \fBgl_get_line()\fR what to set \fBerrno\fR to if told to abort.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1342
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1343
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1344
The \fIflags\fR argument is a bitwise OR of zero or more of the following enumerators:
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1345
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1346
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1347
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1348
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1349
\fB\fBGLS_RESTORE_SIG\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1350
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1351
.RS 20n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1352
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1353
Restore the caller's signal environment while handling the signal.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1354
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1355
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1356
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1357
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1358
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1359
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1360
\fB\fBGLS_RESTORE_TTY\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1361
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1362
.RS 20n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1363
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1364
Restore the caller's terminal settings while handling the signal.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1365
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1366
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1367
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1368
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1369
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1370
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1371
\fB\fBGLS_RESTORE_LINE\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1372
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1373
.RS 20n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1374
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1375
Move the cursor to the start of the line following the input line before invoking the application's signal handler.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1376
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1377
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1378
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1379
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1380
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1381
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1382
\fB\fBGLS_REDRAW_LINE\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1383
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1384
.RS 20n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1385
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1386
Redraw the input line when the application's signal handler returns.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1387
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1388
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1389
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1390
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1391
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1392
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1393
\fB\fBGLS_UNBLOCK_SIG\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1394
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1395
.RS 20n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1396
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1397
Normally, if the calling program has a signal blocked (see \fBsigprocmask\fR(2)), \fBgl_get_line()\fR does not trap that signal. This flag tells \fBgl_get_line()\fR to trap the signal and unblock it for the duration of the call to \fBgl_get_line()\fR.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1398
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1399
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1400
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1401
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1402
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1403
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1404
\fB\fBGLS_DONT_FORWARD\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1405
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1406
.RS 20n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1407
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1408
If this flag is included, the signal will not be forwarded to the signal handler of the calling program.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1409
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1410
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1411
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1412
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1413
Two commonly useful flag combinations are also enumerated as follows:
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1414
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1415
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1416
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1417
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1418
\fB\fBGLS_RESTORE_ENV\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1419
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1420
.RS 21n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1421
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1422
\fBGLS_RESTORE_SIG\fR | \fBGLS_RESTORE_TTY\fR |\fBGLS_REDRAW_LINE\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1423
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1424
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1425
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1426
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1427
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1428
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1429
\fB\fBGLS_SUSPEND_INPUT\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1430
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1431
.RS 21n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1432
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1433
\fBGLS_RESTORE_ENV\fR | \fBGLS_RESTORE_LINE\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1434
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1435
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1436
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1437
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1438
If your signal handler, or the default system signal handler for this signal, if you have not overridden it, never either writes to the terminal, nor suspends or terminates the calling program, then you can safely set the \fIflags\fR argument to 0.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1439
.RS +4
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1440
.TP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1441
.ie t \(bu
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1442
.el o
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1443
The cursor does not get left in the middle of the input line.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1444
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1445
.RS +4
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1446
.TP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1447
.ie t \(bu
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1448
.el o
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1449
So that the user can type in input and have it echoed.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1450
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1451
.RS +4
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1452
.TP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1453
.ie t \(bu
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1454
.el o
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1455
So that you do not need to end each output line with \er\en, instead of just \en.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1456
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1457
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1458
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1459
The \fBGL_RESTORE_ENV\fR combination is the same as \fBGL_SUSPEND_INPUT\fR, except that it does not move the cursor. If your signal handler does not read or write anything to the terminal, the user will not see any visible indication that a signal was caught. This can be useful if you have a signal handler that only occasionally writes to the terminal, where using \fBGL_SUSPEND_LINE\fR would cause the input line to be unnecessarily duplicated when nothing had been written to the terminal. Such a signal handler, when it does write to the terminal, should be sure to start a new line at the start of its first write, by writing a new line before returning. If the signal arrives while the user is entering a line that only occupies a signal terminal line, or if the cursor is on the last terminal line of a longer input line, this will have the same effect as \fBGL_SUSPEND_INPUT\fR. Otherwise it will start writing on a line that already contains part of the displayed input line. This does not do any harm, but it looks a bit ugly, which is why the \fBGL_SUSPEND_INPUT\fR combination is better if you know that you are always going to be writting to the terminal.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1460
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1461
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1462
The \fIafter\fR argument, which determines what \fBgl_get_line()\fR does after the application's signal handler returns (if  it returns), can take any one of the following values:
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1463
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1464
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1465
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1466
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1467
\fB\fBGLS_RETURN\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1468
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1469
.RS 16n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1470
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1471
Return the completed input line, just as though the user had pressed the return key.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1472
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1473
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1474
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1475
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1476
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1477
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1478
\fB\fBGLS_ABORT\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1479
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1480
.RS 16n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1481
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1482
Cause \fBgl_get_line()\fR to abort. When this happens, \fBgl_get_line()\fR returns \fINULL\fR, and a following call to \fBgl_return_status()\fR will return \fBGLR_SIGNAL\fR. Note that if the application needs \fBerrno\fR always to have a meaningful value when \fBgl_get_line()\fR returns \fINULL\fR, the callback function should set \fBerrno\fR appropriately.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1483
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1484
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1485
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1486
.ne 2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1487
.mk
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1488
.na
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1489
\fB\fBGLS_CONTINUE\fR\fR
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1490
.ad
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1491
.RS 16n
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1492
.rt  
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1493
Resume command line editing.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1494
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1495
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1496
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1497
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1498
The \fIerrno_value\fR argument is intended to be combined with the \fBGLS_ABORT\fR option, telling \fBgl_get_line()\fR what to set the standard \fBerrno\fR variable to before returning \fINULL\fR to the calling program. It can also, however, be used with the \fBGL_RETURN\fR option, in case you want to have a way to distinguish between an input line that was entered using the return key, and one that was entered by the receipt of a signal.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1499
.SS "Reliable Signal Handling"
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1500
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1501
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1502
Signal handling is suprisingly hard to do reliably without race conditions. In \fBgl_get_line()\fR a lot of care has been taken to allow applications to perform reliable signal handling around \fBgl_get_line()\fR. This section explains how to make use of this.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1503
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1504
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1505
As an example of the problems that can arise if the application is not written correctly, imagine that one's application has a \fBSIGINT\fR signal handler that sets a global flag. Now suppose that the application tests this flag just before invoking \fBgl_get_line()\fR. If a \fBSIGINT\fR signal happens to be received in the small window of time between the statement that tests the value of this flag, and the statement that calls \fBgl_get_line()\fR, then \fBgl_get_line()\fR will not see the signal, and will not be interrupted. As a result, the application will not be able to respond to the signal until the user gets around to finishing entering the input line and \fBgl_get_line()\fR returns. Depending on the application, this might or might not be a disaster, but at the very least it would puzzle the user.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1506
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1507
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1508
The way to avoid such problems is to do the following.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1509
.RS +4
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1510
.TP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1511
1.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1512
If needed, use the \fBgl_trap_signal()\fR function to configure \fBgl_get_line()\fR to abort when important signals are caught.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1513
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1514
.RS +4
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1515
.TP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1516
2.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1517
Configure \fBgl_get_line()\fR such that if any of the signals that it catches are blocked when \fBgl_get_line()\fR is called, they will be unblocked automatically during times when \fBgl_get_line()\fR is waiting for I/O. This can be done either on a per signal basis, by calling the \fBgl_trap_signal()\fR function, and specifying the \fBGLS_UNBLOCK\fR attribute of the signal, or globally by calling the \fBgl_catch_blocked()\fR function. This function simply adds the \fBGLS_UNBLOCK\fR attribute to all of the signals that it is currently configured to trap.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1518
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1519
.RS +4
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1520
.TP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1521
3.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1522
Just before calling \fBgl_get_line()\fR, block delivery of all of the signals that \fBgl_get_line()\fR is configured to trap. This can be done using the POSIX sigprocmask function in conjunction with the \fBgl_list_signals()\fR function. This function returns the set of signals that it is currently configured to catch in the set argument, which is in the form required by \fBsigprocmask\fR(2).
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1523
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1524
.RS +4
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1525
.TP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1526
4.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1527
In the example, one would now test the global flag that the signal handler sets, knowing that there is now no danger of this flag being set again until \fBgl_get_line()\fR unblocks its signals while performing I/O.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1528
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1529
.RS +4
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1530
.TP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1531
5.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1532
Eventually \fBgl_get_line()\fR returns, either because a signal was caught, an error occurred, or the user finished entering their input line.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1533
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1534
.RS +4
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1535
.TP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1536
6.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1537
Now one would check the global signal flag again, and if it is set, respond to it, and zero the flag.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1538
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1539
.RS +4
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1540
.TP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1541
7.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1542
Use \fBsigprocmask()\fR to unblock the signals that were blocked in step 3.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1543
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1544
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1545
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1546
The same technique can be used around certain POSIX signal-aware functions, such as \fBsigsetjmp\fR(3C) and \fBsigsuspend\fR(2), and in particular, the former of these two functions can be used in conjunction with \fBsiglongjmp\fR(3C) to implement race-condition free signal handling around other long-running system calls. The \fBgl_get_line()\fR function manages to reliably trap signals around calls to functions like \fBread\fR(2) and \fBselect\fR(3C) without race conditions.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1547
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1548
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1549
The \fBgl_get_line()\fR function first uses the POSIX \fBsigprocmask()\fR function to block the delivery of all of the signals that it is currently configured to catch. This is redundant if the application has already blocked them, but it does no harm. It undoes this step just before returning.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1550
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1551
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1552
Whenever \fBgl_get_line()\fR needs to call read or select to wait for input from the user, it first calls the POSIX \fBsigsetjmp()\fR function, being sure to specify a non-zero value for its \fIsavemask\fR argument.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1553
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1554
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1555
If \fBsigsetjmp()\fR returns zero, \fBgl_get_line()\fR then does the following.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1556
.RS +4
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1557
.TP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1558
1.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1559
It uses the POSIX \fBsigaction\fR(2) function to register a temporary signal handler to all of the signals that it is configured to catch. This signal handler does two things.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1560
.RS +4
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1561
.TP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1562
a.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1563
It records the number of the signal that was received in a file-scope variable.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1564
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1565
.RS +4
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1566
.TP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1567
b.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1568
It then calls the POSIX \fBsiglongjmp()\fR function using the buffer that was passed to \fBsigsetjmp()\fR for its first argument and a non-zero value for its second argument.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1569
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1570
When this signal handler is registered, the \fIsa_mask\fR member of the \fBstruct sigaction\fR \fIact\fR argument of the call to \fBsigaction()\fR is configured to contain all of the signals that \fBgl_get_line()\fR is catching. This ensures that only one signal will be caught at once by our signal handler, which in turn ensures that multiple instances of our signal handler do not tread on each other's toes.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1571
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1572
.RS +4
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1573
.TP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1574
2.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1575
Now that the signal handler has been set up, \fBgl_get_line()\fR unblocks all of the signals that it is configured to catch.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1576
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1577
.RS +4
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1578
.TP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1579
3.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1580
It then calls the \fBread()\fR or \fBselect()\fR function to wait for keyboard input.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1581
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1582
.RS +4
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1583
.TP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1584
4.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1585
If this function returns (that is, no signal is received), \fBgl_get_line()\fR blocks delivery of the signals of interest again.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1586
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1587
.RS +4
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1588
.TP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1589
5.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1590
It then reinstates the signal handlers that were displaced by the one that was just installed.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1591
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1592
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1593
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1594
Alternatively, if \fBsigsetjmp()\fR returns non-zero, this means that one of the signals being trapped was caught while the above steps were executing. When this happens, \fBgl_get_line()\fR does the following.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1595
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1596
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1597
First, note that when a call to \fBsiglongjmp()\fR causes \fBsigsetjmp()\fR to return, provided that the \fIsavemask\fR argument of \fBsigsetjmp()\fR was non-zero, the signal process mask is restored to how it was when \fBsigsetjmp()\fR was called. This is the important difference between \fBsigsetjmp()\fR and the older problematic \fBsetjmp\fR(3C), and is the essential ingredient that makes it possible to avoid signal handling race conditions. Because of this we are guaranteed that all of the signals that we blocked before calling \fBsigsetjmp()\fR are blocked again as soon as any signal is caught. The following statements, which are then executed, are thus guaranteed to be executed without any further signals being caught.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1598
.RS +4
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1599
.TP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1600
1.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1601
If so instructed by the \fBgl_get_line()\fR configuration attributes of the signal that was caught, \fBgl_get_line()\fR restores the terminal attributes to the state that they had when \fBgl_get_line()\fR was called. This is particularly important for signals that suspend or terminate the process, since otherwise the terminal would be left in an unusable state.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1602
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1603
.RS +4
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1604
.TP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1605
2.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1606
It then reinstates the application's signal handlers.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1607
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1608
.RS +4
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1609
.TP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1610
3.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1611
Then it uses the C standard-library \fBraise\fR(3C) function to re-send the application the signal that was caught.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1612
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1613
.RS +4
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1614
.TP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1615
4.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1616
Next it unblocks delivery of the signal that we just sent. This results in the signal that was just sent by \fBraise()\fR being caught by the application's original signal handler, which can now handle it as it sees fit.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1617
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1618
.RS +4
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1619
.TP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1620
5.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1621
If the signal handler returns (that is, it does not terminate the process), \fBgl_get_line()\fR blocks delivery of the above signal again.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1622
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1623
.RS +4
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1624
.TP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1625
6.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1626
It then undoes any actions performed in the first of the above steps and redisplays the line, if the signal configuration calls for this.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1627
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1628
.RS +4
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1629
.TP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1630
7.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1631
\fBgl_get_line()\fR then either resumes trying to read a character, or aborts, depending on the configuration of the signal that was caught.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1632
.RE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1633
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1634
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1635
What the above steps do in essence is to take asynchronously delivered signals and handle them synchronously, one at a time, at a point in the code where \fBgl_get_line()\fR has complete control over its environment.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1636
.SS "The Terminal Size"
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1637
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1638
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1639
On most systems the combination of the \fBTIOCGWINSZ\fR ioctl and the \fBSIGWINCH\fR signal is used to maintain an accurate idea of the terminal size. The terminal size is newly queried every time that \fBgl_get_line()\fR is called and whenever a \fBSIGWINCH\fR signal is received.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1640
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1641
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1642
On the few systems where this mechanism is not available, at startup \fBnew_GetLine()\fR first looks for the \fBLINES\fR and \fBCOLUMNS\fR environment variables. If these are not found, or they contain unusable values, then if a terminal information database like \fBterminfo\fR or \fBtermcap\fR is available, the default size of the terminal is looked up in this database. If this too fails to provide the terminal size, a default size of 80 columns by 24 lines is used.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1643
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1644
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1645
Even on systems that do support ioctl(\fBTIOCGWINSZ\fR), if the terminal is on the other end of a serial line, the terminal driver generally has no way of detecting when a resize occurs or of querying what the current size is. In such cases no \fBSIGWINCH\fR is sent to the process, and the dimensions returned by ioctl(\fBTIOCGWINSZ\fR) are not correct. The only way to handle such instances is to provide a way for the user to enter a command that tells the remote system what the new size is. This command would then call the \fBgl_set_term_size()\fR function to tell \fBgl_get_line()\fR about the change in size.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1646
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1647
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1648
The \fIncolumn\fR and \fInline\fR arguments are used to specify the new dimensions of the terminal, and must not be less than 1. On systems that do support ioctl(\fBTIOCGWINSZ\fR), this function first calls ioctl(\fBTIOCSWINSZ\fR) to tell the terminal driver about the change in size. In non-blocking server-I/O mode, if a line is currently being input, the input line is then redrawn to accomodate the changed size. Finally the new values are recorded in \fIgl\fR for future use by \fBgl_get_line()\fR.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1649
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1650
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1651
The \fBgl_terminal_size()\fR function allows you to query the current size of the terminal, and install an alternate fallback size for cases where the size is not available. Beware that the terminal size will not be available if reading from a pipe or a file, so the default values can be important even on systems that do support ways of finding out the terminal size.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1652
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1653
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1654
This function first updates \fBgl_get_line()\fR's fallback terminal dimensions, then records its findings in the return value.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1655
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1656
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1657
The \fIdef_ncolumn\fR and \fIdef_nline\fR arguments specify the default number of terminal columns and lines to use if the terminal size cannot be determined by ioctl(\fBTIOCGWINSZ\fR) or environment variables.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1658
.SS "Hiding What You Type"
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1659
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1660
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1661
When entering sensitive information, such as passwords, it is best not to have the text that you are entering echoed on the terminal. Furthermore, such text should not be recorded in the history list, since somebody finding your terminal unattended could then recall it, or somebody snooping through your directories could see it in your history file. With this in mind, the \fBgl_echo_mode()\fR function allows you to toggle on and off the display and archival of any text that is subsequently entered in calls to \fBgl_get_line()\fR.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1662
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1663
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1664
The \fIenable\fR argument specifies whether entered text should be visible or not. If it is 0, then subsequently entered lines will not be visible on the terminal, and will not be recorded in the history list. If it is 1, then subsequent input lines will be displayed as they are entered, and provided that history has not been turned off with a call to \fBgl_toggle_history()\fR, then they will also be archived in the history list. Finally, if the enable argument is -1, then the echoing mode is left unchanged, which allows you to non-destructively query the current setting through the return value. In all cases, the return value of the function is 0 if echoing was disabled before the function was called, and 1 if it was enabled.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1665
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1666
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1667
When echoing is turned off, note that although tab completion will invisibly complete your prefix as far as possible, ambiguous completions will not be displayed.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1668
.SS "Single Character Queries"
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1669
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1670
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1671
Using \fBgl_get_line()\fR to query the user for a single character reply, is inconvenient for the user, since they must hit the enter or return key before the character that they typed is returned to the program. Thus the \fBgl_query_char()\fR function has been provided for single character queries like this.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1672
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1673
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1674
This function displays the specified prompt at the start of a new line, and waits for the user to type a character. When the user types a character, \fBgl_query_char()\fR displays it to the right of the prompt, starts a newline, then returns the character to the calling program. The return value of the function is the character that was typed. If the read had to be aborted for some reason, EOF is returned instead. In the latter case, the application can call the previously documented \fBgl_return_status()\fR, to find out what went wrong. This could, for example, have been the reception of a signal, or the optional inactivity timer going off.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1675
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1676
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1677
If the user simply hits enter, the value of the \fIdefchar\fR argument is substituted. This means that when the user hits either newline or return, the character specified in \fIdefchar\fR, is displayed after the prompt, as though the user had typed it, as well as being returned to the calling application. If such a replacement is not important, simply pass '\en' as the value of \fIdefchar\fR.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1678
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1679
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1680
If the entered character is an unprintable character, it is displayed symbolically. For example, control-A is displayed as \fB^A\fR, and characters beyond 127 are displayed in octal, preceded by a backslash.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1681
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1682
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1683
As with \fBgl_get_line()\fR, echoing of the entered character can be disabled using the \fBgl_echo_mode()\fR function.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1684
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1685
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1686
If the calling process is suspended while waiting for the user to type their response, the cursor is moved to the line following the prompt line, then when the process resumes, the prompt is redisplayed, and \fBgl_query_char()\fR resumes waiting for the user to type a character.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1687
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1688
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1689
Note that in non-blocking server mode, if an incomplete input line is in the process of being read when \fBgl_query_char()\fR is called, the partial input line is discarded, and erased from the terminal, before the new prompt is displayed. The next call to \fBgl_get_line()\fR will thus start editing a new line.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1690
.SS "Reading Raw Characters"
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1691
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1692
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1693
Whereas the \fBgl_query_char()\fR function visibly prompts the user for a character, and displays what they typed, the \fBgl_read_char()\fR function reads a signal character from the user, without writing anything to the terminal, or perturbing any incompletely entered input line. This means that it can be called not only from between calls to \fBgl_get_line()\fR, but also from callback functions that the application has registered to be called by \fBgl_get_line()\fR.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1694
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1695
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1696
On success, the return value of \fBgl_read_char()\fR is the character that was read. On failure, EOF is returned, and the \fBgl_return_status()\fR function can be called to find out what went wrong. Possibilities include the optional inactivity timer going off, the receipt of a signal that is configured to abort \fBgl_get_line()\fR, or terminal I/O blocking, when in non-blocking server-I/O mode.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1697
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1698
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1699
Beware that certain keyboard keys, such as function keys, and cursor keys, usually generate at least three characters each, so a single call to \fBgl_read_char()\fR will not be enough to identify such keystrokes.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1700
.SS "Clearing The Terminal"
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1701
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1702
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1703
The calling program can clear the terminal by calling \fBgl_erase_terminal()\fR. In non-blocking server-I/O mode, this function also arranges for the current input line to be redrawn from scratch when \fBgl_get_line()\fR is next called.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1704
.SS "Displaying Text Dynamically"
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1705
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1706
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1707
Between calls to \fBgl_get_line()\fR, the \fBgl_display_text()\fR function provides a convenient way to display paragraphs of text, left-justified and split over one or more terminal lines according to the constraints of the current width of the terminal. Examples of the use of this function may be found in the demo programs, where it is used to display introductions. In those examples the advanced use  of optional prefixes, suffixes and filled lines to draw a box around the text is also illustrated.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1708
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1709
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1710
If \fIgl\fR is not currently connected to a terminal, for example if the output of a program that uses \fBgl_get_line()\fR is being piped to another program or redirected to a file, then the value of the \fIdef_width\fR parameter is used as the terminal width.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1711
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1712
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1713
The \fIindentation\fR argument specifies the number of characters to use to indent each line of ouput. The \fIfill_char\fR argument specifies the character that will be used to perform this indentation.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1714
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1715
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1716
The \fIprefix\fR argument can be either \fINULL\fR or a string to place at the beginning of each new line (after any indentation). Similarly, the \fIsuffix\fR argument can be either \fINULL\fR or a string to place at the end of each line. The suffix is placed flush against the right edge of the terminal, and any space between its first character and the last word on that line is filled with the character specified by the \fIfill_char\fR argument. Normally the fill-character is a space.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1717
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1718
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1719
The \fIstart\fR argument tells \fBgl_display_text()\fR how many characters have already been written to the current terminal line, and thus tells it the starting column index of the cursor. Since the return value of \fBgl_display_text()\fR is the ending column index of the cursor, by passing the return value of one call to the start argument of the next call, a paragraph that is broken between more than one string can be composed by calling \fBgl_display_text()\fR for each successive portion of the paragraph. Note that literal newline characters are necessary at the end of each paragraph to force a new line to be started.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1720
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1721
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1722
On error, \fBgl_display_text()\fR returns -1.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1723
.SS "Callback Function Facilities"
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1724
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1725
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1726
Unless otherwise stated, callback functions such as tab completion callbacks and event callbacks should not call any functions in this module. The following functions, however, are designed specifically to be used by callback functions.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1727
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1728
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1729
Calling the \fBgl_replace_prompt()\fR function from a callback tells \fBgl_get_line()\fR to display a different prompt when the callback returns. Except in non-blocking server mode, it has no effect if used between calls to \fBgl_get_line()\fR. In non-blocking server mode, when used between two calls to \fBgl_get_line()\fR that are operating on the same input line, the current input line will be re-drawn with the new prompt on the following call to \fBgl_get_line()\fR.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1730
.SS "International Character Sets"
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1731
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1732
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1733
Since \fBlibtecla\fR(3LIB) version 1.4.0, \fBgl_get_line()\fR has been 8-bit clean. This means that all 8-bit characters that are printable in the user's current locale are now displayed verbatim and included in the returned input line. Assuming that the calling program correctly contains a call like the following,
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1734
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1735
.in +2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1736
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1737
setlocale(LC_CTYPE, "")
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1738
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1739
.in -2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1740
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1741
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1742
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1743
then the current locale is determined by the first of the environment variables \fBLC_CTYPE\fR, \fBLC_ALL\fR, and \fBLANG\fR that is found to contain a valid locale name. If none of these variables are defined, or the program neglects to call \fBsetlocale\fR(3C), then the default C locale is used, which is US 7-bit ASCII. On most UNIX-like platforms, you can get a list of valid locales by typing the command:
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1744
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1745
.in +2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1746
.nf
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1747
locale -a
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1748
.fi
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1749
.in -2
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1750
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1751
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1752
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1753
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1754
at the shell prompt. Further documentation on how the user can make use of this to enter international characters can be found in the \fBtecla\fR(5) man page.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1755
.SS "Thread Safety"
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1756
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1757
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1758
Unfortunately neither \fBterminfo\fR nor \fBtermcap\fR were designed to be reentrant, so you cannot safely use the functions of the getline module in multiple threads (you can use the separate file-expansion and word-completion  modules in multiple threads, see the corresponding man pages for details). However due to the use of POSIX reentrant functions for looking up home directories, it is safe to use this module from a single thread of a multi-threaded program, provided that your other threads do not use any \fBtermcap\fR or \fBterminfo\fR functions.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1759
.SH ATTRIBUTES
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1760
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1761
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1762
See \fBattributes\fR(5) for descriptions of the following attributes:
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1763
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1764
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1765
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1766
.TS
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1767
tab() box;
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1768
cw(2.75i) |cw(2.75i) 
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1769
lw(2.75i) |lw(2.75i) 
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1770
.
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1771
ATTRIBUTE TYPEATTRIBUTE VALUE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1772
_
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1773
Interface StabilityCommitted
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1774
_
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1775
MT-LevelMT-Safe
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1776
.TE
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1777
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1778
.SH SEE ALSO
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1779
.sp
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1780
.LP
7c568e880861 7143177 move libtecla from ON to Userland (Userland portion)
John Beck <John.Beck@Oracle.COM>
parents:
diff changeset
  1781
\fBcpl_complete_word\fR(3TECLA), \fBef_expand_file\fR(3TECLA), \fBgl_io_mode\fR(3TECLA), \fBlibtecla\fR(3LIB), \fBpca_lookup_file\fR(3TECLA), \fBattributes\fR(5), \fBtecla\fR(5)