1*c7ef0cfcSnicm /* $OpenBSD: m_pad.c,v 1.6 2023/10/17 09:52:10 nicm Exp $ */
29f1aa62bSmillert
3457960bfSmillert /****************************************************************************
4*c7ef0cfcSnicm * Copyright 2020,2021 Thomas E. Dickey *
5*c7ef0cfcSnicm * Copyright 1998-2010,2012 Free Software Foundation, Inc. *
6457960bfSmillert * *
7457960bfSmillert * Permission is hereby granted, free of charge, to any person obtaining a *
8457960bfSmillert * copy of this software and associated documentation files (the *
9457960bfSmillert * "Software"), to deal in the Software without restriction, including *
10457960bfSmillert * without limitation the rights to use, copy, modify, merge, publish, *
11457960bfSmillert * distribute, distribute with modifications, sublicense, and/or sell *
12457960bfSmillert * copies of the Software, and to permit persons to whom the Software is *
13457960bfSmillert * furnished to do so, subject to the following conditions: *
14457960bfSmillert * *
15457960bfSmillert * The above copyright notice and this permission notice shall be included *
16457960bfSmillert * in all copies or substantial portions of the Software. *
17457960bfSmillert * *
18457960bfSmillert * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
19457960bfSmillert * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
20457960bfSmillert * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
21457960bfSmillert * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
22457960bfSmillert * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
23457960bfSmillert * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
24457960bfSmillert * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
25457960bfSmillert * *
26457960bfSmillert * Except as contained in this notice, the name(s) of the above copyright *
27457960bfSmillert * holders shall not be used in advertising or otherwise to promote the *
28457960bfSmillert * sale, use or other dealings in this Software without prior written *
29457960bfSmillert * authorization. *
30457960bfSmillert ****************************************************************************/
31457960bfSmillert
32457960bfSmillert /****************************************************************************
3381d8c4e1Snicm * Author: Juergen Pfeifer, 1995,1997 *
34457960bfSmillert ****************************************************************************/
359f1aa62bSmillert
369f1aa62bSmillert /***************************************************************************
379f1aa62bSmillert * Module m_pad *
389f1aa62bSmillert * Control menus padding character *
399f1aa62bSmillert ***************************************************************************/
409f1aa62bSmillert
419f1aa62bSmillert #include "menu.priv.h"
429f1aa62bSmillert
43*c7ef0cfcSnicm MODULE_ID("$Id: m_pad.c,v 1.6 2023/10/17 09:52:10 nicm Exp $")
449f1aa62bSmillert
459f1aa62bSmillert /* Macro to redraw menu if it is posted and changed */
469f1aa62bSmillert #define Refresh_Menu(menu) \
479f1aa62bSmillert if ( (menu) && ((menu)->status & _POSTED) )\
489f1aa62bSmillert {\
499f1aa62bSmillert _nc_Draw_Menu( menu );\
509f1aa62bSmillert _nc_Show_Menu( menu ); \
519f1aa62bSmillert }
529f1aa62bSmillert
539f1aa62bSmillert /*---------------------------------------------------------------------------
549f1aa62bSmillert | Facility : libnmenu
559f1aa62bSmillert | Function : int set_menu_pad(MENU* menu, int pad)
569f1aa62bSmillert |
579f1aa62bSmillert | Description : Set the character to be used to separate the item name
589f1aa62bSmillert | from its description. This must be a printable
599f1aa62bSmillert | character.
609f1aa62bSmillert |
619f1aa62bSmillert | Return Values : E_OK - success
629f1aa62bSmillert | E_BAD_ARGUMENT - an invalid value has been passed
639f1aa62bSmillert +--------------------------------------------------------------------------*/
MENU_EXPORT(int)64*c7ef0cfcSnicm MENU_EXPORT(int)
6584af20ceSmillert set_menu_pad(MENU *menu, int pad)
669f1aa62bSmillert {
679f1aa62bSmillert bool do_refresh = (menu != (MENU *)0);
689f1aa62bSmillert
69*c7ef0cfcSnicm T((T_CALLED("set_menu_pad(%p,%d)"), (void *)menu, pad));
7081d8c4e1Snicm
7181d8c4e1Snicm if (!isprint(UChar(pad)))
729f1aa62bSmillert RETURN(E_BAD_ARGUMENT);
739f1aa62bSmillert
749f1aa62bSmillert Normalize_Menu(menu);
75*c7ef0cfcSnicm menu->pad = (unsigned char)pad;
769f1aa62bSmillert
779f1aa62bSmillert if (do_refresh)
789f1aa62bSmillert Refresh_Menu(menu);
799f1aa62bSmillert
809f1aa62bSmillert RETURN(E_OK);
819f1aa62bSmillert }
829f1aa62bSmillert
839f1aa62bSmillert /*---------------------------------------------------------------------------
849f1aa62bSmillert | Facility : libnmenu
859f1aa62bSmillert | Function : int menu_pad(const MENU *menu)
869f1aa62bSmillert |
879f1aa62bSmillert | Description : Return the value of the padding character
889f1aa62bSmillert |
899f1aa62bSmillert | Return Values : The pad character
909f1aa62bSmillert +--------------------------------------------------------------------------*/
91*c7ef0cfcSnicm MENU_EXPORT(int)
menu_pad(const MENU * menu)9284af20ceSmillert menu_pad(const MENU *menu)
939f1aa62bSmillert {
94*c7ef0cfcSnicm T((T_CALLED("menu_pad(%p)"), (const void *)menu));
9581d8c4e1Snicm returnCode(Normalize_Menu(menu)->pad);
969f1aa62bSmillert }
979f1aa62bSmillert
989f1aa62bSmillert /* m_pad.c ends here */
99