1*c7ef0cfcSnicm /* $OpenBSD: m_spacing.c,v 1.7 2023/10/17 09:52:10 nicm Exp $ */
29f1aa62bSmillert
3457960bfSmillert /****************************************************************************
4*c7ef0cfcSnicm * Copyright 2020 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 ****************************************************************************/
350107aba4Smillert
360107aba4Smillert /***************************************************************************
379f1aa62bSmillert * Module m_spacing *
380107aba4Smillert * Routines to handle spacing between entries *
390107aba4Smillert ***************************************************************************/
400107aba4Smillert
410107aba4Smillert #include "menu.priv.h"
420107aba4Smillert
43*c7ef0cfcSnicm MODULE_ID("$Id: m_spacing.c,v 1.7 2023/10/17 09:52:10 nicm Exp $")
440107aba4Smillert
450107aba4Smillert #define MAX_SPC_DESC ((TABSIZE) ? (TABSIZE) : 8)
460107aba4Smillert #define MAX_SPC_COLS ((TABSIZE) ? (TABSIZE) : 8)
470107aba4Smillert #define MAX_SPC_ROWS (3)
480107aba4Smillert
490107aba4Smillert /*---------------------------------------------------------------------------
500107aba4Smillert | Facility : libnmenu
510107aba4Smillert | Function : int set_menu_spacing(MENU *menu,int desc, int r, int c);
520107aba4Smillert |
5381d8c4e1Snicm | Description : Set the spacing between entries
540107aba4Smillert |
550107aba4Smillert | Return Values : E_OK - on success
560107aba4Smillert +--------------------------------------------------------------------------*/
MENU_EXPORT(int)57*c7ef0cfcSnicm MENU_EXPORT(int)
5881d8c4e1Snicm set_menu_spacing(MENU *menu, int s_desc, int s_row, int s_col)
590107aba4Smillert {
600107aba4Smillert MENU *m; /* split for ATAC workaround */
6181d8c4e1Snicm
62*c7ef0cfcSnicm T((T_CALLED("set_menu_spacing(%p,%d,%d,%d)"),
63*c7ef0cfcSnicm (void *)menu, s_desc, s_row, s_col));
6481d8c4e1Snicm
650107aba4Smillert m = Normalize_Menu(menu);
660107aba4Smillert
670107aba4Smillert assert(m);
680107aba4Smillert if (m->status & _POSTED)
690107aba4Smillert RETURN(E_POSTED);
700107aba4Smillert
710107aba4Smillert if (((s_desc < 0) || (s_desc > MAX_SPC_DESC)) ||
720107aba4Smillert ((s_row < 0) || (s_row > MAX_SPC_ROWS)) ||
730107aba4Smillert ((s_col < 0) || (s_col > MAX_SPC_COLS)))
740107aba4Smillert RETURN(E_BAD_ARGUMENT);
750107aba4Smillert
76*c7ef0cfcSnicm m->spc_desc = (short)(s_desc ? s_desc : 1);
77*c7ef0cfcSnicm m->spc_rows = (short)(s_row ? s_row : 1);
78*c7ef0cfcSnicm m->spc_cols = (short)(s_col ? s_col : 1);
790107aba4Smillert _nc_Calculate_Item_Length_and_Width(m);
800107aba4Smillert
810107aba4Smillert RETURN(E_OK);
820107aba4Smillert }
830107aba4Smillert
840107aba4Smillert /*---------------------------------------------------------------------------
850107aba4Smillert | Facility : libnmenu
860107aba4Smillert | Function : int menu_spacing (const MENU *,int *,int *,int *);
870107aba4Smillert |
880107aba4Smillert | Description : Retrieve info about spacing between the entries
890107aba4Smillert |
900107aba4Smillert | Return Values : E_OK - on success
910107aba4Smillert +--------------------------------------------------------------------------*/
92*c7ef0cfcSnicm MENU_EXPORT(int)
menu_spacing(const MENU * menu,int * s_desc,int * s_row,int * s_col)9384af20ceSmillert menu_spacing(const MENU *menu, int *s_desc, int *s_row, int *s_col)
940107aba4Smillert {
950107aba4Smillert const MENU *m; /* split for ATAC workaround */
9681d8c4e1Snicm
97*c7ef0cfcSnicm T((T_CALLED("menu_spacing(%p,%p,%p,%p)"),
98*c7ef0cfcSnicm (const void *)menu,
99*c7ef0cfcSnicm (void *)s_desc,
100*c7ef0cfcSnicm (void *)s_row,
101*c7ef0cfcSnicm (void *)s_col));
10281d8c4e1Snicm
1030107aba4Smillert m = Normalize_Menu(menu);
1040107aba4Smillert
1050107aba4Smillert assert(m);
10681d8c4e1Snicm if (s_desc)
10781d8c4e1Snicm *s_desc = m->spc_desc;
10881d8c4e1Snicm if (s_row)
10981d8c4e1Snicm *s_row = m->spc_rows;
11081d8c4e1Snicm if (s_col)
11181d8c4e1Snicm *s_col = m->spc_cols;
1120107aba4Smillert
1130107aba4Smillert RETURN(E_OK);
1140107aba4Smillert }
1150107aba4Smillert
1160107aba4Smillert /* m_spacing.c ends here */
117