~ubuntu-branches/debian/sid/ncurses/sid-200908151543

« back to all changes in this revision

Viewing changes to ncurses/tinfo/lib_options.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2009-05-24 15:13:01 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20090524151301-uixgxq2zonfov2nr
Tags: 5.7+20090523-1
MergingĀ upstreamĀ versionĀ 5.7+20090523.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/****************************************************************************
2
 
 * Copyright (c) 1998-2006,2008 Free Software Foundation, Inc.              *
 
2
 * Copyright (c) 1998-2008,2009 Free Software Foundation, Inc.              *
3
3
 *                                                                          *
4
4
 * Permission is hereby granted, free of charge, to any person obtaining a  *
5
5
 * copy of this software and associated documentation files (the            *
30
30
 *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
31
31
 *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
32
32
 *     and: Thomas E. Dickey                        1996-on                 *
 
33
 *     and: Juergen Pfeifer                         2009                    *
33
34
 ****************************************************************************/
34
35
 
35
36
/*
43
44
 
44
45
#include <term.h>
45
46
 
46
 
MODULE_ID("$Id: lib_options.c,v 1.58 2008/08/16 21:20:48 Werner.Fink Exp $")
47
 
 
48
 
static int _nc_curs_set(SCREEN *, int);
 
47
#ifndef CUR
 
48
#define CUR SP_TERMTYPE
 
49
#endif
 
50
 
 
51
MODULE_ID("$Id: lib_options.c,v 1.64 2009/05/23 23:58:07 tom Exp $")
 
52
 
49
53
static int _nc_meta(SCREEN *, bool);
50
54
 
51
55
NCURSES_EXPORT(int)
52
56
idlok(WINDOW *win, bool flag)
53
57
{
 
58
#if NCURSES_SP_FUNCS
 
59
    SCREEN *sp = CURRENT_SCREEN;
 
60
#endif
54
61
    T((T_CALLED("idlok(%p,%d)"), win, flag));
55
62
 
56
63
    if (win) {
72
79
}
73
80
 
74
81
NCURSES_EXPORT(int)
75
 
halfdelay(int t)
 
82
NCURSES_SP_NAME(halfdelay) (NCURSES_SP_DCLx int t)
76
83
{
77
84
    T((T_CALLED("halfdelay(%d)"), t));
78
85
 
79
 
    if (t < 1 || t > 255 || SP == 0)
 
86
    if (t < 1 || t > 255 || SP_PARM == 0)
80
87
        returnCode(ERR);
81
88
 
82
89
    cbreak();
83
 
    SP->_cbreak = t + 1;
 
90
    SP_PARM->_cbreak = t + 1;
84
91
    returnCode(OK);
85
92
}
86
93
 
 
94
#if NCURSES_SP_FUNCS
 
95
NCURSES_EXPORT(int)
 
96
halfdelay(int t)
 
97
{
 
98
    return NCURSES_SP_NAME(halfdelay) (CURRENT_SCREEN, t);
 
99
}
 
100
#endif
 
101
 
87
102
NCURSES_EXPORT(int)
88
103
nodelay(WINDOW *win, bool flag)
89
104
{
148
163
/* curs_set() moved here to narrow the kernel interface */
149
164
 
150
165
NCURSES_EXPORT(int)
 
166
NCURSES_SP_NAME(curs_set) (NCURSES_SP_DCLx int vis)
 
167
{
 
168
    int result = ERR;
 
169
 
 
170
    T((T_CALLED("curs_set(%p,%d)"), SP_PARM, vis));
 
171
    if (SP_PARM != 0 && vis >= 0 && vis <= 2) {
 
172
        int cursor = SP_PARM->_cursor;
 
173
 
 
174
        if (vis == cursor) {
 
175
            result = cursor;
 
176
        } else {
 
177
            switch (vis) {
 
178
            case 2:
 
179
                result = _nc_putp_flush("cursor_visible", cursor_visible);
 
180
                break;
 
181
            case 1:
 
182
                result = _nc_putp_flush("cursor_normal", cursor_normal);
 
183
                break;
 
184
            case 0:
 
185
                result = _nc_putp_flush("cursor_invisible", cursor_invisible);
 
186
                break;
 
187
            }
 
188
            if (result != ERR)
 
189
                result = (cursor == -1 ? 1 : cursor);
 
190
            SP_PARM->_cursor = vis;
 
191
        }
 
192
    }
 
193
    returnCode(result);
 
194
}
 
195
 
 
196
#if NCURSES_SP_FUNCS
 
197
NCURSES_EXPORT(int)
151
198
curs_set(int vis)
152
199
{
153
 
    int result;
154
 
 
155
 
    T((T_CALLED("curs_set(%d)"), vis));
156
 
    result = _nc_curs_set(SP, vis);
157
 
    returnCode(result);
 
200
    return (NCURSES_SP_NAME(curs_set) (CURRENT_SCREEN, vis));
158
201
}
 
202
#endif
159
203
 
160
204
NCURSES_EXPORT(int)
161
 
typeahead(int fd)
 
205
NCURSES_SP_NAME(typeahead) (NCURSES_SP_DCLx int fd)
162
206
{
163
207
    T((T_CALLED("typeahead(%d)"), fd));
164
 
    if (SP != 0) {
165
 
        SP->_checkfd = fd;
 
208
    if (SP_PARM != 0) {
 
209
        SP_PARM->_checkfd = fd;
166
210
        returnCode(OK);
167
211
    } else {
168
212
        returnCode(ERR);
169
213
    }
170
214
}
171
215
 
 
216
#if NCURSES_SP_FUNCS
 
217
NCURSES_EXPORT(int)
 
218
typeahead(int fd)
 
219
{
 
220
    return NCURSES_SP_NAME(typeahead) (CURRENT_SCREEN, fd);
 
221
}
 
222
#endif
 
223
 
172
224
/*
173
225
**      has_key()
174
226
**
190
242
}
191
243
 
192
244
NCURSES_EXPORT(int)
 
245
NCURSES_SP_NAME(has_key) (NCURSES_SP_DCLx int keycode)
 
246
{
 
247
    T((T_CALLED("has_key(%p,%d)"), SP_PARM, keycode));
 
248
    returnCode(SP != 0 ? has_key_internal(keycode, SP_PARM->_keytry) : FALSE);
 
249
}
 
250
 
 
251
#if NCURSES_SP_FUNCS
 
252
NCURSES_EXPORT(int)
193
253
has_key(int keycode)
194
254
{
195
 
    T((T_CALLED("has_key(%d)"), keycode));
196
 
    returnCode(SP != 0 ? has_key_internal(keycode, SP->_keytry) : FALSE);
 
255
    return NCURSES_SP_NAME(has_key) (CURRENT_SCREEN, keycode);
197
256
}
 
257
#endif
198
258
#endif /* NCURSES_EXT_FUNCS */
199
259
 
200
260
/*
202
262
 * than cur_term.
203
263
 */
204
264
#undef CUR
205
 
#define CUR (sp->_term)->type.
206
 
 
207
 
static int
208
 
_nc_putp(const char *name GCC_UNUSED, const char *value)
209
 
{
210
 
    int rc = ERR;
211
 
 
212
 
    if (value) {
213
 
        TPUTS_TRACE(name);
214
 
        rc = putp(value);
215
 
    }
216
 
    return rc;
217
 
}
218
 
 
219
 
static int
220
 
_nc_putp_flush(const char *name, const char *value)
 
265
#define CUR SP_TERMTYPE
 
266
 
 
267
NCURSES_EXPORT(int)
 
268
NCURSES_SP_NAME(_nc_putp_flush) (NCURSES_SP_DCLx
 
269
                                 const char *name, const char *value)
221
270
{
222
271
    int rc = _nc_putp(name, value);
223
272
    if (rc != ERR) {
226
275
    return rc;
227
276
}
228
277
 
 
278
#if NCURSES_SP_FUNCS
 
279
NCURSES_EXPORT(int)
 
280
_nc_putp_flush(const char *name, const char *value)
 
281
{
 
282
    return NCURSES_SP_NAME(_nc_putp_flush) (CURRENT_SCREEN, name, value);
 
283
}
 
284
#endif
 
285
 
229
286
/* Turn the keypad on/off
230
287
 *
231
288
 * Note:  we flush the output because changing this mode causes some terminals
245
302
         * has wgetch() reading in more than one thread.  putp() and below
246
303
         * may use SP explicitly.
247
304
         */
248
 
        if (_nc_use_pthreads && sp != SP) {
 
305
        if (_nc_use_pthreads && sp != CURRENT_SCREEN) {
249
306
            SCREEN *save_sp;
250
307
 
251
308
            /* cannot use use_screen(), since that is not in tinfo library */
252
309
            _nc_lock_global(curses);
253
 
            save_sp = SP;
 
310
            save_sp = CURRENT_SCREEN;
254
311
            _nc_set_screen(sp);
255
312
            rc = _nc_keypad(sp, flag);
256
313
            _nc_set_screen(save_sp);
276
333
}
277
334
 
278
335
static int
279
 
_nc_curs_set(SCREEN *sp, int vis)
280
 
{
281
 
    int result = ERR;
282
 
 
283
 
    T((T_CALLED("curs_set(%d)"), vis));
284
 
    if (sp != 0 && vis >= 0 && vis <= 2) {
285
 
        int cursor = sp->_cursor;
286
 
 
287
 
        if (vis == cursor) {
288
 
            result = cursor;
289
 
        } else {
290
 
            switch (vis) {
291
 
            case 2:
292
 
                result = _nc_putp_flush("cursor_visible", cursor_visible);
293
 
                break;
294
 
            case 1:
295
 
                result = _nc_putp_flush("cursor_normal", cursor_normal);
296
 
                break;
297
 
            case 0:
298
 
                result = _nc_putp_flush("cursor_invisible", cursor_invisible);
299
 
                break;
300
 
            }
301
 
            if (result != ERR)
302
 
                result = (cursor == -1 ? 1 : cursor);
303
 
            sp->_cursor = vis;
304
 
        }
305
 
    }
306
 
    returnCode(result);
307
 
}
308
 
 
309
 
static int
310
336
_nc_meta(SCREEN *sp, bool flag)
311
337
{
312
338
    int result = ERR;
313
339
 
314
340
    /* Ok, we stay relaxed and don't signal an error if win is NULL */
315
341
 
316
 
    if (SP != 0) {
317
 
        SP->_use_meta = flag;
 
342
    if (sp != 0) {
 
343
        sp->_use_meta = flag;
318
344
 
319
345
        if (flag) {
320
346
            _nc_putp("meta_on", meta_on);