1*30b89059Srillig.\" $NetBSD: msgc.1,v 1.27 2021/10/11 18:08:12 rillig Exp $ 2584c2298Sphil.\" 3584c2298Sphil.\" Copyright 1997 Piermont Information Systems Inc. 4584c2298Sphil.\" All rights reserved. 5584c2298Sphil.\" 6584c2298Sphil.\" Written by Philip A. Nelson for Piermont Information Systems Inc. 7584c2298Sphil.\" 8584c2298Sphil.\" Redistribution and use in source and binary forms, with or without 9584c2298Sphil.\" modification, are permitted provided that the following conditions 10584c2298Sphil.\" are met: 11584c2298Sphil.\" 1. Redistributions of source code must retain the above copyright 12584c2298Sphil.\" notice, this list of conditions and the following disclaimer. 13584c2298Sphil.\" 2. Redistributions in binary form must reproduce the above copyright 14584c2298Sphil.\" notice, this list of conditions and the following disclaimer in the 15584c2298Sphil.\" documentation and/or other materials provided with the distribution. 1640c86e8bSmbalmer.\" 3. The name of Piermont Information Systems Inc. may not be used to endorse 17584c2298Sphil.\" or promote products derived from this software without specific prior 18584c2298Sphil.\" written permission. 19584c2298Sphil.\" 20584c2298Sphil.\" THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS'' 21584c2298Sphil.\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22584c2298Sphil.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23584c2298Sphil.\" ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE 24584c2298Sphil.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25584c2298Sphil.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26584c2298Sphil.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27584c2298Sphil.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28584c2298Sphil.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29584c2298Sphil.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30584c2298Sphil.\" THE POSSIBILITY OF SUCH DAMAGE. 31584c2298Sphil.\" 32*30b89059Srillig.Dd October 11, 2021 33584c2298Sphil.Dt MSGC 1 34997634feSjoerg.Os 35584c2298Sphil.Sh NAME 364ac74dd2Sjhawk.Nm msgc , 374ac74dd2Sjhawk.Nm msg_window , 384ac74dd2Sjhawk.Nm msg_string , 394ac74dd2Sjhawk.Nm msg_clear , 404ac74dd2Sjhawk.Nm msg_standout , 414ac74dd2Sjhawk.Nm msg_standend , 424ac74dd2Sjhawk.Nm msg_display , 434ac74dd2Sjhawk.Nm msg_display_add , 44d13b2dd8Smbalmer.Nm msg_printf , 454ac74dd2Sjhawk.Nm msg_prompt , 464ac74dd2Sjhawk.Nm msg_prompt_add , 4715cd94ddSdsl.Nm msg_prompt_win , 484ac74dd2Sjhawk.Nm msg_prompt_noecho , 49556e606cSdsl.Nm msg_row , 504ac74dd2Sjhawk.Nm msg_table_add 51584c2298Sphil.Nd simple message list compiler 52584c2298Sphil.Sh SYNOPSIS 53584c2298Sphilmsgc 54584c2298Sphil.Op Fl o Ar name 55584c2298Sphil.Ar file 56584c2298Sphil.Pp 5788e16b23Sjoerg.Fd #include \&"msg_defs.h" 58584c2298Sphil.Ft void 59584c2298Sphil.Fn msg_window "WINDOW *window" 60a70b70f9Scgd.Ft const char * 61a70b70f9Scgd.Fn msg_string "msg msg_no" 62584c2298Sphil.Ft void 63584c2298Sphil.Fn msg_clear "void" 64584c2298Sphil.Ft void 65584c2298Sphil.Fn msg_standout "void" 66584c2298Sphil.Ft void 67584c2298Sphil.Fn msg_standend "void" 68584c2298Sphil.Ft void 69a70b70f9Scgd.Fn msg_display "msg msg_no" ... 70584c2298Sphil.Ft void 71a70b70f9Scgd.Fn msg_display_add "msg msg_no" ... 72584c2298Sphil.Ft void 73d13b2dd8Smbalmer.Fn msg_printf "fmt" ... 74d13b2dd8Smbalmer.Ft void 75a70b70f9Scgd.Fn msg_prompt "msg msg_no" "const char *def" "char *val" "int max_chars" ... 76584c2298Sphil.Ft void 77a70b70f9Scgd.Fn msg_prompt_add "msg msg_no" "const char *def" "char *val" "int max_chars" ... 78584c2298Sphil.Ft void 7915cd94ddSdsl.Fn msg_prompt_win "msg msg_no" "WINDOW *win" "const char *def" "char *val" "int max_chars" ... 8015cd94ddSdsl.Ft void 81a70b70f9Scgd.Fn msg_prompt_noecho "msg msg_no" "const char *def" "char *val" "int max_chars" ... 82556e606cSdsl.Ft int 83556e606cSdsl.Fn msg_row "void" 84e8b59e21Scgd.Ft void 85a70b70f9Scgd.Fn msg_table_add "msg msg_no" ... 86584c2298Sphil.Sh DESCRIPTION 87e65d3f80SwizThis implements a curses based message display system. 88e65d3f80SwizA source file that lists messages with associated names is given to 89584c2298Sphil.Nm 90584c2298Sphiland produces both a .c and a .h file that implement the menu system. 91584c2298SphilThe standard root name of the files is 92979f7a00Slukem.Pa msg_defs . 93584c2298SphilThe 94584c2298Sphil.Fl o Ar name 95584c2298Sphilcan be used to specify a different root name. 96faa0b302Sgarbled.Sh ENVIRONMENT 97faa0b302Sgarbled.Bl -tag -width MSGDEF 98faa0b302Sgarbled.It Ev MSGDEF 99faa0b302SgarbledCan be set to point to a different set of 100faa0b302Sgarbleddefinition files for 101faa0b302Sgarbled.Nm msgc . 102faa0b302SgarbledThe current location defaults to 103faa0b302Sgarbled.Pa /usr/share/misc . 104faa0b302Sgarbled.El 105faa0b302Sgarbled.Sh FILES 10688e16b23Sjoerg.Bl -item 107faa0b302Sgarbled.It 108faa0b302Sgarbled.Pa /usr/share/misc/msg_sys.def 109faa0b302Sgarbled.El 110584c2298Sphil.Sh SOURCE DESCRIPTION 111e65d3f80SwizThe format is very simple. 112e65d3f80SwizEach message is started with the word 113979f7a00Slukem.Sq message 114e65d3f80Swizfollowed by the name of the message. 115e65d3f80SwizThe body of the message is next and is started by a { and closed by a }. 116e65d3f80SwizThe braces are not part of the message. 117*30b89059SrilligEverything, including newlines between the braces, is part of the message. 118584c2298Sphil.Sh MESSAGE FUNCTIONS 119*30b89059SrilligThe defined messages are used through calls to routines that manipulate 120e65d3f80Swizthe messages. 121e65d3f80SwizYou first need to set the 122979f7a00Slukem.Xr curses 3 123584c2298Sphilenvironment up and then tell the message system which window to use 124*30b89059Srilligfor displaying the messages by calling the function 125979f7a00Slukem.Fn msg_window . 126584c2298Sphil.Pp 127*30b89059SrilligAll variable argument lists in the functions are used as arguments to 128e65d3f80Swiz.Xr sprintf 3 . 129e65d3f80SwizThe messages may have 130e65d3f80Swiz.Xr sprintf 3 131e65d3f80Swizconversions in them and the corresponding parameters should match. 132e65d3f80SwizMessages are identified by name using the notation 133dface83fSriz.Sq MSG_name 134584c2298Sphilwhere 135979f7a00Slukem.Dq name 136e65d3f80Swizis the name in the message source file. 137*30b89059Srillig(The definitions are accessed by including the generated .h file into each 138e65d3f80Swizsource file wanting to use the message routines.) 139584c2298Sphil.Pp 140584c2298SphilThe function 141584c2298Sphil.Fn msg_string 142584c2298Sphiljust returns a pointer to the actual message string. 143584c2298SphilThe functions 144584c2298Sphil.Fn msg_clear , 145584c2298Sphil.Fn msg_standout 146584c2298Sphiland 147584c2298Sphil.Fn msg_standend 148584c2298Sphilrespectively clear the message window, set standout mode and clear standout 14952e42eacSjhawkmode. 15052e42eacSjhawk.Pp 15152e42eacSjhawkThe functions 152584c2298Sphil.Fn msg_display 153584c2298Sphiland 154584c2298Sphil.Fn msg_display_add 155*30b89059Srilligcause the given message to be displayed in the message window and do 156e65d3f80Swizthe requested conversions before printing. 157e65d3f80SwizThe difference is that 158584c2298Sphil.Fn msg_display 159e65d3f80Swizclears the window before displaying the message. 160e65d3f80SwizThese functions fill paragraphs for readability. 161e65d3f80SwizThe 16252e42eacSjhawk.Fn msg_table_add 16352e42eacSjhawkfunction behaves like 16452e42eacSjhawk.Fn msg_display_add 16552e42eacSjhawkbut does not fill text. 166d47aeb29Swiz.Pp 167d13b2dd8SmbalmerThe function 168d13b2dd8Smbalmer.Fn msg_printf 169d13b2dd8Smbalmerallows to display a raw message without going through the message catalog. 170584c2298Sphil.Pp 171e65d3f80SwizThe remaining functions deal with a prompt facility. 172e65d3f80SwizA prompt message is either taken from the message directory or from a 173e65d3f80Swizgiven string. 174e65d3f80SwizThe message is processed with 175e65d3f80Swiz.Xr sprintf 3 176e65d3f80Swizand then displayed. 177e65d3f80SwizIf the parameter 178584c2298Sphil.Ar def 179e65d3f80Swizis 180e65d3f80Swiz.No non- Ns Dv NULL 181e65d3f80Swizand not a string of zero length, a default value is printed 182e65d3f80Swizin brackets. 183e65d3f80SwizThe user is allowed to type in a response. 184e65d3f80SwizIf the user types just the newline character, the default is returned 185e65d3f80Swizin the value. 186d6493c16SwizThe parameter 187584c2298Sphil.Ar max_chars 188d6493c16Swizis the length of the parameter 189584c2298Sphil.Ar val , 190584c2298Sphilwhere the results are stored. 191584c2298SphilThe parameters 192584c2298Sphil.Ar def 193584c2298Sphiland 194584c2298Sphil.Ar val 195e65d3f80Swizmay point to the same character array. 196e65d3f80SwizIf the default is chosen, the character array is not changed. 197584c2298SphilThe functions 198584c2298Sphil.Fn msg_echo 199584c2298Sphiland 200584c2298Sphil.Fn msg_noecho 201*30b89059Srilligcontrol whether the prompt routines echo or don't echo the input that 202584c2298Sphilis typed by the user. 20315cd94ddSdsl.Pp 20415cd94ddSdsl.Fn msg_prompt_win 20515cd94ddSdsluses the specified curses window instead of the default one. 206556e606cSdsl.Pp 207556e606cSdsl.Fn msg_row 208556e606cSdslreturn the current row - i.e.: getcury(msg_win) + getbegy(msg_win). 209d2d0c784Swiz.Sh AUTHORS 210584c2298SphilPhilip A. Nelson for Piermont Information Systems Inc. 211