GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: lib/libmenu/m_item_opt.c Lines: 0 26 0.0 %
Date: 2017-11-07 Branches: 0 18 0.0 %

Line Branch Exec Source
1
/* $OpenBSD: m_item_opt.c,v 1.9 2010/01/12 23:22:08 nicm Exp $ */
2
3
/****************************************************************************
4
 * Copyright (c) 1998-2003,2004 Free Software Foundation, Inc.              *
5
 *                                                                          *
6
 * Permission is hereby granted, free of charge, to any person obtaining a  *
7
 * copy of this software and associated documentation files (the            *
8
 * "Software"), to deal in the Software without restriction, including      *
9
 * without limitation the rights to use, copy, modify, merge, publish,      *
10
 * distribute, distribute with modifications, sublicense, and/or sell       *
11
 * copies of the Software, and to permit persons to whom the Software is    *
12
 * furnished to do so, subject to the following conditions:                 *
13
 *                                                                          *
14
 * The above copyright notice and this permission notice shall be included  *
15
 * in all copies or substantial portions of the Software.                   *
16
 *                                                                          *
17
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
18
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
19
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
20
 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
21
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
22
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
23
 * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
24
 *                                                                          *
25
 * Except as contained in this notice, the name(s) of the above copyright   *
26
 * holders shall not be used in advertising or otherwise to promote the     *
27
 * sale, use or other dealings in this Software without prior written       *
28
 * authorization.                                                           *
29
 ****************************************************************************/
30
31
/****************************************************************************
32
 *   Author:  Juergen Pfeifer, 1995,1997                                    *
33
 ****************************************************************************/
34
35
/***************************************************************************
36
* Module m_item_opt                                                        *
37
* Menus item option routines                                               *
38
***************************************************************************/
39
40
#include "menu.priv.h"
41
42
MODULE_ID("$Id: m_item_opt.c,v 1.9 2010/01/12 23:22:08 nicm Exp $")
43
44
/*---------------------------------------------------------------------------
45
|   Facility      :  libnmenu
46
|   Function      :  int set_item_opts(ITEM *item, Item_Options opts)
47
|
48
|   Description   :  Set the options of the item. If there are relevant
49
|                    changes, the item is connected and the menu is posted,
50
|                    the menu will be redisplayed.
51
|
52
|   Return Values :  E_OK            - success
53
|                    E_BAD_ARGUMENT  - invalid item options
54
+--------------------------------------------------------------------------*/
55
NCURSES_EXPORT(int)
56
set_item_opts(ITEM * item, Item_Options opts)
57
{
58
  T((T_CALLED("set_menu_opts(%p,%d)"), item, opts));
59
60
  opts &= ALL_ITEM_OPTS;
61
62
  if (opts & ~ALL_ITEM_OPTS)
63
    RETURN(E_BAD_ARGUMENT);
64
65
  if (item)
66
    {
67
      if (item->opt != opts)
68
	{
69
	  MENU *menu = item->imenu;
70
71
	  item->opt = opts;
72
73
	  if ((!(opts & O_SELECTABLE)) && item->value)
74
	    item->value = FALSE;
75
76
	  if (menu && (menu->status & _POSTED))
77
	    {
78
	      Move_And_Post_Item(menu, item);
79
	      _nc_Show_Menu(menu);
80
	    }
81
	}
82
    }
83
  else
84
    _nc_Default_Item.opt = opts;
85
86
  RETURN(E_OK);
87
}
88
89
/*---------------------------------------------------------------------------
90
|   Facility      :  libnmenu
91
|   Function      :  int item_opts_off(ITEM *item, Item_Options opts)
92
|
93
|   Description   :  Switch of the options for this item.
94
|
95
|   Return Values :  E_OK            - success
96
|                    E_BAD_ARGUMENT  - invalid options
97
+--------------------------------------------------------------------------*/
98
NCURSES_EXPORT(int)
99
item_opts_off(ITEM * item, Item_Options opts)
100
{
101
  ITEM *citem = item;		/* use a copy because set_item_opts must detect
102
103
				   NULL item itself to adjust its behavior */
104
105
  T((T_CALLED("item_opts_off(%p,%d)"), item, opts));
106
107
  if (opts & ~ALL_ITEM_OPTS)
108
    RETURN(E_BAD_ARGUMENT);
109
  else
110
    {
111
      Normalize_Item(citem);
112
      opts = citem->opt & ~(opts & ALL_ITEM_OPTS);
113
      returnCode(set_item_opts(item, opts));
114
    }
115
}
116
117
/*---------------------------------------------------------------------------
118
|   Facility      :  libnmenu
119
|   Function      :  int item_opts_on(ITEM *item, Item_Options opts)
120
|
121
|   Description   :  Switch on the options for this item.
122
|
123
|   Return Values :  E_OK            - success
124
|                    E_BAD_ARGUMENT  - invalid options
125
+--------------------------------------------------------------------------*/
126
NCURSES_EXPORT(int)
127
item_opts_on(ITEM * item, Item_Options opts)
128
{
129
  ITEM *citem = item;		/* use a copy because set_item_opts must detect
130
131
				   NULL item itself to adjust its behavior */
132
133
  T((T_CALLED("item_opts_on(%p,%d)"), item, opts));
134
135
  opts &= ALL_ITEM_OPTS;
136
  if (opts & ~ALL_ITEM_OPTS)
137
    RETURN(E_BAD_ARGUMENT);
138
  else
139
    {
140
      Normalize_Item(citem);
141
      opts = citem->opt | opts;
142
      returnCode(set_item_opts(item, opts));
143
    }
144
}
145
146
/*---------------------------------------------------------------------------
147
|   Facility      :  libnmenu
148
|   Function      :  Item_Options item_opts(const ITEM *item)
149
|
150
|   Description   :  Switch of the options for this item.
151
|
152
|   Return Values :  Items options
153
+--------------------------------------------------------------------------*/
154
NCURSES_EXPORT(Item_Options)
155
item_opts(const ITEM * item)
156
{
157
  T((T_CALLED("item_opts(%p)"), item));
158
  returnItemOpts(ALL_ITEM_OPTS & Normalize_Item(item)->opt);
159
}
160
161
/* m_item_opt.c ends here */